public class ShapeLibrary
extends java.lang.Object
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 and Description |
|---|
ShapeLibrary(Shape[] shapes) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public ShapeLibrary(Shape[] shapes)
public static ShapeLibrary loadFrom(java.io.File file)
file - A File object that contains the shape library data.ShapeLibrary instance.public static ShapeLibrary loadFrom(org.xml.sax.InputSource source)
source - An InputSource object that contains the shape library data.ShapeLibrary instance.public void saveTo(java.lang.String filename)
throws com.mindfusion.common.XmlException
filename - The name of the file where the library should be saved.com.mindfusion.common.XmlExceptionpublic org.w3c.dom.Element toDOM(org.w3c.dom.Document owner)
owner - The XML document.public static ShapeLibrary fromXmlElement(org.w3c.dom.Element shapes) throws javax.xml.transform.TransformerException, com.mindfusion.common.XmlException
shapes - An XML element containing the shape library data.ShapeLibrary instance.com.mindfusion.common.XmlExceptionjavax.xml.transform.TransformerExceptionpublic Shape[] getShapes()
Shape objects.public void setShapes(Shape[] shapes)
shapes - An array of Shape objects.public void makeImagesRelativeTo(java.lang.String shapeLibraryPath)
throws java.net.URISyntaxException
java.net.URISyntaxException