Class CohenSutherlandClipping

java.lang.Object
technology.tabula.CohenSutherlandClipping

public final class CohenSutherlandClipping extends Object
Implements the well known Cohen Sutherland line clipping algorithm (line against clip rectangle).
  • Constructor Details

    • CohenSutherlandClipping

      public CohenSutherlandClipping()
      Creates a Cohen Sutherland clipper with clip window (0, 0, 0, 0).
    • CohenSutherlandClipping

      public CohenSutherlandClipping(Rectangle2D clipWindow)
      Creates a Cohen Sutherland clipper with the given clip window.
      Parameters:
      clipWindow - the clip window to use.
  • Method Details

    • setClip

      public void setClip(Rectangle2D clipWindow)
      Sets the clip rectangle.
      Parameters:
      clipWindow - the clip window.
    • clip

      public boolean clip(Line2D.Float line)
      Clips a given line against the clip window. The modification (if needed) is done in place.
      Parameters:
      line - the line to clip.
      Returns:
      true if line is clipped, false if line is totally outside the clip window.