I am looking for an alternative to FontLoader.computeStringWidth, since this is a Class from the com.sun package and should not be used.
This is used to dynamically set the prefWidth based on text in order to consider text font size (which may come from CSS). Having multiple GridPane I want the first column to be aligned with all the grids.
For example
From this:
| Column1Text | Column2 |
| Column1TextMore | Column2 |
| Column1TextSomeMore | Column2 |
To this (disregard the dots):
| Column1Text .................| Column2 |
| Column1TextMore .........| Column2 |
| Column1TextSomeMore | Column2 |
I did find one accepted answer here which was to create a temporary Scene, add a Text to it, then call applyCss and finally get the width. However I did not like this alternative. Must be a better way.
https://stackoverflow.com/a/13020490/1835477
In my case I have multiple grids, and creating a Scene/Text for each seems like a poor solution (performance wise) and not particularly elegant.
No better solution has presented itself than the one described on this answer.
Place the String to be measured in a Text object.
Create a throwaway Scene and place the Text object in the Scene.
Call applyCss on Text object.
Get the width of the Text object's layout bounds.
Sample:
final Text text = new Text("XYZ");
new Scene(new Group(text));
text.applyCss();
final double width = text.getLayoutBounds().getWidth();
Related
Is there any way to get the text or UIElement from a position?
I have a table on a website that I need to fetch a cell from.
The HTML table has a column of IDs and a column of status.
I am finding the ID that matches my known ID value and storing the Y part of the position.
This is how I know what row I am on.
Then I go to the status column with a known X coordinate.
What is the best function for me to get the Text/UIElement at those coordinates?
example (I need the status of the object with an ID of '2'):
(should return "bad")
ID | etc | etc | Status | etc
----|-----|-----|--------|-----
0 | ... | ... | good | ...
----|-----|-----|--------|-----
1 | ... | ... | great | ...
----|-----|-----|--------|-----
2 | ... | ... | bad | ...
----|-----|-----|--------|-----
3 | ... | ... | good | ...
I know you can mouse click on a position, but how can I get the text(UIElement works too) of a position?
If there is a faster/more reliable method to get the status that doesn't involve coordinates, I'm all ears
Your best option would be to use UiPath's data scraping feature.
When used on an HTML Table it will return you a data table containing all of the data contained within the table.
You can then use a for each row activity that will loop through the table.
Inside the for each row activity, you can put an If statement with the following condition row("ID").ToString.Equals("THE ID YOUR LOOKING FOR, IN THIS CASE, 2")
In the true section of the If statement, you can have an assign activity to get the value of the status column which can be retrieved using the following row("Status").ToString. You can leave the false section empty as this won't be needed
I am trying to modify the font color of a specific word in my values. What kind of expression could I write that would target this word and style the font to be red? I've heard of modifying the placeholder to accept HTML but I'm not sure this will help.
The value is made up from a case in the dataset that pulls from two tables that have gender so: "(consumer gender) | (caretaker gender)"
Possible values would be: Male | Male, Male | Female, Missing | Male, Missing | Female, Missing | Missing ….etc
What I'm trying to do is just target the "Missing" values and change the font color to red. Any way to do this? I've tried modifying the font color expression but only can figure out ways to modify the whole string as opposed to just that one word.
You can do this but it's a bit of a pain..
I used a quick dataset to demo the results built from the following SQL
DECLARE #t TABLE (textData varchar(20))
INSERT INTO #t VALUES
('Male | Male'), ('Male | Female'), ('Missing | Male'), ('Missing | Female'), ('Missing | Missing')
SELECT * FROM #t
The column we will use is just called textData
Start with an empty cell.
In the empty cell, double click to get a cursor, right-click inside the cell and choose "Create Placeholder"
Right-click the placeholder and set it's expression to somethign like...
=TRIM(LEFT(Fields!textData.Value, InStr(Fields!textData.Value, "|") -1))
This will get the text from the left side from the pipe symbol. Click OK to get back to designer. click just after the new placeholder and type the pipe symbol (with spaces if required).
Next right click after the pipe symbol and add another placeholder. This time we will use an expression to get the right side of the pipe symbol.
=TRIM(MID(Fields!textData.Value, InStr(Fields!textData.Value, "|")+1 ))
Now we've got the data displaying, select the first placeholder and set its color property to
=IIF(TRIM(LEFT(Fields!textData.Value, InStr(Fields!textData.Value, "|") -1)) = "Missing", "Red", Nothing)
repeat for the second placeholder this time using this expression.
=IIF(TRIM(MID(Fields!textData.Value, InStr(Fields!textData.Value, "|")+1 )) = "Missing", "Red", Nothing)
IN my simple design, the left column shows the original unaltered data from the dataset, the right column contains out two placeholders with colors.
The final output looks like this.
I'm trying to create accessible table which Adobe Reader pronounce 'correctly'. It means that before pronouncing contents of the cell it speaks name of the header of the current column (or row). (It explained better at the first link below).
For this I've created single-page document with a table like this.
+------+-----+-----+
| Name | Sex | Age |
+------+-----+-----+
|Antony|Male | 26 |
+------+-----+-----+
|Robert|Male | 36 |
+------+-----+-----+
Then with "Touch Up Reading Order" tool I've changed properties of each cell to create references to header cells.
It expected to pronounce:
"Name. Antony. Sex. Male. Age. Twenty six. Name. Robert. Sex. Male. Age. Thirty six."
But it read table row by row.
Maybe I didn't enable something?
I've used this links to prepare document:
http://teachingcommons.cdl.edu/access/docs_multi/pdf_vid_tut/repair_docs/identifying/identifying_table_headers.shtml (Associating Data Cells to Row and Column Headers)
http://www.the508compliantpdf.com/creating_complex_tables_in_indesign_and_acrobat/
I found this question, but I don't want explicit <br>s in my cell; I just want it to line-wrap where necessary.
e.g.,
================ ============
a short sentence second cell
a much longer bottom right
sentence
================ ============
I want "a much longer sentence" to all fit in one cell. I'd need to use very long lines of text unless I can find a way to wrap it. Is this possible?
I'm using NoTex w/ PDF output if relevant.
There is a clean way. The issue is by default the columns are set to no-wrap, so that's why you get the scroll. To fix that you have to override the css with the following:
/* override table no-wrap */
.wy-table-responsive table td, .wy-table-responsive table th {
white-space: normal;
}
The simple table style does not support wrapping blocks. Use the grid style instead, like this:
+------------------+--------------+
| a short sentence | second cell |
+------------------+--------------+
| a much longer | bottom right |
| sentence | |
+------------------+--------------+
These tables are more tedious to work with, but they're more flexible. See the full documentation for details.
A workaround for this problem is to use a replace directive:
================ ============
a short sentence second cell
|long_sentence| bottom right
================ ============
.. |long_sentence| replace:: a much longer sentence
The example ddbeck presented may work because the sentence is to short. In the case of the lenght of the sentence dont fit in the screen, the sentence will not continue in a new line. Instead, the table will create a horizontal scrollbar. There is no clean way for solving this problem. You can implicit use pipe to implicitly change line like you saw here.
If you want alternatives to write your tables in restructuredtext, more pratical ways, you can check it in Sphinx/Rest Memo.
I wrote a python utility to format fixed-width plaintext table with multiline cells: https://github.com/kkew3/tabulate. Hope it helps.
I have created a custom auto report (by clicking file > print - then modify to create new) with various fields but when physically printing the report, the first column wraps the text so it looks something like this:
Item # | Item Name | Qty
--------------------------
5439988 | Test Item | 2
0049E
Other columns do not wrap text like this, is there any way of changing the column widths to stop this kind of behaviour so i can improve the aesthetics of the report?
Check the DisplayLength attribute on the extended data type of the corresponding field.