Class GCity

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

    public class GCity
    extends sag.elements.GGroup
    Class for rendering cities on the map
    Author:
    Juno Veenstra
    • Field Summary

      • Fields inherited from class sag.elements.GElement

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

      Constructors 
      Constructor Description
      GCity​(City city)
      Construct a new GCity object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      City getCity()
      City object getter
      java.lang.String getName()
      City name getter
      GCity onEnter​(java.util.function.Consumer<GCity> action)
      Method for defining enterAction in lambdas
      GCity onSelect​(java.util.function.Consumer<GCity> selectAction)
      Method for defining selectAction in lambdas
      void scaleToScreen​(float scale, float defaultScale)
      Scale the city icon and labels to be screen space.
      void setHighlighted​(boolean highlighted)  
      void setHighlightedWeak​(boolean highlighted)  
      void showName​(boolean visible)
      Show the city's name This method does nothing if the screen is zoomed in to the point where the name is always visible
      • 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
    • Constructor Detail

      • GCity

        public GCity​(City city)
        Construct a new GCity object
        Parameters:
        city - City object carrying information about the city
    • Method Detail

      • onSelect

        public GCity onSelect​(java.util.function.Consumer<GCity> selectAction)
        Method for defining selectAction in lambdas
        Parameters:
        selectAction - Consumer to be set
        Returns:
        this
      • onEnter

        public GCity onEnter​(java.util.function.Consumer<GCity> action)
        Method for defining enterAction in lambdas
        Parameters:
        action - Consumer to be set
        Returns:
        this
      • setHighlighted

        public void setHighlighted​(boolean highlighted)
      • setHighlightedWeak

        public void setHighlightedWeak​(boolean highlighted)
      • getName

        public java.lang.String getName()
        City name getter
        Returns:
        City's name
      • getCity

        public City getCity()
        City object getter
        Returns:
        This city as a City object
      • scaleToScreen

        public void scaleToScreen​(float scale,
                                  float defaultScale)
        Scale the city icon and labels to be screen space.

        Also shows/hides the name depending on how zoomed in the screen is

        Parameters:
        scale - Scale to which gets scaled, should be the multiplicative inverse of the zoom
        defaultScale - The worlds default scale ('correctScale'). Used to calculate the zoom percentage
      • showName

        public void showName​(boolean visible)
        Show the city's name This method does nothing if the screen is zoomed in to the point where the name is always visible
        Parameters:
        visible - Whether visible or hidden