JGraph X 1.4.0.9

## com.mxgraph.canvas
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 Summary
`protected java.awt.Graphics2D` `g` Global graphics handle to the image.
`protected java.util.Hashtable<java.lang.String,java.awt.Image>` `imageCache` Cache for images.
`protected javax.swing.CellRendererPane` `rendererPane` Optional renderer pane to be used for HTML label rendering.
`protected boolean` `replaceHtmlLinefeeds` Specifies if linefeeds should be replaced with breaks in HTML markup.
`protected static java.util.Map<java.lang.String,mxIShape>` `shapes` Maps from names to mxIVertexShape instances.
`static java.lang.String` `TEXT_SHAPE_DEFAULT`
`static java.lang.String` `TEXT_SHAPE_HTML`
`protected static java.util.Map<java.lang.String,mxITextShape>` `textShapes` Maps from names to mxITextShape instances.

Fields inherited from class com.mxgraph.canvas.mxBasicCanvas
`DEFAULT_IMAGEBASEPATH, drawLabels, imageBasePath, scale, translate`

Constructor Summary
`mxGraphics2DCanvas()` Constructs a new graphics canvas with an empty graphics object.
`mxGraphics2DCanvas(java.awt.Graphics2D g)` Constructs a new graphics canvas for the given graphics object.

Method Summary
`java.awt.Paint` `createFillPaint(mxRectangle bounds, java.util.Map<java.lang.String,java.lang.Object> style)`
`java.awt.Stroke` `createStroke(java.util.Map<java.lang.String,java.lang.Object> style)`
`java.awt.Graphics2D` `createTemporaryGraphics(java.util.Map<java.lang.String,java.lang.Object> style, float opacity, mxRectangle bounds)`
`java.lang.Object` `drawCell(mxCellState state)` Draws the given cell.
`void` `drawImage(java.awt.Rectangle bounds, java.lang.String imageUrl)`
`java.lang.Object` `drawLabel(java.lang.String text, mxCellState state, boolean html)` Draws the given label.
`void` `fillShape(java.awt.Shape shape)`
`void` `fillShape(java.awt.Shape shape, boolean shadow)`
`void` `flushImageCache()`
`java.awt.Graphics2D` `getGraphics()` Returns the graphics object for this canvas.
`javax.swing.CellRendererPane` `getRendererPane()`
`mxIShape` `getShape(java.util.Map<java.lang.String,java.lang.Object> style)`
`mxITextShape` `getTextShape(java.util.Map<java.lang.String,java.lang.Object> style, boolean html)`
`boolean` `isReplaceHtmlLinefeeds()` Returns replaceHtmlLinefeeds
`java.awt.Image` `loadImage(java.lang.String image)` Returns an image instance for the given URL.
`void` `paintPolyline(mxPoint[] points, boolean rounded)`
`void` `paintRectangle(java.awt.Rectangle bounds, java.awt.Color background, java.awt.Color border)`
`static void` `putShape(java.lang.String name, mxIShape shape)`
`static void` `putTextShape(java.lang.String name, mxITextShape shape)`
`void` `setGraphics(java.awt.Graphics2D g)` Sets the graphics object for this canvas.
`void` `setReplaceHtmlLinefeeds(boolean value)` Returns replaceHtmlLinefeeds

Methods inherited from class com.mxgraph.canvas.mxBasicCanvas
`getImageBasePath, getImageForStyle, getScale, getTranslate, isDrawLabels, setDrawLabels, setImageBasePath, setScale, setTranslate`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TEXT_SHAPE_DEFAULT

    public static final java.lang.String TEXT_SHAPE_DEFAULT

See Also:
  Constant Field Values

### TEXT_SHAPE_HTML

    public static final java.lang.String TEXT_SHAPE_HTML

See Also:
  Constant Field Values

### shapes

    protected static java.util.Map<java.lang.String,mxIShape> shapes

  Maps from names to mxIVertexShape instances.

### textShapes

    protected static java.util.Map<java.lang.String,mxITextShape> textShapes

  Maps from names to mxITextShape instances. There are currently three different hardcoded text shapes available here: default, html and wrapped.

### imageCache

    protected java.util.Hashtable<java.lang.String,java.awt.Image> imageCache

  Cache for images.

### replaceHtmlLinefeeds

    protected boolean replaceHtmlLinefeeds

  Specifies if linefeeds should be replaced with breaks in HTML markup. Default is true.

### rendererPane

    protected javax.swing.CellRendererPane rendererPane

  Optional renderer pane to be used for HTML label rendering.

### g

    protected java.awt.Graphics2D g

  Global graphics handle to the image.

Constructor Detail

### mxGraphics2DCanvas

    public mxGraphics2DCanvas()

  Constructs a new graphics canvas with an empty graphics object.

### mxGraphics2DCanvas

    public mxGraphics2DCanvas(java.awt.Graphics2D g)

  Constructs a new graphics canvas for the given graphics object.

Method Detail

### putShape

    public static void putShape(java.lang.String name,
                                mxIShape shape)

### getShape

    public mxIShape getShape(java.util.Map<java.lang.String,java.lang.Object> style)

### putTextShape

    public static void putTextShape(java.lang.String name,
                                    mxITextShape shape)

### getTextShape

    public mxITextShape getTextShape(java.util.Map<java.lang.String,java.lang.Object> style,
                                     boolean html)

### getRendererPane

    public javax.swing.CellRendererPane getRendererPane()

### isReplaceHtmlLinefeeds

    public boolean isReplaceHtmlLinefeeds()

  Returns replaceHtmlLinefeeds

### setReplaceHtmlLinefeeds

    public void setReplaceHtmlLinefeeds(boolean value)

  Returns replaceHtmlLinefeeds

### getGraphics

    public java.awt.Graphics2D getGraphics()

  Returns the graphics object for this canvas.

### setGraphics

    public void setGraphics(java.awt.Graphics2D g)

  Sets the graphics object for this canvas.

### drawCell

    public java.lang.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 java.lang.Object drawLabel(java.lang.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.

### loadImage

    public java.awt.Image loadImage(java.lang.String image)

  Returns an image instance for the given URL. If the URL has been loaded before than an instance of the same instance is returned as in the previous call.

### flushImageCache

    public void flushImageCache()

### drawImage

    public void drawImage(java.awt.Rectangle bounds,
                          java.lang.String imageUrl)

### paintPolyline

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

### paintRectangle

    public void paintRectangle(java.awt.Rectangle bounds,
                               java.awt.Color background,
                               java.awt.Color border)

### fillShape

    public void fillShape(java.awt.Shape shape)

### fillShape

    public void fillShape(java.awt.Shape shape,
                          boolean shadow)

### createStroke

    public java.awt.Stroke createStroke(java.util.Map<java.lang.String,java.lang.Object> style)

### createFillPaint

    public java.awt.Paint createFillPaint(mxRectangle bounds,
                                          java.util.Map<java.lang.String,java.lang.Object> style)

### createTemporaryGraphics

    public java.awt.Graphics2D createTemporaryGraphics(java.util.Map<java.lang.String,java.lang.Object> style,
                                                       float opacity,
                                                       mxRectangle bounds)

JGraph X 1.4.0.9

Copyright (c) 2010 Gaudenz Alder. All rights reserved.