drawables
Class DrawablePolygon

java.lang.Object
  |
  +--drawables.Drawable
        |
        +--drawables.FilledDrawable
              |
              +--drawables.DrawablePolygon
All Implemented Interfaces:
EntryReadable, java.io.Serializable
Direct Known Subclasses:
DrawablePolyline

public class DrawablePolygon
extends FilledDrawable

Class for drawable polygons.

See Also:
Serialized Form

Field Summary
protected  int num
          Number of coordinates.
protected  int[] outX
          Output buffer for x-coordinates.
protected  int[] outY
          Output buffer for y-coordinates.
protected  int[] xCoords
          x-coordinates.
protected  int[] yCoords
          y-coordinates.
 
Fields inherited from class drawables.FilledDrawable
filled
 
Fields inherited from class drawables.Drawable
AREALAYER, BITMAPLAYER, container, DEFMAXSCALE, DEFMINSCALE, layer, LINELAYER, maxScale, mbr, minScale, nextOfLayer, obj, POINTLAYER, pres, selected, TEXTLAYER
 
Constructor Summary
DrawablePolygon()
          Constructor.
DrawablePolygon(int npoints, int[] xpoints, int[] ypoints)
          Constructor for non-filled polygons with holes.
DrawablePolygon(int npoints, int[] xpoints, int[] ypoints, boolean filled, java.lang.String presName)
          Constructor for polygons.
DrawablePolygon(int npoints, int[] xpoints, int[] ypoints, boolean filled, java.lang.String presName, int minScale, int maxScale)
          Constructor for polygons.
 
Method Summary
static java.awt.Rectangle computeMBR(int num, int[] xCoords, int[] yCoords)
          Computes the minimum bounding box for coordinate arrays.
protected  void drawProtected(java.awt.Graphics g, int scale, int mode, int value)
          Draws the polygon using a given GraphicContext, if the scale is observed.
 int getNumberOfPoints()
          Returns the number of points.
 EntryReadable read(java.io.DataInputStream r)
          Reads the polygon from the data input stream.
 EntryReadable read(EntryInput r)
          Reads the polygon from the EntryInput.
 void write(java.io.DataOutputStream out, int type)
          Writes the polygon to the data output stream.
 void writeGML(EntryWriter out)
          Writes the primitive as GML tag.
protected  void writeProtected(EntryWriter out, int type)
          Writes the polygon to the EntryWriter.
 
Methods inherited from class drawables.FilledDrawable
isFilled, setFilling
 
Methods inherited from class drawables.Drawable
computeDistance, computeDistanceTo, contains, draw, draw, draw, draw, getContainer, getId, getLayer, getMaxScale, getMBR, getMinScale, getNextOfLayer, getObject, getPresentation, getPresentation, getType, interacts, intersects, intersects, intersects, isContainedBy, isVisible, readCoord, readCoord, readDrawable, readDrawable, setContainer, setLayer, setMaxScale, setMBR, setMinScale, setNextOfLayer, setObject, setPresentation, setSelection, toString, write, writeCoord, writeCoord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xCoords

protected int[] xCoords
x-coordinates.


yCoords

protected int[] yCoords
y-coordinates.


num

protected int num
Number of coordinates.


outX

protected int[] outX
Output buffer for x-coordinates.


outY

protected int[] outY
Output buffer for y-coordinates.

Constructor Detail

DrawablePolygon

public DrawablePolygon()
Constructor.


DrawablePolygon

public DrawablePolygon(int npoints,
                       int[] xpoints,
                       int[] ypoints)
Constructor for non-filled polygons with holes.

Parameters:
npoints - number of points
xpoints - x-coordinates (will not be duplicated!)
ypoints - y-coordinaten (will not be duplicated!)

DrawablePolygon

public DrawablePolygon(int npoints,
                       int[] xpoints,
                       int[] ypoints,
                       boolean filled,
                       java.lang.String presName)
Constructor for polygons.

Parameters:
npoints - number of points
xpoints - x-coordinates (will not be duplicated!)
ypoints - y-coordinaten (will not be duplicated!)
filled - polygon filled?
presName - name of the presentation object

DrawablePolygon

public DrawablePolygon(int npoints,
                       int[] xpoints,
                       int[] ypoints,
                       boolean filled,
                       java.lang.String presName,
                       int minScale,
                       int maxScale)
Constructor for polygons.

Parameters:
npoints - number of points
xpoints - x-coordinates (will not be duplicated!)
ypoints - y-coordinaten (will not be duplicated!)
filled - polygon filled?
presName - name of the presentation object
minScale - least detailed scale where the drawable is visible
maxScale - most detailed scale where the drawable is visible
Method Detail

computeMBR

public static java.awt.Rectangle computeMBR(int num,
                                            int[] xCoords,
                                            int[] yCoords)
Computes the minimum bounding box for coordinate arrays.

Parameters:
num - number of points
xCoords - x-coordinates
yCoords - y-coordinates
Returns:
the mbr

drawProtected

protected void drawProtected(java.awt.Graphics g,
                             int scale,
                             int mode,
                             int value)
Draws the polygon using a given GraphicContext, if the scale is observed.

Specified by:
drawProtected in class Drawable
Parameters:
g - graphical context
scale - actual scale
mode - actual mode
value - presentation value

getNumberOfPoints

public int getNumberOfPoints()
Returns the number of points.

Returns:
number of points

read

public EntryReadable read(java.io.DataInputStream r)
                   throws java.io.IOException
Reads the polygon from the data input stream. The first entry is the "type".
type == 0: num,xCoords/yCoords
type == 1: filled,presName
type == 2: minScale,maxScale type == 3: layer

Parameters:
r - data input stream
Returns:
this
java.io.IOException

read

public EntryReadable read(EntryInput r)
Reads the polygon from the EntryInput. First entry is the "type".
type == 0: num,xCoords/yCoords
type == 1: filled,presName
type == 2: minScale,maxScale type == 3: layer

Parameters:
r - EntryInput
Returns:
this

write

public void write(java.io.DataOutputStream out,
                  int type)
Writes the polygon to the data output stream.

Parameters:
out - data output stream
type - type of the output; meaning see read-operation

writeGML

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

Overrides:
writeGML in class Drawable
Parameters:
out - entry writer

writeProtected

protected void writeProtected(EntryWriter out,
                              int type)
Writes the polygon to the EntryWriter.

Specified by:
writeProtected in class Drawable
Parameters:
out - entry writer
type - type of the output; meaning see read-operation