com.mxgraph.shape

## Class mxStencil

- java.lang.Object
- - com.mxgraph.shape.mxStencil

- All Implemented Interfaces:
    mxIShape

      public class mxStencil
      extends java.lang.Object
      implements mxIShape

  Implements a stencil for the given XML definition. This class implements the mxGraph stencil schema.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `aspect` Holds the aspect of the shape.
    `protected org.w3c.dom.Element` | `bgNode` Holds the XML node with the stencil description.
    `protected org.w3c.dom.Element` | `desc` Holds the top-level node of the stencil definition.
    `protected org.w3c.dom.Element` | `fgNode` Holds the XML node with the stencil description.
    `protected double` | `h0` Holds the height of the shape.
    `protected double` | `lastMoveX` Holds the last x-position of the cursor.
    `protected double` | `lastMoveY` Holds the last y-position of the cursor.
    `protected java.lang.String` | `strokewidth` Holds the strokewidth direction from the description.
    `protected double` | `w0` Holds the width of the shape.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `mxStencil(org.w3c.dom.Element description)` Constructs a new stencil for the given mxGraph shape description.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected mxRectangle` | `computeAspect(mxCellState state, mxRectangle bounds, java.lang.String direction)` Returns a rectangle that contains the offset in x and y and the horizontal and vertical scale in width and height used to draw this shape inside the given rectangle.
    `protected mxGraphicsCanvas2D` | `createCanvas(mxGraphics2DCanvas gc)` Creates the canvas for rendering the stencil.
    `protected void` | `drawElement(mxGraphicsCanvas2D canvas, mxCellState state, org.w3c.dom.Element node, mxRectangle aspect)` Drawsthe given element.
    `protected void` | `drawShadow(mxGraphicsCanvas2D canvas, mxCellState state, double rotation, boolean flipH, boolean flipV, mxRectangle bounds, double alpha, boolean filled)` Draws the shadow.
    `boolean` | `drawShape(mxGraphicsCanvas2D canvas, mxCellState state, mxRectangle bounds, boolean background)` Draws this stencil inside the given bounds.
    `java.lang.String` | `evaluateAttribute(org.w3c.dom.Element elt, java.lang.String attribute, mxCellState state)` Gets the attribute for the given name from the given node.
    `org.w3c.dom.Element` | `getDescription()` Returns the description.
    `protected double` | `getDouble(org.w3c.dom.Element elt, java.lang.String attribute)` Returns the given attribute or 0.
    `protected double` | `getDouble(org.w3c.dom.Element elt, java.lang.String attribute, double defaultValue)` Returns the given attribute or the default value.
    `protected int` | `getInt(org.w3c.dom.Element elt, java.lang.String attribute, int defaultValue)` Returns the given attribute or the default value.
    `protected java.lang.String` | `getString(org.w3c.dom.Element elt, java.lang.String attribute, java.lang.String defaultValue)` Returns the given attribute or the default value.
    `void` | `paintShape(mxGraphics2DCanvas gc, mxCellState state)` Paints the stencil for the given state.
    `protected void` | `parseDescription()` Parses the description of this shape.
    `void` | `setDescription(org.w3c.dom.Element value)` Sets the description.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### desc

          protected org.w3c.dom.Element desc

      Holds the top-level node of the stencil definition.

    - #### aspect

          protected java.lang.String aspect

      Holds the aspect of the shape. Default is "auto".

    - #### w0

          protected double w0

      Holds the width of the shape. Default is 100.

    - #### h0

          protected double h0

      Holds the height of the shape. Default is 100.

    - #### bgNode

          protected org.w3c.dom.Element bgNode

      Holds the XML node with the stencil description.

    - #### fgNode

          protected org.w3c.dom.Element fgNode

      Holds the XML node with the stencil description.

    - #### strokewidth

          protected java.lang.String strokewidth

      Holds the strokewidth direction from the description.

    - #### lastMoveX

          protected double lastMoveX

      Holds the last x-position of the cursor.

    - #### lastMoveY

          protected double lastMoveY

      Holds the last y-position of the cursor.

  - ### Constructor Detail

    - #### mxStencil

          public mxStencil(org.w3c.dom.Element description)

      Constructs a new stencil for the given mxGraph shape description.

  - ### Method Detail

    - #### getDescription

          public org.w3c.dom.Element getDescription()

      Returns the description.

    - #### setDescription

          public void setDescription(org.w3c.dom.Element value)

      Sets the description.

    - #### createCanvas

          protected mxGraphicsCanvas2D createCanvas(mxGraphics2DCanvas gc)

      Creates the canvas for rendering the stencil.

    - #### paintShape

          public void paintShape(mxGraphics2DCanvas gc,
                        mxCellState state)

      Paints the stencil for the given state.
      Specified by:
        `paintShape` in interface `mxIShape`

    - #### drawShadow

          protected void drawShadow(mxGraphicsCanvas2D canvas,
                        mxCellState state,
                        double rotation,
                        boolean flipH,
                        boolean flipV,
                        mxRectangle bounds,
                        double alpha,
                        boolean filled)

      Draws the shadow.

    - #### drawShape

          public boolean drawShape(mxGraphicsCanvas2D canvas,
                          mxCellState state,
                          mxRectangle bounds,
                          boolean background)

      Draws this stencil inside the given bounds.

    - #### computeAspect

          protected mxRectangle computeAspect(mxCellState state,
                                  mxRectangle bounds,
                                  java.lang.String direction)

      Returns a rectangle that contains the offset in x and y and the horizontal and vertical scale in width and height used to draw this shape inside the given rectangle.

    - #### drawElement

          protected void drawElement(mxGraphicsCanvas2D canvas,
                         mxCellState state,
                         org.w3c.dom.Element node,
                         mxRectangle aspect)

      Drawsthe given element.

    - #### getInt

          protected int getInt(org.w3c.dom.Element elt,
                   java.lang.String attribute,
                   int defaultValue)

      Returns the given attribute or the default value.

    - #### getDouble

          protected double getDouble(org.w3c.dom.Element elt,
                         java.lang.String attribute)

      Returns the given attribute or 0.

    - #### getDouble

          protected double getDouble(org.w3c.dom.Element elt,
                         java.lang.String attribute,
                         double defaultValue)

      Returns the given attribute or the default value.

    - #### getString

          protected java.lang.String getString(org.w3c.dom.Element elt,
                                   java.lang.String attribute,
                                   java.lang.String defaultValue)

      Returns the given attribute or the default value.

    - #### parseDescription

          protected void parseDescription()

      Parses the description of this shape.

    - #### evaluateAttribute

          public java.lang.String evaluateAttribute(org.w3c.dom.Element elt,
                                           java.lang.String attribute,
                                           mxCellState state)

      Gets the attribute for the given name from the given node. If the attribute does not exist then the text content of the node is evaluated and if it is a function it is invoked with as the only argument and the return value is used as the attribute value to be returned.

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