Back to index

moin  1.9.0~rc2
Public Member Functions | Package Attributes | Private Member Functions | Private Attributes
CH.ifa.draw.figures.ElbowHandle Class Reference

A Handle to move an ElbowConnection left/right or up/down. More...

List of all members.

Public Member Functions

 ElbowHandle (LineConnection owner, int segment)
void invokeStart (int x, int y, DrawingView view)
void invokeStep (int x, int y, int anchorX, int anchorY, DrawingView view)
Point locate ()
void draw (Graphics g)

Package Attributes

int fLastY

Private Member Functions

boolean isVertical (Point p1, Point p2)
int constrainX (int x)
int constrainY (int y)
LineConnection ownerConnection ()

Private Attributes

int fSegment
int fLastX

Detailed Description

A Handle to move an ElbowConnection left/right or up/down.

Definition at line 16 of file ElbowHandle.java.


Constructor & Destructor Documentation

CH.ifa.draw.figures.ElbowHandle.ElbowHandle ( LineConnection  owner,
int  segment 
) [inline]

Definition at line 21 of file ElbowHandle.java.

                                                          {
        super(owner);
        fSegment = segment;
    }

Member Function Documentation

int CH.ifa.draw.figures.ElbowHandle.constrainX ( int  x) [inline, private]

Definition at line 77 of file ElbowHandle.java.

                                  {
        LineConnection line = ownerConnection();
        Figure startFigure = line.start().owner();
        Figure endFigure = line.end().owner();
        Rectangle start = startFigure.displayBox();
        Rectangle end = endFigure.displayBox();
        Insets i1 = startFigure.connectionInsets();
        Insets i2 = endFigure.connectionInsets();

        int r1x, r1width, r2x, r2width;
        r1x = start.x + i1.left;
        r1width = start.width - i1.left - i1.right-1;

        r2x = end.x + i2.left;
        r2width = end.width - i2.left - i2.right-1;

        if (fSegment == 0)
            x = Geom.range(r1x, r1x + r1width, x);
        if (fSegment == line.pointCount()-2)
            x = Geom.range(r2x, r2x + r2width, x);
        return x;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

int CH.ifa.draw.figures.ElbowHandle.constrainY ( int  y) [inline, private]

Definition at line 100 of file ElbowHandle.java.

                                  {
        LineConnection line = ownerConnection();
        Figure startFigure = line.start().owner();
        Figure endFigure = line.end().owner();
        Rectangle start = startFigure.displayBox();
        Rectangle end = endFigure.displayBox();
        Insets i1 = startFigure.connectionInsets();
        Insets i2 = endFigure.connectionInsets();

        int r1y, r1height, r2y, r2height;
        r1y = start.y + i1.top;
        r1height = start.height - i1.top - i1.bottom-1;
        r2y = end.y + i2.top;
        r2height = end.height - i2.top - i2.bottom-1;

        if (fSegment == 0)
            y = Geom.range(r1y, r1y + r1height, y);
        if (fSegment == line.pointCount()-2)
            y = Geom.range(r2y, r2y + r2height, y);
        return y;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.ElbowHandle.draw ( Graphics  g) [inline]

Definition at line 67 of file ElbowHandle.java.

                                 {
        Rectangle r = displayBox();

        g.setColor(Color.yellow);
        g.fillOval(r.x, r.y, r.width, r.height);

        g.setColor(Color.black);
        g.drawOval(r.x, r.y, r.width, r.height);
    }
void CH.ifa.draw.figures.ElbowHandle.invokeStart ( int  x,
int  y,
DrawingView  view 
) [inline]

Definition at line 26 of file ElbowHandle.java.

                                                              {
        fLastX = x;
        fLastY = y;
    }
void CH.ifa.draw.figures.ElbowHandle.invokeStep ( int  x,
int  y,
int  anchorX,
int  anchorY,
DrawingView  view 
) [inline]

Definition at line 31 of file ElbowHandle.java.

                                                                                      {
        LineConnection line = ownerConnection();
        Point p1 = line.pointAt(fSegment);
        Point p2 = line.pointAt(fSegment+1);
        int ddx = x - fLastX;
        int ddy = y - fLastY;

        Point np1;
        Point np2;
        if (isVertical(p1, p2)) {
            int cx = constrainX(p1.x + ddx);
            np1 = new Point(cx, p1.y);
            np2 = new Point(cx, p2.y);
        } else {
            int cy = constrainY(p1.y + ddy);
            np1 = new Point(p1.x, cy);
            np2 = new Point(p2.x, cy);
        }
        line.setPointAt(np1, fSegment);
        line.setPointAt(np2, fSegment+1);
        fLastX = x;
        fLastY = y;
    }

Here is the call graph for this function:

boolean CH.ifa.draw.figures.ElbowHandle.isVertical ( Point  p1,
Point  p2 
) [inline, private]

Definition at line 55 of file ElbowHandle.java.

                                                   {
        return p1.x == p2.x;
    }

Here is the caller graph for this function:

Definition at line 59 of file ElbowHandle.java.

                          {
        LineConnection line = ownerConnection();
        int segment = Math.min(fSegment, line.pointCount()-2);
        Point p1 = line.pointAt(segment);
        Point p2 = line.pointAt(segment+1);
        return new Point((p1.x + p2.x)/2, (p1.y + p2.y)/2);
    }

Here is the call graph for this function:

Definition at line 122 of file ElbowHandle.java.

                                             {
        return (LineConnection)owner();
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 19 of file ElbowHandle.java.

Definition at line 19 of file ElbowHandle.java.

Definition at line 18 of file ElbowHandle.java.


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