com.mindfusion.diagramming
Class ScriptHelper

java.lang.Object
  extended by com.mindfusion.diagramming.ScriptHelper

public class ScriptHelper
extends java.lang.Object

Provides helper methods to help accessing the JDiagram API from JavaScript. An instance of this class is returned by the DiagramApplet.getScriptHelper() method.


Constructor Summary
ScriptHelper()
           
 
Method Summary
 AnchorPattern anchorPatternFromId(java.lang.String id)
          Gets the AnchorPattern object that has the specified ID.
 AnchorPattern createAnchorPattern(java.lang.String id)
          Creates a new empty AnchorPattern with the specified identifier.
 AnchorPoint createAnchorPoint(float x, float y)
          Creates a new AnchorPoint instance by setting its relative position in nodes.
 AnnealLayout createAnnealLayout()
          Creates a new AnnealLayout instance.
 CircularLayout createCircularLayout()
          Creates a new CircularLayout instance.
 java.awt.Color createColor(int r, int g, int b)
          Creates a new Color instance.
 java.awt.Font createFont(java.lang.String name, float size)
          Creates a Font object with the specified name and size.
 GradientBrush createGradientBrush(int r1, int g1, int b1, int r2, int g2, int b2, int angle)
          Creates a new GradientBrush instance.
 GridLayout createGridLayout()
          Creates a new GridLayout instance.
 LayeredLayout createLayeredLayout()
          Creates a new LayeredLayout instance.
 OrthogonalLayout createOrthogonalLayout()
          Creates a new OrthogonalLayout instance.
 OrthogonalRouter createOrthogonalRouter()
          Creates a new OrthogonalRouter instance.
 java.awt.print.PageFormat createPageFormat()
          Creates a java.awt.print.PageFormat instance.
 java.awt.print.Paper createPaper()
          Creates a java.awt.print.Paper instance.
 PathFinder createPathFinder()
          Creates a new PathFinder instance.
 Pen createPen(float width, int r, int g, int b)
          Creates a new Pen instance.
 java.awt.Point createPoint(int x, int y)
          Creates a Point instance with the specified coordinates.
 java.awt.geom.Point2D.Float createPointF(float x, float y)
          Creates a Point2D.Float instance with the specified coordinates.
 java.awt.Rectangle createRectangle(int x, int y, int width, int height)
          Creates a Rectangle instance with the specified coordinates.
 java.awt.geom.Rectangle2D.Float createRectangleF(float x, float y, float width, float height)
          Creates a Rectangle2D.Float instance with the specified coordinates.
 java.awt.Dimension createSize(int width, int height)
          Creates a Dimension instance with the specified width and height.
 java.awt.geom.Dimension2D createSizeF(float width, float height)
          Creates a Dimension2D instance with the specified width and height.
 SolidBrush createSolidBrush(int r, int g, int b)
          Creates a new SolidBrush instance.
 SolidBrush createSolidBrush(int r, int g, int b, int a)
          Creates a new SolidBrush instance.
 SpringLayout createSpringLayout()
          Creates a new SpringLayout instance.
 TextFormat createTextFormat(int horizontalAlign, int verticalAlign, boolean noWrap, boolean wrapAtCharacter)
          Creates a TextFormat object.
 TreeLayout createTreeLayout()
          Creates a new TreeLayout instance.
static java.lang.Object getConstant(java.lang.String className, java.lang.String field)
          Provides access to constants (public static fields) defined in subpackages of com.mindfusion.diagramming.
 ShapeList getShapes()
          Gets the list of predefined shapes.
 void loadShapeLibrary(java.lang.String url)
          Loads a ShapeLibrary from the specified URL.
 Shape shapeFromId(java.lang.String shapeId)
          Gets the predefined shape that has the specified ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptHelper

public ScriptHelper()
Method Detail

shapeFromId

public Shape shapeFromId(java.lang.String shapeId)
Gets the predefined shape that has the specified ID.

Parameters:
shapeId - A string identifying the shape.
Returns:
A Shape instance identified by the shapeId parameter.

getShapes

public ShapeList getShapes()
Gets the list of predefined shapes.

Returns:
A ShapeList instance containing the predefined JDiagram shapes.

loadShapeLibrary

public void loadShapeLibrary(java.lang.String url)
Loads a ShapeLibrary from the specified URL. The URL must be fully qualified, relative paths are not supported.

Parameters:
url - Location of the shape library file.

createGridLayout

public GridLayout createGridLayout()
Creates a new GridLayout instance.

Returns:
A GridLayout instance.

createLayeredLayout

public LayeredLayout createLayeredLayout()
Creates a new LayeredLayout instance.

Returns:
A LayeredLayout instance.

createSpringLayout

public SpringLayout createSpringLayout()
Creates a new SpringLayout instance.

Returns:
A SpringLayout instance.

createTreeLayout

public TreeLayout createTreeLayout()
Creates a new TreeLayout instance.

Returns:
A TreeLayout instance.

createAnnealLayout

public AnnealLayout createAnnealLayout()
Creates a new AnnealLayout instance.

Returns:
A AnnealLayout instance.

createOrthogonalRouter

public OrthogonalRouter createOrthogonalRouter()
Creates a new OrthogonalRouter instance.

Returns:
An OrthogonalRouter instance.

createOrthogonalLayout

public OrthogonalLayout createOrthogonalLayout()
Creates a new OrthogonalLayout instance.

Returns:
An OrthogonalLayout instance.

createCircularLayout

public CircularLayout createCircularLayout()
Creates a new CircularLayout instance.

Returns:
An CircularLayout instance.

createPathFinder

public PathFinder createPathFinder()
Creates a new PathFinder instance.

Returns:
A PathFinder instance.

createPageFormat

public java.awt.print.PageFormat createPageFormat()
Creates a java.awt.print.PageFormat instance.

Returns:
A java.awt.print.PageFormat instance.

createPaper

public java.awt.print.Paper createPaper()
Creates a java.awt.print.Paper instance.

Returns:
A java.awt.print.Paper instance.

createColor

public java.awt.Color createColor(int r,
                                  int g,
                                  int b)
Creates a new Color instance.

Parameters:
r - A int value specifying the red channel value.
g - A int value specifying the green channel value.
b - A int value specifying the blue channel value.
Returns:
A Color instance.

createPen

public Pen createPen(float width,
                     int r,
                     int g,
                     int b)
Creates a new Pen instance.

Parameters:
width - A float value representing the pen width.
r - A int value specifying the red channel value.
g - A int value specifying the green channel value.
b - A int value specifying the blue channel value.
Returns:
A Pen instance.

createSolidBrush

public SolidBrush createSolidBrush(int r,
                                   int g,
                                   int b)
Creates a new SolidBrush instance.

Parameters:
r - A int value specifying the red channel value.
g - A int value specifying the green channel value.
b - A int value specifying the blue channel value.
Returns:
A SolidBrush instance.

createSolidBrush

public SolidBrush createSolidBrush(int r,
                                   int g,
                                   int b,
                                   int a)
Creates a new SolidBrush instance.

Parameters:
r - A int value specifying the red channel value.
g - A int value specifying the green channel value.
b - A int value specifying the blue channel value.
a - A int value specifying the alpha component.
Returns:
A SolidBrush instance.

createGradientBrush

public GradientBrush createGradientBrush(int r1,
                                         int g1,
                                         int b1,
                                         int r2,
                                         int g2,
                                         int b2,
                                         int angle)
Creates a new GradientBrush instance.

Parameters:
r1 - A int value specifying the first color's red channel value.
g1 - A int value specifying the first color's green channel value.
b1 - A int value specifying the first color's blue channel value.
r2 - A int value specifying the second color's red channel value.
g2 - A int value specifying the second color's green channel value.
b2 - A int value specifying the second color's blue channel value.
angle - An int value specifying the gradient's angle.
Returns:
A GradientBrush instance.

createSize

public java.awt.Dimension createSize(int width,
                                     int height)
Creates a Dimension instance with the specified width and height.

Parameters:
width - Specifies the width.
height - Specifies the height.
Returns:
A Dimension object.

createRectangle

public java.awt.Rectangle createRectangle(int x,
                                          int y,
                                          int width,
                                          int height)
Creates a Rectangle instance with the specified coordinates.

Parameters:
x - X coordinate of the rectangle.
y - Y coordinate of the rectangle.
width - Width of the rectangle.
height - Height of the rectangle.
Returns:
A Rectangle instance.

createSizeF

public java.awt.geom.Dimension2D createSizeF(float width,
                                             float height)
Creates a Dimension2D instance with the specified width and height.

Parameters:
width - Specifies the width.
height - Specifies the height.
Returns:
A Dimension2D object.

createRectangleF

public java.awt.geom.Rectangle2D.Float createRectangleF(float x,
                                                        float y,
                                                        float width,
                                                        float height)
Creates a Rectangle2D.Float instance with the specified coordinates.

Parameters:
x - X coordinate of the rectangle.
y - Y coordinate of the rectangle.
width - Width of the rectangle.
height - Height of the rectangle.
Returns:
A Rectangle2D.Float instance.

createPoint

public java.awt.Point createPoint(int x,
                                  int y)
Creates a Point instance with the specified coordinates.

Parameters:
x - X coordinate of the rectangle.
y - Y coordinate of the rectangle.
Returns:
A Point instance.

createPointF

public java.awt.geom.Point2D.Float createPointF(float x,
                                                float y)
Creates a Point2D.Float instance with the specified coordinates.

Parameters:
x - X coordinate of the rectangle.
y - Y coordinate of the rectangle.
Returns:
A Point2D.Float instance.

createFont

public java.awt.Font createFont(java.lang.String name,
                                float size)
Creates a Font object with the specified name and size.

Parameters:
name - The font name.
size - The font size.
Returns:
A java.awt.Font instance.

getConstant

public static java.lang.Object getConstant(java.lang.String className,
                                           java.lang.String field)
Provides access to constants (public static fields) defined in subpackages of com.mindfusion.diagramming. E.g. to access field DashFrame of class com.mindfusion.diagramming.HandlesStyle invoke getConstant("HandlesStyle", "SquareHandles").

Parameters:
className - Name of the class that defines the constant.
field - Name of the constant field.
Returns:
The constant value

createTextFormat

public TextFormat createTextFormat(int horizontalAlign,
                                   int verticalAlign,
                                   boolean noWrap,
                                   boolean wrapAtCharacter)
Creates a TextFormat object.

Parameters:
horizontalAlign - Specifies the horizontal alignment.
verticalAlign - Specifies the vertical alignment.
noWrap - Specifies whether text wrapping should be disabled.
wrapAtCharacter - Specifies whether text can be wrapped to a new line at an arbitrary character.
Returns:
A TextFormat object.

createAnchorPattern

public AnchorPattern createAnchorPattern(java.lang.String id)
Creates a new empty AnchorPattern with the specified identifier.

Parameters:
id - A string used to identify the new AnchorPattern.
Returns:
An AnchorPattern object.

createAnchorPoint

public AnchorPoint createAnchorPoint(float x,
                                     float y)
Creates a new AnchorPoint instance by setting its relative position in nodes. The point will allow both outgoing and incoming arrows.

Parameters:
x - The horizontal position of the anchor point specified as percents of the node width.
y - The vertical position of the anchor point specified as percents of the node height.
Returns:
An AnchorPoint object.

anchorPatternFromId

public AnchorPattern anchorPatternFromId(java.lang.String id)
Gets the AnchorPattern object that has the specified ID.

Parameters:
id - A string identifying the AnchorPattern.
Returns:
An AnchorPattern instance identified by the id parameter.