I am using FlowPane so I can wrap/unwrap nodes when the container is resized. There are many nodes in the FlowPane and thus the are laid out in several lines. The orientation is horizontal. What I want to achieve is the justify alignment of nodes. Just like in MS Word, you can justify the paragraph and all nodes will be spread with equal space between nodes for each line. Is it possible to do it in JavaFX?
Related
I know how to use alignment/distribution with inkscape.
But they only work once. It does not persist.
Example:
As soon as I change the size of one of the objects, and the alignment gets lost.
Is there a way to persist the alignment?
Example: If I change the size of the circle, its center should still be centered.
If Inkscape can't do that. Is there an other tool which can do this?
There is no such thing as persistent alignment in Inkscape AFAIK.
One thing you can do is resize objects around their center (holding shift while resizing).
Another option (my preferred) is to enable snapping to midpoints, centers of objects and centers of rotation, and to use guides. This way you can quickly snap objects back in place after modification.
Your question relates to the more general issue of
transformation anchors, regardless of whether there are alignment requirements or not.
The currently available simple method, holding shift while resizing, always uses the center of the object as the anchor, which may or may not be what you want (in your example, you may want to keep centered alignment in the vertical direction, but left alignment for each object in the horizontal direction).
There is a proposal for selecting the transformation anchor.
As per official documentation, The anchors let you decide the transformation center to use when entering a numerical value for a transformation (let it be from the toolbar or in the Object->Transform... dialog).
The interface would let you select the center for the transformation. Then, you would have 3 (vertical) x 3 (horizontal) = 9 possible anchors.
AFAIK, this is not available yet.
In order to change the size of any vectorial component and persist its transformation center you have three options:
holding shift + mouse drag (will perform symmetric transformation)
holding shift + ctrl (will scale but keeping the same aspect ratio)
holding shift + ctrl + alt (will scale upwards/downwards by twice/half the size && keeping the same ratio)
I am aware that I can call IDWriteTextLayout::GetMetrics, but this gives me the boundaries of the text including space above and below the text for the ascender and descender, etc. However, what I'm looking for is the exact amount of space that the text actually takes up. How would I obtain or calculate this bounding box?
You should use GetMetrics() together with GetOverhangMetrics(), subtracting overhang metrics from layout metrics will give you ink rectangle.
I'm trying to draw a tree within a GEF editor. The problem is that I need to draw it bottom up. I have a primary layer for the node figures, and a connection layer for the connections.
The primary layer is a FreeformLayer, the root edit part a ScalableFreeformLayeredPane. The primary layer has a XYLayout.
Now I need to find the bottom edge of the editor (= viewport???) in order to be able to draw the bottom level of figures ("tokens") at that position (bottom y of primary layer - height of tokens = y of tokens). How can I get that?
I've tried to do it with BorderLayout so the tokens get painted at the bottom of the editor (BorderLayout.BOTTOM), and the nodes above it in BorderLayout.CENTER, but I've run into trouble with selections, and the layout is far from what I want to achieve.
So basically I want to have all nodes in one layer. I can set the position of the tokens, but the nodes above them must be calculated dynamically. How can I do this within XYLayout?
Many thanks in advance!
(Alternatively, positioning the tokens in the y-centered would be acceptable if it's easier to achieve)
You could look at Zest Layout Algorithms to have some inspiration:
http://www.eclipse.org/gef/zest/
I'm doing some graphics processing and I have a logic where in I have a bitmap with edges and I disregard all table edges from the letters E.g.
0000000000
0111111110
0100000010
0102220010
0100200010
0100200010
0100000010
0111111110
0000000000
0 - background color
1 - ignored edges
2 - edges I need
My logic is just simple, if a number of continuous pixels exceeds a certain threshold, e.g. 20pixels of continuous edges, it will consider it as a line and disregard it.
My problem is that on big font size and letters such as H and T, it will definitely exceed the threshold. Please advise is there a better way or additional logic i need to implement in order to separate table lines from letters.
[update] Additional consideration: Performance, this logic will be used during touch movement (dragging). It will be called a lot of times so it needs to be fast.
If table lines are guaranteed to be thin, then ignore thick lines. However, if the lines in your application are generated by edge detection (which are always 1-pixel thin) then connected-component will be needed.
Basically, the "thickness" refers to thickness measured from an edge profile:
00000000100000000 This line has thickness 1
00000011111000000 This line has thickness 5. However, this cannot occur in the output of edge detection, because edge detection algorithms are specifically designed to remove this condition.
00000000111111111 This is a transition from black to white.
Table lines usually have small thickness. Large fonts usually have transition from black to white because their thickness is larger than the edge profile window.
I'm halfway there please see the edit
OK here's my problem, I'm generating a graph of a python module, including all the files with their functions/methods/classes.
I want to arrange it so, that nodes gather in circles around their parent nodes, currently everything is on one gargantuan horizontal row, which makes the thing >50k pixels wide and also let's the svg converter fail(only renders about the half of the graph).
I went through the docs but couldn't find anything that seems to do the trick.
So the question is:
Is there a simple way to do this or do I have to layout the whole thing by myself? :/
EDIT:
Thanks to Andrews comment I've got the right layout, the only problem now is that it's a bit to "compact"... so the question now is, how to fix this?
i've mentioned all of the most significant parameters that influence your current layout and then suggested values for those parameters. Still, i suspect you can get the layout that you want just from applying a couple of these suggestions.
reduce the edge weight, eg, [weight=0.5]; this will make the
edges longer, causing the tight
clusters you currently see in your
graph to 'fan out'.
get rid of the node borders, node_A
[color=none; shape=plaintext];
especially for oval-shaped nodes, a
substantial fraction of the total
node space is 'unused' (ie, not used
to display the node label).
explicitly set the font size for
the nodes (the node borders are
enlarged so that they surround the
node text, which means that the font
size and amount of text for a given
node has a significant effect on its
size); [fontsize=11] should be large
enough to be legible yet also reduce
the 'cluttered' appearance (the
default size is 14).
increase minimum separation between
nodes, via 'nodesep'; eg, nodesep=2.0; this will
directly address your objection
regarding your graph being "too
compact." ('nodesep' and 'ranksep'
probably affect how dot draws a graph
more than any other parameters for
node, edge, or graph. In your case,
it looks like you have only two ranks
of nodes; 'ranksep' sets the minimum
distance between nodes of different
ranks--it looks like all of the nodes
that comprise your graph are of the
same rank (except for few top level
nodes in the centers).
explicitly set total graph size, eg,
size="7.75,10.25" (ensures that your
graph fits on an 8.5 x 11 page and
that it occupies the entire space)
And one purely aesthetic suggestion
that at most will only help your
graph appear less cluttered: the
default fontcolor for both edges and
nodes is black. The majority of the
ink on your graph is from those two
structures (particularly if you
remove the node borders), so i would
for instance set either the node
(text) fontcolor or the edge
fontcolor to "blue" to help the eye
distinguish the two sets of graph
structures.
If it is too compact, you will want to mess with the edge length. You have a couple options depending on the graph layout:
If your layout is sfdp or fdp, tweak the graph property K. Default is 0.3.
For neato (or fdp), tweak the edge property len. Default is 1.0 for neato and 0.3 for fdp.
For dot you can use the edge property minlen which is the minimum edge length. Default is 1.
You might also want to mess with the graph property model which determines clustering behavior. Specifically, try subset. I believe this handles len for you:
http://www.graphviz.org/doc/info/attrs.html#d:model
Also, you can remove overlaps all together with scaling techniques: http://www.graphviz.org/doc/info/attrs.html#d:overlap
I have around 500 nodes and used doug's recommendation.
This is my sample code that works (in python):
f = Digraph('companies',filename='companies.gv',
edge_attr={'weight':'1',
'fontsize':'11',
'fontcolor':'blue',
'len':'4'},
graph_attr={'fixedsize':'false',
'bgcolor':'transparent'},
node_attr={'fontsize':'11',
'shape':'plaintext',
'color':'none',
'fontcolor':'black'})
f.attr(layout="neato")
f.attr(nodesep='3')
f.attr(ranksep='3')
f.attr(size='5000,5000')