Package org.jungrapht.visualization
Class DefaultRenderContext<V,E>
- java.lang.Object
-
- org.jungrapht.visualization.DefaultRenderContext<V,E>
-
- Type Parameters:
V
- vertex typeE
- edge type
- All Implemented Interfaces:
RenderContext<V,E>
,RenderContextStateChange.Producer
public class DefaultRenderContext<V,E> extends Object implements RenderContext<V,E>
- Author:
- Tom Nelson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultRenderContext.ShapeFunctionSupplier<V>
Supplies Shapes for vertices by checking various properties-
Nested classes/interfaces inherited from interface org.jungrapht.visualization.RenderContext
RenderContext.DirectedEdgeArrowPredicate, RenderContext.UndirectedEdgeArrowPredicate
-
-
Field Summary
Fields Modifier and Type Field Description protected Function<E,Paint>
arrowDrawPaintFunction
implement to providePaint
s for edge arrow outlineprotected Function<E,Paint>
arrowFillPaintFunction
implement to providePaint
s for edge arrowsprotected float
arrowPlacementTolerance
protected boolean
arrowsOnUndirectedEdges
whentrue
, draws arrows at both ends of undirected edges default isfalse
- no arrows drawn for undirected edgesstatic String
EDGE_WIDTH
protected Shape
edgeArrow
protected Stroke
edgeArrowStroke
protected Function<E,Stroke>
edgeArrowStrokeFunction
implement to provideStroke
s for edge arrowsprotected Function<E,Paint>
edgeDrawPaintFunction
implement to provide draw s for edgesprotected Function<E,Paint>
edgeFillPaintFunction
implement to provide fill color for edges (rarely useful)protected Function<E,Font>
edgeFontFunction
implement to provide s for edge labelsprotected Predicate<E>
edgeIncludePredicate
protected Function<E,String>
edgeLabelFunction
implement to provide edge labelsprotected EdgeLabelRenderer
edgeLabelRenderer
protected BiFunction<org.jgrapht.Graph<V,E>,E,Shape>
edgeShapeFunction
protected Stroke
edgeStroke
theStroke
used to draw edgesprotected Function<E,Stroke>
edgeStrokeFunction
implement to provideStroke
s for edgesprotected float
edgeStrokeWidth
protected GraphicsDecorator
graphicsContext
protected int
labelOffset
protected MultiLayerTransformer
multiLayerTransformer
protected EdgeIndexFunction<V,E>
parallelEdgeIndexFunction
protected GraphElementAccessor<V,E>
pickSupport
pluggable support for picking graph elements by finding them based on their coordinates.protected boolean
renderEdgeArrow
protected CellRendererPane
rendererPane
The CellRendererPane is used here just as it is in JTree and JTable, to allow a pluggable JLabel-based renderer for Vertex and Edge label strings and icons.protected JComponent
screenDevice
the JComponent that this Renderer will display the graph onprotected MutableSelectedState<E>
selectedEdgeState
Holds asubset of edges that are selectedprotected MutableSelectedState<V>
selectedVertexState
Holds a subset of vertices that are selectedprotected Function<V,Paint>
vertexDrawPaintFunction
implement to provide outline color for verticesprotected Function<V,Paint>
vertexFillPaintFunction
implement to provide fill color for vertices.protected Function<V,Font>
vertexFontFunction
implement to provideFont
s for verticesprotected Function<V,Icon>
vertexIconFunction
protected Predicate<V>
vertexIncludePredicate
Implement to limit which vertices are renderedprotected Function<V,Paint>
vertexLabelDrawPaintFunction
implement to provide Colors for vertex labelsprotected Function<V,String>
vertexLabelFunction
provide labels for verticesprotected VertexLabelRenderer
vertexLabelRenderer
A default GraphLabelRenderer - selected Vertex labels are blue, selected edge labels are cyanprotected Function<V,Shape>
vertexShapeFunction
implement to provide Shapes for verticesprotected Function<V,Stroke>
vertexStrokeFunction
theStroke
used to draw (outline) vertex shapes-
Fields inherited from interface org.jungrapht.visualization.RenderContext
dashing, dotting, LABEL_OFFSET
-
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jungrapht.visualization.RenderContext
getUnarticulatedEdgeShapeFunction, getVertexBoundsFunction
-
-
-
-
Field Detail
-
EDGE_WIDTH
public static final String EDGE_WIDTH
- See Also:
- Constant Field Values
-
selectedVertexState
protected MutableSelectedState<V> selectedVertexState
Holds a subset of vertices that are selected
-
selectedEdgeState
protected MutableSelectedState<E> selectedEdgeState
Holds asubset of edges that are selected
-
edgeStrokeWidth
protected float edgeStrokeWidth
-
vertexIncludePredicate
protected Predicate<V> vertexIncludePredicate
Implement to limit which vertices are rendered
-
vertexStrokeFunction
protected Function<V,Stroke> vertexStrokeFunction
theStroke
used to draw (outline) vertex shapes
-
vertexShapeFunction
protected Function<V,Shape> vertexShapeFunction
implement to provide Shapes for vertices
-
vertexDrawPaintFunction
protected Function<V,Paint> vertexDrawPaintFunction
implement to provide outline color for vertices
-
vertexFillPaintFunction
protected Function<V,Paint> vertexFillPaintFunction
implement to provide fill color for vertices. Default version uses default fill paint and selected vertex fill paing
-
vertexFontFunction
protected Function<V,Font> vertexFontFunction
implement to provideFont
s for vertices
-
vertexLabelDrawPaintFunction
protected Function<V,Paint> vertexLabelDrawPaintFunction
implement to provide Colors for vertex labels
-
edgeStrokeFunction
protected Function<E,Stroke> edgeStrokeFunction
implement to provideStroke
s for edges
-
edgeFillPaintFunction
protected Function<E,Paint> edgeFillPaintFunction
implement to provide fill color for edges (rarely useful)
-
edgeDrawPaintFunction
protected Function<E,Paint> edgeDrawPaintFunction
implement to provide draw s for edges
-
edgeFontFunction
protected Function<E,Font> edgeFontFunction
implement to provide s for edge labels
-
edgeArrow
protected Shape edgeArrow
-
arrowPlacementTolerance
protected float arrowPlacementTolerance
-
edgeArrowStroke
protected Stroke edgeArrowStroke
-
edgeArrowStrokeFunction
protected Function<E,Stroke> edgeArrowStrokeFunction
implement to provideStroke
s for edge arrows
-
arrowFillPaintFunction
protected Function<E,Paint> arrowFillPaintFunction
implement to providePaint
s for edge arrows
-
arrowDrawPaintFunction
protected Function<E,Paint> arrowDrawPaintFunction
implement to providePaint
s for edge arrow outline
-
arrowsOnUndirectedEdges
protected boolean arrowsOnUndirectedEdges
whentrue
, draws arrows at both ends of undirected edges default isfalse
- no arrows drawn for undirected edges
-
renderEdgeArrow
protected boolean renderEdgeArrow
-
edgeShapeFunction
protected BiFunction<org.jgrapht.Graph<V,E>,E,Shape> edgeShapeFunction
-
parallelEdgeIndexFunction
protected EdgeIndexFunction<V,E> parallelEdgeIndexFunction
-
multiLayerTransformer
protected MultiLayerTransformer multiLayerTransformer
-
pickSupport
protected GraphElementAccessor<V,E> pickSupport
pluggable support for picking graph elements by finding them based on their coordinates.
-
labelOffset
protected int labelOffset
-
screenDevice
protected JComponent screenDevice
the JComponent that this Renderer will display the graph on
-
rendererPane
protected CellRendererPane rendererPane
The CellRendererPane is used here just as it is in JTree and JTable, to allow a pluggable JLabel-based renderer for Vertex and Edge label strings and icons.
-
vertexLabelRenderer
protected VertexLabelRenderer vertexLabelRenderer
A default GraphLabelRenderer - selected Vertex labels are blue, selected edge labels are cyan
-
edgeLabelRenderer
protected EdgeLabelRenderer edgeLabelRenderer
-
graphicsContext
protected GraphicsDecorator graphicsContext
-
-
Method Detail
-
getRenderContextStateChangeSupport
public RenderContextStateChange.Support getRenderContextStateChangeSupport()
getter for event support. Caller can add itself as a listener to RenderContextStateChange events- Specified by:
getRenderContextStateChangeSupport
in interfaceRenderContextStateChange.Producer
- Returns:
- theRenderContextStateChangeSupport that will fire events to listeners
-
setupArrows
public void setupArrows(boolean directed)
sets the arrow functions, depending on the graph type- Specified by:
setupArrows
in interfaceRenderContext<V,E>
-
getVertexShapeFunction
public Function<V,Shape> getVertexShapeFunction()
- Specified by:
getVertexShapeFunction
in interfaceRenderContext<V,E>
- Returns:
- the vertexShapeFunction
-
setVertexShapeFunction
public void setVertexShapeFunction(Function<V,Shape> vertexShapeFunction)
- Specified by:
setVertexShapeFunction
in interfaceRenderContext<V,E>
- Parameters:
vertexShapeFunction
- the vertexShapeFunction to set
-
getVertexStrokeFunction
public Function<V,Stroke> getVertexStrokeFunction()
- Specified by:
getVertexStrokeFunction
in interfaceRenderContext<V,E>
- Returns:
- the vertexStrokeFunction
-
setVertexStrokeFunction
public void setVertexStrokeFunction(Function<V,Stroke> vertexStrokeFunction)
- Specified by:
setVertexStrokeFunction
in interfaceRenderContext<V,E>
- Parameters:
vertexStrokeFunction
- the vertexStrokeFunction to set
-
getDashing
public static float[] getDashing()
-
getDotting
public static float[] getDotting()
-
getArrowPlacementTolerance
public float getArrowPlacementTolerance()
- Specified by:
getArrowPlacementTolerance
in interfaceRenderContext<V,E>
-
setArrowPlacementTolerance
public void setArrowPlacementTolerance(float arrow_placement_tolerance)
- Specified by:
setArrowPlacementTolerance
in interfaceRenderContext<V,E>
-
getEdgeArrow
public Shape getEdgeArrow()
- Specified by:
getEdgeArrow
in interfaceRenderContext<V,E>
-
setEdgeArrow
public void setEdgeArrow(Shape shape)
- Specified by:
setEdgeArrow
in interfaceRenderContext<V,E>
-
renderEdgeArrow
public boolean renderEdgeArrow()
- Specified by:
renderEdgeArrow
in interfaceRenderContext<V,E>
-
setRenderEdgeArrow
public void setRenderEdgeArrow(boolean render)
- Specified by:
setRenderEdgeArrow
in interfaceRenderContext<V,E>
-
setEdgeArrowWidth
public void setEdgeArrowWidth(int edgeArrowWidth)
- Specified by:
setEdgeArrowWidth
in interfaceRenderContext<V,E>
-
getEdgeArrowWidth
public int getEdgeArrowWidth()
- Specified by:
getEdgeArrowWidth
in interfaceRenderContext<V,E>
-
setEdgeArrowLength
public void setEdgeArrowLength(int edgeArrowLength)
- Specified by:
setEdgeArrowLength
in interfaceRenderContext<V,E>
-
getEdgeArrowLength
public int getEdgeArrowLength()
- Specified by:
getEdgeArrowLength
in interfaceRenderContext<V,E>
-
setArrowsOnUndirectedEdges
public void setArrowsOnUndirectedEdges(boolean arrowsOnUndirectedEdges)
- Specified by:
setArrowsOnUndirectedEdges
in interfaceRenderContext<V,E>
-
getArrowsOnUndirectedEdges
public boolean getArrowsOnUndirectedEdges()
- Specified by:
getArrowsOnUndirectedEdges
in interfaceRenderContext<V,E>
-
getEdgeFontFunction
public Function<E,Font> getEdgeFontFunction()
- Specified by:
getEdgeFontFunction
in interfaceRenderContext<V,E>
-
setEdgeFontFunction
public void setEdgeFontFunction(Function<E,Font> edgeFontFunction)
- Specified by:
setEdgeFontFunction
in interfaceRenderContext<V,E>
-
getEdgeIncludePredicate
public Predicate<E> getEdgeIncludePredicate()
- Specified by:
getEdgeIncludePredicate
in interfaceRenderContext<V,E>
-
setEdgeIncludePredicate
public void setEdgeIncludePredicate(Predicate<E> edgeIncludePredicate)
- Specified by:
setEdgeIncludePredicate
in interfaceRenderContext<V,E>
-
getEdgeLabelCloseness
public float getEdgeLabelCloseness()
- Specified by:
getEdgeLabelCloseness
in interfaceRenderContext<V,E>
-
setEdgeLabelCloseness
public void setEdgeLabelCloseness(float closeness)
- Specified by:
setEdgeLabelCloseness
in interfaceRenderContext<V,E>
-
getEdgeLabelRenderer
public EdgeLabelRenderer getEdgeLabelRenderer()
- Specified by:
getEdgeLabelRenderer
in interfaceRenderContext<V,E>
-
setEdgeLabelRenderer
public void setEdgeLabelRenderer(EdgeLabelRenderer edgeLabelRenderer)
- Specified by:
setEdgeLabelRenderer
in interfaceRenderContext<V,E>
-
getEdgeFillPaintFunction
public Function<E,Paint> getEdgeFillPaintFunction()
- Specified by:
getEdgeFillPaintFunction
in interfaceRenderContext<V,E>
-
setEdgeDrawPaintFunction
public void setEdgeDrawPaintFunction(Function<E,Paint> edgeDrawPaintFunction)
- Specified by:
setEdgeDrawPaintFunction
in interfaceRenderContext<V,E>
-
getEdgeDrawPaintFunction
public Function<E,Paint> getEdgeDrawPaintFunction()
- Specified by:
getEdgeDrawPaintFunction
in interfaceRenderContext<V,E>
-
setEdgeFillPaintFunction
public void setEdgeFillPaintFunction(Function<E,Paint> edgeFillPaintFunction)
- Specified by:
setEdgeFillPaintFunction
in interfaceRenderContext<V,E>
-
getEdgeShapeFunction
public BiFunction<org.jgrapht.Graph<V,E>,E,Shape> getEdgeShapeFunction()
- Specified by:
getEdgeShapeFunction
in interfaceRenderContext<V,E>
-
setEdgeShapeFunction
public void setEdgeShapeFunction(BiFunction<org.jgrapht.Graph<V,E>,E,Shape> edgeShapeFunction)
- Specified by:
setEdgeShapeFunction
in interfaceRenderContext<V,E>
-
getVertexLabelPosition
public Renderer.VertexLabel.Position getVertexLabelPosition()
- Specified by:
getVertexLabelPosition
in interfaceRenderContext<V,E>
-
setVertexLabelPosition
public void setVertexLabelPosition(Renderer.VertexLabel.Position vertexLabelPosition)
- Specified by:
setVertexLabelPosition
in interfaceRenderContext<V,E>
-
getEdgeLabelFunction
public Function<E,String> getEdgeLabelFunction()
- Specified by:
getEdgeLabelFunction
in interfaceRenderContext<V,E>
-
setEdgeLabelFunction
public void setEdgeLabelFunction(Function<E,String> edgeLabelFunction)
- Specified by:
setEdgeLabelFunction
in interfaceRenderContext<V,E>
-
edgeStrokeFunction
public Function<E,Stroke> edgeStrokeFunction()
- Specified by:
edgeStrokeFunction
in interfaceRenderContext<V,E>
-
setEdgeStrokeFunction
public void setEdgeStrokeFunction(Function<E,Stroke> edgeStrokeFunction)
- Specified by:
setEdgeStrokeFunction
in interfaceRenderContext<V,E>
-
setEdgeWidth
public void setEdgeWidth(float edgeWidth)
- Specified by:
setEdgeWidth
in interfaceRenderContext<V,E>
-
getEdgeWidth
public float getEdgeWidth()
- Specified by:
getEdgeWidth
in interfaceRenderContext<V,E>
-
getEdgeArrowStrokeFunction
public Function<E,Stroke> getEdgeArrowStrokeFunction()
- Specified by:
getEdgeArrowStrokeFunction
in interfaceRenderContext<V,E>
-
setEdgeArrowStrokeFunction
public void setEdgeArrowStrokeFunction(Function<E,Stroke> edgeArrowStrokeFunction)
- Specified by:
setEdgeArrowStrokeFunction
in interfaceRenderContext<V,E>
-
getGraphicsContext
public GraphicsDecorator getGraphicsContext()
- Specified by:
getGraphicsContext
in interfaceRenderContext<V,E>
-
setGraphicsContext
public void setGraphicsContext(GraphicsDecorator graphicsContext)
- Specified by:
setGraphicsContext
in interfaceRenderContext<V,E>
-
getLabelOffset
public int getLabelOffset()
- Specified by:
getLabelOffset
in interfaceRenderContext<V,E>
-
setLabelOffset
public void setLabelOffset(int labelOffset)
- Specified by:
setLabelOffset
in interfaceRenderContext<V,E>
-
getParallelEdgeIndexFunction
public EdgeIndexFunction<V,E> getParallelEdgeIndexFunction()
- Specified by:
getParallelEdgeIndexFunction
in interfaceRenderContext<V,E>
-
setParallelEdgeIndexFunction
public void setParallelEdgeIndexFunction(EdgeIndexFunction<V,E> parallelEdgeIndexFunction)
- Specified by:
setParallelEdgeIndexFunction
in interfaceRenderContext<V,E>
-
getSelectedEdgeState
public MutableSelectedState<E> getSelectedEdgeState()
- Specified by:
getSelectedEdgeState
in interfaceRenderContext<V,E>
-
setSelectedEdgeState
public void setSelectedEdgeState(MutableSelectedState<E> pickedEdgeState)
- Specified by:
setSelectedEdgeState
in interfaceRenderContext<V,E>
-
getSelectedVertexState
public MutableSelectedState<V> getSelectedVertexState()
- Specified by:
getSelectedVertexState
in interfaceRenderContext<V,E>
-
setSelectedVertexState
public void setSelectedVertexState(MutableSelectedState<V> pickedVertexState)
- Specified by:
setSelectedVertexState
in interfaceRenderContext<V,E>
-
getRendererPane
public CellRendererPane getRendererPane()
- Specified by:
getRendererPane
in interfaceRenderContext<V,E>
-
setRendererPane
public void setRendererPane(CellRendererPane rendererPane)
- Specified by:
setRendererPane
in interfaceRenderContext<V,E>
-
getScreenDevice
public JComponent getScreenDevice()
- Specified by:
getScreenDevice
in interfaceRenderContext<V,E>
-
setScreenDevice
public void setScreenDevice(JComponent screenDevice)
- Specified by:
setScreenDevice
in interfaceRenderContext<V,E>
-
getVertexFontFunction
public Function<V,Font> getVertexFontFunction()
- Specified by:
getVertexFontFunction
in interfaceRenderContext<V,E>
-
setVertexFontFunction
public void setVertexFontFunction(Function<V,Font> vertexFontFunction)
- Specified by:
setVertexFontFunction
in interfaceRenderContext<V,E>
-
getVertexIconFunction
public Function<V,Icon> getVertexIconFunction()
- Specified by:
getVertexIconFunction
in interfaceRenderContext<V,E>
-
setVertexIconFunction
public void setVertexIconFunction(Function<V,Icon> vertexIconFunction)
- Specified by:
setVertexIconFunction
in interfaceRenderContext<V,E>
-
getVertexIncludePredicate
public Predicate<V> getVertexIncludePredicate()
- Specified by:
getVertexIncludePredicate
in interfaceRenderContext<V,E>
-
setVertexIncludePredicate
public void setVertexIncludePredicate(Predicate<V> vertexIncludePredicate)
- Specified by:
setVertexIncludePredicate
in interfaceRenderContext<V,E>
-
getVertexLabelRenderer
public VertexLabelRenderer getVertexLabelRenderer()
- Specified by:
getVertexLabelRenderer
in interfaceRenderContext<V,E>
-
setVertexLabelRenderer
public void setVertexLabelRenderer(VertexLabelRenderer vertexLabelRenderer)
- Specified by:
setVertexLabelRenderer
in interfaceRenderContext<V,E>
-
getVertexFillPaintFunction
public Function<V,Paint> getVertexFillPaintFunction()
- Specified by:
getVertexFillPaintFunction
in interfaceRenderContext<V,E>
-
setVertexFillPaintFunction
public void setVertexFillPaintFunction(Function<V,Paint> vertexFillPaintFunction)
- Specified by:
setVertexFillPaintFunction
in interfaceRenderContext<V,E>
-
getVertexDrawPaintFunction
public Function<V,Paint> getVertexDrawPaintFunction()
- Specified by:
getVertexDrawPaintFunction
in interfaceRenderContext<V,E>
-
setVertexDrawPaintFunction
public void setVertexDrawPaintFunction(Function<V,Paint> vertexDrawPaintFunction)
- Specified by:
setVertexDrawPaintFunction
in interfaceRenderContext<V,E>
-
getVertexLabelFunction
public Function<V,String> getVertexLabelFunction()
- Specified by:
getVertexLabelFunction
in interfaceRenderContext<V,E>
-
setVertexLabelFunction
public void setVertexLabelFunction(Function<V,String> vertexLabelFunction)
- Specified by:
setVertexLabelFunction
in interfaceRenderContext<V,E>
-
setVertexLabelDrawPaintFunction
public void setVertexLabelDrawPaintFunction(Function<V,Paint> vertexLabelDrawPaintFunction)
- Specified by:
setVertexLabelDrawPaintFunction
in interfaceRenderContext<V,E>
-
getVertexLabelDrawPaintFunction
public Function<V,Paint> getVertexLabelDrawPaintFunction()
- Specified by:
getVertexLabelDrawPaintFunction
in interfaceRenderContext<V,E>
-
getPickSupport
public GraphElementAccessor<V,E> getPickSupport()
- Specified by:
getPickSupport
in interfaceRenderContext<V,E>
- Returns:
- the pickSupport
-
setPickSupport
public void setPickSupport(GraphElementAccessor<V,E> pickSupport)
- Specified by:
setPickSupport
in interfaceRenderContext<V,E>
- Parameters:
pickSupport
- the pickSupport to set
-
getMultiLayerTransformer
public MultiLayerTransformer getMultiLayerTransformer()
- Specified by:
getMultiLayerTransformer
in interfaceRenderContext<V,E>
-
setMultiLayerTransformer
public void setMultiLayerTransformer(MultiLayerTransformer basicTransformer)
- Specified by:
setMultiLayerTransformer
in interfaceRenderContext<V,E>
-
getArrowDrawPaintFunction
public Function<E,Paint> getArrowDrawPaintFunction()
- Specified by:
getArrowDrawPaintFunction
in interfaceRenderContext<V,E>
-
getArrowFillPaintFunction
public Function<E,Paint> getArrowFillPaintFunction()
- Specified by:
getArrowFillPaintFunction
in interfaceRenderContext<V,E>
-
setArrowDrawPaintFunction
public void setArrowDrawPaintFunction(Function<E,Paint> arrowDrawPaintFunction)
- Specified by:
setArrowDrawPaintFunction
in interfaceRenderContext<V,E>
-
setArrowFillPaintFunction
public void setArrowFillPaintFunction(Function<E,Paint> arrowFillPaintFunction)
- Specified by:
setArrowFillPaintFunction
in interfaceRenderContext<V,E>
-
-