Back to index

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

A Handle to scale and rotate a PolygonFigure. More...

Collaboration diagram for CH.ifa.draw.contrib.PolygonScaleHandle:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PolygonScaleHandle (PolygonFigure owner)
void invokeStart (int x, int y, Drawing drawing)
void invokeStep (int dx, int dy, Drawing drawing)
void invokeEnd (int dx, int dy, Drawing drawing)
Point locate ()
void draw (Graphics g)

Package Functions

Point getOrigin ()

Private Attributes

Point fOrigin = null
Point fCurrent = null
Polygon fOrigPoly = null

Detailed Description

A Handle to scale and rotate a PolygonFigure.

Definition at line 19 of file PolygonScaleHandle.java.


Constructor & Destructor Documentation

Definition at line 25 of file PolygonScaleHandle.java.

                                                 {
    super(owner);
 }

Member Function Documentation

void CH.ifa.draw.contrib.PolygonScaleHandle.draw ( Graphics  g) [inline]

Definition at line 73 of file PolygonScaleHandle.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);

    /*
     * for debugging ...
    Point ctr = ((PolygonFigure)(owner())).center();
    g.setColor(Color.blue);
    g.fillOval(ctr.x, ctr.y, r.width, r.height);

    g.setColor(Color.black);
    g.drawOval(ctr.x, ctr.y, r.width, r.height);

    */
  }

Definition at line 53 of file PolygonScaleHandle.java.

                    { // find a nice place to put handle
    // Need to pick a place that will not overlap with point handle
    // and is internal to polygon

    // Try for one HANDLESIZE step away from outermost toward center

    Point outer = ((PolygonFigure)(owner())).outermostPoint();
    Point ctr = ((PolygonFigure)(owner())).center();
    double len = Geom.length(outer.x, outer.y, ctr.x, ctr.y);
    if (len == 0) // best we can do?
      return new Point(outer.x - HANDLESIZE/2, outer.y + HANDLESIZE/2);

    double u = HANDLESIZE / len;
    if (u > 1.0) // best we can do?
      return new Point((outer.x * 3 + ctr.x)/4, (outer.y * 3 + ctr.y)/4);
    else
      return new Point((int)(outer.x * (1.0 - u) + ctr.x * u),
                       (int)(outer.y * (1.0 - u) + ctr.y * u));
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.contrib.PolygonScaleHandle.invokeEnd ( int  dx,
int  dy,
Drawing  drawing 
) [inline]

Definition at line 40 of file PolygonScaleHandle.java.

                                                           {
    fOrigPoly = null;
    fOrigin = null;
    fCurrent = null;
  }
void CH.ifa.draw.contrib.PolygonScaleHandle.invokeStart ( int  x,
int  y,
Drawing  drawing 
) [inline]

Definition at line 29 of file PolygonScaleHandle.java.

                                                           {
    fOrigPoly = ((PolygonFigure)(owner())).getPolygon();
    fOrigin = getOrigin();
    fCurrent = new Point(fOrigin.x, fOrigin.y);
  }

Here is the call graph for this function:

void CH.ifa.draw.contrib.PolygonScaleHandle.invokeStep ( int  dx,
int  dy,
Drawing  drawing 
) [inline]

Definition at line 35 of file PolygonScaleHandle.java.

                                                           {
    fCurrent = new Point(fOrigin.x + dx, fOrigin.y + dy);
    ((PolygonFigure)(owner())).scaleRotate(fOrigin, fOrigPoly, fCurrent);
  }

Definition at line 46 of file PolygonScaleHandle.java.

                        {
    if (fCurrent != null)
      return fCurrent;
    else
      return getOrigin();
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 22 of file PolygonScaleHandle.java.

Definition at line 21 of file PolygonScaleHandle.java.

Definition at line 23 of file PolygonScaleHandle.java.


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