Class mxGraphics2DCanvas

java.lang.Object
com.mxgraph.canvas.mxBasicCanvas
com.mxgraph.canvas.mxGraphics2DCanvas
All Implemented Interfaces:
mxICanvas
Direct Known Subclasses:
mxInteractiveCanvas

public class mxGraphics2DCanvas extends mxBasicCanvas
An implementation of a canvas that uses Graphics2D for painting.
  • Field Details

    • TEXT_SHAPE_DEFAULT

      public static final String TEXT_SHAPE_DEFAULT
      See Also:
    • TEXT_SHAPE_HTML

      public static final String TEXT_SHAPE_HTML
      See Also:
    • IMAGE_SCALING

      public static int IMAGE_SCALING
      Specifies the image scaling quality. Default is Image.SCALE_SMOOTH.
    • shapes

      protected static Map<String,mxIShape> shapes
      Maps from names to mxIVertexShape instances.
    • textShapes

      protected static Map<String,mxITextShape> textShapes
      Maps from names to mxITextShape instances. There are currently three different hardcoded text shapes available here: default, html and wrapped.
    • rendererPane

      protected CellRendererPane rendererPane
      Optional renderer pane to be used for HTML label rendering.
    • g

      protected Graphics2D g
      Global graphics handle to the image.
  • Constructor Details

    • mxGraphics2DCanvas

      public mxGraphics2DCanvas()
      Constructs a new graphics canvas with an empty graphics object.
    • mxGraphics2DCanvas

      public mxGraphics2DCanvas(Graphics2D g)
      Constructs a new graphics canvas for the given graphics object.
  • Method Details

    • putShape

      public static void putShape(String name, mxIShape shape)
    • getShape

      public mxIShape getShape(Map<String,Object> style)
    • putTextShape

      public static void putTextShape(String name, mxITextShape shape)
    • getTextShape

      public mxITextShape getTextShape(Map<String,Object> style, boolean html)
    • getRendererPane

      public CellRendererPane getRendererPane()
    • getGraphics

      public Graphics2D getGraphics()
      Returns the graphics object for this canvas.
    • setGraphics

      public void setGraphics(Graphics2D g)
      Sets the graphics object for this canvas.
    • drawCell

      public Object drawCell(mxCellState state)
      Description copied from interface: mxICanvas
      Draws the given cell.
      Parameters:
      state - State of the cell to be painted.
      Returns:
      Object that represents the cell.
    • drawLabel

      public Object drawLabel(String text, mxCellState state, boolean html)
      Description copied from interface: mxICanvas
      Draws the given label.
      Parameters:
      text - String that represents the label.
      state - State of the cell whose label is to be painted.
      html - Specifies if the label contains HTML markup.
      Returns:
      Object that represents the label.
    • drawImage

      public void drawImage(Rectangle bounds, String imageUrl)
    • drawImage

      public void drawImage(Rectangle bounds, String imageUrl, boolean preserveAspect, boolean flipH, boolean flipV)
    • drawImageImpl

      protected void drawImageImpl(Image image, int x, int y)
      Implements the actual graphics call.
    • getImageSize

      protected Dimension getImageSize(Image image)
      Returns the size for the given image.
    • paintPolyline

      public void paintPolyline(mxPoint[] points, boolean rounded)
    • paintRectangle

      public void paintRectangle(Rectangle bounds, Color background, Color border)
    • fillShape

      public void fillShape(Shape shape)
    • fillShape

      public void fillShape(Shape shape, boolean shadow)
    • createStroke

      public Stroke createStroke(Map<String,Object> style)
    • createFillPaint

      public Paint createFillPaint(mxRectangle bounds, Map<String,Object> style)
    • createTemporaryGraphics

      public Graphics2D createTemporaryGraphics(Map<String,Object> style, float opacity, mxRectangle bounds)