Class GRegion

  • All Implemented Interfaces:
    java.lang.Iterable<sag.elements.GElement>, sag.elements.Drawable

    public class GRegion
    extends sag.elements.GGroup
    A class for displaying regions on a map.

    The class is mainly a container for GPolygons and a GText label but also has methods for scaling it's children to screen space

    Author:
    Juno Veenstra
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean firstPoly
      Whether this polygon is the first.
      static float maxX
      Bounds of the entire map.
      static float maxY
      Bounds of the entire map.
      static float minX
      Bounds of the entire map.
      static float minY
      Bounds of the entire map.
      static float REGION_LINE_SIZE
      Size of the region's outline relative to screen space
      • Fields inherited from class sag.elements.GElement

        handleMouseEvents, mouseListener, mouseListenerSync, positionX, positionY, rawSVGElement, rotation, scaleX, scaleY, skewX, skewY
    • Constructor Summary

      Constructors 
      Constructor Description
      GRegion​(Region region, float screenFontSize)
      Create a Region and it's polygons at several levels of detail.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float getArea()
      Region area getter
      java.lang.String getName()
      Region name getter
      void initLabel​(float x, float y, float width)
      Initialize the label with the region's name as text
      void scaleAllScreen​(float zoom, float defaultScale)
      Scales all polygon outlines and text size to screen space
      void scaleFont​(float zoom)
      Scale font to screenSize, needs to be called when the screen zooms in/out
      • Methods inherited from class sag.elements.GGroup

        addChild, addChild, getChildByRenderingIndex, getNumChildren, getRawSVGGroup, indexOfChild, iterator, processMouseButtonEvent, processMouseMotionEvent, processMouseWheelEvent, removeChild, renderChildAfter, renderChildBefore, renderChildEarlier, renderChildFirst, renderChildLast, renderChildLater, setChildRenderingIndex, setRootSAGPanel, swapChildren
      • Methods inherited from class sag.elements.GElement

        amIPicked, executeUpdate, flipHorizontal, flipVertical, getGElement, getParent, getPositionX, getPositionY, getRGBStringFromColor, getRootSAGPanel, getRotation, getScaleX, getScaleY, getSkewX, getSkewY, move, removeCSSAttribute, removeXMLAttribute, rotate, scale, scale, setAttribute, setCSSAttribute, setCSSAttribute, setDisplay, setFill, setFill, setFillOpacity, setMouseEventListener, setOpacity, setParent, setPosition, setRotation, setScale, setScale, setSkew, setStroke, setStroke, setStroke, setStrokeLinecap, setStrokeLinejoin, setStrokeOpacity, setStrokePattern, setStrokePatternOffset, setStrokeWidth, setXMLAttribute, setXMLAttribute, skew, unsetFill, unsetFillOpacity, unsetOpacity, unsetStroke, unsetStrokeLinecap, unsetStrokeLinejoin, unsetStrokeOpacity, unsetStrokePattern, unsetStrokePatternOffset, unsetStrokeWidth, update, updateTransform
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • REGION_LINE_SIZE

        public static final float REGION_LINE_SIZE
        Size of the region's outline relative to screen space
        See Also:
        Constant Field Values
      • firstPoly

        public static boolean firstPoly
        Whether this polygon is the first. Used for map bound calculation
      • minX

        public static float minX
        Bounds of the entire map. Used to compute the center and the scale of the entire map.
      • maxX

        public static float maxX
        Bounds of the entire map. Used to compute the center and the scale of the entire map.
      • minY

        public static float minY
        Bounds of the entire map. Used to compute the center and the scale of the entire map.
      • maxY

        public static float maxY
        Bounds of the entire map. Used to compute the center and the scale of the entire map.
    • Constructor Detail

      • GRegion

        public GRegion​(Region region,
                       float screenFontSize)
        Create a Region and it's polygons at several levels of detail.
        Parameters:
        region - Region this GRegion represents
        screenFontSize - The font size scaled to screen space (when zooming in/out, the font stays the same perceived size)
    • Method Detail

      • initLabel

        public void initLabel​(float x,
                              float y,
                              float width)
        Initialize the label with the region's name as text
        Parameters:
        x - Label x coordinate
        y - Label y coordinate
        width - Label width
      • scaleFont

        public void scaleFont​(float zoom)
        Scale font to screenSize, needs to be called when the screen zooms in/out
        Parameters:
        zoom - Zoom to be scaled to, should be the multiplicative inverse of the zoom
      • scaleAllScreen

        public void scaleAllScreen​(float zoom,
                                   float defaultScale)
        Scales all polygon outlines and text size to screen space
        Parameters:
        zoom - Zoom to be scaled to, should be the multiplicative inverse of the zoom
        defaultScale - The scale when at 100% zoom. Used to calculate the zoom percentage
      • getName

        public java.lang.String getName()
        Region name getter
        Returns:
        Region name
      • getArea

        public float getArea()
        Region area getter
        Returns:
        Area