Class XmlCanvas2D

Base class for all canvases. The following methods make up the public interface of the canvas 2D for all painting in mxGraph:

  • ,
  • , ,
  • , , , , , , , , , , ,
  • , , , , ,
  • , , ,
  • , , , ,
  • , moveTo, , ,
  • , ,

<AbstractCanvas2D.arcTo> is an additional method for drawing paths. This is a synthetic method, meaning that it is turned into a sequence of curves by default. Subclassers may add native support for arcs.

Constructor: D

Constructs a new abstract canvas.

Hierarchy (view full)

Constructors

Properties

closeOp: string = 'Z'

Holds the operator for closing curves. Default is 'Z'.

compressed: boolean = true

Specifies if the output should be compressed by removing redundant calls.

true
converter: UrlConverter

Holds the to convert image URLs.

curveOp: string = 'C'

Contains the string used for bezier curves. Default is 'C'.

lastX: number = 0

Holds the last x coordinate.

lastY: number = 0

Holds the last y coordinate.

lineOp: string = 'L'

Contains the string used for moving in paths. Default is 'L'.

moveOp: string = 'M'

Contains the string used for moving in paths. Default is 'M'.

path: (string | number)[] = []

Holds the current path as an array.

pointerEvents: boolean = false

Boolean value that specifies if events should be handled. Default is false.

pointerEventsValue: null | string = null
quadOp: string = 'Q'

Contains the string used for quadratic paths. Default is 'Q'.

root: Element

Reference to the container for the SVG content.

rotateHtml: boolean = true

Switch for rotation of HTML. Default is false.

state: CanvasState = ...

Holds the current state.

states: CanvasState[] = []

Stack of states.

textEnabled: boolean = true

Specifies if text output should be enabled.

true

Methods

  • Adds the given arc to the current path. This is a synthetic operation that is broken down into curves.

    Parameters

    • rx: number
    • ry: number
    • angle: number
    • largeArcFlag: boolean
    • sweepFlag: boolean
    • x: number
    • y: number

    Returns void

  • Adds a bezier curve to the current path.

    Parameters

    • x1: number

      Number that represents the x-coordinate of the first control point.

    • y1: number

      Number that represents the y-coordinate of the first control point.

    • x2: number

      Number that represents the x-coordinate of the second control point.

    • y2: number

      Number that represents the y-coordinate of the second control point.

    • x3: number

      Number that represents the x-coordinate of the endpoint.

    • y3: number

      Number that represents the y-coordinate of the endpoint.

    Returns void

  • Puts an ellipse into the drawing buffer.

    Parameters

    • x: number

      Number that represents the x-coordinate of the ellipse.

    • y: number

      Number that represents the y-coordinate of the ellipse.

    • w: number

      Number that represents the width of the ellipse.

    • h: number

      Number that represents the height of the ellipse.

    Returns void

  • Paints an image.

    Parameters

    • x: number

      Number that represents the x-coordinate of the image.

    • y: number

      Number that represents the y-coordinate of the image.

    • w: number

      Number that represents the width of the image.

    • h: number

      Number that represents the height of the image.

    • src: string

      String that specifies the URL of the image.

    • aspect: boolean = true

      Boolean indicating if the aspect of the image should be preserved.

    • flipH: boolean = false

      Boolean indicating if the image should be flipped horizontally.

    • flipV: boolean = false

      Boolean indicating if the image should be flipped vertically.

    Returns void

  • Draws a line to the given coordinates.

    Parameters

    • x: number

      Number that represents the x-coordinate of the endpoint.

    • y: number

      Number that represents the y-coordinate of the endpoint.

    Returns void

  • Moves the current path the given point.

    Parameters

    • x: number

      Number that represents the x-coordinate of the point.

    • y: number

      Number that represents the y-coordinate of the point.

    Returns void

  • Adds a quadratic curve to the current path.

    Parameters

    • x1: number

      Number that represents the x-coordinate of the control point.

    • y1: number

      Number that represents the y-coordinate of the control point.

    • x2: number

      Number that represents the x-coordinate of the endpoint.

    • y2: number

      Number that represents the y-coordinate of the endpoint.

    Returns void

  • Puts a rectangle into the drawing buffer.

    Parameters

    • x: number

      Number that represents the x-coordinate of the rectangle.

    • y: number

      Number that represents the y-coordinate of the rectangle.

    • w: number

      Number that represents the width of the rectangle.

    • h: number

      Number that represents the height of the rectangle.

    Returns void

  • Rotates and/or flips the output around a given center. (Note: Due to limitations in VML, the rotation cannot be concatenated.)

    Parameters

    • theta: number

      Number that represents the angle of the rotation (in degrees).

    • flipH: boolean

      Boolean indicating if the output should be flipped horizontally.

    • flipV: boolean

      Boolean indicating if the output should be flipped vertically.

    • cx: number

      Number that represents the x-coordinate of the rotation center.

    • cy: number

      Number that represents the y-coordinate of the rotation center.

    Returns void

  • Puts a rounded rectangle into the drawing buffer.

    Parameters

    • x: number

      Number that represents the x-coordinate of the rectangle.

    • y: number

      Number that represents the y-coordinate of the rectangle.

    • w: number

      Number that represents the width of the rectangle.

    • h: number

      Number that represents the height of the rectangle.

    • dx: number

      Number that represents the horizontal rounding.

    • dy: number

      Number that represents the vertical rounding.

    Returns void

  • Sets the current dash pattern.

    Parameters

    • value: string

      String that represents the dash pattern, which is a sequence of numbers defining the length of the dashes and the length of the spaces between the dashes. The lengths are relative to the line width - a length of 1 is equals to the line width.

    Returns void

    '3 3'
    
  • Sets the current font family.

    Parameters

    • value: string

      String representation of the font family. This handles the same values as the CSS font-family property.

    Returns void

    mxConstants.DEFAULT_FONTFAMILY

  • Sets the gradient. Note that the coordinates may be ignored by some implementations.

    Parameters

    • color1: null | string

      Hexadecimal representation of the start color.

    • color2: null | string

      Hexadecimal representation of the end color.

    • x: number

      X-coordinate of the gradient region.

    • y: number

      y-coordinate of the gradient region.

    • w: number

      Width of the gradient region.

    • h: number

      Height of the gradient region.

    • direction: DirectionValue

      One of Constants#DIRECTION_NORTH, Constants#DIRECTION_EAST, Constants#DIRECTION_SOUTH or Constants#DIRECTION_WEST.

    • alpha1: number = 1.0

      Optional alpha of the start color. Default is 1. Possible values are between 1 (opaque) and 0 (transparent).

    • alpha2: number = 1.0

      Optional alpha of the end color. Default is 1. Possible values are between 1 (opaque) and 0 (transparent).

    Returns void

  • Sets the line cap.

    Parameters

    • value: string

      String that represents the line cap. Possible values are flat, round and square.

    Returns void

    'flat' which corresponds to 'butt' in SVG
    
  • Sets the current shadows alpha. Default is mxConstants.SHADOW_OPACITY

    Parameters

    • value: number

      Number that represents the new alpha. Possible values are between 1 (opaque) and 0 (transparent).

    Returns void

  • Paints the given text. Possible values for format are empty string for plain text and html for HTML markup. Background and border color as well as clipping is not available in plain text labels for VML. HTML labels are not available as part of shapes with no foreignObject support in SVG (eg. IE9, IE10).

    Parameters

    • x: number

      Number that represents the x-coordinate of the text.

    • y: number

      Number that represents the y-coordinate of the text.

    • w: number

      Number that represents the available width for the text or 0 for automatic width.

    • h: number

      Number that represents the available height for the text or 0 for automatic height.

    • str: string | HTMLElement

      String that specifies the text to be painted.

    • align: null | string = null

      String that represents the horizontal alignment.

    • valign: null | string = null

      String that represents the vertical alignment.

    • wrap: null | boolean = null

      Boolean that specifies if word-wrapping is enabled. Requires w > 0.

    • format: null | string = null

      Empty string for plain text or 'html' for HTML markup.

    • overflow: null | string = null

      Specifies the overflow behaviour of the label. Requires w > 0 and/or h > 0.

    • clip: null | boolean = null

      Boolean that specifies if the label should be clipped. Requires w > 0 and/or h > 0.

    • rotation: null | number = null

      Number that specifies the angle of the rotation around the anchor point of the text.

    • dir: null | TextDirectionValue = null

      Optional string that specifies the text direction. Possible values are rtl and ltr.

    Returns void