This seems like a good enhancement request. Please enter a JIRA for it.
Steve
On 2014-06-11, 10:17 AM, Jeff Martin wrote:
Below is my poor man's getVisibleBounds. I'm using this so that my custom text
pane only needs to add child nodes for lines of text that are visible - similar
to how ListView and friends only add cell nodes for visible items. I hope I'm
on the right track - I was surprised that my web search for getVisibleBounds()
came up so empty. If nobody points out my idiocy, I'm going to put this in a
blog.
jeff
/**
* Returns the visible bounds for a node based on ancestor clips (or null if
no clipping found).
*/
public static Bounds getVisibleBounds(Node aNode)
{
// Get parent visible bounds (if set, convert to local)
Bounds bounds = aNode.getParent()!=null?
getVisibleBounds(aNode.getParent()) : null;
if(bounds!=null) { if(!bounds.isEmpty()) bounds =
aNode.parentToLocal(bounds); else return bounds; }
// If node has clip, get clip local bounds (intersected with parent visible bounds if present)
if(aNode.getClip()!=null) { Node clip = aNode.getClip(); Bounds cb =
clip.getBoundsInLocal();
bounds = bounds!=null? getIntersectingBounds(cb, bounds) : cb; }
// Return node visible bounds
return bounds;
}
/**
* Returns the intersection bounds of two bounds.
*/
public static Bounds getIntersectingBounds(Bounds b1, Bounds b2)
{
if(!b1.intersects(b2)) return new BoundingBox(0,0,-1,-1);
double minx = Math.max(b1.getMinX(), b2.getMinX());
double miny = Math.max(b1.getMinY(), b2.getMinY());
double maxx = Math.min(b1.getMaxX(), b2.getMaxX());
double maxy = Math.min(b1.getMaxY(), b2.getMaxY());
return new BoundingBox(minx, miny, maxx-minx, maxy-miny);
}
On Jun 10, 2014, at 6:59 PM, Jeff Martin <j...@reportmill.com> wrote:
What is the JFX equivalent of JComponent.getVisibleRect() - and is there a way
to get a notification when it changes?
jeff