java.lang.Object
com.github.basking2.sdsai.marchinesquares.Side
Direct Known Subclasses:
Side.ArtificialSide

public class Side extends Object
A side is one cell value and optionally one or two points on the edge of a Tile. Points are assigned as either a begin or end point. That is, what role does that point play in the contour of the cell of the tile the side is describing.
  • Field Details

    • cell

      public byte cell
      The value in the data grid. This is -1, 0, or 1. This is used to construct contours with neighboring tiles.
    • beginPoint

      public LinkedList.Node<Point> beginPoint
      A point that begins a contour in a particular cell. Its next field should be defined. The endPoint of one side should be linked to the beginPoint of another side in the same cell.
    • endPoint

      public LinkedList.Node<Point> endPoint
      A point that ends a contour. Its next field will be empty if only a single cell is contoured. The endPoint of one side should be linked to the beginPoint of another side.
    • BOGUS_VALUE

      public static byte BOGUS_VALUE
      This is used to construct artificial sides as place holders.
  • Constructor Details

    • Side

      public Side(byte cell, LinkedList.Node<Point> beginPoint, LinkedList.Node<Point> endPoint)
      Constructor.
      Parameters:
      cell - A cell value.
      beginPoint - A point of a line.
      endPoint - A point of a line.
    • Side

      public Side(byte cell)
      Constructor.
      Parameters:
      cell - A cell value.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setPoints

      public void setPoints(double x, double y, byte side, byte color, byte left, byte right)
    • buildArtificialSide

      public static Side buildArtificialSide(double x, double y, byte side, byte color, byte left, byte right)
      Build an artificial side with the correct number of points.
      Parameters:
      x - The x value to create points at.
      y - The y value to create points at.
      side - The side of a cell that this lies on. The values are 0 is the top, 1 is the right, 2 is the bottom, and 3 is the left.
      color - The color to set the linked list nodes to.
      left - The value of the point that is on the left of the side, the side being viewed from the center of the cell. The counter-clockwise most point.
      right - The value of the point that is on the right of the side, the side being viewed from the center of the cell. The clockwise most point.
      Returns:
      A built artificial side.
    • swapPoints

      public void swapPoints()
    • prettyPrint

      public String prettyPrint()