How to change the default label positions of connectors in Enterprise Architect - position

I'm drawing activity diagram by Enterprise Architect 12. The diagram type is Activity under UML Behavioral. I found the positions of the labels of connectors are close to the target element as shown in the picture. It's very confusing.
How to change the default label positions to make them close to the source element as shown in picture?
Or is there any easy way to change the label of connector from Target Top Label to Source Top Label?

Better you use Guards for the label which you find in the Constraints tab. These appear in the middle label position and enclosed in square brackets. This is actually what you want to show.
For your amusement here's my original answer
There is no way to change the label position the way you want it out-of-the-box. You will need to write a script to do that.
There are two ways to accomplish such a script. The most comfortable is to use an add-in that responds to EA_OnPostNewConnector. You would then need to check whether the connector is one from a Decision to an Action and move the label accordingly.
The second one is to have a simple script (you might edit in EA's scripting window) that you run for an open diagram to scan for all Decisions in a diagram and alter the label position accordingly.
Altering the label
Once you got a connector from a Decision to an Action at hand you will need to change the label position like this:
get the according connector from DiagramLinks since it has the label position
get the element IDs from Connector.ClientID and .SupplierID and retrieve the elements with Respository.GetElementByID(<id>)
assign both elements to either decision or action by looking into the Element.Type
get the according DiagramObjects from the diagram which match the both elements (so you can get their position on the diagram)
now it's time for a little trigonometry: the position (DiagramElement.Left, .Right, .Top and .Bottom contain the appropriate coordinates) of the two elements makes out a vector at which end you calculate (I will leave you some fun) the label position where you think it should go
finally you take this coordinate and put it into the label position (see below).
The label position is stored in DiagramObject.Geometry. This is a semicolon separated string where one tag is LRT=<colon-list>;. <colon-list> itself is a colon-separated list where two are something like OX=-1:OY=-71: and represent the label position. This is a position relative to the "normal" position where the label is placed initially by EA.
So all in all: lot's of fun awaiting you :-/

Related

Can you hide a node when not directly above a parent in Godot?

So I have an instanced scene that is supposed to be the child of a colour rect in my tree. I want to randomly generate the nodes, but I also want parts of the view to be cut off if the texture no longer is above the main section. I know you can render nodes below their parents, but I don't know if stopping part of them from rendering is physically possible.
In this image I want the bottom circle to remain the same, but the top circle to not show anything above the dark purple box
This is the node tree in the editor
Is there any way to do this directly, or am I gonna have to use a viewport of some variety?
I believe what you want is to set rect_clip_content to true on the ColorRect (or whatever Control). Making invisible any part of its children outside of it.
From Godot's documentation:
bool rect_clip_content
Enables whether rendering of CanvasItem based children should be clipped to this control's rectangle. If true, parts of a child which would be visibly outside of this control's rectangle will not be rendered.
If what you want is the opposite, perhaps you can use z_index to have something render on top, occluding the parts you don't want visible.
There is also a trick you can use with lights (including 2D lights):
Make a light that matches the area you want things to be visible.
Set a custom material that will be transparent by default, but visible on the light pass. The simpler way to do this is to set the light_mode of the material to "Light Only". You could also do it with a custom shader instead.
Making something disappear with light, in 2D, is impossible. In 3D, you can use flags_use_shadow_to_opacity. That is how you make a shadow catcher.
But, there is one more trick: you can use a mask. This should give you full control of when to show or hide things. So, if none of the above solutions works for you, use a mask. I have an explanation in a different answer. See also: How to crop sprite in a non-rectangular form?.
Mighty Mochi Games recently (2022-03-30) made a compilation of the different approaches in video form: Mask Methods Collection - Godot 3.x - 2D
.

React-Native Change Text With setNativeProps

Has anyone figured out a way to dynamically mutate text on the screen without triggering a render?
A large part of my screen utilizes setNativeProps for moving parts, meaning that the animations become lagged despite using shouldComponentUpdate. I would like to use the Text tag instead of the TextInput tag workaround suggested in this post for stylistic reasons.
Best case scenario is a workaround that involves setNaiveProps as it would follow the pattern of the rest of the screen; however, I currently plan to render all the numbers 0-9 on the screen an move them into place at the moment, so any help would be greatly appreciated!
As it turns out, you can actually format TextInputs the same exact way as Text elements (from what I have tested). For placing text horizontally, you have to set the width (something I had trouble with before). For those still interested in the original question however, you can nest TextInputs inside of a Text Element (one per text element because there is no justification and it automatically places them in a row). Styling applied to the Text Element will apply to the TextInput.

javafx drawing lines and text

I've got a problem with drawing lines in JavaFx. We're making an application simulating traffic - there are 16 streets, and every street has a different color dependent on traffic. There is a very simple picture:
http://img546.imageshack.us/img546/9949/uliceu.jpg
My first idea on how to do this was to draw streets as lines and simply change its colors. But I cant put a text on the line (I want a text with a street name). So I tried to put a line and a text on the StackPane. Then I added that StackPanes on BorderPane center... But it didnt work. Seems like StackPane doesn't respect line's start x, start y... The lines overlapped each other.
Main pane of the app is BorderPane and I want to put a map on center. It doesn't need to be resized dynamically, we have only one map so It can be positioned in static way.
I need something like that:
http://img834.imageshack.us/img834/1157/ulicac.jpg
But streets need to connect to each other... like on the first picture
Have you any suggestions on how to do that?
Any tips would be appreciated :)
Like that:
Group gr = new Group();
Text text = new Text("1st Street");
text.setFill(Color.web("fabbff"));
Line line = new Line(0, 150, 200,150);
line.setStrokeWidth(20);
line.setStroke(Color.web("000000"));
gr.getChildren().addAll(line, text);
group.getChildren().addAll(gr, //and every other street);
The StackPane you were using will by default centre everything in the centre of the StackPane, which won't be what you want.
Instead of a StackPane, use a plain Pane (if you need to CSS style the pane or have controls in the Pane resize when you resize the Pane), otherwise, use a Group. As you state that the map you are drawing doesn't need to be resized dynamically, then perhaps just a Group is fine.
The order in which items are placed inside the group or pane's children list will determine the order in which items are rendered. Items added first to the list will be rendered first and items added last to the list will be rendered on top of the items added first. So you add Street lines to your Pane or Group first, and then add Text (or Labels) on top of the streets.
Another option is to use a direct draw Canvas, but, for your application, using scene graph objects in a Pane or Group is probably a better approach.
Use either one Pane/Group with all of the streets added first, followed by all of the names or one Pane/Group for all streets and another for all street names. Separate panes might be nice because you could toggle visibility on the street names as needed by setting a visible flag on the street name group. Don't use one group for both a street and its name, then try to layer multiple street+streetname groups on top of each other, otherwise at the intersections some of the street names will be obscured by streets running on the top of them.
when I draw a line I can specify position x,y, but I can't set position of Text or Label... or can I?
In addition to positioning lines by providing coordinates to them at line creation, you also need to position the text so that it will be displayed on top of the lines. You can use the text.relocate(x, y) method to locate the text at a given location.
I know this is an old thread. However, I had the same question: How to add labels to the line that are robust against moving the line arround. This code works for me:
line = new Line();
line.startXProperty().bind(source.layoutXProperty().add(source.getBoundsInParent().getWidth() / 2.0));
line.startYProperty().bind( source.layoutYProperty().add(source.getBoundsInParent().getHeight() / 2.0));
line.endXProperty().bind( target.layoutXProperty().add( target.getBoundsInParent().getWidth() / 2.0));
line.endYProperty().bind( target.layoutYProperty().add( target.getBoundsInParent().getHeight() / 2.0));
label.layoutXProperty().bind(line.endXProperty().subtract(line.endXProperty().subtract(line.startXProperty()).divide(2)));
label.layoutYProperty().bind(line.endYProperty().subtract(line.endYProperty().subtract(line.startYProperty()).divide(2)));
getChildren().addAll( line, label);

Is it possible for text/font to overlap input field?

I am wondering if it is possible to make the font/text inside of an input field overlap the input field itself. I'd like to know if this is possible without doing something like creating two input fields with one overlapping the other and one having a hidden field box.
For instance, say you have a font that looks like handwriting and you want the descenders of lowercase letters (the bottom parts of "p" "y" "g" for instance) to hang below the field box rather than get cut off by it - similar to how handwriting extends below the baseline when writing on lined paper.
I've done extensive searching with little luck, so even if someone knows of a better search term than "text overlapping input-box" and similar such strings, that in iteself would be a tremendous help.
The thing is, I don't know of a CSS selector that just focuses on the text inside the input-box or I would try to increase the z-index of the text so that it would be on a layer above the box.
Have you tried setting a background image on the input element? Your background image could be the line.
i.e.
input {
background: url(path/to/image.png) repeat-x;
}
EDIT:
I've had a quick play with this and have got something up and running here: http://jsfiddle.net/qUc9Y/
I've wrapped the input in another element (fieldset.input-wrapper) and moved your CSS transitions to this new element. I've pushed the input down relatively 10px so it overhangs the shadow created by the container. I've set the background of the input to transparent so the box shadows on the .input-wrapper are visible through it.
Finally, I've added some quick jQuery so that when the input is hovered, the css transitions are applied to the new .input-wrapper container (i.e. the input's parent). You should be able to do the same for focus/blur.
I hope this helps.
EDIT 2:
The focus state should now work too, see http://jsfiddle.net/yZ3uw/14/ .

How do I implement a group of strings that starts randomly, but is bound by relevance upon selection?

Okay the title may be a little confusing, but here's what I'm trying to do :) I have a game in XNA where every tap from the user draws a moving circle on the screen. The circle has a tag, say 'dogs' displayed on it. So imagine multiple taps on the screen, and we have all these circles of various colors and sizes moving around the screen with different (but constant) velocities. Each circle with different tags: 'dogs', 'cats' and so on...
Clicking on empty space generates a new circle at that point. Clicking on one of the circles "selects" it, turning it into a greeen shade and slowing its velocity down to a fraction of what it was. Clicking on it again "unselects" it, and restores its original color and velocity (trajectory does not change).
With each circle comes a tag, and as of now I'm populating these tags randomly from a string array (which means there's a chance tags will repeat). I would like the tags for newly created circles to be relevant to previous "selected" tags. So when I click on 'dogs', I would like 'German Shepherd' but I would also like 'dog parks' and 'lemurs' assuming dogs get along well with lemurs.
What would be the best way to approach this problem. In my head I have a massive many-to-many mapping, but I can't seem to translate it to code. Thanks for looking.
FYI I'm using the sample project from here:
http://mobile.tutsplus.com/tutorials/windows/introduction-to-xna-on-windows-phone-7/
At a glance your data structure sounds like a tree, except each node has a list of parents instead of a single parent. You could describe it as many to many like you said, but there's likely more links in the child direction than the parent direction.
Alternatively you could leave it as a tree structure and add a list of associations to nodes, so that like you say lemurs and dogs can be associated, even though they are not in a parent / child relationship.

Resources