Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes
CH.ifa.draw.figures.LineFigure Class Reference

A line figure. More...

Inheritance diagram for CH.ifa.draw.figures.LineFigure:
Inheritance graph
[legend]
Collaboration diagram for CH.ifa.draw.figures.LineFigure:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LineFigure ()
 Constructs a LineFigure with both start and end set to Point(0,0).
Point startPoint ()
 Gets a copy of the start point.
Point endPoint ()
 Gets a copy of the end point.
void startPoint (int x, int y)
 Sets the start point.
void endPoint (int x, int y)
 Sets the end point.
void setPoints (Point start, Point end)
 Sets the start and end point.
void basicDisplayBox (Point origin, Point corner)
Rectangle displayBox ()
boolean isEmpty ()
Vector handles ()
void addPoint (int x, int y)
 Adds a node to the list of points.
Enumeration points ()
int pointCount ()
void setPointAt (Point p, int i)
 Changes the position of a node.
void insertPointAt (Point p, int i)
 Insert a node at the given point.
void removePointAt (int i)
int splitSegment (int x, int y)
 Splits the segment at the given point if a segment was hit.
Point pointAt (int i)
boolean joinSegments (int x, int y)
 Joins to segments into one if the given point hits a node of the polyline.
Connector connectorAt (int x, int y)
void setStartDecoration (LineDecoration l)
 Sets the start decoration.
void setEndDecoration (LineDecoration l)
 Sets the end decoration.
void draw (Graphics g, boolean showGuides)
boolean containsPoint (int x, int y)
int findSegment (int x, int y)
 Gets the segment of the polyline that is hit by the given point.
Object getAttribute (String name)
 Gets the attribute with the given name.
void setAttribute (String name, Object value)
 Sets the attribute with the given name.
void write (StorableOutput dw)
String getMap ()
void read (StorableInput dr) throws IOException

Static Public Member Functions

static Locator locator (int pointIndex)
 Creates a locator for the point with the given index.

Static Public Attributes

static final int ARROW_TIP_NONE = 0
static final int ARROW_TIP_START = 1
static final int ARROW_TIP_END = 2
static final int ARROW_TIP_BOTH = 3

Protected Member Functions

void basicMoveBy (int dx, int dy)
Color getFrameColor ()
void setFrameColor (Color c)

Protected Attributes

Vector fPoints
LineDecoration fStartDecoration = null
LineDecoration fEndDecoration = null
Color fFrameColor = Color.black

Private Attributes

int lineFigureSerializedDataVersion = 1

Static Private Attributes

static final long serialVersionUID = 511503575249212371L

Detailed Description

A line figure.

Definition at line 17 of file LineFigure.java.


Constructor & Destructor Documentation

Constructs a LineFigure with both start and end set to Point(0,0).

Definition at line 28 of file LineFigure.java.

                        {
        addPoint(0, 0);
        addPoint(0, 0);
    }

Here is the call graph for this function:


Member Function Documentation

void CH.ifa.draw.figures.PolyLineFigure.addPoint ( int  x,
int  y 
) [inline, inherited]

Adds a node to the list of points.

Definition at line 80 of file PolyLineFigure.java.

                                       {
        fPoints.addElement(new Point(x, y));
        changed();
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.LineFigure.basicDisplayBox ( Point  origin,
Point  corner 
) [inline]

Reimplemented from CH.ifa.draw.figures.PolyLineFigure.

Definition at line 69 of file LineFigure.java.

                                                            {
        setPoints(origin, corner);
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.basicMoveBy ( int  dx,
int  dy 
) [inline, protected, inherited]

Reimplemented in CH.ifa.draw.figures.LineConnection.

Definition at line 93 of file PolyLineFigure.java.

                                               {
        Enumeration k = fPoints.elements();
        while (k.hasMoreElements())
            ((Point) k.nextElement()).translate(dx, dy);
    }
Connector CH.ifa.draw.figures.PolyLineFigure.connectorAt ( int  x,
int  y 
) [inline, inherited]

Definition at line 153 of file PolyLineFigure.java.

                                               {
        return new PolyLineConnector(this);
    }
boolean CH.ifa.draw.figures.PolyLineFigure.containsPoint ( int  x,
int  y 
) [inline, inherited]

Definition at line 208 of file PolyLineFigure.java.

                                               {
        Rectangle bounds = displayBox();
        bounds.grow(4,4);
        if (!bounds.contains(x, y))
            return false;

        Point p1, p2;
        for (int i = 0; i < fPoints.size()-1; i++) {
            p1 = (Point) fPoints.elementAt(i);
            p2 = (Point) fPoints.elementAt(i+1);
            if (Geom.lineContainsPoint(p1.x, p1.y, p2.x, p2.y, x, y))
                return true;
        }
        return false;
    }

Here is the call graph for this function:

Rectangle CH.ifa.draw.figures.PolyLineFigure.displayBox ( ) [inline, inherited]

Definition at line 53 of file PolyLineFigure.java.

                                  {
        Enumeration k = points();
        Rectangle r = new Rectangle((Point) k.nextElement());
       
        while (k.hasMoreElements())
            r.add((Point) k.nextElement());
       
        return r;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.draw ( Graphics  g,
boolean  showGuides 
) [inline, inherited]

Definition at line 171 of file PolyLineFigure.java.

                                                     {
        g.setColor(getFrameColor());
        Point p1, p2;
        for (int i = 0; i < fPoints.size()-1; i++) {
            p1 = (Point) fPoints.elementAt(i);
            p2 = (Point) fPoints.elementAt(i+1);
            g.drawLine(p1.x, p1.y, p2.x, p2.y);
        }
        decorate(g);
       if (showGuides) {
           drawURL(g);
       }
    }

Here is the call graph for this function:

Gets a copy of the end point.

Definition at line 43 of file LineFigure.java.

                            {
        return pointAt(1);
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.LineFigure.endPoint ( int  x,
int  y 
) [inline]

Sets the end point.

Definition at line 57 of file LineFigure.java.

                                        {
        setPointAt(new Point(x,y), 1);
    }

Here is the call graph for this function:

int CH.ifa.draw.figures.PolyLineFigure.findSegment ( int  x,
int  y 
) [inline, inherited]

Gets the segment of the polyline that is hit by the given point.

Returns:
the index of the segment or -1 if no segment was hit.

Definition at line 229 of file PolyLineFigure.java.

                                         {
        Point p1, p2;
        for (int i = 0; i < fPoints.size()-1; i++) {
            p1 = (Point) fPoints.elementAt(i);
            p2 = (Point) fPoints.elementAt(i+1);
            if (Geom.lineContainsPoint(p1.x, p1.y, p2.x, p2.y, x, y))
                return i;
        }
        return -1;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Object CH.ifa.draw.figures.PolyLineFigure.getAttribute ( String  name) [inline, inherited]

Gets the attribute with the given name.

PolyLineFigure maps "ArrowMode"to a line decoration.

Definition at line 258 of file PolyLineFigure.java.

                                            {
        if (name.equals("FrameColor")) {
            return getFrameColor();
        } else if (name.equals("ArrowMode")) {
            int value = 0;
            if (fStartDecoration != null)
                value |= ARROW_TIP_START;
            if (fEndDecoration != null)
                value |= ARROW_TIP_END;
            return new Integer(value);
       }
        return super.getAttribute(name);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Color CH.ifa.draw.figures.PolyLineFigure.getFrameColor ( ) [inline, protected, inherited]

Definition at line 378 of file PolyLineFigure.java.

                                    {
        return fFrameColor;
    }

Here is the caller graph for this function:

String CH.ifa.draw.figures.PolyLineFigure.getMap ( ) [inline, inherited]

Definition at line 315 of file PolyLineFigure.java.

                           {
       String sensitive = (String)getAttribute("Sensitive");
       if (sensitive == null || sensitive.length() == 0)
           return "";
       try {
              sensitive = URLDecoder.decode(sensitive);
       } catch (Exception e) {}
       Enumeration k = fPoints.elements();
       boolean first  = true;
       String forwards = "", backwards = "";
        for (int i = 1; i < fPoints.size(); i++) {
            Point p1 = (Point)fPoints.elementAt(i-1);
            Point p2 = (Point)fPoints.elementAt(i);
           double l = Math.sqrt((p2.x-p1.x) * (p2.x-p1.x) +
                             (p2.y-p1.y) * (p2.y-p1.y));
           int x = (int)(4 * (p2.y-p1.y) / l);
           int y = (int)(4 * (p2.x-p1.x) / l);
           if (!first) {
              forwards += ",";
              backwards = "," + backwards;
           }
           first = false;
           forwards += (p1.x + x) + "," + (p1.y + y) + "," +
              (p2.x + x) + "," + (p2.y + y);
           backwards = (p2.x - x) + "," + (p2.y - y) + "," +
              (p1.x - x) + "," + (p1.y - y) + backwards;
        }
       return "<area shape=\"poly\" coords=\"" +
           forwards + "," + backwards + "\" href=\"" +
           sensitive + "\" />\n";
    }

Here is the call graph for this function:

Vector CH.ifa.draw.figures.PolyLineFigure.handles ( ) [inline, inherited]

Reimplemented in CH.ifa.draw.figures.LineConnection, and CH.ifa.draw.figures.ElbowConnection.

Definition at line 67 of file PolyLineFigure.java.

                            {
        Vector handles = new Vector(fPoints.size());
        for (int i = 0; i < fPoints.size(); i++)
            handles.addElement(new PolyLineHandle(this, locator(i), i));
        return handles;
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.insertPointAt ( Point  p,
int  i 
) [inline, inherited]

Insert a node at the given point.

Reimplemented in CH.ifa.draw.figures.LineConnection.

Definition at line 111 of file PolyLineFigure.java.

                                              {
        fPoints.insertElementAt(p, i);
        changed();
    }

Here is the caller graph for this function:

boolean CH.ifa.draw.figures.PolyLineFigure.isEmpty ( ) [inline, inherited]

Definition at line 63 of file PolyLineFigure.java.

                             {
        return (size().width < 3) && (size().height < 3);
    }

Here is the call graph for this function:

boolean CH.ifa.draw.figures.PolyLineFigure.joinSegments ( int  x,
int  y 
) [inline, inherited]

Joins to segments into one if the given point hits a node of the polyline.

Returns:
true if the two segments were joined.

Definition at line 142 of file PolyLineFigure.java.

                                              {
        for (int i= 1; i < fPoints.size()-1; i++) {
            Point p = pointAt(i);
            if (Geom.length(x, y, p.x, p.y) < 3) {
                removePointAt(i);
                return true;
            }
        }
        return false;
    }

Here is the call graph for this function:

static Locator CH.ifa.draw.figures.PolyLineFigure.locator ( int  pointIndex) [inline, static, inherited]

Creates a locator for the point with the given index.

Definition at line 374 of file PolyLineFigure.java.

                                                  {
        return new PolyLineLocator(pointIndex);
    }

Here is the caller graph for this function:

Point CH.ifa.draw.figures.PolyLineFigure.pointAt ( int  i) [inline, inherited]

Definition at line 133 of file PolyLineFigure.java.

                                {
        return (Point)fPoints.elementAt(i);
    }

Here is the caller graph for this function:

int CH.ifa.draw.figures.PolyLineFigure.pointCount ( ) [inline, inherited]

Definition at line 89 of file PolyLineFigure.java.

                            {
        return fPoints.size();
    }

Here is the caller graph for this function:

Enumeration CH.ifa.draw.figures.PolyLineFigure.points ( ) [inline, inherited]

Definition at line 85 of file PolyLineFigure.java.

                                {
        return fPoints.elements();
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.read ( StorableInput  dr) throws IOException [inline, inherited]

Reimplemented in CH.ifa.draw.figures.LineConnection.

Definition at line 347 of file PolyLineFigure.java.

                                                          {
       // test for the next token being a number to allow us to
       // skip attribute reading which. Old-format files don't
       // have attributes on connections.
       super.read(dr);
        int size = dr.readInt();
       if (size == -1) {
           // Temp for files created during devt. Remove when we're sure
           // they are all gone
           String s = dr.readString();
           setAttribute("Sensitive", s);
           size = dr.readInt();
       }
        fPoints = new Vector(size);
        for (int i=0; i<size; i++) {
            int x = dr.readInt();
            int y = dr.readInt();
            fPoints.addElement(new Point(x,y));
        }
        fStartDecoration = (LineDecoration)dr.readStorable();
        fEndDecoration = (LineDecoration)dr.readStorable();
        fFrameColor = dr.readColor();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.removePointAt ( int  i) [inline, inherited]

Reimplemented in CH.ifa.draw.figures.LineConnection.

Definition at line 116 of file PolyLineFigure.java.

                                     {
        willChange();
        fPoints.removeElementAt(i);
        changed();
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.setAttribute ( String  name,
Object  value 
) [inline, inherited]

Sets the attribute with the given name.

PolyLineFigure interprets "ArrowMode"to set the line decoration.

Definition at line 277 of file PolyLineFigure.java.

                                                        {
        if (name.equals("FrameColor")) {
            setFrameColor((Color)value);
            changed();
        } else if (name.equals("ArrowMode")) {
            Integer intObj = (Integer) value;
            if (intObj != null) {
                int decoration = intObj.intValue();
                if ((decoration & ARROW_TIP_START) != 0)
                    fStartDecoration = new ArrowTip();
                else
                    fStartDecoration = null;
                if ((decoration & ARROW_TIP_END) != 0)
                    fEndDecoration = new ArrowTip();
                else
                    fEndDecoration = null;
            }
            changed();
       } else {
            super.setAttribute(name, value);
           changed();
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Sets the end decoration.

Definition at line 167 of file PolyLineFigure.java.

                                                   {
        fEndDecoration = l;
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.setFrameColor ( Color  c) [inline, protected, inherited]

Definition at line 382 of file PolyLineFigure.java.

                                          {
        fFrameColor = c;
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.setPointAt ( Point  p,
int  i 
) [inline, inherited]

Changes the position of a node.

Reimplemented in CH.ifa.draw.figures.LineConnection.

Definition at line 102 of file PolyLineFigure.java.

                                           {
        willChange();
        fPoints.setElementAt(p, i);
        changed();
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.LineFigure.setPoints ( Point  start,
Point  end 
) [inline]

Sets the start and end point.

Definition at line 64 of file LineFigure.java.

                                                  {
        setPointAt(start, 0);
        setPointAt(end, 1);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Sets the start decoration.

Definition at line 160 of file PolyLineFigure.java.

                                                     {
        fStartDecoration = l;
    }

Here is the caller graph for this function:

int CH.ifa.draw.figures.PolyLineFigure.splitSegment ( int  x,
int  y 
) [inline, inherited]

Splits the segment at the given point if a segment was hit.

Returns:
the index of the segment or -1 if no segment was hit.

Definition at line 126 of file PolyLineFigure.java.

                                          {
        int i = findSegment(x, y);
        if (i != -1)
            insertPointAt(new Point(x, y), i+1);
        return i+1;
    }

Here is the call graph for this function:

Gets a copy of the start point.

Definition at line 36 of file LineFigure.java.

                              {
        return pointAt(0);
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.LineFigure.startPoint ( int  x,
int  y 
) [inline]

Sets the start point.

Definition at line 50 of file LineFigure.java.

                                          {
        setPointAt(new Point(x,y), 0);
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.PolyLineFigure.write ( StorableOutput  dw) [inline, inherited]

Reimplemented in CH.ifa.draw.figures.LineConnection.

Definition at line 301 of file PolyLineFigure.java.

                                         {
        super.write(dw);
        dw.writeInt(fPoints.size());
        Enumeration k = fPoints.elements();
        while (k.hasMoreElements()) {
            Point p = (Point) k.nextElement();
            dw.writeInt(p.x);
            dw.writeInt(p.y);
        }
        dw.writeStorable(fStartDecoration);
        dw.writeStorable(fEndDecoration);
        dw.writeColor(fFrameColor);
    }

Here is the caller graph for this function:


Member Data Documentation

final int CH.ifa.draw.figures.PolyLineFigure.ARROW_TIP_BOTH = 3 [static, inherited]

Definition at line 27 of file PolyLineFigure.java.

final int CH.ifa.draw.figures.PolyLineFigure.ARROW_TIP_END = 2 [static, inherited]

Definition at line 26 of file PolyLineFigure.java.

final int CH.ifa.draw.figures.PolyLineFigure.ARROW_TIP_NONE = 0 [static, inherited]

Definition at line 24 of file PolyLineFigure.java.

final int CH.ifa.draw.figures.PolyLineFigure.ARROW_TIP_START = 1 [static, inherited]

Definition at line 25 of file PolyLineFigure.java.

Definition at line 31 of file PolyLineFigure.java.

Color CH.ifa.draw.figures.PolyLineFigure.fFrameColor = Color.black [protected, inherited]

Definition at line 32 of file PolyLineFigure.java.

Vector CH.ifa.draw.figures.PolyLineFigure.fPoints [protected, inherited]

Definition at line 29 of file PolyLineFigure.java.

Definition at line 30 of file PolyLineFigure.java.

Definition at line 23 of file LineFigure.java.

final long CH.ifa.draw.figures.LineFigure.serialVersionUID = 511503575249212371L [static, private]

Reimplemented from CH.ifa.draw.figures.PolyLineFigure.

Definition at line 22 of file LineFigure.java.


The documentation for this class was generated from the following file: