Class Shape


  • public class Shape
    extends java.lang.Object
    Data class to store the outline for background imagery coverage. Configuration data for imagery to describe the coverage area (ImageryInfo.ImageryBounds).
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  Shape.CoordinateList
      A list of Coordinates that attempts to be very efficient in terms of CPU time and memory allocations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Polygon coords  
    • Constructor Summary

      Constructors 
      Constructor Description
      Shape()
      Constructs a new empty Shape.
      Shape​(java.lang.String asString, java.lang.String separator)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPoint​(java.lang.String sLat, java.lang.String sLon)  
      boolean contains​(LatLon latlon)
      Check if the coordinates are inside this shape.
      java.lang.String encodeAsString​(java.lang.String separator)
      Encodes this as a string so that it may be parsed using Shape(String, String)
      static java.lang.String encodeAsString​(java.util.List<Shape> shapes)
      Encodes the shapes as a string using , and ; as separators
      boolean equals​(java.lang.Object obj)  
      private static boolean equalsPolygon​(java.awt.Polygon first, java.awt.Polygon second)
      Check that two Polygons are equal
      java.util.List<org.openstreetmap.gui.jmapviewer.Coordinate> getPoints()  
      int hashCode()  
      private static int hashPolygon​(java.awt.Polygon coords)
      Hash a polygon
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • coords

        private final java.awt.Polygon coords
    • Constructor Detail

      • Shape

        public Shape​(java.lang.String asString,
                     java.lang.String separator)
      • Shape

        public Shape()
        Constructs a new empty Shape.
    • Method Detail

      • encodeAsString

        public java.lang.String encodeAsString​(java.lang.String separator)
        Encodes this as a string so that it may be parsed using Shape(String, String)
        Parameters:
        separator - The separator
        Returns:
        The string encoded shape
      • encodeAsString

        public static java.lang.String encodeAsString​(java.util.List<Shape> shapes)
        Encodes the shapes as a string using , and ; as separators
        Parameters:
        shapes - The shapes to encode
        Returns:
        The string encoded shapes
      • getPoints

        public java.util.List<org.openstreetmap.gui.jmapviewer.Coordinate> getPoints()
      • contains

        public boolean contains​(LatLon latlon)
        Check if the coordinates are inside this shape.
        Parameters:
        latlon - The latlon to look for
        Returns:
        true if the LatLon is inside the shape.
        See Also:
        Polygon.contains(int, int)
      • addPoint

        public void addPoint​(java.lang.String sLat,
                             java.lang.String sLon)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashPolygon

        private static int hashPolygon​(java.awt.Polygon coords)
        Hash a polygon
        Parameters:
        coords - The polygon to hash
        Returns:
        The hashcode to use; equivalent to Object.hashCode(), but zero allocations.
      • equalsPolygon

        private static boolean equalsPolygon​(java.awt.Polygon first,
                                             java.awt.Polygon second)
        Check that two Polygons are equal
        Parameters:
        first - The first polygon to check
        second - The second polygon to check
        Returns:
        true if the polygons are equal