Package draw

Class Block3D

java.lang.Object
draw.Block3D
All Implemented Interfaces:
Serializable, Comparable<Block3D>

public class Block3D extends Object implements Comparable<Block3D>, Serializable
Internal class for a 3D block.
Since:
2004.06.05
See Also:
  • Constructor Details

    • Block3D

      public Block3D(double x, double y, double z, double w, double d, double h)
      Create a 3D block.
      Parameters:
      x - the x-coordinate of the lower left corner
      y - the y-coordinate of the lower left corner
      z - the z-coordinate of the lower left corner
      w - the width of the block
      d - the depth of the block
      h - the height of the block
      Since:
      2004.06.05 (Christian Borgelt)
  • Method Details

    • project

      public void project(Proj3D proj)
      Project the block to 2D.

      The projection is stored internally and is used when the block is to be drawn.

      Parameters:
      proj - the 3D to 2D projection to use
      Since:
      2004.06.05 (Christian Borgelt)
    • isLeftVisible

      public boolean isLeftVisible()
      Check whether the left side of the block is visible.
      Returns:
      whether the left side of the block is visible
      Since:
      2004.06.05 (Christian Borgelt)
    • isFrontVisible

      public boolean isFrontVisible()
      Check whether the front side of the block is visible.
      Returns:
      whether the front side of the block is visible
      Since:
      2004.06.05 (Christian Borgelt)
    • isBottomVisible

      public boolean isBottomVisible()
      Check whether the bottom side of the block is visible.
      Returns:
      whether the bottom side of the block is visible
      Since:
      2004.06.05 (Christian Borgelt)
    • isRightVisible

      public boolean isRightVisible()
      Check whether the right side of the block is visible.
      Returns:
      whether the right side of the block is visible
      Since:
      2004.06.05 (Christian Borgelt)
    • isBackVisible

      public boolean isBackVisible()
      Check whether the back side of the block is visible.
      Returns:
      whether the back side of the block is visible
      Since:
      2004.06.05 (Christian Borgelt)
    • isTopVisible

      public boolean isTopVisible()
      Check whether the top side of the block is visible.
      Returns:
      whether the top side of the block is visible
      Since:
      2004.06.05 (Christian Borgelt)
    • getHeight

      public double getHeight()
      Get the height of the block.
      Returns:
      the height of the block
      Since:
      2013.11.26 (Christian Borgelt)
    • compareTo

      public int compareTo(Block3D obj)
      Compare the depth of the projections of two blocks.
      Specified by:
      compareTo in interface Comparable<Block3D>
      Parameters:
      obj - the block to compare to
      Returns:
      -1, if this block is nearer to the eye,
      +1, if this block is farther from the eye,
      0, if both blocks have the same (minimum) distance
      Since:
      2004.06.05 (Christian Borgelt)
    • paint

      public void paint(Graphics g, Color[] colors)
      Paint a block.
      Parameters:
      g - the graphics to use for the drawing
      colors - the colors to use for the different sides
      Since:
      2004.06.05 (Christian Borgelt)
    • label

      public void label(Graphics g, Font3D font, String s)
      Draw a label on a block.
      Parameters:
      g - the graphics to use for the drawing
      font - the font to use for the text
      s - the string to label the block with
      Since:
      2004.06.05 (Christian Borgelt)