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 classDefaultRenderContext.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>arrowDrawPaintFunctionimplement to providePaints for edge arrow outlineprotected Function<E,Paint>arrowFillPaintFunctionimplement to providePaints for edge arrowsprotected floatarrowPlacementToleranceprotected booleanarrowsOnUndirectedEdgeswhentrue, draws arrows at both ends of undirected edges default isfalse- no arrows drawn for undirected edgesstatic StringEDGE_WIDTHprotected ShapeedgeArrowprotected StrokeedgeArrowStrokeprotected Function<E,Stroke>edgeArrowStrokeFunctionimplement to provideStrokes for edge arrowsprotected Function<E,Paint>edgeDrawPaintFunctionimplement to provide draw s for edgesprotected Function<E,Paint>edgeFillPaintFunctionimplement to provide fill color for edges (rarely useful)protected Function<E,Font>edgeFontFunctionimplement to provide s for edge labelsprotected Predicate<E>edgeIncludePredicateprotected Function<E,String>edgeLabelFunctionimplement to provide edge labelsprotected EdgeLabelRendereredgeLabelRendererprotected BiFunction<org.jgrapht.Graph<V,E>,E,Shape>edgeShapeFunctionprotected StrokeedgeStroketheStrokeused to draw edgesprotected Function<E,Stroke>edgeStrokeFunctionimplement to provideStrokes for edgesprotected floatedgeStrokeWidthprotected GraphicsDecoratorgraphicsContextprotected intlabelOffsetprotected MultiLayerTransformermultiLayerTransformerprotected EdgeIndexFunction<V,E>parallelEdgeIndexFunctionprotected GraphElementAccessor<V,E>pickSupportpluggable support for picking graph elements by finding them based on their coordinates.protected booleanrenderEdgeArrowprotected CellRendererPanerendererPaneThe 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 JComponentscreenDevicethe JComponent that this Renderer will display the graph onprotected MutableSelectedState<E>selectedEdgeStateHolds asubset of edges that are selectedprotected MutableSelectedState<V>selectedVertexStateHolds a subset of vertices that are selectedprotected Function<V,Paint>vertexDrawPaintFunctionimplement to provide outline color for verticesprotected Function<V,Paint>vertexFillPaintFunctionimplement to provide fill color for vertices.protected Function<V,Font>vertexFontFunctionimplement to provideFonts for verticesprotected Function<V,Icon>vertexIconFunctionprotected Predicate<V>vertexIncludePredicateImplement to limit which vertices are renderedprotected Function<V,Paint>vertexLabelDrawPaintFunctionimplement to provide Colors for vertex labelsprotected Function<V,String>vertexLabelFunctionprovide labels for verticesprotected VertexLabelRenderervertexLabelRendererA default GraphLabelRenderer - selected Vertex labels are blue, selected edge labels are cyanprotected Function<V,Shape>vertexShapeFunctionimplement to provide Shapes for verticesprotected Function<V,Stroke>vertexStrokeFunctiontheStrokeused 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
theStrokeused 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 provideFonts for vertices
-
vertexLabelDrawPaintFunction
protected Function<V,Paint> vertexLabelDrawPaintFunction
implement to provide Colors for vertex labels
-
edgeStrokeFunction
protected Function<E,Stroke> edgeStrokeFunction
implement to provideStrokes 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 provideStrokes for edge arrows
-
arrowFillPaintFunction
protected Function<E,Paint> arrowFillPaintFunction
implement to providePaints for edge arrows
-
arrowDrawPaintFunction
protected Function<E,Paint> arrowDrawPaintFunction
implement to providePaints 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:
getRenderContextStateChangeSupportin 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:
setupArrowsin interfaceRenderContext<V,E>
-
getVertexShapeFunction
public Function<V,Shape> getVertexShapeFunction()
- Specified by:
getVertexShapeFunctionin interfaceRenderContext<V,E>- Returns:
- the vertexShapeFunction
-
setVertexShapeFunction
public void setVertexShapeFunction(Function<V,Shape> vertexShapeFunction)
- Specified by:
setVertexShapeFunctionin interfaceRenderContext<V,E>- Parameters:
vertexShapeFunction- the vertexShapeFunction to set
-
getVertexStrokeFunction
public Function<V,Stroke> getVertexStrokeFunction()
- Specified by:
getVertexStrokeFunctionin interfaceRenderContext<V,E>- Returns:
- the vertexStrokeFunction
-
setVertexStrokeFunction
public void setVertexStrokeFunction(Function<V,Stroke> vertexStrokeFunction)
- Specified by:
setVertexStrokeFunctionin 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:
getArrowPlacementTolerancein interfaceRenderContext<V,E>
-
setArrowPlacementTolerance
public void setArrowPlacementTolerance(float arrow_placement_tolerance)
- Specified by:
setArrowPlacementTolerancein interfaceRenderContext<V,E>
-
getEdgeArrow
public Shape getEdgeArrow()
- Specified by:
getEdgeArrowin interfaceRenderContext<V,E>
-
setEdgeArrow
public void setEdgeArrow(Shape shape)
- Specified by:
setEdgeArrowin interfaceRenderContext<V,E>
-
renderEdgeArrow
public boolean renderEdgeArrow()
- Specified by:
renderEdgeArrowin interfaceRenderContext<V,E>
-
setRenderEdgeArrow
public void setRenderEdgeArrow(boolean render)
- Specified by:
setRenderEdgeArrowin interfaceRenderContext<V,E>
-
setEdgeArrowWidth
public void setEdgeArrowWidth(int edgeArrowWidth)
- Specified by:
setEdgeArrowWidthin interfaceRenderContext<V,E>
-
getEdgeArrowWidth
public int getEdgeArrowWidth()
- Specified by:
getEdgeArrowWidthin interfaceRenderContext<V,E>
-
setEdgeArrowLength
public void setEdgeArrowLength(int edgeArrowLength)
- Specified by:
setEdgeArrowLengthin interfaceRenderContext<V,E>
-
getEdgeArrowLength
public int getEdgeArrowLength()
- Specified by:
getEdgeArrowLengthin interfaceRenderContext<V,E>
-
setArrowsOnUndirectedEdges
public void setArrowsOnUndirectedEdges(boolean arrowsOnUndirectedEdges)
- Specified by:
setArrowsOnUndirectedEdgesin interfaceRenderContext<V,E>
-
getArrowsOnUndirectedEdges
public boolean getArrowsOnUndirectedEdges()
- Specified by:
getArrowsOnUndirectedEdgesin interfaceRenderContext<V,E>
-
getEdgeFontFunction
public Function<E,Font> getEdgeFontFunction()
- Specified by:
getEdgeFontFunctionin interfaceRenderContext<V,E>
-
setEdgeFontFunction
public void setEdgeFontFunction(Function<E,Font> edgeFontFunction)
- Specified by:
setEdgeFontFunctionin interfaceRenderContext<V,E>
-
getEdgeIncludePredicate
public Predicate<E> getEdgeIncludePredicate()
- Specified by:
getEdgeIncludePredicatein interfaceRenderContext<V,E>
-
setEdgeIncludePredicate
public void setEdgeIncludePredicate(Predicate<E> edgeIncludePredicate)
- Specified by:
setEdgeIncludePredicatein interfaceRenderContext<V,E>
-
getEdgeLabelCloseness
public float getEdgeLabelCloseness()
- Specified by:
getEdgeLabelClosenessin interfaceRenderContext<V,E>
-
setEdgeLabelCloseness
public void setEdgeLabelCloseness(float closeness)
- Specified by:
setEdgeLabelClosenessin interfaceRenderContext<V,E>
-
getEdgeLabelRenderer
public EdgeLabelRenderer getEdgeLabelRenderer()
- Specified by:
getEdgeLabelRendererin interfaceRenderContext<V,E>
-
setEdgeLabelRenderer
public void setEdgeLabelRenderer(EdgeLabelRenderer edgeLabelRenderer)
- Specified by:
setEdgeLabelRendererin interfaceRenderContext<V,E>
-
getEdgeFillPaintFunction
public Function<E,Paint> getEdgeFillPaintFunction()
- Specified by:
getEdgeFillPaintFunctionin interfaceRenderContext<V,E>
-
setEdgeDrawPaintFunction
public void setEdgeDrawPaintFunction(Function<E,Paint> edgeDrawPaintFunction)
- Specified by:
setEdgeDrawPaintFunctionin interfaceRenderContext<V,E>
-
getEdgeDrawPaintFunction
public Function<E,Paint> getEdgeDrawPaintFunction()
- Specified by:
getEdgeDrawPaintFunctionin interfaceRenderContext<V,E>
-
setEdgeFillPaintFunction
public void setEdgeFillPaintFunction(Function<E,Paint> edgeFillPaintFunction)
- Specified by:
setEdgeFillPaintFunctionin interfaceRenderContext<V,E>
-
getEdgeShapeFunction
public BiFunction<org.jgrapht.Graph<V,E>,E,Shape> getEdgeShapeFunction()
- Specified by:
getEdgeShapeFunctionin interfaceRenderContext<V,E>
-
setEdgeShapeFunction
public void setEdgeShapeFunction(BiFunction<org.jgrapht.Graph<V,E>,E,Shape> edgeShapeFunction)
- Specified by:
setEdgeShapeFunctionin interfaceRenderContext<V,E>
-
getVertexLabelPosition
public Renderer.VertexLabel.Position getVertexLabelPosition()
- Specified by:
getVertexLabelPositionin interfaceRenderContext<V,E>
-
setVertexLabelPosition
public void setVertexLabelPosition(Renderer.VertexLabel.Position vertexLabelPosition)
- Specified by:
setVertexLabelPositionin interfaceRenderContext<V,E>
-
getEdgeLabelFunction
public Function<E,String> getEdgeLabelFunction()
- Specified by:
getEdgeLabelFunctionin interfaceRenderContext<V,E>
-
setEdgeLabelFunction
public void setEdgeLabelFunction(Function<E,String> edgeLabelFunction)
- Specified by:
setEdgeLabelFunctionin interfaceRenderContext<V,E>
-
edgeStrokeFunction
public Function<E,Stroke> edgeStrokeFunction()
- Specified by:
edgeStrokeFunctionin interfaceRenderContext<V,E>
-
setEdgeStrokeFunction
public void setEdgeStrokeFunction(Function<E,Stroke> edgeStrokeFunction)
- Specified by:
setEdgeStrokeFunctionin interfaceRenderContext<V,E>
-
setEdgeWidth
public void setEdgeWidth(float edgeWidth)
- Specified by:
setEdgeWidthin interfaceRenderContext<V,E>
-
getEdgeWidth
public float getEdgeWidth()
- Specified by:
getEdgeWidthin interfaceRenderContext<V,E>
-
getEdgeArrowStrokeFunction
public Function<E,Stroke> getEdgeArrowStrokeFunction()
- Specified by:
getEdgeArrowStrokeFunctionin interfaceRenderContext<V,E>
-
setEdgeArrowStrokeFunction
public void setEdgeArrowStrokeFunction(Function<E,Stroke> edgeArrowStrokeFunction)
- Specified by:
setEdgeArrowStrokeFunctionin interfaceRenderContext<V,E>
-
getGraphicsContext
public GraphicsDecorator getGraphicsContext()
- Specified by:
getGraphicsContextin interfaceRenderContext<V,E>
-
setGraphicsContext
public void setGraphicsContext(GraphicsDecorator graphicsContext)
- Specified by:
setGraphicsContextin interfaceRenderContext<V,E>
-
getLabelOffset
public int getLabelOffset()
- Specified by:
getLabelOffsetin interfaceRenderContext<V,E>
-
setLabelOffset
public void setLabelOffset(int labelOffset)
- Specified by:
setLabelOffsetin interfaceRenderContext<V,E>
-
getParallelEdgeIndexFunction
public EdgeIndexFunction<V,E> getParallelEdgeIndexFunction()
- Specified by:
getParallelEdgeIndexFunctionin interfaceRenderContext<V,E>
-
setParallelEdgeIndexFunction
public void setParallelEdgeIndexFunction(EdgeIndexFunction<V,E> parallelEdgeIndexFunction)
- Specified by:
setParallelEdgeIndexFunctionin interfaceRenderContext<V,E>
-
getSelectedEdgeState
public MutableSelectedState<E> getSelectedEdgeState()
- Specified by:
getSelectedEdgeStatein interfaceRenderContext<V,E>
-
setSelectedEdgeState
public void setSelectedEdgeState(MutableSelectedState<E> pickedEdgeState)
- Specified by:
setSelectedEdgeStatein interfaceRenderContext<V,E>
-
getSelectedVertexState
public MutableSelectedState<V> getSelectedVertexState()
- Specified by:
getSelectedVertexStatein interfaceRenderContext<V,E>
-
setSelectedVertexState
public void setSelectedVertexState(MutableSelectedState<V> pickedVertexState)
- Specified by:
setSelectedVertexStatein interfaceRenderContext<V,E>
-
getRendererPane
public CellRendererPane getRendererPane()
- Specified by:
getRendererPanein interfaceRenderContext<V,E>
-
setRendererPane
public void setRendererPane(CellRendererPane rendererPane)
- Specified by:
setRendererPanein interfaceRenderContext<V,E>
-
getScreenDevice
public JComponent getScreenDevice()
- Specified by:
getScreenDevicein interfaceRenderContext<V,E>
-
setScreenDevice
public void setScreenDevice(JComponent screenDevice)
- Specified by:
setScreenDevicein interfaceRenderContext<V,E>
-
getVertexFontFunction
public Function<V,Font> getVertexFontFunction()
- Specified by:
getVertexFontFunctionin interfaceRenderContext<V,E>
-
setVertexFontFunction
public void setVertexFontFunction(Function<V,Font> vertexFontFunction)
- Specified by:
setVertexFontFunctionin interfaceRenderContext<V,E>
-
getVertexIconFunction
public Function<V,Icon> getVertexIconFunction()
- Specified by:
getVertexIconFunctionin interfaceRenderContext<V,E>
-
setVertexIconFunction
public void setVertexIconFunction(Function<V,Icon> vertexIconFunction)
- Specified by:
setVertexIconFunctionin interfaceRenderContext<V,E>
-
getVertexIncludePredicate
public Predicate<V> getVertexIncludePredicate()
- Specified by:
getVertexIncludePredicatein interfaceRenderContext<V,E>
-
setVertexIncludePredicate
public void setVertexIncludePredicate(Predicate<V> vertexIncludePredicate)
- Specified by:
setVertexIncludePredicatein interfaceRenderContext<V,E>
-
getVertexLabelRenderer
public VertexLabelRenderer getVertexLabelRenderer()
- Specified by:
getVertexLabelRendererin interfaceRenderContext<V,E>
-
setVertexLabelRenderer
public void setVertexLabelRenderer(VertexLabelRenderer vertexLabelRenderer)
- Specified by:
setVertexLabelRendererin interfaceRenderContext<V,E>
-
getVertexFillPaintFunction
public Function<V,Paint> getVertexFillPaintFunction()
- Specified by:
getVertexFillPaintFunctionin interfaceRenderContext<V,E>
-
setVertexFillPaintFunction
public void setVertexFillPaintFunction(Function<V,Paint> vertexFillPaintFunction)
- Specified by:
setVertexFillPaintFunctionin interfaceRenderContext<V,E>
-
getVertexDrawPaintFunction
public Function<V,Paint> getVertexDrawPaintFunction()
- Specified by:
getVertexDrawPaintFunctionin interfaceRenderContext<V,E>
-
setVertexDrawPaintFunction
public void setVertexDrawPaintFunction(Function<V,Paint> vertexDrawPaintFunction)
- Specified by:
setVertexDrawPaintFunctionin interfaceRenderContext<V,E>
-
getVertexLabelFunction
public Function<V,String> getVertexLabelFunction()
- Specified by:
getVertexLabelFunctionin interfaceRenderContext<V,E>
-
setVertexLabelFunction
public void setVertexLabelFunction(Function<V,String> vertexLabelFunction)
- Specified by:
setVertexLabelFunctionin interfaceRenderContext<V,E>
-
setVertexLabelDrawPaintFunction
public void setVertexLabelDrawPaintFunction(Function<V,Paint> vertexLabelDrawPaintFunction)
- Specified by:
setVertexLabelDrawPaintFunctionin interfaceRenderContext<V,E>
-
getVertexLabelDrawPaintFunction
public Function<V,Paint> getVertexLabelDrawPaintFunction()
- Specified by:
getVertexLabelDrawPaintFunctionin interfaceRenderContext<V,E>
-
getPickSupport
public GraphElementAccessor<V,E> getPickSupport()
- Specified by:
getPickSupportin interfaceRenderContext<V,E>- Returns:
- the pickSupport
-
setPickSupport
public void setPickSupport(GraphElementAccessor<V,E> pickSupport)
- Specified by:
setPickSupportin interfaceRenderContext<V,E>- Parameters:
pickSupport- the pickSupport to set
-
getMultiLayerTransformer
public MultiLayerTransformer getMultiLayerTransformer()
- Specified by:
getMultiLayerTransformerin interfaceRenderContext<V,E>
-
setMultiLayerTransformer
public void setMultiLayerTransformer(MultiLayerTransformer basicTransformer)
- Specified by:
setMultiLayerTransformerin interfaceRenderContext<V,E>
-
getArrowDrawPaintFunction
public Function<E,Paint> getArrowDrawPaintFunction()
- Specified by:
getArrowDrawPaintFunctionin interfaceRenderContext<V,E>
-
getArrowFillPaintFunction
public Function<E,Paint> getArrowFillPaintFunction()
- Specified by:
getArrowFillPaintFunctionin interfaceRenderContext<V,E>
-
setArrowDrawPaintFunction
public void setArrowDrawPaintFunction(Function<E,Paint> arrowDrawPaintFunction)
- Specified by:
setArrowDrawPaintFunctionin interfaceRenderContext<V,E>
-
setArrowFillPaintFunction
public void setArrowFillPaintFunction(Function<E,Paint> arrowFillPaintFunction)
- Specified by:
setArrowFillPaintFunctionin interfaceRenderContext<V,E>
-
-