/**
   * Gets the vertices.
   *
   * @param resolution the resolution
   * @return the vertices
   */
  protected Vertex[] getVertices(int resolution) {
    Vertex[] verts = new Vertex[resolution + 1];

    float t;
    float inc = degrees / (float) resolution;

    double cosTheta = Math.cos(theta);
    double sinTheta = Math.sin(theta);

    MTColor fillColor = this.getFillColor();

    for (int i = 0; i < resolution; i++) {
      t = 0 + (i * inc);
      //			float x = (float) (centerPoint.x + (radiusX * Math.cos(t) * cosTheta) //TODO remove theta
      // stuff? oder enablen als parameter?
      //						- (radiusY * Math.sin(t) * sinTheta) );
      //			float y = (float) (centerPoint.y + (radiusX * Math.cos(t) * sinTheta)
      //						+ (radiusY * Math.sin(t) * cosTheta) );
      float x =
          (float)
              (centerPoint.x
                  - (radiusX * Math.cos(t) * cosTheta)
                  + (radiusY * Math.sin(t) * sinTheta));
      float y =
          (float)
              (centerPoint.y
                  - (radiusX * Math.cos(t) * sinTheta)
                  - (radiusY * Math.sin(t) * cosTheta));

      verts[i] =
          new Vertex(
              x,
              y,
              centerPoint.z,
              fillColor.getR(),
              fillColor.getG(),
              fillColor.getB(),
              fillColor.getAlpha());
    }
    verts[verts.length - 1] = verts[0];
    //		System.out.println("Points: " + verts.length);

    // Create tex coords
    float width = radiusX * 2;
    float height = radiusY * 2;
    float upperLeftX = centerPoint.x - radiusX;
    float upperLeftY = centerPoint.y - radiusY;
    for (int i = 0; i < verts.length; i++) {
      Vertex vertex = verts[i];
      vertex.setTexCoordU((vertex.x - upperLeftX) / width);
      vertex.setTexCoordV((vertex.y - upperLeftY) / height);
      // System.out.println("TexU:" + vertex.getTexCoordU() + " TexV:" + vertex.getTexCoordV());
    }

    return verts;
  }
 /**
  * Unhighlight button.
  *
  * @param shape the shape
  * @param opacity the opacity
  */
 private void unhighlightButton(AbstractShape shape, float opacity) {
   MTColor c = shape.getFillColor();
   c.setAlpha(opacity);
   shape.setFillColor(c);
 }
Beispiel #3
0
  /**
   * Gets the vertices.
   *
   * @param resolution the resolution
   * @return the vertices
   */
  protected Vertex[] getVertices(int resolution) {
    Vertex[] verts;
    if (degrees < (float) Math.toRadians(360) && arcMode == pie) verts = new Vertex[resolution + 2];
    else verts = new Vertex[resolution + 1];

    float t;
    float inc = degrees / (float) resolution;

    double cosTheta = Math.cos(theta);
    double sinTheta = Math.sin(theta);

    MTColor fillColor = this.getFillColor();

    for (int i = 0; i < resolution; i++) {
      t = 0 + (i * inc);
      //			float x = (float) (centerPoint.x + (radiusX * Math.cos(t) * cosTheta) //TODO remove theta
      // stuff? oder enablen als parameter?
      //						- (radiusY * Math.sin(t) * sinTheta) );
      //			float y = (float) (centerPoint.y + (radiusX * Math.cos(t) * sinTheta)
      //						+ (radiusY * Math.sin(t) * cosTheta) );
      float x =
          (float)
              (centerPoint.x
                  - (radiusX * Math.cos(t) * cosTheta)
                  + (radiusY * Math.sin(t) * sinTheta));
      float y =
          (float)
              (centerPoint.y
                  - (radiusX * Math.cos(t) * sinTheta)
                  - (radiusY * Math.sin(t) * cosTheta));

      verts[i] =
          new Vertex(
              x,
              y,
              centerPoint.z,
              fillColor.getR(),
              fillColor.getG(),
              fillColor.getB(),
              fillColor.getAlpha());
    }
    if (degrees < (float) Math.toRadians(360) && arcMode == pie)
      verts[verts.length - 2] =
          new Vertex(
              centerPoint.x,
              centerPoint.y,
              centerPoint.z,
              fillColor.getR(),
              fillColor.getG(),
              fillColor.getB(),
              fillColor.getAlpha());
    verts[verts.length - 1] =
        (Vertex)
            verts[0]
                .getCopy(); // NEED TO USE COPY BECAUSE TEX COORDS MAY GET SCALED DOUBLE IF SAME
                            // VERTEX OBJECT!
    //		System.out.println("Points: " + verts.length);

    // Create tex coords
    float width = radiusX * 2;
    float height = radiusY * 2;
    float upperLeftX = centerPoint.x - radiusX;
    float upperLeftY = centerPoint.y - radiusY;
    for (int i = 0; i < verts.length; i++) {
      Vertex vertex = verts[i];
      vertex.setTexCoordU((vertex.x - upperLeftX) / width);
      vertex.setTexCoordV((vertex.y - upperLeftY) / height);
      //			System.out.println("TexU:" + vertex.getTexCoordU() + " TexV:" + vertex.getTexCoordV());
    }

    return verts;
  }
 /**
  * Highlight button.
  *
  * @param shape the shape
  */
 private void highlightButton(AbstractShape shape) {
   MTColor c = shape.getFillColor();
   c.setAlpha(255);
   shape.setFillColor(c);
 }