com.tensegrity.graph.view.geometry
Class GraphGeometryService

java.lang.Object
  extended bycom.tensegrity.graph.view.geometry.GraphGeometryService

public class GraphGeometryService
extends java.lang.Object

This class has static method(s) for loading xml geometry-data resources from files with java's built-in classloader-based resource loading facility.

Version:
$Id: GraphGeometryService.java,v 1.25 2005/12/12 15:21:57 MichaelKegel Exp $
Author:
MichaelKegel
See Also:
GeometryPool, GraphGeometryService

Method Summary
static java.lang.Object createObjectFromItem(GeometryDescriptorItem item)
          This method constructs an object from the given GeometryDescriptorItem.
static AttributeSet getItemAttributes(int itemType)
          Returns the AttributeSet for the given item identifier.
static void init()
           
static void loadGeometriesFromResource(java.lang.String filename, java.lang.Class resourceclass)
          Loads the given geometry into the GeometryPool
static void loadGeometriesFromResource(java.lang.String filename, java.lang.Class resourceClass, boolean overwriteExisting)
          Loads the geometry definitions from the file given through filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static final void init()

loadGeometriesFromResource

public static final void loadGeometriesFromResource(java.lang.String filename,
                                                    java.lang.Class resourceclass)
                                             throws ReadException
Loads the given geometry into the GeometryPool

Parameters:
filename - the filename for the resource, which is passed to the ClassLoader of the given class. The ClassLoader will then figure out the exact location of the geometry definitions.
resourceclass - the class whose ClassLoader to use for loading the geometry definitions.
Throws:
ReadException - thrown if the loading failed.

loadGeometriesFromResource

public static final void loadGeometriesFromResource(java.lang.String filename,
                                                    java.lang.Class resourceClass,
                                                    boolean overwriteExisting)
                                             throws XMLParseException,
                                                    ReadException
Loads the geometry definitions from the file given through filename. The filename must be relative to the reference class given by resourceClass.
The flag given by overwriteExisting indicates whether to overwrite definitions that have been loaded previously and have the same name as the ones that should be loaded from the file.

Parameters:
filename - the relative filename
overwriteExisting - flag that indicates whether to overwrite existing definition with the same name
Throws:
XMLParseException - thrown when an error occurs while read xml from the file given by filename
ReadException - thrown when an error occurs while translating the read xml structure into corresponding definition objects

getItemAttributes

public static final AttributeSet getItemAttributes(int itemType)
Returns the AttributeSet for the given item identifier.

Parameters:
itemType - the item identifier.
Returns:
the AttributeSet for the given item identifier.

createObjectFromItem

public static final java.lang.Object createObjectFromItem(GeometryDescriptorItem item)
                                                   throws GeometryItemCreationException
This method constructs an object from the given GeometryDescriptorItem.

Parameters:
item - the GeometryDescriptorItem to create on object from.
Returns:
the object that was created from the given GeometryDescriptorItem.
Throws:
GeometryItemCreationException - thrown if item creation failed.


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