Class BitmapShape

  • All Implemented Interfaces:
    Shape

    public class BitmapShape
    extends java.lang.Object
    implements Shape
    Represents a bitmap copy of the shape. This may be useful for displaying the shape or for defining shapes as a bitmap is easier to understand than vectors.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BitmapShape.EuclidianDistanceVectorization
      Encode a bitmap shape by using the Euclidean distance between plotted points to determine which vectors take precedence.
      static class  BitmapShape.SweepVectorization
      Encode a bitmap shape by going to a corner and sweeping back-and-forth across the image.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.util.List<java.util.List<java.lang.Boolean>> grid  
      java.lang.String label  
      java.awt.Point origin  
    • Constructor Summary

      Constructors 
      Constructor Description
      BitmapShape()  
      BitmapShape​(int height, int width)  
      BitmapShape​(int height, int width, java.lang.String label)  
      BitmapShape​(java.lang.String label)  
    • Field Detail

      • label

        public final java.lang.String label
      • grid

        public final java.util.List<java.util.List<java.lang.Boolean>> grid
      • origin

        public final java.awt.Point origin
    • Constructor Detail

      • BitmapShape

        public BitmapShape()
      • BitmapShape

        public BitmapShape​(java.lang.String label)
      • BitmapShape

        public BitmapShape​(int height,
                           int width)
      • BitmapShape

        public BitmapShape​(int height,
                           int width,
                           java.lang.String label)
    • Method Detail

      • insertColumn

        public void insertColumn()
      • addColumn

        public void addColumn()
      • insertRow

        public void insertRow()
      • addRow

        public void addRow()
      • appendBitmapRow

        public void appendBitmapRow​(java.lang.String line)
      • getHeight

        public int getHeight()
      • getWidth

        public int getWidth()
      • plot

        public void plot​(int x,
                         int y)
      • plot

        public void plot​(int x,
                         int y,
                         java.lang.Boolean pixel)
      • get

        public java.lang.Boolean get​(int x,
                                     int y)
      • get

        public java.lang.Boolean get​(java.awt.Point point)
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Shape
        Indicates if this shape is empty.
        Specified by:
        isEmpty in interface Shape
      • getLabel

        public java.lang.String getLabel()
        Description copied from interface: Shape
        Get the label of this shape.
        Specified by:
        getLabel in interface Shape
      • toBitmap

        public BitmapShape toBitmap()
        Description copied from interface: Shape
        Transform to a BitmapShape.
        Specified by:
        toBitmap in interface Shape
      • toVector

        public VectorShape toVector()
        Convert this bitmap shape to a vector shape. The shape chosen encodes to the least number of bytes in the resulting file.
        Specified by:
        toVector in interface Shape