I have an item ( TextField, or TextArea, ...). It has a content value , say "hello world". How to know the number of pixels that this "hello world" String value is occupying on the screen ?
You can get the preferred width/height to get a rough estimation (you would also need to add the margin's to get accurate sizing). However the layout manager views these as guidelines not as final sizes and can decide on placing a component anywhere.
During runtime e.g. paint etc. the getX/Y/Width/Height argument provide accurate component size and position. However, these are only valid for the current paint operation since a device may be rotated or might require layout reflow.
You need to be more specific on what you are trying to accomplish.
Related
I'm implementing the class diagram where the users can change the class' name, attributes and methods. I'm having trouble with resizing the class rectangle width depending on name, attribute or method length. These can overflow and go outside the rectangle, and I just can't find a method to get the correct size.
I also have added an element tool to the elementView, and set its x and y to "100%". According to documentation: "Use percentage strings (e.g. '40%') to position the button relatively to the element width/height." but I guess this isn't the model's size, as I typed JSON.stringify(graph.toJSON()) and got the following.
JSON.stringify(graph.toJSON())
The size is the default value I set (260x100).
I checked the size of the attribute using DevTools:
Size of attribute
The gray button detects the width number I need (330), so I guess that the x in element tools is the elementView's width. I looked at the documentation and can't find any method like .size() or .getSize() for the elementView. I need to resize the rectangle to the size of Max(name length, attribute length, method length) + some aditional space to not look cramped up. I have seen some solutions like "Use [number of letters] * [some constant]" but that is no good as typing 5 "W"s doesn't take the same space as typing 5 "i"s.
So how do I get the width of the whole element (in my case 330 from text length + the three pixels from the left border of the rectangle to the first text letter)?
Okay, so after searching through several Google Groups chats I found some pieces of code that helped me.
For getting the width I needed, I used elementView.getBBox().width.
Where I didn't have the element view right at hand, I at least had the model ID, and so I used paper.findViewByModel(modelId) to get the element view.
I am using citrix vdi to read an element on webpage. It is able to highlight and read the value in open vdi but in close vdi layout of webpage messes up and element i need went out of bound/off screen from webpage. I have tried minimize and maximize before reading value but invain. I also tried html mode and AA still cannot read it. In html mode i kept only path attribute for element, value remains exactly same on close and open vdi. The only difference i have notice is width of div in which element resides. Div width changes in open 1921and close 1203 which i assume push element out of screen bounds. Any help will be appreciated.
When working with Blue Prism don’t rely on initial attribute set. You need to choose as few attributes as possible to uniquely identify element. You should always untick attributes that are empty or it’s value it’s “Self” (for example Element ID attribute tends to have such value which doesn’t mean anything). Generally, attributes connected with elements position on the screen or its size are not helpful, because it may be easily affected.
When working with HTML spy mode your elements don’t need to be visible on screen to interact with them (unless you are using surface automation techniques), HTML elements don’t have any Visible or Screen Visible attributes.
Try to use attributes like:
Tag Name
Class Name
ID
If Value has always particular text, use wildcard type of match: text
Path attribute is not always the best choice as it might change because web page is dynamic or application update mess up the layout. If you won’t be able to identify element any other way, make sure you use Path as Dynamic match type & store it as environmental variable, so it could be easily adjusted if needed.
If you have problems reading value using “Get Current Value”, try “Get HTML Attribute” in Read stage options & try “Value” or “Title” as an Input.
I'm new to the google cardboard sdk. I need to draw a slightly different image for the left eye as compared to the right(I know distortion correction is taken care of). I saw the "Eye" class spec (an instance of which is passed to OnDrawEye()) from the docs.It does not seem to contain info of which eye is being referred to. How do I tell if the image is being rendered for the right or left eye and code accordingly?
In the class where you implements the CardboardView.StereoRenderer you have to define the function onDrawEye(), int this function you receive a parameter of type Eye, from that parameter you can know what eye is rendering at the moment with the function getType(). You can check the eye with the constants defined in Eye.Type
I'm having trouble creating a fluid layout with Vaadin. As I understand it, in order for a container's size to be calculated based on its contents, I have to use the setSizeUndefined() method.
This works fine, but an issue arises when I want to add components wich take up all the available space to this container with undefined size. I cannot get this to work.
Here's a simplified sample of what I'm trying to do:
VerticalLayout layout = new VerticalLayout();
layout.setSizeUndefined();
layout.setMargin(false);
layout.addComponent(createButton("A somewhat longer label"));
layout.addComponent(createButton("Short label"));
private Button createButton(String label) {
Button button = new Button(label);
button.setSizeFull();
button.setWidth("100%");
return button;
}
The buttons do not take up the entire width of the vertical layout container. I have read here and there that one is not allowed to set "100%" sizes inside containers with undefined size, but then how am I supposed to achieve what I want to achieve bearing in mind that I need that undefined size for my fluid layout?
In case someone thinks the undefined size is not necessary for my use case, I'll be happy to provide more information on that. I have a strong Flex background which may cause met to look at this problem from the wrong angle.
You are correct, you cannot use relatively sized components within a VerticalLayout that has an undefined size. The functionality you are looking for exists in an add-on called WeeLayout.
Is there any way to append a blank stringItem in form? I want to show a gauge in a form but it should be center aligned. There is no way to do this I think unless there are a few items before the gauge. So I was thinking to add a few null stringItems but they dont work. This is my code so far.
loadingDialog = new javax.microedition.lcdui.Form("Please Wait");
Gauge gau = new Gauge("\nPlease wait.", false, Gauge.INDEFINITE,
Gauge.CONTINUOUS_RUNNING);
gau.setPreferredSize(230,80);
gau.setLayout(Item.LAYOUT_BOTTOM);
//Displayable SizeCanvas = new MyCanvas();
StringItem st = new StringItem(" ", " ");
loadingDialog.append(st);
loadingDialog.append(gau);
parentMidlet.displays.setCurrent(loadingDialog);
There is a special layout directive to center an item, called unsurprisingly, LAYOUT_CENTER
Using the code snippet you gave, this directive could be set like,
gau.setLayout(Item.LAYOUT_BOTTOM | Item.LAYOUT_CENTER);
Or, if you want to have it set in a separate statement,
gau.setLayout(gau.getLayout() | Item.LAYOUT_CENTER);
If your device is MIDP 2.0, this directive is not mandated to follow (although one can expect a device of reasonable quality to support it). In MIDP 2.1 device, it is mandated to be supported by explicit requirement in the specification.
By the way, for more advanced purposes of item alignment, there is a dedicated lcdui object called Spacer:
A blank, non-interactive item that has a settable minimum size. The minimum width is useful for allocating flexible amounts of space between Items within the same row of a Form. The minimum height is useful for enforcing a particular minimum height of a row. The application can set the minimum width or height to any non-negative value. The implementation may enforce implementation-defined maximum values for the minimum width and height...
...Spacer's primary purpose is to position other item...