Package hec.map

Class MapGlyph

java.lang.Object
hec.map.MapGlyph
All Implemented Interfaces:
Comparable<MapGlyph>
Direct Known Subclasses:
AiDemGlyph, AiShapeGlyph, AnnotationMapGlyph, DemGlyph, DlgGlyph, DxfGlyph, Flo2dGlyph, ImageGlyph, InundationGroupGlyph, LegendGlyph, NetTinGlyph, RasterGlyph, StreamAlignmentGlyph, TinGlyph, TmsMapGlyph, VrtMapGlyph

public abstract class MapGlyph extends Object implements Comparable<MapGlyph>
Abstract base class for specific glyphs that performs drawing and editing functions for Map objects.

  • Field Details

    • _glyphLevel

      protected float _glyphLevel
    • _mapPanel

      protected MapPanel _mapPanel
      the MapPanel that this MapGlyph is drawing in
    • _map

      protected MapObjectInterface _map
      the Data object that this MapGlyph represents
    • _mapIdentifier

      protected MapIdentifier _mapIdentifier
      the _map's MapIdentifier
    • _listenerList

      protected EventListenerList _listenerList
      this MapGlyph's EventListenerList
    • _changeEvent

      protected transient ChangeEvent _changeEvent
      Only one ChangeEvent is needed per glyph instance since the event's only state is the shown property. The source of events generated is always "this".
    • _paintOk

      protected static boolean _paintOk
      true as long as the MapGlyph should keep painting
    • XOR_COLOR

      protected static Color XOR_COLOR
      the XOR color
    • maxPtArraySz

      protected static int maxPtArraySz
      the default size of the xarray and yarray
    • xarray

      protected static int[] xarray
      Use of this array isn't thread-safe and it should go away. a static xarray to use during drawing
    • yarray

      protected static int[] yarray
      Use of this array isn't thread-safe and it should go away. a static yarray to use during drawing
    • _parentGlyph

      protected MapGlyph _parentGlyph
      the parent MapGlph. Can be null
    • needsRepaint

      protected boolean needsRepaint
  • Constructor Details

    • MapGlyph

      public MapGlyph()
      Create a new MapGlyph object
    • MapGlyph

      public MapGlyph(MapPanel panel, MapObjectInterface map)
      Create a new MapGlyph object

      Parameters:
      panel - the MapPanel that this MapGlyph is to draw in
      map - the data that this MapGlyph is representing
  • Method Details

    • setMaximumScale

      public void setMaximumScale(int maxScale)
    • setMinimumScale

      public void setMinimumScale(int minScale)
    • setGlyphLevel

      public void setGlyphLevel(float glyphLevel)
    • getGlyphLevel

      public float getGlyphLevel()
    • setMapPanel

      public void setMapPanel(MapPanel panel)
      Sets the MapPanel of the MapGlyph object

      Parameters:
      panel - The new MapPanel value
    • setMap

      public void setMap(MapObjectInterface map)
      Sets the MapObjectInterface of the MapGlyph object

      Parameters:
      map - The new Map value
    • setDataRecord

      public void setDataRecord(GlyphDataRecord rec)
      Sets the DataRecord of the MapGlyph's MapIdentifier

      Parameters:
      rec - The new DataRecord value
    • setShown

      public void setShown(boolean shown)
      Sets whether this MapGlyph will draw in the MapPanel

      Parameters:
      shown - true if the MapGlyph is to draw
    • getMaximumScale

      public int getMaximumScale()
    • getMinimumScale

      public int getMinimumScale()
    • getDefaultDataRecord

      public GlyphDataRecord getDefaultDataRecord()
      Gets the DefaultDataRecord of the MapGlyph object

      Returns:
      null unless overridden to return something else
    • getMapPanel

      public MapPanel getMapPanel()
      Gets the MapPanel of the MapGlyph object

      Returns:
      The MapPanel value
    • getMap

      public MapObjectInterface getMap()
      Gets the MapObjectInterface that this MapGlyph is drawing

      Returns:
      The Map value
    • getDataRecord

      public GlyphDataRecord getDataRecord()
      Gets the DataRecord of the MapGlyph's MapIdentifier object

      Returns:
      The DataRecord value
    • getName

      public String getName()
      Gets the Name of the MapGlyph object

      Returns:
      The Name value
    • getDescription

      public String getDescription()
      Gets the Description of the MapGlyph object. by default return the maps' name

      Returns:
      The description value
    • isShown

      public boolean isShown()
      Gets whether this MapGlyph is currently drawn in the MapPanel

      Returns:
      true if this MapGlyph is drawing in the MapPanel
    • getBounds

      public WorldRect getBounds()
      Gets the Bounds of the MapGlyph object

      Returns:
      The Bounds value
    • transformRectToLocal

      protected LocalRect transformRectToLocal(WorldRect bounds)
    • transformRect

      protected WorldRect transformRect(WorldRect bounds)
    • transformPointToLocal

      protected LocalPt transformPointToLocal(WorldPt pt) throws CRSException
      Throws:
      CRSException
    • transformPointToWorld

      protected WorldPt transformPointToWorld(LocalPt pt) throws CRSException
      Throws:
      CRSException
    • transformPoint

      protected WorldPt transformPoint(WorldPt pt, CoordinateReferenceSystem fromCrs, CoordinateReferenceSystem toCrs) throws CRSException
      Transforms a world point from one coordinate system to another.

      Parameters:
      pt -

      Returns:

      Throws:
      CRSException
    • transformWorldToLocalArrays

      protected void transformWorldToLocalArrays(double[] xarray, double[] yarray, double[] outxarray, double[] outyarray, int offset, int numPoints) throws CRSException
      Transforms data from a world point in the "map objects" coordinate system, to the map display coordinate system, and then to the local pixel point on the map screen

      Parameters:
      xarray - a list of xdata, the transformed data
      yarray - a list of ydata,
      outxarray - a list of transformed xdata
      outyarray - a list of transformed ydata,
      offset - the offset from the start of the x/y data arrays
      numPoints - the number of points from the offset to compute

      Throws:
      CRSException
    • transformLocalToWorldArrays

      protected void transformLocalToWorldArrays(double[] xarray, double[] yarray, double[] outxarray, double[] outyarray, int offset, int numPoints) throws CRSException
      Transforms data from a world point in the "map objects" coordinate system, to the map display coordinate system, and then to the local pixel point on the map screen

      Parameters:
      xarray - a list of xdata, the transformed data
      yarray - a list of ydata,
      outxarray - a list of transformed xdata
      outyarray - a list of transformed ydata,
      offset - the offset from the start of the x/y data arrays
      numPoints - the number of points from the offset to compute

      Throws:
      CRSException
    • transformArrays

      protected void transformArrays(double[] xarray, double[] yarray, double[] outxarray, double[] outyarray, int offset, int numPoints, CoordinateReferenceSystem fromCrs, CoordinateReferenceSystem toCrs) throws CRSException
      Transforms data from on coordinate system to another.

      Parameters:
      xarray - a list of xdata, the transformed data
      yarray - a list of ydata,
      outxarray - a list of transformed xdata
      outyarray - a list of transformed ydata,
      offset - the offset from the start of the x/y data arrays
      numPoints - the number of points from the offset to compute
      fromCrs - the coordinate system that the input x/y data will be in
      toCrs - the coordinate system of the output x/y data

      Throws:
      CRSException
    • transformRect

      protected WorldRect transformRect(WorldRect bounds, CoordinateReferenceSystem fromCrs, CoordinateReferenceSystem toCrs)
    • transformLookup

      protected Transform transformLookup(CoordinateReferenceSystem srcCrs, CoordinateReferenceSystem targetCrs)
    • getToolTipText

      public String getToolTipText(WorldPt wpt, MouseEvent e)
      Gets the ToolTipText of the MapGlyph object

      Parameters:
      wpt - the WorldPt location of the mouse cursor
      e - the MouseEvent

      Returns:
      The ToolTipText at wpt
    • isAttributeAvailable

      public boolean isAttributeAvailable(String s)
      Gets the AttributeAvailable attribute of the MapGlyph object

      Parameters:
      s - Description

      Returns:
      The AttributeAvailable value
    • isWriteLocked

      public boolean isWriteLocked()
      does the Application hold the write lock for this glyph data

      Returns:
      true if the Application holds the write lock for this glyph's data
    • getAttributeSet

      public ModelDrawingAttributeSet getAttributeSet()
      Gets the AttributeSet of the MapGlyph object

      Returns:
      The AttributeSet value
    • getSelectedObject

      public NamedType getSelectedObject()
      override to return the selected glyph object

      Returns:
      The Selected Object
    • getSelections

      public NamedType[] getSelections()
      override to return more than a wrapper around getSelectedObject()

      Returns:
      the first selected object.
    • toString

      public String toString()
      return's the string representation of this MapGlyph. By Default it's the name of the _map's MapIdentifier

      Overrides:
      toString in class Object
      Returns:
      the name of this MapGlyph
    • findObject

      public NamedType findObject(LocalPt pt)
      find the NamedType object held by this MapGlyph that resides as LocalPt pt.

      Parameters:
      pt - the LocalPt to find an Object at

      Returns:
      the NamedType Object at pt.
    • hasMap

      public boolean hasMap()
      return whether the MapGlyph has a MapObjectInterface

      Returns:
      true if _map != null
    • showMapElement

      public void showMapElement(String glyphName, String glyphElement, boolean show)
      show or hide the Map Element glyphElement. This base class handled the hec.map.ModelDrawingAttributeSet.SHOWN flag

      Parameters:
      glyphName - the name of the MapGlyph or child MapGlyphs
      glyphElement - the Map Element to
      show - true to show glyphElement
    • fillMap

      public void fillMap(boolean load)
      have the _map load or unload its data.

      Parameters:
      load - true if _map is load it's data
    • objectPopupMenu

      public boolean objectPopupMenu(LocalPt pt, int modifiers)
      called when the user right clicks on the map panel. If the MapGlyph can process the event successfully then it should return true. Otherwise the MapPanel will pass the event to the next MapGlyph.

      Parameters:
      pt - the location that the right click took place
      modifiers - the MouseEvent Modifiers. Useful to see if the Shift/Control/Alt keys were pressed

      Returns:
      true if the MapGlyph has handled this event. this class always returns false
    • objectSelect

      public NamedType objectSelect(LocalPt pt, int modifiers)
      called when the user single clicks on the MapPanel. If the MapGlyph can process the event successfully then it should return true. Otherwise the MapPanel will pass the event to the next MapGlyph.

      Parameters:
      pt - the location that the single click took place
      modifiers - the MouseEvent Modifiers. Useful to see if the Shift/Control/Alt keys were pressed

      Returns:
      The object at pt. this class always returns false
    • objectDoubleClick

      public boolean objectDoubleClick(LocalPt pt, int modifiers)
      called when the user double clicks on the MapPanel. If the MapGlyph can process the event successfully then it should return true. Otherwise the MapPanel will pass the event to the next MapGlyph.

      Parameters:
      pt - the location that the right click took place
      modifiers - the MouseEvent Modifiers. Useful to see if the Shift/Control/Alt keys were pressed

      Returns:
      true if the MapGlyph has handled this event. this class always returns false
    • draw

      public abstract void draw(Graphics graphics, MapScale scl)
      draw this MapGlyph to graphics using the MapScale scl

      Parameters:
      graphics - the Graphics to draw to
      scl - The current MapScale
    • drawConformingString

      public void drawConformingString(Graphics g, MapScale scl, WorldLine line, String str, double coord, int baseoffset, Font font, Color color, int bank, float priority)
      Draw string rotated to best fit location on a line

      Parameters:
      g - the Graphics to draw to
      scl - the Current MapScale
      line - the line to fit the string to
      str - the string to draw
      coord - the location relative to the line to draw.
      baseoffset - the offset from line to draw str
      font - the Font to render str with
      color - the foreground color to render str with
      bank - the side of line to draw the string on
      priority - the Priority to give to this string. -1 means to always draw.

      See Also:
    • drawConformingString2

      public void drawConformingString2(Graphics g, MapScale scl, WorldLine line, String str, double coord, Font font, Color color, int bank)
      Draw string that follows the line

      Parameters:
      g - the Graphics to draw to
      scl - the Current MapScale
      line - the line to fit the string to
      str - the string to draw
      coord - the location relative to the line to draw.
      font - the Font to render str with
      color - the foreground color to render str with
      bank - the side of line to draw the string on

      See Also:
    • clearSelection

      public void clearSelection()
      clear the selection of the MapGlyph
    • clearSelection

      public void clearSelection(String name)
      remove the Selection with the name name from the selection list

      Parameters:
      name - the name of the object to remove
    • addGlyphSelectionListener

      public void addGlyphSelectionListener(GlyphSelectionListener msl)
      Adds a feature to the GlyphSelectionListener attribute of the MapGlyph object

      Parameters:
      msl - The feature to be added to the GlyphSelectionListener attribute
    • removeGlyphSelectionListener

      public void removeGlyphSelectionListener(GlyphSelectionListener msl)
      remove the GlyphSelectionListener msl from the _listenerList

      Parameters:
      msl - the GlyphSelectionListener to remove
    • addChangeListener

      public void addChangeListener(ChangeListener cl)
      Adds a feature to the ChangeListener attribute of the MapGlyph object

      Parameters:
      cl - The feature to be added to the ChangeListener attribute
    • removeChangeListener

      public void removeChangeListener(ChangeListener cl)
      retmove the ChangeListener cl from the _listenerList

      Parameters:
      cl - Description
    • close

      public void close()
      called when the Glyph is no longer held by the MapPanel
    • hasChildGlyphs

      public boolean hasChildGlyphs()
      get whether this glyph contains child glyphs

      Returns:
      true if the MapGlyph holds child MapGlyphs
    • glyphVector

      public Vector<MapGlyph> glyphVector()
      get the MapGlyph's list of child MapGlyphs

      Returns:
      the Vector of child MapGlyphs
    • findGlyphOfClass

      public MapGlyph findGlyphOfClass(String classname)
      finds the MapGlyph of type classname in the list of child MapGlyphs

      Parameters:
      classname - the classname of the child MapGlyphs

      Returns:
      the child MapGlyph with the class of classname
    • init

      protected void init()
      called when the MapGlyph is made active. Any initialization should be performed here.
    • reInit

      public void reInit()
    • intersects

      public boolean intersects(Graphics2D graphics, MapScale scl, int[] xarray, int[] yarray, int numpts)
      return whether the line intersects with the scale

      Parameters:
      scl - the MapScale

      Returns:
      true if any of the point in the line intersect with the current scale
    • fireStateChanged

      protected void fireStateChanged()
      Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
    • fireGlyphSelectionChanged

      protected void fireGlyphSelectionChanged(NamedType selectedObj)
      Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

      Parameters:
      selectedObj - the object that was selected
    • drawLine

      public void drawLine(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor)
    • drawLine

      public void drawLine(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor, boolean drawPoints, Color pointColor, int halfPointSize)
      draw the line on the map. This will draw the line in chunks if the line is too large.  If the outline color is specified, and the line gets drawn in segments where the segments meet there will be a line between them.

      Parameters:
      g - The Graphics context to draw on
      line - The WorldLine to draw
      scl - The MapScale
      halfwidth - the width of the line
      fillColor - the Fill Color. NULL to not fill the line
      outlineColor - The outlineColor. NULL for no outline
      drawPoints -
      pointColor -
      halfPointSize -
    • drawLine

      public void drawLine(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor, boolean drawPoints, Color pointColor, int halfPointSize, boolean isXOR)
    • drawLine

      public void drawLine(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor, boolean drawPoints, Color pointColor, int halfPointSize, boolean isXOR, float alpha)
    • drawLine2D

      public void drawLine2D(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor, boolean drawPoints, Color pointColor, int halfPointSize, boolean isXOR)
      draw the line using graphics 2d

      Parameters:
      g -
      line -
      scl -
      halfwidth -
      fillColor -
      outlineColor -
      drawPoints -
      pointColor -
      halfPointSize -
      isXOR -
    • drawRegion

      public void drawRegion(Graphics g, MapScale scl, WorldRegion region, boolean drawPts, Color outline, Color fill)
    • drawRegion

      public void drawRegion(Graphics g, MapScale scl, WorldRegion region, boolean drawPts, Color outline, Color fill, float alpha)
    • setPaintOk

      public static void setPaintOk(boolean b)
      Sets whether MapGlyphs should continue painting.

      Parameters:
      b - The new PaintOk value
    • isPaintOk

      public static boolean isPaintOk()
      Gets whether MapGlyph's should continue painting.

      Returns:
      The PaintOk value
    • isShiftDown

      public static boolean isShiftDown(int modifiers)
      Returns whether or not the Shift modifier is down in modifiers.

      Parameters:
      modifiers - the modifiers from the MouseEvent

      Returns:
      true if modifiers has the shift key down
    • isControlDown

      public static boolean isControlDown(int modifiers)
      Returns whether or not the Control modifier is down in modifiers

      Parameters:
      modifiers - the modifiers from the MouseEvent

      Returns:
      true if modifiers has the control key down
    • isMetaDown

      public static boolean isMetaDown(int modifiers)
      Returns whether or not the Meta modifier is down in modifiers

      Parameters:
      modifiers - the modifiers from the MouseEvent

      Returns:
      true if modifiers has the meta key down
    • isAltDown

      public static boolean isAltDown(int modifiers)
      Returns whether or not the Alt modifier is down in modifiers

      Parameters:
      modifiers - the modifiers from the MouseEvent

      Returns:
      true if modifiers has the alt key down
    • checkXYArraySize

      public static void checkXYArraySize(int size)
      checks the xarray and yarray size to make sure that they are at least size in length. if maxPtArraySz is less than size then the xarray and yarray are reallocated to be size in length. No array copying is performed.

      Parameters:
      size - the minimum length for xarray and yarray.
    • containsSelection

      public boolean containsSelection(Object object)
      Parameters:
      object -
    • setParentGlyph

      public void setParentGlyph(MapGlyph glyph)
    • getParentGlyph

      public MapGlyph getParentGlyph()
    • compareTo

      public int compareTo(MapGlyph o)
      Specified by:
      compareTo in interface Comparable<MapGlyph>
    • isRepaintNeeded

      public boolean isRepaintNeeded()
    • setRepaintNeeded

      public void setRepaintNeeded(boolean isDirty)
    • shouldReturn

      public static boolean shouldReturn(long[] nextCheck)