JGraph X 1.3.0.0

## 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.

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
`protected java.awt.Polygon` `createArrow(mxPoint p0, mxPoint pe)` Creates a polygon that represents an arrow.
`protected void` `drawActor(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws an actor shape for the given parameters.
`protected void` `drawArrow(java.util.List<mxPoint> pts, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws the given arrow shape.
`protected void` `drawCloud(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws a cloud shape for the given parameters.
`protected void` `drawConnector(java.util.List<mxPoint> pts, float penWidth, java.awt.Color penColor, java.lang.Object startMarker, float startSize, java.lang.Object endMarker, float endSize, boolean rounded, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the given connector shape.
`protected void` `drawCylinder(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean isShadow)` Draws a cylinder for the given parameters.
`java.lang.Object` `drawEdge(java.util.List<mxPoint> pts, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the given edge.
`protected void` `drawHexagon(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow, java.lang.String direction)` Draws a hexagon shape for the given parameters.
`protected void` `drawHtmlText(java.lang.String text, int x, int y, int w, int h, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the specified HTML markup.
`protected void` `drawImage(int x, int y, int w, int h, java.lang.String image)` Draws an image for the given parameters.
`java.lang.Object` `drawLabel(java.lang.String label, int x, int y, int w, int h, java.util.Map<java.lang.String,java.lang.Object> style, boolean isHtml)` Draws the given label.
`void` `drawLine(int x0, int y0, int x1, int y1)` Draws the given line if the line is inside the clipping area.
`void` `drawLine(java.util.List<mxPoint> pts, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the given lines as segments between all points of the given list of mxPoints.
`mxPoint` `drawMarker(java.lang.Object type, mxPoint p0, mxPoint pe, float size, float strokeWidth)` Draws the given type of marker.
`protected void` `drawOval(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws an oval for the given parameters.
`protected void` `drawPath(java.awt.geom.GeneralPath path, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws a path for the given parameters.
`protected void` `drawPlainText(java.lang.String text, int x, int y, int w, int h, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the specified string as plain text.
`protected void` `drawPolygon(java.awt.Polygon polygon, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws a a polygon for the given parameters.
`protected void` `drawRect(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow, boolean rounded)` Draws a rectangle for the given parameters.
`protected void` `drawRhombus(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow)` Draws a rhombus (aka.
`void` `drawShape(int x, int y, int w, int h, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the shape specified with the STYLE_SHAPE key in the given style.
`protected void` `drawTriangle(int x, int y, int w, int h, java.awt.Color fillColor, java.awt.Paint fillPaint, java.awt.Color penColor, boolean shadow, java.lang.String direction)` Draws a triangle shape for the given parameters.
`java.lang.Object` `drawVertex(int x, int y, int w, int h, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the given vertex.
`static int` `getArcSize(int w, int h)` Computes the arc size for the given dimension.
`protected java.awt.Paint` `getFillPaint(java.awt.Rectangle bounds, java.awt.Color fillColor, java.util.Map<java.lang.String,java.lang.Object> style)`
`java.awt.Graphics2D` `getGraphics()` Returns the graphics object for this canvas.
`protected java.awt.Image` `loadImage(java.lang.String image)` Returns an image instance for the given URL.
`void` `setGraphics(java.awt.Graphics2D g)` Sets the graphics object for this canvas.
`protected void` `setStroke(float penWidth, java.util.Map<java.lang.String,java.lang.Object> style)` Draws the given lines as segments between all points of the given list of mxPoints.

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

### imageCache

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

  Cache for images.

### 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

### 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.

### loadImage

    protected 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.

### drawVertex

    public java.lang.Object drawVertex(int x,
                                       int y,
                                       int w,
                                       int h,
                                       java.util.Map<java.lang.String,java.lang.Object> style)

  Description copied from interface: `mxICanvas`
  Draws the given vertex.

  Parameters:
    `x` - X-coordinate of the vertex.
    `y` - Y-coordinate of the vertex.
    `w` - Width of the vertex.
    `h` - Height of the vertex.
    `style` - Style of the vertex.
  Returns:
    Optional object that represents the vertex.

### drawEdge

    public java.lang.Object drawEdge(java.util.List<mxPoint> pts,
                                     java.util.Map<java.lang.String,java.lang.Object> style)

  Description copied from interface: `mxICanvas`
  Draws the given edge.

  Parameters:
    `pts` - List of mxPoints that make up the edge.
    `style` - Style of the edge.
  Returns:
    Optional object that represents the edge.

### drawLabel

    public java.lang.Object drawLabel(java.lang.String label,
                                      int x,
                                      int y,
                                      int w,
                                      int h,
                                      java.util.Map<java.lang.String,java.lang.Object> style,
                                      boolean isHtml)

  Description copied from interface: `mxICanvas`
  Draws the given label.

  Parameters:
    `label` - String that represents the label.
    `x` - X-coordinate of the label.
    `y` - Y-coordinate of the label.
    `w` - Width of the label.
    `h` - Height of the label.
    `style` - Style of the label.
    `isHtml` - Specifies if the label contains HTML markup.
  Returns:
    Optional object that represents the label.

### drawShape

    public void drawShape(int x,
                          int y,
                          int w,
                          int h,
                          java.util.Map<java.lang.String,java.lang.Object> style)

  Draws the shape specified with the STYLE_SHAPE key in the given style.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `style` - Style of the the shape.

### drawPolygon

    protected void drawPolygon(java.awt.Polygon polygon,
                               java.awt.Color fillColor,
                               java.awt.Paint fillPaint,
                               java.awt.Color penColor,
                               boolean shadow)

  Draws a a polygon for the given parameters.

  Parameters:
    `polygon` - Points of the polygon.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawPath

    protected void drawPath(java.awt.geom.GeneralPath path,
                            java.awt.Color fillColor,
                            java.awt.Paint fillPaint,
                            java.awt.Color penColor,
                            boolean shadow)

  Draws a path for the given parameters.

  Parameters:
    `path` - Path object to be drawn.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawRect

    protected void drawRect(int x,
                            int y,
                            int w,
                            int h,
                            java.awt.Color fillColor,
                            java.awt.Paint fillPaint,
                            java.awt.Color penColor,
                            boolean shadow,
                            boolean rounded)

  Draws a rectangle for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.
    `rounded` - Boolean indicating if the rectangle is rounded.

### drawImage

    protected void drawImage(int x,
                             int y,
                             int w,
                             int h,
                             java.lang.String image)

  Draws an image for the given parameters.

  Parameters:
    `x` - X-coordinate of the image.
    `y` - Y-coordinate of the image.
    `w` - Width of the image.
    `h` - Height of the image.
    `image` - URL of the image.

### drawOval

    protected void drawOval(int x,
                            int y,
                            int w,
                            int h,
                            java.awt.Color fillColor,
                            java.awt.Paint fillPaint,
                            java.awt.Color penColor,
                            boolean shadow)

  Draws an oval for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawRhombus

    protected void drawRhombus(int x,
                               int y,
                               int w,
                               int h,
                               java.awt.Color fillColor,
                               java.awt.Paint fillPaint,
                               java.awt.Color penColor,
                               boolean shadow)

  Draws a rhombus (aka. diamond) for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawCylinder

    protected void drawCylinder(int x,
                                int y,
                                int w,
                                int h,
                                java.awt.Color fillColor,
                                java.awt.Paint fillPaint,
                                java.awt.Color penColor,
                                boolean isShadow)

  Draws a cylinder for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `isShadow` - Boolean indicating if a shadow should be painted.

### drawActor

    protected void drawActor(int x,
                             int y,
                             int w,
                             int h,
                             java.awt.Color fillColor,
                             java.awt.Paint fillPaint,
                             java.awt.Color penColor,
                             boolean shadow)

  Draws an actor shape for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawCloud

    protected void drawCloud(int x,
                             int y,
                             int w,
                             int h,
                             java.awt.Color fillColor,
                             java.awt.Paint fillPaint,
                             java.awt.Color penColor,
                             boolean shadow)

  Draws a cloud shape for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawTriangle

    protected void drawTriangle(int x,
                                int y,
                                int w,
                                int h,
                                java.awt.Color fillColor,
                                java.awt.Paint fillPaint,
                                java.awt.Color penColor,
                                boolean shadow,
                                java.lang.String direction)

  Draws a triangle shape for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### drawHexagon

    protected void drawHexagon(int x,
                               int y,
                               int w,
                               int h,
                               java.awt.Color fillColor,
                               java.awt.Paint fillPaint,
                               java.awt.Color penColor,
                               boolean shadow,
                               java.lang.String direction)

  Draws a hexagon shape for the given parameters.

  Parameters:
    `x` - X-coordinate of the shape.
    `y` - Y-coordinate of the shape.
    `w` - Width of the shape.
    `h` - Height of the shape.
    `fillColor` - Optional fill color of the shape.
    `fillPaint` - Optional paint of the shape.
    `penColor` - Optional stroke color.
    `shadow` - Boolean indicating if a shadow should be painted.

### getArcSize

    public static int getArcSize(int w,
                                 int h)

  Computes the arc size for the given dimension.

  Parameters:
    `w` - Width of the rectangle.
    `h` - Height of the rectangle.
  Returns:
    Returns the arc size for the given dimension.

### createArrow

    protected java.awt.Polygon createArrow(mxPoint p0,
                                           mxPoint pe)

  Creates a polygon that represents an arrow.

  Parameters:
    `p0` - Start point of the arrow.
    `pe` - End point of the arrow.
  Returns:
    Returns the polygon to be painted.

### drawArrow

    protected void drawArrow(java.util.List<mxPoint> pts,
                             java.awt.Color fillColor,
                             java.awt.Paint fillPaint,
                             java.awt.Color penColor,
                             boolean shadow)

  Draws the given arrow shape.

  Parameters:
    `pts` - List of points that define the line.

### drawConnector

    protected void drawConnector(java.util.List<mxPoint> pts,
                                 float penWidth,
                                 java.awt.Color penColor,
                                 java.lang.Object startMarker,
                                 float startSize,
                                 java.lang.Object endMarker,
                                 float endSize,
                                 boolean rounded,
                                 java.util.Map<java.lang.String,java.lang.Object> style)

  Draws the given connector shape.

  Parameters:
    `pts` - List of points that define the line.

### getFillPaint

    protected java.awt.Paint getFillPaint(java.awt.Rectangle bounds,
                                          java.awt.Color fillColor,
                                          java.util.Map<java.lang.String,java.lang.Object> style)

  Parameters:
    `fillColor` -
    `style` -
  Returns:
    Returns the paint to be used for filling.

### drawLine

    public void drawLine(java.util.List<mxPoint> pts,
                         java.util.Map<java.lang.String,java.lang.Object> style)

  Draws the given lines as segments between all points of the given list of mxPoints.

  Parameters:
    `pts` - List of points that define the line.
    `style` - Style to be used for painting the line.

### setStroke

    protected void setStroke(float penWidth,
                             java.util.Map<java.lang.String,java.lang.Object> style)

  Draws the given lines as segments between all points of the given list of mxPoints.

  Parameters:
    `penWidth` - Specifies the width of the pen.
    `style` - Style to be used for painting the line.

### drawLine

    public void drawLine(int x0,
                         int y0,
                         int x1,
                         int y1)

  Draws the given line if the line is inside the clipping area. This method assumes that the stroke on the graphics object is already set.

### drawMarker

    public mxPoint drawMarker(java.lang.Object type,
                              mxPoint p0,
                              mxPoint pe,
                              float size,
                              float strokeWidth)

  Draws the given type of marker.

  Parameters:
    `type` -
    `p0` -
    `pe` -
    `size` -
    `strokeWidth` -
  Returns:
    Return the mxPoint that defines the offset.

### drawHtmlText

    protected void drawHtmlText(java.lang.String text,
                                int x,
                                int y,
                                int w,
                                int h,
                                java.util.Map<java.lang.String,java.lang.Object> style)

  Draws the specified HTML markup.

  Parameters:
    `text` - HTML markup to be painted.
    `x` - X-coordinate of the text.
    `y` - Y-coordinate of the text.
    `w` - Width of the text.
    `h` - Height of the text.
    `style` - Style to be used for painting the text.

### drawPlainText

    protected void drawPlainText(java.lang.String text,
                                 int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.util.Map<java.lang.String,java.lang.Object> style)

  Draws the specified string as plain text.

  Parameters:
    `text` - HTML markup to be painted.
    `x` - X-coordinate of the text.
    `y` - Y-coordinate of the text.
    `w` - Width of the text.
    `h` - Height of the text.
    `style` - Style to be used for painting the text.

JGraph X 1.3.0.0

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