Back to index

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

A Handle to rotate a TriangleFigure. More...

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

List of all members.

Public Member Functions

 TriangleRotationHandle (TriangleFigure 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 fCenter = null

Detailed Description

A Handle to rotate a TriangleFigure.

Definition at line 19 of file TriangleRotationHandle.java.


Constructor & Destructor Documentation

Definition at line 24 of file TriangleRotationHandle.java.

                                                      {
    super(owner);
 }

Member Function Documentation

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

Definition at line 65 of file TriangleRotationHandle.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);
  }

Definition at line 48 of file TriangleRotationHandle.java.

                    { // find a nice place to put handle
    // almost same code as PolygonScaleHandle
    Polygon p = ((TriangleFigure)(owner())).polygon();
    Point first = new Point(p.xpoints[0], p.ypoints[0]);
    Point ctr = owner().center();
    double len = Geom.length(first.x, first.y, ctr.x, ctr.y);
    if (len == 0) // best we can do?
      return new Point(first.x - HANDLESIZE/2, first.y + HANDLESIZE/2);

    double u = HANDLESIZE / len;
    if (u > 1.0) // best we can do?
      return new Point((first.x * 3 + ctr.x)/4, (first.y * 3 + ctr.y)/4);
    else
      return new Point((int)(first.x * (1.0 - u) + ctr.x * u),
                       (int)(first.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.TriangleRotationHandle.invokeEnd ( int  dx,
int  dy,
Drawing  drawing 
) [inline]

Definition at line 39 of file TriangleRotationHandle.java.

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

Definition at line 28 of file TriangleRotationHandle.java.

                                                           {
    fCenter = owner().center();
    fOrigin = getOrigin();
  }

Here is the call graph for this function:

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

Definition at line 33 of file TriangleRotationHandle.java.

                                                           {
    double angle = Math.atan2(fOrigin.y + dy - fCenter.y,
                              fOrigin.x + dx - fCenter.x);
    ((TriangleFigure)(owner())).rotate(angle);
  }

Definition at line 44 of file TriangleRotationHandle.java.

                        {
    return getOrigin();
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 22 of file TriangleRotationHandle.java.

Definition at line 21 of file TriangleRotationHandle.java.


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