com.mindfusion.diagramming
Class ShapeLibrary

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

public class ShapeLibrary
extends java.lang.Object

The ShapeLibrary class represents a collection of shape definitions stored together.

Shape libraries can be created using the ShapeDesigner tool that comes with Diagram.NET. Use the loadFrom(java.io.File) method to load a shape library from a file. The loaded shapes can be accessed through the getShapes() method. They will be automatically added to the shared list of shapes kept in the Shape class, which lets you access them via the Shape.fromId(java.lang.String) method. A shape library can be saved into a file in XML based format using the saveTo(java.lang.String) method.


Constructor Summary
ShapeLibrary(Shape[] shapes)
           
 
Method Summary
static ShapeLibrary fromXmlElement(org.w3c.dom.Element shapes)
          Creates a ShapeLibrary from a DOM tree.
 Shape[] getShapes()
          Gets the shapes contained in this library.
static ShapeLibrary loadFrom(java.io.File file)
          Loads (creates) a ShapeLibrary object from the specified file.
static ShapeLibrary loadFrom(org.xml.sax.InputSource source)
          Loads (creates) a ShapeLibrary object from the specified XML source.
 void makeImagesRelativeTo(java.lang.String shapeLibraryPath)
          Makes image locations relative to specified shapeLibraryPath so that the shape library can be moved/distributed.
 void saveTo(java.lang.String filename)
          Saves the shape library to the specified file.
 void setShapes(Shape[] shapes)
          Sets the shape library shapes.
 org.w3c.dom.Element toDOM(org.w3c.dom.Document owner)
          Converts the ShapeLibrary to a DOM element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeLibrary

public ShapeLibrary(Shape[] shapes)
Method Detail

loadFrom

public static ShapeLibrary loadFrom(java.io.File file)
Loads (creates) a ShapeLibrary object from the specified file.

Parameters:
file - A File object that contains the shape library data.
Returns:
The new ShapeLibrary instance.

loadFrom

public static ShapeLibrary loadFrom(org.xml.sax.InputSource source)
Loads (creates) a ShapeLibrary object from the specified XML source.

Parameters:
source - An InputSource object that contains the shape library data.
Returns:
The new ShapeLibrary instance.

saveTo

public void saveTo(java.lang.String filename)
            throws XmlException
Saves the shape library to the specified file.

Parameters:
filename - The name of the file where the library should be saved.
Throws:
XmlException

toDOM

public org.w3c.dom.Element toDOM(org.w3c.dom.Document owner)
Converts the ShapeLibrary to a DOM element.

Parameters:
owner - The XML document.
Returns:
An XML element containing the shape library data.

fromXmlElement

public static ShapeLibrary fromXmlElement(org.w3c.dom.Element shapes)
                                   throws javax.xml.transform.TransformerException,
                                          XmlException
Creates a ShapeLibrary from a DOM tree.

Parameters:
shapes - An XML element containing the shape library data.
Returns:
The new ShapeLibrary instance.
Throws:
XmlException
javax.xml.transform.TransformerException

getShapes

public Shape[] getShapes()
Gets the shapes contained in this library.

Returns:
An array of Shape objects.

setShapes

public void setShapes(Shape[] shapes)
Sets the shape library shapes.

Parameters:
shapes - An array of Shape objects.

makeImagesRelativeTo

public void makeImagesRelativeTo(java.lang.String shapeLibraryPath)
                          throws java.net.URISyntaxException
Makes image locations relative to specified shapeLibraryPath so that the shape library can be moved/distributed. This method is supposed to be called before serialization.

Throws:
java.net.URISyntaxException