Package org.graphstream.ui.swing
Class SwingGraphRenderer
java.lang.Object
org.graphstream.ui.swing.SwingGraphRenderer
- All Implemented Interfaces:
org.graphstream.ui.graphicGraph.StyleGroupListener,org.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
public class SwingGraphRenderer
extends java.lang.Object
implements org.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>, org.graphstream.ui.graphicGraph.StyleGroupListener
2D renderer.
The role of this class is to equip each style group with a specific renderer and
to call these renderer to redraw the graph when needed. The renderers then equip
each node, edge and sprite with a skeleton that gives is main geometry, then
selects a shape according to the group style. The shape will be "applied" to
each element to draw in the group. The shape will be moved and scaled according
to the skeleton.
A render pass begins by using the camera instance to set up the projection (allows
to pass from graph units to pixels, make a rotation a zoom or a translation) and
render each style group once for the shadows, and once for the real rendering
in Z order.
This class also handles a "selection" object that represents the current selection
and renders it.
The renderer uses a backend so that it can adapt to multiple rendering
targets (here Swing and OpenGL). As the shapes are finally responsible
for drawing the graph, the backend is also responsible for the shape
creation.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_RENDERER -
Constructor Summary
Constructors Constructor Description SwingGraphRenderer() -
Method Summary
Modifier and Type Method Description java.util.Collection<org.graphstream.ui.graphicGraph.GraphicElement>allGraphicElementsIn(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2)voidbeginSelectionAt(double x, double y)voidclose()org.graphstream.ui.view.ViewcreateDefaultView(org.graphstream.ui.view.Viewer viewer, java.lang.String id)voidelementStyleChanged(org.graphstream.graph.Element element, org.graphstream.ui.graphicGraph.StyleGroup oldStyle, org.graphstream.ui.graphicGraph.StyleGroup style)voidendSelectionAt(double x, double y)org.graphstream.ui.graphicGraph.GraphicElementfindGraphicElementAt(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y)org.graphstream.ui.view.camera.CameragetCamera()voidmoveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y)voidopen(org.graphstream.ui.graphicGraph.GraphicGraph graph, java.awt.Container drawingSurface)voidrender(java.awt.Graphics2D g, int x, int y, int width, int height)java.awt.ContainerrenderingSurface()voidscreenshot(java.lang.String filename, int width, int height)voidselectionGrowsAt(double x, double y)voidsetBackLayerRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer)voidsetForeLayoutRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer)
-
Field Details
-
DEFAULT_RENDERER
public static final java.lang.String DEFAULT_RENDERER- See Also:
- Constant Field Values
-
-
Constructor Details
-
SwingGraphRenderer
public SwingGraphRenderer()
-
-
Method Details
-
open
public void open(org.graphstream.ui.graphicGraph.GraphicGraph graph, java.awt.Container drawingSurface)- Specified by:
openin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
close
public void close()- Specified by:
closein interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
getCamera
public org.graphstream.ui.view.camera.Camera getCamera()- Specified by:
getCamerain interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
renderingSurface
public java.awt.Container renderingSurface() -
beginSelectionAt
public void beginSelectionAt(double x, double y)- Specified by:
beginSelectionAtin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
selectionGrowsAt
public void selectionGrowsAt(double x, double y)- Specified by:
selectionGrowsAtin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
endSelectionAt
public void endSelectionAt(double x, double y)- Specified by:
endSelectionAtin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
moveElementAtPx
public void moveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y)- Specified by:
moveElementAtPxin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
render
public void render(java.awt.Graphics2D g, int x, int y, int width, int height)- Specified by:
renderin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
screenshot
public void screenshot(java.lang.String filename, int width, int height)- Specified by:
screenshotin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
setBackLayerRenderer
public void setBackLayerRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer)- Specified by:
setBackLayerRendererin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
setForeLayoutRenderer
public void setForeLayoutRenderer(org.graphstream.ui.view.LayerRenderer<java.awt.Graphics2D> renderer)- Specified by:
setForeLayoutRendererin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
elementStyleChanged
public void elementStyleChanged(org.graphstream.graph.Element element, org.graphstream.ui.graphicGraph.StyleGroup oldStyle, org.graphstream.ui.graphicGraph.StyleGroup style)- Specified by:
elementStyleChangedin interfaceorg.graphstream.ui.graphicGraph.StyleGroupListener
-
createDefaultView
public org.graphstream.ui.view.View createDefaultView(org.graphstream.ui.view.Viewer viewer, java.lang.String id)- Specified by:
createDefaultViewin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
findGraphicElementAt
public org.graphstream.ui.graphicGraph.GraphicElement findGraphicElementAt(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y)- Specified by:
findGraphicElementAtin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-
allGraphicElementsIn
public java.util.Collection<org.graphstream.ui.graphicGraph.GraphicElement> allGraphicElementsIn(java.util.EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2)- Specified by:
allGraphicElementsInin interfaceorg.graphstream.ui.view.GraphRenderer<java.awt.Container,java.awt.Graphics2D>
-