mxGraph 2.4.0.1


com.mxgraph.canvas
Interface mxICanvas2D

All Known Implementing Classes:
mxGraphicsCanvas2D

public interface mxICanvas2D

Requirements for implementing technologies: - Path rendering (move, line, quad, curve, arc) - Images, flip v/h, aspect, alpha (PNG, JPG, GIF) - Linear gradients (in all four directions) - Transparency, fill and stroke - Rotation, flip v/h - Font rendering - Dash patterns - Clipping by path (not just rectangle) - Alpha gradients (for glass effect) - Encode result as image (PNG, JPG)


Method Summary
 void begin()
          Begins a new path.
 void close()
          Closes the current path.
 void curveTo(double x1, double y1, double x2, double y2, double x3, double y3)
          Draws a bezier curve to the given point.
 void ellipse(double x, double y, double w, double h)
          Next fill or stroke should draw an ellipse.
 void fill()
          Fills the current path.
 void fillAndStroke()
          Fills and paints the outline of the current path.
 void image(double x, double y, double w, double h, String src, boolean aspect, boolean flipH, boolean flipV)
          Draws the given image.
 void lineTo(double x, double y)
          Draws a line to the given path.
 void moveTo(double x, double y)
          Moves to the given path.
 void quadTo(double x1, double y1, double x2, double y2)
          Draws a quadratic curve to the given point.
 void rect(double x, double y, double w, double h)
          Next fill or stroke should draw a rectangle.
 void restore()
          Restores the previous state of the canvas.
 void rotate(double theta, boolean flipH, boolean flipV, double cx, double cy)
          Rotates the canvas by the given angle around the given center.
 void roundrect(double x, double y, double w, double h, double dx, double dy)
          Next fill or stroke should draw a round rectangle.
 void save()
          Saves the current state of the canvas.
 void scale(double value)
          Uniformaly scales the canvas by the given amount.
 void setAlpha(double value)
          Default value 1.
 void setDashed(boolean value)
          Sets the dashed state.
 void setDashPattern(String value)
          Sets the dash pattern.
 void setFillColor(String value)
          Default value mxConstants.NONE.
 void setFontBackgroundColor(String value)
          Default value "#000000".
 void setFontBorderColor(String value)
          Default value "#000000".
 void setFontColor(String value)
          Default value "#000000".
 void setFontFamily(String value)
          Default value mxConstants.DEFAULT_FONTFAMILY.
 void setFontSize(double value)
          Default value mxConstants.DEFAULT_FONTSIZE.
 void setFontStyle(int value)
          Default value 0.
 void setGradient(String color1, String color2, double x, double y, double w, double h, String direction, double alpha1, double alpha2)
          Prepares the canvas to draw a gradient.
 void setLineCap(String value)
          Sets the linecap.
 void setLineJoin(String value)
          Sets the linejoin.
 void setMiterLimit(double value)
          Sets the miterlimit.
 void setShadow(boolean enabled)
          Enables or disables the painting of shadows.
 void setShadowAlpha(double value)
          Default value mxConstants.NONE.
 void setShadowColor(String value)
          Default value mxConstants.NONE.
 void setShadowOffset(double dx, double dy)
          Default value mxConstants.NONE.
 void setStrokeColor(String value)
          Sets the stroke color.
 void setStrokeWidth(double value)
          Sets the stroke width.
 void stroke()
          Paints the outline of the current path.
 void text(double x, double y, double w, double h, String str, String align, String valign, boolean wrap, String format, String overflow, boolean clip, double rotation)
          Draws the given string.
 void translate(double dx, double dy)
          Translates the canvas by the given amount.
 

Method Detail

save

void save()
Saves the current state of the canvas.


restore

void restore()
Restores the previous state of the canvas.


scale

void scale(double value)
Uniformaly scales the canvas by the given amount.

Parameters:
value - The new scale value.

translate

void translate(double dx,
               double dy)
Translates the canvas by the given amount.

Parameters:
dx - X-coordinate of the translation.
dy - Y-coordinate of the translation.

rotate

void rotate(double theta,
            boolean flipH,
            boolean flipV,
            double cx,
            double cy)
Rotates the canvas by the given angle around the given center. This method may add rendering overhead and should be used with care.

Parameters:
theta - Rotation angle in degrees (0 - 360).
flipH - Specifies if drawing should be flipped horizontally.
flipV - Specifies if drawing should be flipped vertically.
cx - X-coordinate of the center point.
cy - Y-coordinate of the center point.

setStrokeWidth

void setStrokeWidth(double value)
Sets the stroke width. This should default to 1 if unset.

Parameters:
value - Width of the stroke. The value should be multiplied by the current scale.

setStrokeColor

void setStrokeColor(String value)
Sets the stroke color. This should default to mxConstants.NONE if unset.

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setDashed

void setDashed(boolean value)
Sets the dashed state. This should default to false if unset.

Parameters:
value - Boolean representing the dashed state.

setDashPattern

void setDashPattern(String value)
Sets the dash pattern. This should default to "3 3" if unset.

Parameters:
value - Space separated list of floats representing the dash pattern. The value should be multiplied by the current scale.

setLineCap

void setLineCap(String value)
Sets the linecap. This should default to "flat" if unset.

Parameters:
value - "flat", "square" or "round".

setLineJoin

void setLineJoin(String value)
Sets the linejoin. This should default to "miter" if unset.

Parameters:
value - "miter", "round" or "bevel".

setMiterLimit

void setMiterLimit(double value)
Sets the miterlimit. This should default to 10 if unset.

Parameters:
value -

setFontSize

void setFontSize(double value)
Default value mxConstants.DEFAULT_FONTSIZE.

Parameters:
value -

setFontColor

void setFontColor(String value)
Default value "#000000".

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setFontFamily

void setFontFamily(String value)
Default value mxConstants.DEFAULT_FONTFAMILY.

Parameters:
value -

setFontStyle

void setFontStyle(int value)
Default value 0. See mxConstants.STYLE_FONTSTYLE.

Parameters:
value -

setFontBackgroundColor

void setFontBackgroundColor(String value)
Default value "#000000".

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setFontBorderColor

void setFontBorderColor(String value)
Default value "#000000".

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setAlpha

void setAlpha(double value)
Default value 1. This method may add rendering overhead and should be used with care.

Parameters:
value -

setFillColor

void setFillColor(String value)
Default value mxConstants.NONE.

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setGradient

void setGradient(String color1,
                 String color2,
                 double x,
                 double y,
                 double w,
                 double h,
                 String direction,
                 double alpha1,
                 double alpha2)
Prepares the canvas to draw a gradient.

Parameters:
color1 -
color2 -
x -
y -
w -
h -
direction - Direction may be null. Use default value mxConstants.DIRECTION_SOUTH.

setShadow

void setShadow(boolean enabled)
Enables or disables the painting of shadows.

Parameters:
enabled - Whether the shadow should be enabled.

setShadowColor

void setShadowColor(String value)
Default value mxConstants.NONE.

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setShadowAlpha

void setShadowAlpha(double value)
Default value mxConstants.NONE.

Parameters:
value - Hex representation of the color or mxConstants.NONE.

setShadowOffset

void setShadowOffset(double dx,
                     double dy)
Default value mxConstants.NONE.

Parameters:
value - Hex representation of the color or mxConstants.NONE.

rect

void rect(double x,
          double y,
          double w,
          double h)
Next fill or stroke should draw a rectangle.

Parameters:
x -
y -
w -
h -

roundrect

void roundrect(double x,
               double y,
               double w,
               double h,
               double dx,
               double dy)
Next fill or stroke should draw a round rectangle.

Parameters:
x -
y -
w -
h -
dx -
dy -

ellipse

void ellipse(double x,
             double y,
             double w,
             double h)
Next fill or stroke should draw an ellipse.

Parameters:
x -
y -
w -
h -

image

void image(double x,
           double y,
           double w,
           double h,
           String src,
           boolean aspect,
           boolean flipH,
           boolean flipV)
Draws the given image.

Parameters:
x -
y -
w -
h -
src -
aspect -
flipH -
flipV -

text

void text(double x,
          double y,
          double w,
          double h,
          String str,
          String align,
          String valign,
          boolean wrap,
          String format,
          String overflow,
          boolean clip,
          double rotation)
Draws the given string. Possible values for format are empty string for plain text and html for HTML markup.

Parameters:
x -
y -
w -
h -
str -
align -
valign -
vertical -

begin

void begin()
Begins a new path.


moveTo

void moveTo(double x,
            double y)
Moves to the given path.

Parameters:
x -
y -

lineTo

void lineTo(double x,
            double y)
Draws a line to the given path.

Parameters:
x -
y -

quadTo

void quadTo(double x1,
            double y1,
            double x2,
            double y2)
Draws a quadratic curve to the given point.

Parameters:
x1 -
y1 -
x2 -
y2 -

curveTo

void curveTo(double x1,
             double y1,
             double x2,
             double y2,
             double x3,
             double y3)
Draws a bezier curve to the given point.

Parameters:
x1 -
y1 -
x2 -
y2 -
x3 -
y3 -

close

void close()
Closes the current path.


stroke

void stroke()
Paints the outline of the current path.


fill

void fill()
Fills the current path.


fillAndStroke

void fillAndStroke()
Fills and paints the outline of the current path.


mxGraph 2.4.0.1


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.