Class SwingThreadSpatial<T,NT>
- java.lang.Object
-
- org.jungrapht.visualization.spatial.SwingThreadSpatial<T,NT>
-
- All Implemented Interfaces:
LayoutStateChange.Listener,LayoutVertexPositionChange.Listener<NT>,Spatial<T,NT>
public class SwingThreadSpatial<T,NT> extends Object implements Spatial<T,NT>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jungrapht.visualization.spatial.Spatial
Spatial.NoOp<T,NT>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSwingThreadSpatial(Spatial<T,NT> delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Spatial<T,NT>after(Runnable after)voidclear()destroy the current spatial structureTgetClosestElement(double x, double y)TgetClosestElement(Point2D p)TreeNodegetContainingLeaf(Object element)Set<? extends TreeNode>getContainingLeafs(double x, double y)Set<? extends TreeNode>getContainingLeafs(Point2D p)List<Shape>getGrid()Rectangle2DgetLayoutArea()LayoutModelgetLayoutModel()Collection<Shape>getPickShapes()a short-lived collection of recent pick target areasSpatial<T,NT>getSpatial()Rectangle2DgetUnion(Rectangle2D rect, double x, double y)Rectangle2DgetUnion(Rectangle2D rect, Point2D p)expands the passed rectangle so that it includes the passed pointSet<T>getVisibleElements(Shape shape)booleanisActive()voidlayoutStateChanged(LayoutStateChange.Event evt)voidlayoutVertexPositionChanged(LayoutVertexPositionChange.Event<NT> evt)voidlayoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<NT> evt)static <T,NT>
SwingThreadSpatial<T,NT>of(Spatial<T,NT> delegate)voidrecalculate()rebuild the data structurevoidsetActive(boolean active)a flag to suggest whether or not the spatial structure should be usedvoidsetBounds(Rectangle2D bounds)voidupdate(T element, Point location)update the spatial structure with the (possibly new) location of the passed element
-
-
-
Method Detail
-
of
public static <T,NT> SwingThreadSpatial<T,NT> of(Spatial<T,NT> delegate)
-
layoutStateChanged
public void layoutStateChanged(LayoutStateChange.Event evt)
- Specified by:
layoutStateChangedin interfaceLayoutStateChange.Listener
-
setActive
public void setActive(boolean active)
Description copied from interface:Spatiala flag to suggest whether or not the spatial structure should be used
-
isActive
public boolean isActive()
-
getPickShapes
public Collection<Shape> getPickShapes()
Description copied from interface:Spatiala short-lived collection of recent pick target areas- Specified by:
getPickShapesin interfaceSpatial<T,NT>- Returns:
-
clear
public void clear()
Description copied from interface:Spatialdestroy the current spatial structure
-
recalculate
public void recalculate()
Description copied from interface:Spatialrebuild the data structure- Specified by:
recalculatein interfaceSpatial<T,NT>
-
getLayoutArea
public Rectangle2D getLayoutArea()
- Specified by:
getLayoutAreain interfaceSpatial<T,NT>- Returns:
- the 2 dimensional area of interest for this class
-
setBounds
public void setBounds(Rectangle2D bounds)
-
getUnion
public Rectangle2D getUnion(Rectangle2D rect, Point2D p)
Description copied from interface:Spatialexpands the passed rectangle so that it includes the passed point
-
getUnion
public Rectangle2D getUnion(Rectangle2D rect, double x, double y)
-
update
public void update(T element, Point location)
Description copied from interface:Spatialupdate the spatial structure with the (possibly new) location of the passed element
-
getContainingLeafs
public Set<? extends TreeNode> getContainingLeafs(Point2D p)
- Specified by:
getContainingLeafsin interfaceSpatial<T,NT>- Parameters:
p- a point to search in the spatial structure- Returns:
- all leaf nodes that contain the passed point
-
getContainingLeafs
public Set<? extends TreeNode> getContainingLeafs(double x, double y)
- Specified by:
getContainingLeafsin interfaceSpatial<T,NT>- Parameters:
x- the x location to search fory- the y location to search for- Returns:
- all leaf nodes that contain the passed coordinates
-
getContainingLeaf
public TreeNode getContainingLeaf(Object element)
- Specified by:
getContainingLeafin interfaceSpatial<T,NT>- Parameters:
element- element to search for- Returns:
- the leaf node that currently contains the element (not a spatial search)
-
getVisibleElements
public Set<T> getVisibleElements(Shape shape)
- Specified by:
getVisibleElementsin interfaceSpatial<T,NT>- Parameters:
shape- a shape to filter the spatial structure's elements- Returns:
- all elements that are contained in the passed shape
-
getClosestElement
public T getClosestElement(Point2D p)
- Specified by:
getClosestElementin interfaceSpatial<T,NT>- Parameters:
p- a point to search in the spatial structure- Returns:
- the closest element to the passed point
-
getClosestElement
public T getClosestElement(double x, double y)
- Specified by:
getClosestElementin interfaceSpatial<T,NT>- Parameters:
x- coordinate of a point to search in the spatial structurey- coordinate of a point to search in the spatial structure- Returns:
- the closest element to the passed coordinates
-
getLayoutModel
public LayoutModel getLayoutModel()
- Specified by:
getLayoutModelin interfaceSpatial<T,NT>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.Event<NT> evt)
- Specified by:
layoutVertexPositionChangedin interfaceLayoutVertexPositionChange.Listener<T>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<NT> evt)
- Specified by:
layoutVertexPositionChangedin interfaceLayoutVertexPositionChange.Listener<T>
-
-