public class UserActorLibrary
extends java.lang.Object
Red (neuendor) |
Red (neuendor) |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
USER_LIBRARY_NAME
The name of the user library.
|
Constructor and Description |
---|
UserActorLibrary() |
Modifier and Type | Method and Description |
---|---|
static void |
openLibrary(Configuration configuration,
java.io.File file)
Open the MoML file at the given location as a new library in
the actor library for this application.
|
static void |
openUserLibrary(Configuration configuration)
Open the user actor library as a new library in the actor
library for this application.
|
static void |
saveComponentInLibrary(Configuration configuration,
Entity entity)
Save the given entity in the user library in the given
configuration.
|
public static java.lang.String USER_LIBRARY_NAME
This variable is not final so that users of this class may change it.
public static void openUserLibrary(Configuration configuration) throws java.lang.Exception
The name of the user actor library consists of the
values of StringUtilities.preferencesDirectory()
and USER_LIBRARY_NAME
and ".xml" concatenated.
An alternate class can be used to build the library if reading the MoML is not desired. The class must extend ptolemy.moml.LibraryBuilder and the _alternateLibraryBuilder property must be set with the 'value' set to the class that extends LibraryBuilder.
configuration
- The configuration where we look for the
actor library.java.lang.Exception
- If there is a problem opening the configuration,
opening the MoML file, or opening the MoML file as a new library.public static void openLibrary(Configuration configuration, java.io.File file) throws java.lang.Exception
An alternate class can be used to build the library if reading the MoML is not desired. The class must extend ptolemy.moml.LibraryBuilder and the _alternateLibraryBuilder property must be set with the 'value' set to the class that extends LibraryBuilder.
A library of components is a .xml file that defines a MoML Class that extends ptolemy.moml.EntityLibrary, for example, the following file creates a library called "MyActors" that has an XYPlotter in the library:
<?xml version="1.0" standalone="no"?> <!DOCTYPE class PUBLIC "-//UC Berkeley//DTD MoML 1//EN" "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd"> <class name="MyActors" extends="ptolemy.moml.EntityLibrary"> <configure> <group> <entity name="XY Plotter" class="ptolemy.actor.lib.gui.XYPlotter"/> </group> </configure> </class>
Note that one restriction is to see the new library, one must open a new Graph viewer (New -> Graph).
configuration
- The configuration where we look for the
actor library.file
- The MoML file to open.java.lang.Exception
- If there is a problem opening the
configuration, opening the MoML file, or opening the MoML file
as a new library.public static void saveComponentInLibrary(Configuration configuration, Entity entity) throws java.io.IOException, IllegalActionException, NameDuplicationException
configuration
- The configuration.entity
- The entity to save.java.io.IOException
- if the user library cannot be found.IllegalActionException
- If there is a problem creating
the entity in the library.NameDuplicationException
- If a entity with the same
name already exists in the library.