com.tensegrity.graph.element
Class ElementPoolManager

java.lang.Object
  extended bycom.tensegrity.graph.element.ElementPoolManager

public class ElementPoolManager
extends java.lang.Object

Reads the geometry, style and rule XML files and creates the entries in the corresponding pools. This class only contains static methods. To use this PoolManager it is required to either provide a element.xml url, which point to an element.xml file which contains the LOCATIONS Tag, or specify all the locations separately. This way of using the ElementPoolManager would look like:

// specify class to which the files will be relative to.
ElementPoolManager.setLoadClass(MyApplication.class);   
ElementPoolManager.setElementPath("resource/xml/element.xml");
ElementPoolManager.setGeometryPaths(new String[] { "basic-geometry.xml", "icon-geometry.xml"});
ElementPoolManager.setStylePaths(new String[] { "basic-style.xml", "icon-style.xml", "components-style.xml"});
ElementPoolManager.setRulePath("rules.xml");
// done. All locations specified, now load the files
ElementPoolManager.loadElements();
RuleRegistry registry = ElementPoolManager.getRuleRegistry();
// continue...
You may also benefit from the LOCATIONS Tag. Therefore add the LOCATIONS tag to your element.xml file and specify all the locations relative to the element.xml you are modifying. To load the elements.xml file then would look like this:
 ElementPoolManager.setElementPath("c:\\documents\\project1\\joe\\elements.xml");
 Set names = ElementPoolManager.loadElementNames();
 RuleRegistry registry = ElementPoolManager.getRuleRegistry();
 for (Iterator i = names.iterator(); i.hasNext();)
 {
  // do something...
 }
 

Version:
$Id: ElementPoolManager.java,v 1.24 2006/01/05 12:35:49 BurkhardWick Exp $
Author:
MarkusFalkhausen

Method Summary
static void enterKey(java.lang.Object key, java.lang.String elementName)
          Registers a key/value pair internally.
static java.lang.String[] getGeometryURLs()
          Returns the currently used filenames of all geometry files.
static RuleRegistry getRuleRegistry()
          Returns the previously read RuleRegistry.
static java.lang.String[] getStyleURLs()
          Returns the currently used filenames of all style files.
static boolean hasLocations()
          Checks whether the currently set elements.xml file has a location tag.
static void load()
          Loads the geometries from the path given by the foregoing call to the method #setGeometryPaths() styles from the path given by the foregoing call to the method #setStylePaths() elements from the path given by the foregoing call to the method #setElementPath() rules from the path given by the foregoing call to the method #setRulePath() NOTICE:If there was no foregoing call to all of the methods mentioned before or if the pathes passed to the methods are not valid, this method might not work properly.
static java.util.List loadElementNames()
          Method loadElementNames loads the elements.xml file specified by the elementURL field.
static VisualNode resolveVisualNodeElement(java.lang.Object key)
          Resolves a visual-node element from the given key.
static void setElementPath(java.lang.String path)
          Sets the paths used for loading elements files.
static void setGeometryPaths(java.lang.String[] paths)
          Sets the paths used for loading geometry files.
static void setLoadClass(java.lang.Class clazz)
          Sets the class that is the reference for loading.
static void setRulePaths(java.lang.String[] paths)
          Sets the paths used for loading rule files.
static void setStylePaths(java.lang.String[] paths)
          Sets the paths used for loading style files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public static void load()
Loads the NOTICE:If there was no foregoing call to all of the methods mentioned before or if the pathes passed to the methods are not valid, this method might not work properly.

Throws:
XMLParseException - thrown if the xml files are not well formed.

setGeometryPaths

public static void setGeometryPaths(java.lang.String[] paths)
Sets the paths used for loading geometry files.

Parameters:
paths - a string array of paths.

setStylePaths

public static void setStylePaths(java.lang.String[] paths)
Sets the paths used for loading style files.

Parameters:
paths - a string array of paths.

setElementPath

public static void setElementPath(java.lang.String path)
Sets the paths used for loading elements files.


setRulePaths

public static void setRulePaths(java.lang.String[] paths)
Sets the paths used for loading rule files.

Parameters:
paths - a string array of paths.

setLoadClass

public static void setLoadClass(java.lang.Class clazz)
Sets the class that is the reference for loading. This class is the base and relative paths are added to it.

Parameters:
clazz - the reference class for loading resources.

hasLocations

public static boolean hasLocations()
Checks whether the currently set elements.xml file has a location tag. This would allow us, to load the elements file right away, without setting the other locations. These will be set during the read of the elements.

Returns:
boolean true, if the elements.xml is set and contains the the LOCATIONS tag.

loadElementNames

public static final java.util.List loadElementNames()
Method loadElementNames loads the elements.xml file specified by the elementURL field. If the elements.xml file has the optional LOCATIONS tag, all location fields of this manager are initialized according to read values. This method then returns a Set with all the Element names from the elements.xml file.

Returns:
Set the HashSet containing all the loaded elements.

resolveVisualNodeElement

public static VisualNode resolveVisualNodeElement(java.lang.Object key)
Resolves a visual-node element from the given key.

Parameters:
key - the key used for resolving.
Returns:
the found VisualNode.

enterKey

public static void enterKey(java.lang.Object key,
                            java.lang.String elementName)
Registers a key/value pair internally.

Parameters:
key - the key that is submitted.
elementName - the value submitted under the given key.

getRuleRegistry

public static RuleRegistry getRuleRegistry()
Returns the previously read RuleRegistry.

Returns:
RuleRegistry the RuleRegistry constructed form the contents of the default rules xml file, may be null.

getGeometryURLs

public static java.lang.String[] getGeometryURLs()
Returns the currently used filenames of all geometry files.

Returns:
the currently used filenames of all geometry files.

getStyleURLs

public static java.lang.String[] getStyleURLs()
Returns the currently used filenames of all style files.

Returns:
the currently used filenames of all style files.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.