Class SwingGraphRenderer

java.lang.Object
org.graphstream.ui.swing.SwingGraphRenderer
All Implemented Interfaces:
org.graphstream.ui.graphicGraph.StyleGroupListener, org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>

public class SwingGraphRenderer extends Object implements org.graphstream.ui.view.GraphRenderer<Container,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 Details

    • DEFAULT_RENDERER

      public static final String DEFAULT_RENDERER
      See Also:
    • camera

      protected org.graphstream.ui.view.camera.DefaultCamera2D camera
    • graph

      protected org.graphstream.ui.graphicGraph.GraphicGraph graph
    • selection

      protected Selection selection
    • backRenderer

      protected org.graphstream.ui.view.LayerRenderer<Graphics2D> backRenderer
    • foreRenderer

      protected org.graphstream.ui.view.LayerRenderer<Graphics2D> foreRenderer
    • swingBackend

      protected Backend swingBackend
    • uhdBackend

      protected Backend uhdBackend
    • fpsLogger

      protected FPSLogger fpsLogger
  • Constructor Details

    • SwingGraphRenderer

      public SwingGraphRenderer()
  • Method Details

    • open

      public void open(org.graphstream.ui.graphicGraph.GraphicGraph graph, Container drawingSurface)
      Specified by:
      open in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • close

      public void close()
      Specified by:
      close in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • getCamera

      public org.graphstream.ui.view.camera.Camera getCamera()
      Specified by:
      getCamera in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • renderingSurface

      public Container renderingSurface()
    • getStyleRenderer

      protected GraphBackgroundRenderer getStyleRenderer(org.graphstream.ui.graphicGraph.GraphicGraph graph)
      Get (and assign if needed) a style renderer to the graphic graph. The renderer will be reused then.
    • getStyleRenderer

      protected StyleRenderer getStyleRenderer(org.graphstream.ui.graphicGraph.StyleGroup style)
      Get (and assign if needed) a style renderer to a style group. The renderer will be reused then.
    • getStyleRenderer

      protected StyleRenderer getStyleRenderer(org.graphstream.ui.graphicGraph.GraphicElement element)
      Get (and assign if needed) the style renderer associated with the style group of the element.
    • removeRenderers

      protected void removeRenderers()
      Remove all the registered renderers from the graphic graph.
    • beginSelectionAt

      public void beginSelectionAt(double x, double y)
      Specified by:
      beginSelectionAt in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • selectionGrowsAt

      public void selectionGrowsAt(double x, double y)
      Specified by:
      selectionGrowsAt in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • endSelectionAt

      public void endSelectionAt(double x, double y)
      Specified by:
      endSelectionAt in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • moveElementAtPx

      public void moveElementAtPx(org.graphstream.ui.graphicGraph.GraphicElement element, double x, double y)
      Specified by:
      moveElementAtPx in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • render

      public void render(Graphics2D g, int x, int y, int width, int height)
      Specified by:
      render in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • startFrame

      protected void startFrame()
    • endFrame

      protected void endFrame()
    • renderBackLayer

      protected void renderBackLayer()
    • renderForeLayer

      protected void renderForeLayer()
    • renderLayer

      protected void renderLayer(org.graphstream.ui.view.LayerRenderer<Graphics2D> renderer)
      Render a back or from layer.
    • setupGraphics

      protected void setupGraphics()
      Setup the graphic pipeline before drawing.
    • screenshot

      public void screenshot(String filename, int width, int height)
      Specified by:
      screenshot in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • setBackLayerRenderer

      public void setBackLayerRenderer(org.graphstream.ui.view.LayerRenderer<Graphics2D> renderer)
      Specified by:
      setBackLayerRenderer in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • setForeLayoutRenderer

      public void setForeLayoutRenderer(org.graphstream.ui.view.LayerRenderer<Graphics2D> renderer)
      Specified by:
      setForeLayoutRenderer in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • elementStyleChanged

      public void elementStyleChanged(org.graphstream.graph.Element element, org.graphstream.ui.graphicGraph.StyleGroup oldStyle, org.graphstream.ui.graphicGraph.StyleGroup style)
      Specified by:
      elementStyleChanged in interface org.graphstream.ui.graphicGraph.StyleGroupListener
    • createDefaultView

      public org.graphstream.ui.view.View createDefaultView(org.graphstream.ui.view.Viewer viewer, String id)
      Specified by:
      createDefaultView in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • findGraphicElementAt

      public org.graphstream.ui.graphicGraph.GraphicElement findGraphicElementAt(EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x, double y)
      Specified by:
      findGraphicElementAt in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>
    • allGraphicElementsIn

      public Collection<org.graphstream.ui.graphicGraph.GraphicElement> allGraphicElementsIn(EnumSet<org.graphstream.ui.view.util.InteractiveElement> types, double x1, double y1, double x2, double y2)
      Specified by:
      allGraphicElementsIn in interface org.graphstream.ui.view.GraphRenderer<Container,Graphics2D>