drawables
Class Drawable

java.lang.Object
  |
  +--drawables.Drawable
All Implemented Interfaces:
EntryReadable, java.io.Serializable
Direct Known Subclasses:
DrawableBitmap, DrawableLine, DrawableText, Edge, FilledDrawable, Node

public abstract class Drawable
extends java.lang.Object
implements java.io.Serializable, EntryReadable

Basic class for drawable primitives.

See Also:
Serialized Form

Field Summary
static byte AREALAYER
          Standard layer for areal primitives.
static byte BITMAPLAYER
          Standard layer for (not scalable) bitmaps.
protected  DrawableObjects container
          Container of the primitive.
static int DEFMAXSCALE
          Default for the most detailed scale.
static int DEFMINSCALE
          Default for the least detailed scale.
protected  byte layer
          Layer.
static byte LINELAYER
          Standard layer for line primitives.
protected  int maxScale
          The most detailed scale for drawing.
protected  java.awt.Rectangle mbr
          The minimum bounding rectangle.
protected  int minScale
          The least detailed scale for drawing.
protected  Drawable nextOfLayer
          Next primitive of the same layer.
protected  DrawableObject obj
          The corresponding drawable object.
static byte POINTLAYER
          Standard layer for point primitives.
protected  DrawablePresentation pres
          The corresponding presentation object.
protected  boolean selected
          Is the primitive selected?
static byte TEXTLAYER
          Standard layer for text primitives.
 
Constructor Summary
Drawable()
           
 
Method Summary
static double computeDistance(int x1, int y1, int x2, int y2)
          Computes the distance between two points.
 double computeDistanceTo(int x, int y)
          Computes the distance of the drawing primitive to a point.
 boolean contains(java.awt.Rectangle rect)
          Tests whether the drawable primitive contains a given rectangle.
 void draw(java.awt.Graphics g)
          Draws the primitive and the linked primitives.
 void draw(java.awt.Graphics g, int scale)
          Draws the primitive and the linked primitives.
 void draw(java.awt.Graphics g, java.awt.Rectangle r)
          Draws the primitive and the linked primitives.
 void draw(java.awt.Graphics g, java.awt.Rectangle r, int scale)
          Draws the primitive.
protected abstract  void drawProtected(java.awt.Graphics g, int scale, int mode, int value)
          Implements the draw method of a primitive.
 DrawableObjects getContainer()
          Returns the container.
 long getId()
          Returns the identifier of the corresponding object (or 0).
 int getLayer()
          Returns the layer of the primitive.
 int getMaxScale()
          Returns the most detailed scale for drawing.
 java.awt.Rectangle getMBR()
          Returns the minimum bounding rectangle of the primitive.
 int getMinScale()
          Returns the least detailed scale for drawing.
 Drawable getNextOfLayer()
          Returns the next primitive of the same layer.
 DrawableObject getObject()
          Returns the corresponding drawable object.
 DrawablePresentation getPresentation()
          Returns the basic presentation object.
 DrawablePresentation getPresentation(int scale, int mode, int value)
          Returns the presentation object for a given scale, mode and value.
 java.lang.Object getType()
          Returns the class of the primitive as Object.
 boolean interacts(int x, int y, int scale)
          Tests whether the primitive is selected by a given point or not.
 boolean intersects(Drawable prim)
          Tests whether the drawable primitive intersects another primitive.
 boolean intersects(java.lang.Object prim)
          Tests whether the drawable primitive intersects another primitive which is passed as Object.
 boolean intersects(java.awt.Rectangle r)
          Tests whether the drawable primitive intersects a given rectangle.
 boolean isContainedBy(java.awt.Rectangle rect)
          Tests whether the drawable primitive is contained by a given rectangle.
 boolean isVisible(int scale)
          Test whether the drawing primitive is visible or not.
protected static int readCoord(java.io.DataInputStream in)
          Reads a coordinate.
protected static int readCoord(EntryInput in)
          Reads a coordinate.
static Drawable readDrawable(java.io.DataInputStream r, char primType)
          Reads a new primitive from an entry input.
static Drawable readDrawable(EntryInput r, java.lang.String primType)
          Reads a new primitive from an entry input.
 void setContainer(DrawableObjects container)
          Sets the containe of the primitive.
 void setLayer(int layer)
          Sets the layer.
 void setMaxScale(int scale)
          Sets the most detailed scale for drawing.
 void setMBR(java.awt.Rectangle newMBR)
          Sets the minimum bounding rectangle of the primitive.
 void setMinScale(int scale)
          Returns the least detailed scale for drawing.
 void setNextOfLayer(Drawable next)
          Sets the next primitive of the same layer.
 void setObject(DrawableObject obj)
          Sets the corresponding object.
 void setPresentation(DrawablePresentation pres)
          Sets the corresponding presentation object.
 void setSelection(boolean on)
          Selects or deselect the primitive.
 java.lang.String toString()
          Returns a string representation.
 void write(EntryWriter out, int type)
          Writes the primitive.
protected static void writeCoord(java.io.DataOutputStream out, int coord)
          Writes a coordinate.
protected static void writeCoord(EntryWriter out, int coord)
          Writes a coordinate.
 void writeGML(EntryWriter out)
          Writes the primitive as GML tag.
protected abstract  void writeProtected(EntryWriter out, int type)
          Writes the primitive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.EntryReadable
read
 

Field Detail

AREALAYER

public static final byte AREALAYER
Standard layer for areal primitives.

See Also:
Constant Field Values

LINELAYER

public static final byte LINELAYER
Standard layer for line primitives.

See Also:
Constant Field Values

POINTLAYER

public static final byte POINTLAYER
Standard layer for point primitives.

See Also:
Constant Field Values

TEXTLAYER

public static final byte TEXTLAYER
Standard layer for text primitives.

See Also:
Constant Field Values

BITMAPLAYER

public static final byte BITMAPLAYER
Standard layer for (not scalable) bitmaps.

See Also:
Constant Field Values

DEFMINSCALE

public static final int DEFMINSCALE
Default for the least detailed scale.

See Also:
Constant Field Values

DEFMAXSCALE

public static final int DEFMAXSCALE
Default for the most detailed scale.

See Also:
Constant Field Values

mbr

protected java.awt.Rectangle mbr
The minimum bounding rectangle.


minScale

protected int minScale
The least detailed scale for drawing.


maxScale

protected int maxScale
The most detailed scale for drawing.


layer

protected byte layer
Layer.


selected

protected boolean selected
Is the primitive selected?


pres

protected DrawablePresentation pres
The corresponding presentation object.


obj

protected DrawableObject obj
The corresponding drawable object.


container

protected DrawableObjects container
Container of the primitive.


nextOfLayer

protected Drawable nextOfLayer
Next primitive of the same layer.

Constructor Detail

Drawable

public Drawable()
Method Detail

computeDistance

public static double computeDistance(int x1,
                                     int y1,
                                     int x2,
                                     int y2)
Computes the distance between two points.

Parameters:
x1 - x-coordinate of the 1st point
y1 - y-coordinate of the 1st point
x2 - x-coordinate of the 2nd point
y2 - y-coordinate of the 2nd point
Returns:
distance

computeDistanceTo

public double computeDistanceTo(int x,
                                int y)
Computes the distance of the drawing primitive to a point.

Parameters:
x - x-coordinate of the point
y - x-coordinate of the point
Returns:
distance

contains

public boolean contains(java.awt.Rectangle rect)
Tests whether the drawable primitive contains a given rectangle. The default implementation works with the mbr of the primitive.

Parameters:
rect - the rectangle
Returns:
contains?

draw

public void draw(java.awt.Graphics g)
Draws the primitive and the linked primitives.

Parameters:
g - graphical context

draw

public void draw(java.awt.Graphics g,
                 int scale)
Draws the primitive and the linked primitives.

Parameters:
g - graphical context
scale - actual scale

draw

public void draw(java.awt.Graphics g,
                 java.awt.Rectangle r)
Draws the primitive and the linked primitives.

Parameters:
g - graphical context
r - clipping rectangle

draw

public void draw(java.awt.Graphics g,
                 java.awt.Rectangle r,
                 int scale)
Draws the primitive.

Parameters:
g - graphical context
r - clipping rectangle
scale - actual scale

drawProtected

protected abstract void drawProtected(java.awt.Graphics g,
                                      int scale,
                                      int mode,
                                      int value)
Implements the draw method of a primitive.

Parameters:
g - graphical context
mode - actual presentation mode
value - presentation value

getContainer

public DrawableObjects getContainer()
Returns the container.

Returns:
the container

getId

public long getId()
Returns the identifier of the corresponding object (or 0).

Returns:
the ID

getLayer

public int getLayer()
Returns the layer of the primitive.

Returns:
the layer

getMaxScale

public int getMaxScale()
Returns the most detailed scale for drawing.

Returns:
the scale

getMBR

public java.awt.Rectangle getMBR()
Returns the minimum bounding rectangle of the primitive.

Returns:
the MBR

getMinScale

public int getMinScale()
Returns the least detailed scale for drawing.

Returns:
the scale

getNextOfLayer

public Drawable getNextOfLayer()
Returns the next primitive of the same layer.

Returns:
linked primitive

getObject

public DrawableObject getObject()
Returns the corresponding drawable object.

Returns:
drawable object

getPresentation

public DrawablePresentation getPresentation()
Returns the basic presentation object.

Returns:
basic presentation object

getPresentation

public DrawablePresentation getPresentation(int scale,
                                            int mode,
                                            int value)
Returns the presentation object for a given scale, mode and value.

Parameters:
scale - the scale
mode - the presentation mode
value - the presentation value
Returns:
presentation object

getType

public java.lang.Object getType()
Returns the class of the primitive as Object.

Returns:
the type

interacts

public boolean interacts(int x,
                         int y,
                         int scale)
Tests whether the primitive is selected by a given point or not. The default implementation is based on the mbr of the primitive.

Parameters:
x - x-coordinate of the point
y - y-coordinate of the point
scale - actuals scale
Returns:
selected?

intersects

public boolean intersects(Drawable prim)
Tests whether the drawable primitive intersects another primitive. The default implementation is based on the mbr of the primitive.

Returns:
intersects?

intersects

public boolean intersects(java.awt.Rectangle r)
Tests whether the drawable primitive intersects a given rectangle. The default implementation is based on the mbr of the primitive.

Parameters:
r - the rectangle
Returns:
intersects?

intersects

public boolean intersects(java.lang.Object prim)
Tests whether the drawable primitive intersects another primitive which is passed as Object.

Parameters:
prim - the other drawable primitive
Returns:
intersect?

isContainedBy

public boolean isContainedBy(java.awt.Rectangle rect)
Tests whether the drawable primitive is contained by a given rectangle. The default implementation is based on the mbr of the primitive.

Parameters:
rect - the rectangle
Returns:
is contained?

isVisible

public boolean isVisible(int scale)
Test whether the drawing primitive is visible or not.

Parameters:
scale - actual scale (negative value => returns true)
Returns:
is visible?

readCoord

protected static int readCoord(java.io.DataInputStream in)
                        throws java.io.IOException
Reads a coordinate.

Parameters:
in - data input stream
Returns:
the coordinate
java.io.IOException

readCoord

protected static int readCoord(EntryInput in)
Reads a coordinate.

Parameters:
in - entry input
Returns:
the coordinate

readDrawable

public static Drawable readDrawable(java.io.DataInputStream r,
                                    char primType)
                             throws java.io.IOException
Reads a new primitive from an entry input.

Parameters:
r - data input stream
primType - the type of the primitive
Returns:
the primitive or null
java.io.IOException

readDrawable

public static Drawable readDrawable(EntryInput r,
                                    java.lang.String primType)
Reads a new primitive from an entry input.

Parameters:
r - entry input
primType - the type of the primitive
Returns:
the primitive or null

setContainer

public void setContainer(DrawableObjects container)
Sets the containe of the primitive.

Parameters:
container - the container

setLayer

public void setLayer(int layer)
Sets the layer.

Parameters:
layer - new layer

setMaxScale

public void setMaxScale(int scale)
Sets the most detailed scale for drawing.

Parameters:
scale - the scale

setMBR

public void setMBR(java.awt.Rectangle newMBR)
Sets the minimum bounding rectangle of the primitive.

Parameters:
newMBR - the MBR

setMinScale

public void setMinScale(int scale)
Returns the least detailed scale for drawing.

Parameters:
scale - the scale

setNextOfLayer

public void setNextOfLayer(Drawable next)
Sets the next primitive of the same layer.


setObject

public void setObject(DrawableObject obj)
Sets the corresponding object.

Parameters:
obj - the new object

setPresentation

public void setPresentation(DrawablePresentation pres)
Sets the corresponding presentation object.

Parameters:
pres - the new presentation object

setSelection

public void setSelection(boolean on)
Selects or deselect the primitive.

Parameters:
on - selected?

toString

public java.lang.String toString()
Returns a string representation.

Overrides:
toString in class java.lang.Object
Returns:
the string

write

public void write(EntryWriter out,
                  int type)
Writes the primitive.

Parameters:
out - entry writer
type - type of the output (meaning depends on the concrete subclass)

writeCoord

protected static void writeCoord(java.io.DataOutputStream out,
                                 int coord)
Writes a coordinate.

Parameters:
out - data output stream
coord - the x- or y-coordinate

writeCoord

protected static void writeCoord(EntryWriter out,
                                 int coord)
Writes a coordinate.

Parameters:
out - entry writer
coord - the x- or y-coordinate

writeGML

public void writeGML(EntryWriter out)
Writes the primitive as GML tag.

Parameters:
out - entry writer

writeProtected

protected abstract void writeProtected(EntryWriter out,
                                       int type)
Writes the primitive.

Parameters:
out - entry writer
type - type of the output (meaning depends on the concrete subclass)