Class Face

java.lang.Object
org.jfree.chart3d.graphics3d.Face
Direct Known Subclasses:
DoubleSidedFace, LabelFace

public class Face extends Object
Represents a face in one Object3D, defined in terms of vertex indices. It is expected (but not enforced) that all the vertices for the face lie within a single plane. The face will be visible from the "front" side only, which is a function of the order in which the vertices are specified. A special subclass, DoubleSidedFace, is visible from both front and back.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Face(Object3D owner, int[] vertices)
    Creates a new face with the specified vertices that is part of the 3D owner object.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns the average z-value.
    double[]
    Calculates the normal vector for this face.
    Creates and returns a path for the outline of this face.
    A convenience method that looks up and returns the color for this face (obtained by querying the object that owns the face).
    int
    Returns the offset to add to the vertex indices.
    boolean
    Returns true if an outline should be drawn for this face, and false otherwise.
    Returns the object that this face belongs too (as passed to the constructor).
    Returns the tag for this face (always null for this class, subclasses may override).
    int
    Returns the number of vertices in this face.
    int
    Returns the index for the specified vertex.
    boolean
    Returns true if this face is front facing, and false otherwise.
    void
    setOffset(int offset)
    Sets the offset to add to the vertex indices.
    Returns a string representation of this instance, primarily for debugging purposes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Face

      public Face(Object3D owner, int[] vertices)
      Creates a new face with the specified vertices that is part of the 3D owner object. Most faces will have at least three vertices, but a special case with just two vertices (representing a line) is permitted.
      Parameters:
      owner - the object that owns the face (null not permitted).
      vertices - the indices of the vertices (array length >= 2).
      Since:
      1.3
  • Method Details

    • getOwner

      public Object3D getOwner()
      Returns the object that this face belongs too (as passed to the constructor).
      Returns:
      The owner (never null).
      Since:
      1.3
    • getOffset

      public int getOffset()
      Returns the offset to add to the vertex indices.
      Returns:
      The offset.
    • setOffset

      public void setOffset(int offset)
      Sets the offset to add to the vertex indices.
      Parameters:
      offset - the offset.
    • getVertexCount

      public int getVertexCount()
      Returns the number of vertices in this face.
      Returns:
      The number of vertices in this face.
    • getVertexIndex

      public int getVertexIndex(int i)
      Returns the index for the specified vertex.
      Parameters:
      i - the vertex index.
      Returns:
      The index.
    • getColor

      public Color getColor()
      A convenience method that looks up and returns the color for this face (obtained by querying the object that owns the face). The color is not stored as an attribute of the face, because typically an object has many faces that are all the same color.
      Returns:
      The color (never null).
    • getOutline

      public boolean getOutline()
      Returns true if an outline should be drawn for this face, and false otherwise. The value is obtained by querying the object that owns the face.
      Returns:
      A boolean.
    • getTag

      public String getTag()
      Returns the tag for this face (always null for this class, subclasses may override). The TaggedFace class overrides this method.
      Returns:
      null.
      Since:
      1.3
    • calculateNormal

      public double[] calculateNormal(Point3D[] points)
      Calculates the normal vector for this face.
      Parameters:
      points - the vertices of the object that this face belongs to (these can be in world or eye coordinates).
      Returns:
      The normal vector.
    • calculateAverageZValue

      public float calculateAverageZValue(Point3D[] points)
      Returns the average z-value.
      Parameters:
      points - the points.
      Returns:
      The average z-value.
    • isFrontFacing

      public boolean isFrontFacing(Point2D[] projPts)
      Returns true if this face is front facing, and false otherwise.
      Parameters:
      projPts - the projection points.
      Returns:
      A boolean.
    • createPath

      public Path2D createPath(Point2D[] pts)
      Creates and returns a path for the outline of this face.
      Parameters:
      pts - the projected points for the world (null not permitted).
      Returns:
      A path.
      Since:
      1.3
    • toString

      public String toString()
      Returns a string representation of this instance, primarily for debugging purposes.
      Overrides:
      toString in class Object
      Returns:
      A string.