drawables
Class DrawableLine

java.lang.Object
  |
  +--drawables.Drawable
        |
        +--drawables.DrawableLine
All Implemented Interfaces:
EntryReadable, java.io.Serializable

public class DrawableLine
extends Drawable

Drawable class for line segments.

See Also:
Serialized Form

Field Summary
static int BACKWARDS
          in Rückrichtung.
static int BOTHDIRECTIONS
          in beide Richtungen.
static int FORWARDS
          in Hinrichtung.
static int NORMALTYPE
          normaler Linientyp.
static int SPLITTED
          gesplittete Linie.
static int UNDIRECTED
          ungerichtet.
 
Fields inherited from class drawables.Drawable
AREALAYER, BITMAPLAYER, container, DEFMAXSCALE, DEFMINSCALE, layer, LINELAYER, maxScale, mbr, minScale, nextOfLayer, obj, POINTLAYER, pres, selected, TEXTLAYER
 
Constructor Summary
protected DrawableLine()
          Konstruktor.
  DrawableLine(int px1, int py1, int px2, int py2)
          Konstruktor.
  DrawableLine(int px1, int py1, int px2, int py2, java.lang.String presName)
          Konstruktor.
  DrawableLine(int px1, int py1, int px2, int py2, java.lang.String presName, int pMinScale, int pMaxScale)
          Konstruktor.
 
Method Summary
 void changePoint1(int x, int y)
          Changes the first point of the line.
 void changePoint2(int x, int y)
          Changes the second point of the line.
 void deselect(int direction)
          Deselektiert die Linie richtungsbezogen.
static void drawProtected(java.awt.Graphics g, DrawablePresentation ap, java.awt.Color forwardsColor, java.awt.Color backwardsColor, int cx1, int cy1, int cx2, int cy2)
          Zeichnet die Linie im Graphic Context g,
protected  void drawProtected(java.awt.Graphics g, int scale, int mode, int value)
          Zeichnet die Linie im Graphic Context g,
 int getX1()
          Returns the x-coordinate of the first point.
 int getX2()
          Returns the x-coordinate of the second point.
 int getY1()
          Returns the y-coordinate of the first point.
 int getY2()
          Returns the y-coordinate of the second point.
 boolean interacts(int x, int y, int scale)
          Tests whether the primitive is selected by a given point or not.
static boolean interacts(int x, int y, int x1, int y1, int x2, int y2, int mx1, int my1, int mx2, int my2, int scale)
           
 java.awt.Point intersects(DrawableLine line)
          Tests if the lines intersect.
 boolean isSelected()
          Gibt zurück, ob die Linie selektiert ist.
 boolean isSelected(int direction)
          Gibt zurück, ob die Linie richtungsbezogen selektiert ist.
 EntryReadable read(EntryInput r)
          Liest die Linie vom Entry-Input ein.
 void select(int direction)
          Selektiert die Linie richtungsbezogen.
 void setSelection(boolean on)
          (De-)Selektiert die Linie.
 java.awt.Point touches(int x, int y, int tolerance)
          Testet, ob der angegebene Punkt mit einer Toleranz auf der Linie liegt.
 void writeGML(EntryWriter out)
          Writes the primitive as GML tag.
protected  void writeProtected(EntryWriter out, int type)
          Writes the line.
 
Methods inherited from class drawables.Drawable
computeDistance, computeDistanceTo, contains, draw, draw, draw, draw, getContainer, getId, getLayer, getMaxScale, getMBR, getMinScale, getNextOfLayer, getObject, getPresentation, getPresentation, getType, intersects, intersects, intersects, isContainedBy, isVisible, readCoord, readCoord, readDrawable, readDrawable, setContainer, setLayer, setMaxScale, setMBR, setMinScale, setNextOfLayer, setObject, setPresentation, toString, write, writeCoord, writeCoord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDIRECTED

public static final int UNDIRECTED
ungerichtet.

See Also:
Constant Field Values

FORWARDS

public static final int FORWARDS
in Hinrichtung.

See Also:
Constant Field Values

BACKWARDS

public static final int BACKWARDS
in Rückrichtung.

See Also:
Constant Field Values

BOTHDIRECTIONS

public static final int BOTHDIRECTIONS
in beide Richtungen.

See Also:
Constant Field Values

NORMALTYPE

public static final int NORMALTYPE
normaler Linientyp.

See Also:
Constant Field Values

SPLITTED

public static final int SPLITTED
gesplittete Linie.

See Also:
Constant Field Values
Constructor Detail

DrawableLine

protected DrawableLine()
Konstruktor.


DrawableLine

public DrawableLine(int px1,
                    int py1,
                    int px2,
                    int py2)
Konstruktor.

Parameters:
px1 - x-Koordinate des Startpunkts
py1 - y-Koordinate des Startpunkts
px2 - x-Koordinate des Endpunkts
py2 - y-Koordinate des Endpunkts

DrawableLine

public DrawableLine(int px1,
                    int py1,
                    int px2,
                    int py2,
                    java.lang.String presName)
Konstruktor.

Parameters:
px1 - x-Koordinate des Startpunkts
py1 - y-Koordinate des Startpunkts
px2 - x-Koordinate des Endpunkts
py2 - y-Koordinate des Endpunkts
presName - Name des Darstellungsobjekts

DrawableLine

public DrawableLine(int px1,
                    int py1,
                    int px2,
                    int py2,
                    java.lang.String presName,
                    int pMinScale,
                    int pMaxScale)
Konstruktor.

Parameters:
px1 - x-Koordinate des Startpunkts
py1 - y-Koordinate des Startpunkts
px2 - x-Koordinate des Endpunkts
py2 - y-Koordinate des Endpunkts
presName - Name des Darstellungsobjekts
pMinScale - Mindest-Maßstab zum Zeichnen
pMaxScale - Maximal-Maßstab zum Zeichnen
Method Detail

changePoint1

public void changePoint1(int x,
                         int y)
Changes the first point of the line.

Parameters:
x - x-coordinate
y - y-coordinate

changePoint2

public void changePoint2(int x,
                         int y)
Changes the second point of the line.

Parameters:
x - x-coordinate
y - y-coordinate

deselect

public void deselect(int direction)
Deselektiert die Linie richtungsbezogen.


drawProtected

protected void drawProtected(java.awt.Graphics g,
                             int scale,
                             int mode,
                             int value)
Zeichnet die Linie im Graphic Context g,

Specified by:
drawProtected in class Drawable
Parameters:
g - aktueller Graphic Context
scale - aktueller Maßstab
mode - aktueller Darstellungsmodus
value - Darstellungswert

drawProtected

public static void drawProtected(java.awt.Graphics g,
                                 DrawablePresentation ap,
                                 java.awt.Color forwardsColor,
                                 java.awt.Color backwardsColor,
                                 int cx1,
                                 int cy1,
                                 int cx2,
                                 int cy2)
Zeichnet die Linie im Graphic Context g,

Parameters:
g - aktueller Graphic Context
ap - aktuelle Darstellungseigenschaften
cx1 - 1. x-Pixel-Koordinate
cy1 - 1. y-Pixel-Koordinate
cx2 - 2. x-Pixel-Koordinate
cy2 - 2. y-Pixel-Koordinate

getX1

public int getX1()
Returns the x-coordinate of the first point.

Returns:
x-coordinate

getX2

public int getX2()
Returns the x-coordinate of the second point.

Returns:
x-coordinate

getY1

public int getY1()
Returns the y-coordinate of the first point.

Returns:
y-coordinate

getY2

public int getY2()
Returns the y-coordinate of the second point.

Returns:
y-coordinate

interacts

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

Overrides:
interacts in class Drawable
Parameters:
x - x-coordinate of the point
y - y-coordinate of the point
scale - actuals scale
Returns:
selected?

interacts

public static boolean interacts(int x,
                                int y,
                                int x1,
                                int y1,
                                int x2,
                                int y2,
                                int mx1,
                                int my1,
                                int mx2,
                                int my2,
                                int scale)

intersects

public java.awt.Point intersects(DrawableLine line)
Tests if the lines intersect. If they intersect, the intersection point is returned, otherwise null.

Parameters:
line - line to be tested
Returns:
intersection point (or null)

isSelected

public boolean isSelected()
Gibt zurück, ob die Linie selektiert ist.

Returns:
Linie selektiert?

isSelected

public boolean isSelected(int direction)
Gibt zurück, ob die Linie richtungsbezogen selektiert ist.

Returns:
Linie selektiert?

read

public EntryReadable read(EntryInput r)
Liest die Linie vom Entry-Input ein. Erster Eintrag "type".
type == 0: x1,y1,x2,y2
type == 1: presName
type == 2: minScale,maxScale

Parameters:
r - this
Returns:
die Linie

select

public void select(int direction)
Selektiert die Linie richtungsbezogen.


setSelection

public void setSelection(boolean on)
(De-)Selektiert die Linie.

Overrides:
setSelection in class Drawable
Parameters:
on - selektieren?

touches

public java.awt.Point touches(int x,
                              int y,
                              int tolerance)
Testet, ob der angegebene Punkt mit einer Toleranz auf der Linie liegt.

Parameters:
x - x-Koordinate
y - y-Koordinate
tolerance - Toleranzwert
Returns:
Berechneter Lagepunkt; null, falls keine Deckung

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 line.

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