Text in Ellipses JavaFX - text

I created a custom venn chart for two sets an their intersection in JavaFX.
Now I want to show the number of elements in this sets like in the following picture:
The sets are ellipses and I used masks to give the intersection a different color.
Now I want to show the number with size and position related to the available space so that the numbers are always inside the according area.
The width for the text element is easy to calculate, but I don't know how to get available height for the text elements.
Maybe it could be helpful to have the pixels of the ellipses as path, but I have no idea to how I can get this.
Does anyone know how to implement that?
Edit:
I developed an algorithm to find the size of a rectangle, which fits in the required areas of the ellipses. The text are scaled to the size of the rectangle and it works, but now I have another problem.
I need to center the scaled text in the rectangle an I used a StackPane for that. But I can't position the StackPane in the chart parent. If I set the layoutX and layoutY the bounds in parent are different.
For example: stackPane with text = sp;
sp.setLayoutY(122.1662320906945);
The Result for getBoundsInParent().getMinY() is 97.16622924804688;
How can I set the StackPane position, if I use it in a chart class as chart children?

Related

Meshlab non-dispersed vertex Coloring

In meshlab, If I select a vertex and color it with red (per vertex color function), the result becomes
Red is too dispersed.
What I want is just : (image below was edited by photoshop):
How can I do it ?
On triangular meshes, when the color is defined in a per-vertex way, the colors are linearly interpolated across each triangle, so the result is precisely the expected one.
If you need just a way of looking at a few vertices, just enable the visualization of selected vertices and select them.
On the other hand, if you just need to reduce the color's spread, refine the mesh so that the underlying triangles are smaller, and the color is interpolated across a smaller area.
You can get something quite similar to your desired behavior.
The color dispersion is due to Gouraud shading. You can disable it clicking in the tab of face render options and change color button from "vertex" to "face" or "user defined"
To render vertex as "balls with color"
Click on the tab of vertex and choose the option Dot Decorator (1)
Change the size of dots with the Point Size Bar (2)
Let the color buttons in "mesh", not "user defined"

Is there a simple algorithm that can find the envelope of several circles?

Given a number of points on a 2d surface and radiuses for these points I can easily paint circles for them. What I need is an algorithm that only paints the envelope (right word for what I am looking for?) or outer bound of these combined circles. Additionally a second set of circles can 'encroach' on these circles, resulting in a kind of 'border'.
Image of what I am looking for
A quick way to draw the outline of the union of the disks is to
fill all disks in yellow, then
fill all disks in white with a smaller radius.
This can be adapted to the "encroached" circles, provided you only fill the remaining portions of the disks. Unfortunately, in a general setting finding the remaining portions can be an uneasy geometric problem.
There is an alternative approach which can work in all cases:
fill an image with zeroes, then for all disks fill every pixel with the value of the distance to the circumference (maximum at the center), but only keep the highest value so far.
while you do this, fill a second image with the color of the disk that achieved that highest value. (Initialize the image with the background color.)
At the end of this process, the first image will represent a "terrain" made of intersecting cones; and for every point of the terrain, you will know the color.
finally, color the pixels that have a height smaller than the desired stroke width, using the color map.
You can do the drawing in two steps.
1) Draw the outline using the following method: For each point, draw a circle using your favorite circle-drawing method, but before drawing a pixel, ensure that it is not contained inside any other circle. Do this for every point and you will get your outline.
2) Draw the borders between different sets using the following method: For each pair of points from different sets, calculate the two intersection points of the circles. If there is an intersection, the border can be drawn as a segment joining these two points. However, you have to make two lines, one for circle A, and another for circle B. To draw the line for circle A, slightly offset the segment towards point A. Then, use your favorite line-drawing method, but before drawing a pixel, ensure that it is closer to point A that any other point of the opposite set. After drawing the line, repeat the process for circle B. Note that both segment are not guaranteed to be the same length since the asymmetry of the points of the different sets. It will, however, always form a closed shape when all outlines and borders are drawn.

Extend two colors bars across full width of browser?

I have two boxes filled with colors, a green one on the left, and gray one on the right. They go right up against each other in the middle of the screen, and I would like each one to extend the width of the browser, so the green one extends all the way to the left, and the gray one extends all the way to the right, no matter how wide the browser gets. How can I do this?
the width property supports percentage values, which are relative to the size of the window it exists in.
See:
http://learnlayout.com/percent.html
http://www.w3schools.com/cssref/pr_dim_width.asp

Can an Enum be used to provide two values?

For drawing filled shapes like Rectangle, Eclipse need two values width and height (converted from int to float).
There's an enum,
Public enum Sizes : int
{
One=5,
Two=10,
Five=10,
Seven=12,
Ten=15,
}
In terms of drawing a Square of One, should be of width and height of 5. Which is straight forward. However when drawing Oval Shapes and Rectangular shapes above one value isn't sufficient.
Is there a way I could define another float value? So when compared for Ten, it can provide 15 for Width and 10 for Height...
Or does it mean, there should be two enums, one for Width and one for Height?
EDIT to provide more background info:
There's an UI which allows users to create certain shapes.
User inputs are: Shape Type (Line, Rectangle, Eclipse), Points, Size (but this size doesn't exactly reflect the size of the shape. e.g. 10 is a capacity. Capacity 10 must draw 15px Width and 10px height Rectangle/Eclipse).
Line doesn't take Size into account as it is drawn using the Points input. The rest of the shapes do take Size into account. So this is where I need to check the Size(capacity) parameter and issue the correct Width and Height to be drawn.

Three.js calculate .obj size (bottom and top position.y)

How can I calculate object bottom position?
I created an object and a plane, both in (0,0,0) position, but the model geometrical center is placed in that point, not the bottom face of it, in result, the plane is clipping the half of it, see the demo: http://www.edar.com.pl/test-3d-3/
I'd like my models to have the same height when I place them on the screen. Also I want them all to intersect the shadow plane with their bottom parts, so I guess I have to calculate their heights and move them via object.position.y = obj_height/2; ?
Check Three.GeometryUtils.Center() - function which centers the geometry of an object.
So you could copy and modify the function to your liking to center the geometry at the bottom center.
Also you could also iterate over all vertices and just add or remove an offset-vector.

Resources