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 protected
SwingThreadSpatial(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)
void
clear()
destroy the current spatial structureT
getClosestElement(double x, double y)
T
getClosestElement(Point2D p)
TreeNode
getContainingLeaf(Object element)
Set<? extends TreeNode>
getContainingLeafs(double x, double y)
Set<? extends TreeNode>
getContainingLeafs(Point2D p)
List<Shape>
getGrid()
Rectangle2D
getLayoutArea()
LayoutModel
getLayoutModel()
Collection<Shape>
getPickShapes()
a short-lived collection of recent pick target areasSpatial<T,NT>
getSpatial()
Rectangle2D
getUnion(Rectangle2D rect, double x, double y)
Rectangle2D
getUnion(Rectangle2D rect, Point2D p)
expands the passed rectangle so that it includes the passed pointSet<T>
getVisibleElements(Shape shape)
boolean
isActive()
void
layoutStateChanged(LayoutStateChange.Event evt)
void
layoutVertexPositionChanged(LayoutVertexPositionChange.Event<NT> evt)
void
layoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<NT> evt)
static <T,NT>
SwingThreadSpatial<T,NT>of(Spatial<T,NT> delegate)
void
recalculate()
rebuild the data structurevoid
setActive(boolean active)
a flag to suggest whether or not the spatial structure should be usedvoid
setBounds(Rectangle2D bounds)
void
update(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:
layoutStateChanged
in interfaceLayoutStateChange.Listener
-
setActive
public void setActive(boolean active)
Description copied from interface:Spatial
a 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:Spatial
a short-lived collection of recent pick target areas- Specified by:
getPickShapes
in interfaceSpatial<T,NT>
- Returns:
-
clear
public void clear()
Description copied from interface:Spatial
destroy the current spatial structure
-
recalculate
public void recalculate()
Description copied from interface:Spatial
rebuild the data structure- Specified by:
recalculate
in interfaceSpatial<T,NT>
-
getLayoutArea
public Rectangle2D getLayoutArea()
- Specified by:
getLayoutArea
in 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:Spatial
expands 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:Spatial
update the spatial structure with the (possibly new) location of the passed element
-
getContainingLeafs
public Set<? extends TreeNode> getContainingLeafs(Point2D p)
- Specified by:
getContainingLeafs
in 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:
getContainingLeafs
in 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:
getContainingLeaf
in 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:
getVisibleElements
in 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:
getClosestElement
in 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:
getClosestElement
in 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:
getLayoutModel
in interfaceSpatial<T,NT>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.Event<NT> evt)
- Specified by:
layoutVertexPositionChanged
in interfaceLayoutVertexPositionChange.Listener<T>
-
layoutVertexPositionChanged
public void layoutVertexPositionChanged(LayoutVertexPositionChange.GraphEvent<NT> evt)
- Specified by:
layoutVertexPositionChanged
in interfaceLayoutVertexPositionChange.Listener<T>
-
-