Back to index

moin  1.9.0~rc2
Public Member Functions | Protected Attributes | Static Package Attributes
CH.ifa.draw.contrib.TriangleFigure Class Reference

A triangle with same dimensions as its enclosing rectangle, and apex at any of 8 places. More...

List of all members.

Public Member Functions

 TriangleFigure ()
 TriangleFigure (Point origin, Point corner)
Vector handles ()
void rotate (double angle)
Polygon polygon ()
 Return the polygon describing the triangle.
void draw (Graphics g)
Insets connectionInsets ()
boolean containsPoint (int x, int y)
Point center ()
Point chop (Point p)
Object clone ()
void write (StorableOutput dw)
void read (StorableInput dr) throws IOException

Protected Attributes

int fRotation = 0

Static Package Attributes

static double[] rotations

Detailed Description

A triangle with same dimensions as its enclosing rectangle, and apex at any of 8 places.

Definition at line 21 of file TriangleFigure.java.


Constructor & Destructor Documentation

Definition at line 32 of file TriangleFigure.java.

                          {
    super(new Point(0,0), new Point(0,0));
  }

Here is the caller graph for this function:

CH.ifa.draw.contrib.TriangleFigure.TriangleFigure ( Point  origin,
Point  corner 
) [inline]

Definition at line 36 of file TriangleFigure.java.

                                                    {
    super(origin, corner);
  }

Member Function Documentation

Definition at line 149 of file TriangleFigure.java.

                        {
    return PolygonFigure.center(polygon());
  }

Here is the call graph for this function:

Point CH.ifa.draw.contrib.TriangleFigure.chop ( Point  p) [inline]

Definition at line 153 of file TriangleFigure.java.

                             {
    return PolygonFigure.chop(polygon(), p);
  }

Here is the call graph for this function:

Definition at line 157 of file TriangleFigure.java.

                        {
    TriangleFigure figure = (TriangleFigure) super.clone();
    figure.fRotation = fRotation;
    return figure;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 121 of file TriangleFigure.java.

                                   {
    Rectangle r = displayBox();
    switch(fRotation) {
    case 0:
      return new Insets(r.height, r.width/2, 0, r.width/2);
    case 1:
      return new Insets(0, r.width, r.height, 0);
    case 2:
      return new Insets(r.height/2, 0, r.height/2, r.width);
    case 3:
      return new Insets(r.height, r.width, 0, 0);
    case 4:
      return new Insets(0, r.width/2, r.height, r.width/2);
    case 5:
      return new Insets(r.height, 0, 0, r.width);
    case 6:
      return new Insets(r.height/2, r.width, r.height/2, 0);
    case 7:
      return new Insets(0, 0, r.height, r.width);
    default:
      return null;
    }
  }
boolean CH.ifa.draw.contrib.TriangleFigure.containsPoint ( int  x,
int  y 
) [inline]

Definition at line 145 of file TriangleFigure.java.

                                             {
    return polygon().contains(x, y);
  }

Here is the call graph for this function:

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

Definition at line 112 of file TriangleFigure.java.

                               {
    Polygon p = polygon();
    g.setColor(getFillColor());
    g.fillPolygon(p);
    g.setColor(getFrameColor());
    g.drawPolygon(p);
  }

Here is the call graph for this function:

Definition at line 40 of file TriangleFigure.java.

                          {
    Vector h = super.handles();
    h.addElement(new TriangleRotationHandle(this));
    return h;
  }

Return the polygon describing the triangle.

Definition at line 63 of file TriangleFigure.java.

                           {
    Rectangle r = displayBox();
    Polygon p = new Polygon();
    switch (fRotation) {
    case 0:
      p.addPoint(r.x+r.width/2, r.y);
      p.addPoint(r.x+r.width, r.y+r.height);
      p.addPoint(r.x, r.y+r.height);
      break;
    case 1:
      p.addPoint(r.x + r.width, r.y);
      p.addPoint(r.x+r.width, r.y+r.height);
      p.addPoint(r.x, r.y);
      break;
    case 2:
      p.addPoint(r.x + r.width, r.y+r.height/2);
      p.addPoint(r.x, r.y+r.height);
      p.addPoint(r.x, r.y);
      break;
    case 3:
      p.addPoint(r.x+r.width, r.y+r.height);
      p.addPoint(r.x, r.y+r.height);
      p.addPoint(r.x + r.width, r.y);
      break;
    case 4:
      p.addPoint(r.x+r.width/2, r.y+r.height);
      p.addPoint(r.x, r.y);
      p.addPoint(r.x + r.width, r.y);
      break;
    case 5:
      p.addPoint(r.x, r.y+r.height);
      p.addPoint(r.x, r.y);
      p.addPoint(r.x+r.width, r.y+r.height);
      break;
    case 6:
      p.addPoint(r.x, r.y+r.height/2);
      p.addPoint(r.x + r.width, r.y);
      p.addPoint(r.x+r.width, r.y+r.height);
      break;
    case 7:
      p.addPoint(r.x, r.y);
      p.addPoint(r.x + r.width, r.y);
      p.addPoint(r.x, r.y+r.height);
      break;
    }
    return p;
  }

Here is the caller graph for this function:

void CH.ifa.draw.contrib.TriangleFigure.read ( StorableInput  dr) throws IOException [inline]

Definition at line 170 of file TriangleFigure.java.

                                                          {
      super.read(dr);
      fRotation = dr.readInt();
    }

Here is the caller graph for this function:

void CH.ifa.draw.contrib.TriangleFigure.rotate ( double  angle) [inline]

Definition at line 46 of file TriangleFigure.java.

                                   {
    willChange();
    //System.out.println("a:"+angle);
    double dist = Double.MAX_VALUE;
    int best = 0;
    for (int i = 0; i < rotations.length; ++i) {
      double d = Math.abs(angle - rotations[i]);
      if (d < dist) {
        dist = d;
        best = i;
      }
    }
    fRotation = best;
    changed();
  }
void CH.ifa.draw.contrib.TriangleFigure.write ( StorableOutput  dw) [inline]

Definition at line 165 of file TriangleFigure.java.

                                         {
      super.write(dw);
      dw.writeInt(fRotation);
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 30 of file TriangleFigure.java.

double [] CH.ifa.draw.contrib.TriangleFigure.rotations [static, package]
Initial value:
 {
    -Math.PI/2, -Math.PI/4,
    0.0, Math.PI/4,
    Math.PI/2, Math.PI * 3/4,
    Math.PI,  -Math.PI * 3/4
  }

Definition at line 23 of file TriangleFigure.java.


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