drawables
Class DrawableObjects

java.lang.Object
  |
  +--drawables.DrawableObjects
Direct Known Subclasses:
DrawableObjectsWithSearchTree

public class DrawableObjects
extends java.lang.Object

Container class for drawable objects.


Field Summary
protected  DupHashtable hashtable
          Hashtable for ID search.
protected  Drawable[] lastInLayer
          The Last object in a layer.
protected  Drawable[] layer
          The layers.
protected  long maxId
          Highest id of an object
protected  int mode
          Presentation mode
protected  int numOfLayers
          Number of layers.
protected  int numOfModes
          Number of presentation modes
protected  DrawableObject searchObject
          Prepared search object used for hashtable search.
protected  DrawableObject selectedObject
          Selected object.
static int STDMODE
          Standard presentation mode
protected  Drawable visibleDrawable
          Actual drawable used by "getNextVisibleIntersectingObject".
 
Constructor Summary
DrawableObjects(int numOfLayers)
          Constructor.
 
Method Summary
 void addDrawable(Drawable prim)
          Add a drawable into the container.
 void deselect()
          Deselects the selected object.
 void drawAllObjects(java.awt.Graphics g, java.awt.Rectangle r, int scale)
          Zeichnet alle Drawable-Objekte im angegebenen Graphic Context, vorausgesetzt der aktuelle Maßstab wird vom Drawable-Objekt überschritten und es liegt im übergebenen Rechteck.
 void drawAllObjectsOfLayer(int l, java.awt.Graphics g, java.awt.Rectangle r, int scale)
          Zeichnet alle Drawable-Objekte im angegebenen Graphic Context, vorausgesetzt der aktuelle Maßstab wird vom Drawable-Objekt überschritten und es liegt im übergebenen Rechteck.
 java.util.Enumeration elements()
          Returns enumeration of all drawable objects.
 Drawable findNearestDrawable(int x, int y)
          Finds the nearest derawable to a given position.
 java.awt.Rectangle getDataspace()
          Returns the data space of all objects.
 int getMode()
          Returns the presentation mode.
 Drawable getNextDrawable(Drawable prevPrim)
          Returns the next drawable primitive.
 long getNextFreeId()
          Returns the next free identifier.
 DrawableObject getNextVisibleIntersectingObject(int px, int py, int scale, boolean selectable)
          Gibt das nächste benannte, sichtbare und ggf. selektierbare Drawable-Objekt zurück, welches sich an der angegebenen Position befindet und den Maßstab einhält.
 int getNumberOfModes()
          Returns the number of presentation modes.
 int getNumberOfObjects()
          Returns the number of all objects.
 DrawableObject getObjectById(long id)
          Gibt das Drawable-Objekt zurück, welches die übergebende ID besitzt.
 DrawableObject getSelectedObject()
          Returns the selected object.
 DrawableObject getVisibleObjectById(long id, int scale)
          Gibt das Drawable-Objekt zurück, welches die übergebende ID besitzt und sichtbar ist.
 DrawableObject newDrawableObject(long id, DrawableObjectType type, java.lang.String name, java.lang.String info)
          Public "conctructor" of a drawable object; it will also be inserted into the container.
 DrawableObject newDrawableObject(long id, java.lang.String typeName, java.lang.String name, java.lang.String info)
          Public "conctructor" of a drawable object; it will also be inserted into the container.
 DrawableObject newDrawableObject(long id, java.lang.String typeName, java.lang.String name, java.lang.String info, int defScale)
          Public "conctructor" of a drawable object; it will also be inserted into the container.
 DrawableObject readDrawableObject(java.io.DataInputStream r, int version)
          Reads a drawable object from the data input stream.
 DrawableObject readDrawableObject(EntryInput r, int version)
          Reads a drawable object from the entry input.
 void readDrawableObject(EntryInput r, java.lang.String objType)
          Liest das Drawable-Objekt vom Entry-Input ein.
 void remove(DrawableObject obj)
          Löscht das Drawable-Objekt aus dem Container und löst die Beziehung zum Grafik-Primitiv auf.
 void removeAll()
          Removes all objects from the container.
 void removeAllObjectsOfLayer(int l)
          Removes all objects of a given layer from the container.
 void select(DrawableObject obj)
          Deselektiert das bislang selektierte Drawable-Objekt und selektiert das übergebene Objekt.
 void setMode(int mode)
          Sets the presentation mode.
 void setNumberOfModes(int num)
          Sets the number of presentation modes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numOfLayers

protected int numOfLayers
Number of layers.


layer

protected Drawable[] layer
The layers.


lastInLayer

protected Drawable[] lastInLayer
The Last object in a layer.


hashtable

protected DupHashtable hashtable
Hashtable for ID search.


STDMODE

public static final int STDMODE
Standard presentation mode

See Also:
Constant Field Values

mode

protected int mode
Presentation mode


numOfModes

protected int numOfModes
Number of presentation modes


maxId

protected long maxId
Highest id of an object


selectedObject

protected DrawableObject selectedObject
Selected object.


visibleDrawable

protected Drawable visibleDrawable
Actual drawable used by "getNextVisibleIntersectingObject".


searchObject

protected DrawableObject searchObject
Prepared search object used for hashtable search.

Constructor Detail

DrawableObjects

public DrawableObjects(int numOfLayers)
Constructor.

Parameters:
numOfLayers - number of layers
Method Detail

addDrawable

public void addDrawable(Drawable prim)
Add a drawable into the container.

Parameters:
prim - the drawable

deselect

public void deselect()
Deselects the selected object.


drawAllObjects

public void drawAllObjects(java.awt.Graphics g,
                           java.awt.Rectangle r,
                           int scale)
Zeichnet alle Drawable-Objekte im angegebenen Graphic Context, vorausgesetzt der aktuelle Maßstab wird vom Drawable-Objekt überschritten und es liegt im übergebenen Rechteck. Die Zeichenreihenfolge richtet sich nach den Layern.

Parameters:
g - aktueller Graphic Context
r - Clipping-Rechteck
scale - aktueller Maßstab

drawAllObjectsOfLayer

public void drawAllObjectsOfLayer(int l,
                                  java.awt.Graphics g,
                                  java.awt.Rectangle r,
                                  int scale)
Zeichnet alle Drawable-Objekte im angegebenen Graphic Context, vorausgesetzt der aktuelle Maßstab wird vom Drawable-Objekt überschritten und es liegt im übergebenen Rechteck. Es werden nur die Objekte des angegebenen Layers gezeichnet.

Parameters:
l - Layer
g - aktueller Graphic Context
r - Clipping-Rechteck
scale - aktueller Maßstab

elements

public java.util.Enumeration elements()
Returns enumeration of all drawable objects.

Returns:
enumeration

findNearestDrawable

public Drawable findNearestDrawable(int x,
                                    int y)
Finds the nearest derawable to a given position.

Parameters:
x - x-coordinate of the position
y - y-coordinate of the position
Returns:
the nearest drawable

getDataspace

public java.awt.Rectangle getDataspace()
Returns the data space of all objects. Not implemented without search tree.

Returns:
mbr of the data space

getMode

public int getMode()
Returns the presentation mode.

Returns:
presentation mode

getNextDrawable

public Drawable getNextDrawable(Drawable prevPrim)
Returns the next drawable primitive.

Parameters:
prevPrim - previous drawable; null => look for first drawable
Returns:
the primitive (or null)

getNextFreeId

public long getNextFreeId()
Returns the next free identifier.

Returns:
free identifier

getNextVisibleIntersectingObject

public DrawableObject getNextVisibleIntersectingObject(int px,
                                                       int py,
                                                       int scale,
                                                       boolean selectable)
Gibt das nächste benannte, sichtbare und ggf. selektierbare Drawable-Objekt zurück, welches sich an der angegebenen Position befindet und den Maßstab einhält. Falls es kein solches Objekt gibt, wird null zurückgegeben.

Parameters:
px - x-Koordinate der gesuchten Position (in Basis-Koordinaten)
py - y-Koordinate der gesuchten Position (in Basis-Koordinaten)
selectable - muß das Objekt selektierbar sein?
Returns:
gefundenes Drawable-Objekt

getNumberOfModes

public int getNumberOfModes()
Returns the number of presentation modes.

Returns:
the number

getNumberOfObjects

public int getNumberOfObjects()
Returns the number of all objects. Not implemented without search tree.

Returns:
number of all objects

getObjectById

public DrawableObject getObjectById(long id)
Gibt das Drawable-Objekt zurück, welches die übergebende ID besitzt. Falls es kein solches Objekt gibt, wird null zurückgegeben.

Parameters:
id - gesuchte ID
Returns:
gefundenes Drawable-Objekt

getSelectedObject

public DrawableObject getSelectedObject()
Returns the selected object.

Returns:
select object (or null)

getVisibleObjectById

public DrawableObject getVisibleObjectById(long id,
                                           int scale)
Gibt das Drawable-Objekt zurück, welches die übergebende ID besitzt und sichtbar ist. Falls es kein solches Objekt gibt, wird null zurückgegeben.

Parameters:
id - gesuchte ID
scale - Maßstab
Returns:
gefundenes Drawable-Objekt

newDrawableObject

public DrawableObject newDrawableObject(long id,
                                        DrawableObjectType type,
                                        java.lang.String name,
                                        java.lang.String info)
Public "conctructor" of a drawable object; it will also be inserted into the container.

Parameters:
id - id of the object
name - the name of the object
info - attributes
Returns:
the object

newDrawableObject

public DrawableObject newDrawableObject(long id,
                                        java.lang.String typeName,
                                        java.lang.String name,
                                        java.lang.String info)
Public "conctructor" of a drawable object; it will also be inserted into the container.

Parameters:
id - id of the object
typeName - the name of the object type
name - the name of the object
info - attributes
Returns:
the object

newDrawableObject

public DrawableObject newDrawableObject(long id,
                                        java.lang.String typeName,
                                        java.lang.String name,
                                        java.lang.String info,
                                        int defScale)
Public "conctructor" of a drawable object; it will also be inserted into the container.

Parameters:
id - id of the object
typeName - the name of the object type
name - the name of the object
info - attributes
defScale - the default scale
Returns:
the object

readDrawableObject

public DrawableObject readDrawableObject(java.io.DataInputStream r,
                                         int version)
                                  throws java.io.IOException
Reads a drawable object from the data input stream.

Parameters:
r - data input stream
version - the file version
Returns:
the object
java.io.IOException

readDrawableObject

public DrawableObject readDrawableObject(EntryInput r,
                                         int version)
Reads a drawable object from the entry input.

Parameters:
r - entry input
Returns:
the object

readDrawableObject

public void readDrawableObject(EntryInput r,
                               java.lang.String objType)
Liest das Drawable-Objekt vom Entry-Input ein. DEPRECATED!

Parameters:
r - Entry-Input
objType - vom Entry-Input eingelesener Drawable-Typ

remove

public void remove(DrawableObject obj)
Löscht das Drawable-Objekt aus dem Container und löst die Beziehung zum Grafik-Primitiv auf.

Parameters:
obj - zu löschendes Drawable-Objekt

removeAll

public void removeAll()
Removes all objects from the container.


removeAllObjectsOfLayer

public void removeAllObjectsOfLayer(int l)
Removes all objects of a given layer from the container.

Parameters:
l - the layer

select

public void select(DrawableObject obj)
Deselektiert das bislang selektierte Drawable-Objekt und selektiert das übergebene Objekt.

Parameters:
obj - zu löschendes Drawable-Objekt

setMode

public void setMode(int mode)
Sets the presentation mode.

Parameters:
mode - the presentation mode

setNumberOfModes

public void setNumberOfModes(int num)
Sets the number of presentation modes.