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
Abstract base class for specific glyphs that performs drawing and editing
functions for Map objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Inner class to hold Selections in the MapPanel -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeEvent
Only one ChangeEvent is needed per glyph instance since the event's only state is the shown property.protected float
protected EventListenerList
this MapGlyph's EventListenerListprotected MapObjectInterface
the Data object that this MapGlyph representsprotected MapIdentifier
the _map's MapIdentifierprotected MapPanel
the MapPanel that this MapGlyph is drawing inprotected static boolean
true as long as the MapGlyph should keep paintingprotected MapGlyph
the parent MapGlph.protected static int
the default size of the xarray and yarrayprotected boolean
protected static int[]
Use of this array isn't thread-safe and it should go away.protected static Color
the XOR colorprotected static int[]
Use of this array isn't thread-safe and it should go away. -
Constructor Summary
ConstructorsConstructorDescriptionMapGlyph()
Create a new MapGlyph objectMapGlyph
(MapPanel panel, MapObjectInterface map) Create a new MapGlyph object -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a feature to the ChangeListener attribute of the MapGlyph objectvoid
Adds a feature to the GlyphSelectionListener attribute of the MapGlyph objectstatic void
checkXYArraySize
(int size) checks the xarray and yarray size to make sure that they are at least size in length.void
clear the selection of the MapGlyphvoid
clearSelection
(String name) remove the Selection with the name name from the selection listvoid
close()
called when the Glyph is no longer held by the MapPanelint
boolean
containsSelection
(Object object) abstract void
draw this MapGlyph to graphics using the MapScale sclvoid
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 linevoid
drawConformingString2
(Graphics g, MapScale scl, WorldLine line, String str, double coord, Font font, Color color, int bank) Draw string that follows the linevoid
drawLine
(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor) 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.void
drawLine
(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor, boolean drawPoints, Color pointColor, int halfPointSize, boolean isXOR) void
drawLine
(Graphics g, WorldLine line, MapScale scl, double halfwidth, Color fillColor, Color outlineColor, boolean drawPoints, Color pointColor, int halfPointSize, boolean isXOR, float alpha) 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 2dvoid
drawRegion
(Graphics g, MapScale scl, WorldRegion region, boolean drawPts, Color outline, Color fill) void
drawRegion
(Graphics g, MapScale scl, WorldRegion region, boolean drawPts, Color outline, Color fill, float alpha) void
fillMap
(boolean load) have the _map load or unload its data.findGlyphOfClass
(String classname) finds the MapGlyph of type classname in the list of child MapGlyphsfindObject
(LocalPt pt) find the NamedType object held by this MapGlyph that resides as LocalPt pt.protected void
fireGlyphSelectionChanged
(NamedType selectedObj) Notify all listeners that have registered interest for notification on this event type.protected void
Notify all listeners that have registered interest for notification on this event type.Gets the AttributeSet of the MapGlyph objectGets the Bounds of the MapGlyph objectGets the DataRecord of the MapGlyph's MapIdentifier objectGets the DefaultDataRecord of the MapGlyph objectGets the Description of the MapGlyph object.float
getMap()
Gets the MapObjectInterface that this MapGlyph is drawingGets the MapPanel of the MapGlyph objectint
int
getName()
Gets the Name of the MapGlyph objectoverride to return the selected glyph objectoverride to return more than a wrapper around getSelectedObject()getToolTipText
(WorldPt wpt, MouseEvent e) Gets the ToolTipText of the MapGlyph objectget the MapGlyph's list of child MapGlyphsboolean
get whether this glyph contains child glyphsboolean
hasMap()
return whether the MapGlyph has a MapObjectInterfaceprotected void
init()
called when the MapGlyph is made active.boolean
intersects
(Graphics2D graphics, MapScale scl, int[] xarray, int[] yarray, int numpts) return whether the line intersects with the scalestatic boolean
isAltDown
(int modifiers) Returns whether or not the Alt modifier is down in modifiersboolean
Gets the AttributeAvailable attribute of the MapGlyph objectstatic boolean
isControlDown
(int modifiers) Returns whether or not the Control modifier is down in modifiersstatic boolean
isMetaDown
(int modifiers) Returns whether or not the Meta modifier is down in modifiersstatic boolean
Gets whether MapGlyph's should continue painting.boolean
static boolean
isShiftDown
(int modifiers) Returns whether or not the Shift modifier is down in modifiers.boolean
isShown()
Gets whether this MapGlyph is currently drawn in the MapPanelboolean
does the Application hold the write lock for this glyph databoolean
objectDoubleClick
(LocalPt pt, int modifiers) called when the user double clicks on the MapPanel.boolean
objectPopupMenu
(LocalPt pt, int modifiers) called when the user right clicks on the map panel.objectSelect
(LocalPt pt, int modifiers) called when the user single clicks on the MapPanel.void
reInit()
void
retmove the ChangeListener cl from the _listenerListvoid
remove the GlyphSelectionListener msl from the _listenerListvoid
Sets the DataRecord of the MapGlyph's MapIdentifiervoid
setGlyphLevel
(float glyphLevel) void
setMap
(MapObjectInterface map) Sets the MapObjectInterface of the MapGlyph objectvoid
setMapPanel
(MapPanel panel) Sets the MapPanel of the MapGlyph objectvoid
setMaximumScale
(int maxScale) void
setMinimumScale
(int minScale) static void
setPaintOk
(boolean b) Sets whether MapGlyphs should continue painting.void
setParentGlyph
(MapGlyph glyph) void
setRepaintNeeded
(boolean isDirty) void
setShown
(boolean shown) Sets whether this MapGlyph will draw in the MapPanelstatic boolean
shouldReturn
(long[] nextCheck) void
showMapElement
(String glyphName, String glyphElement, boolean show) show or hide the Map Element glyphElement.toString()
return's the string representation of this MapGlyph.protected void
transformArrays
(double[] xarray, double[] yarray, double[] outxarray, double[] outyarray, int offset, int numPoints, CoordinateReferenceSystem fromCrs, CoordinateReferenceSystem toCrs) Transforms data from on coordinate system to another.protected void
transformLocalToWorldArrays
(double[] xarray, double[] yarray, double[] outxarray, double[] outyarray, int offset, int numPoints) 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 screenprotected Transform
transformLookup
(CoordinateReferenceSystem srcCrs, CoordinateReferenceSystem targetCrs) protected WorldPt
transformPoint
(WorldPt pt, CoordinateReferenceSystem fromCrs, CoordinateReferenceSystem toCrs) Transforms a world point from one coordinate system to another.protected LocalPt
protected WorldPt
protected WorldRect
transformRect
(WorldRect bounds) protected WorldRect
transformRect
(WorldRect bounds, CoordinateReferenceSystem fromCrs, CoordinateReferenceSystem toCrs) protected LocalRect
transformRectToLocal
(WorldRect bounds) protected void
transformWorldToLocalArrays
(double[] xarray, double[] yarray, double[] outxarray, double[] outyarray, int offset, int numPoints) 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
-
Field Details
-
_glyphLevel
protected float _glyphLevel -
_mapPanel
the MapPanel that this MapGlyph is drawing in -
_map
the Data object that this MapGlyph represents -
_mapIdentifier
the _map's MapIdentifier -
_listenerList
this MapGlyph's EventListenerList -
_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 _paintOktrue as long as the MapGlyph should keep painting -
XOR_COLOR
the XOR color -
maxPtArraySz
protected static int maxPtArraySzthe default size of the xarray and yarray -
xarray
protected static int[] xarrayUse of this array isn't thread-safe and it should go away. a static xarray to use during drawing -
yarray
protected static int[] yarrayUse of this array isn't thread-safe and it should go away. a static yarray to use during drawing -
_parentGlyph
the parent MapGlph. Can be null -
needsRepaint
protected boolean needsRepaint
-
-
Constructor Details
-
MapGlyph
public MapGlyph()Create a new MapGlyph object -
MapGlyph
Create a new MapGlyph object- Parameters:
panel
- the MapPanel that this MapGlyph is to draw inmap
- 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
Sets the MapPanel of the MapGlyph object- Parameters:
panel
- The new MapPanel value
-
setMap
Sets the MapObjectInterface of the MapGlyph object- Parameters:
map
- The new Map value
-
setDataRecord
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
Gets the DefaultDataRecord of the MapGlyph object- Returns:
- null unless overridden to return something else
-
getMapPanel
Gets the MapPanel of the MapGlyph object- Returns:
- The MapPanel value
-
getMap
Gets the MapObjectInterface that this MapGlyph is drawing- Returns:
- The Map value
-
getDataRecord
Gets the DataRecord of the MapGlyph's MapIdentifier object- Returns:
- The DataRecord value
-
getName
Gets the Name of the MapGlyph object- Returns:
- The Name value
-
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
Gets the Bounds of the MapGlyph object- Returns:
- The Bounds value
-
transformRectToLocal
-
transformRect
-
transformPointToLocal
- Throws:
CRSException
-
transformPointToWorld
- 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 datayarray
- a list of ydata,outxarray
- a list of transformed xdataoutyarray
- a list of transformed ydata,offset
- the offset from the start of the x/y data arraysnumPoints
- 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 datayarray
- a list of ydata,outxarray
- a list of transformed xdataoutyarray
- a list of transformed ydata,offset
- the offset from the start of the x/y data arraysnumPoints
- 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 datayarray
- a list of ydata,outxarray
- a list of transformed xdataoutyarray
- a list of transformed ydata,offset
- the offset from the start of the x/y data arraysnumPoints
- the number of points from the offset to computefromCrs
- the coordinate system that the input x/y data will be intoCrs
- 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
Gets the ToolTipText of the MapGlyph object- Parameters:
wpt
- the WorldPt location of the mouse cursore
- the MouseEvent- Returns:
- The ToolTipText at wpt
-
isAttributeAvailable
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
Gets the AttributeSet of the MapGlyph object- Returns:
- The AttributeSet value
-
getSelectedObject
override to return the selected glyph object- Returns:
- The Selected Object
-
getSelections
override to return more than a wrapper around getSelectedObject()- Returns:
- the first selected object.
-
toString
return's the string representation of this MapGlyph. By Default it's the name of the _map's MapIdentifier -
findObject
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
show or hide the Map Element glyphElement. This base class handled thehec.map.ModelDrawingAttributeSet.SHOWN
flag- Parameters:
glyphName
- the name of the MapGlyph or child MapGlyphsglyphElement
- the Map Element toshow
- 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
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 placemodifiers
- 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
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 placemodifiers
- 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
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 placemodifiers
- 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
draw this MapGlyph to graphics using the MapScale scl- Parameters:
graphics
- the Graphics to draw toscl
- 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 toscl
- the Current MapScaleline
- the line to fit the string tostr
- the string to drawcoord
- the location relative to the line to draw.baseoffset
- the offset from line to draw strfont
- the Font to render str withcolor
- the foreground color to render str withbank
- the side of line to draw the string onpriority
- 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 toscl
- the Current MapScaleline
- the line to fit the string tostr
- the string to drawcoord
- the location relative to the line to draw.font
- the Font to render str withcolor
- the foreground color to render str withbank
- the side of line to draw the string on- See Also:
-
clearSelection
public void clearSelection()clear the selection of the MapGlyph -
clearSelection
remove the Selection with the name name from the selection list- Parameters:
name
- the name of the object to remove
-
addGlyphSelectionListener
Adds a feature to the GlyphSelectionListener attribute of the MapGlyph object- Parameters:
msl
- The feature to be added to the GlyphSelectionListener attribute
-
removeGlyphSelectionListener
remove the GlyphSelectionListener msl from the _listenerList- Parameters:
msl
- the GlyphSelectionListener to remove
-
addChangeListener
Adds a feature to the ChangeListener attribute of the MapGlyph object- Parameters:
cl
- The feature to be added to the ChangeListener attribute
-
removeChangeListener
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
get the MapGlyph's list of child MapGlyphs- Returns:
- the Vector of child MapGlyphs
-
findGlyphOfClass
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
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
-
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 online
- The WorldLine to drawscl
- The MapScalehalfwidth
- the width of the linefillColor
- the Fill Color. NULL to not fill the lineoutlineColor
- The outlineColor. NULL for no outlinedrawPoints
-pointColor
-halfPointSize
-
-
drawLine
-
drawLine
-
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
- Parameters:
object
-
-
setParentGlyph
-
getParentGlyph
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MapGlyph>
-
isRepaintNeeded
public boolean isRepaintNeeded() -
setRepaintNeeded
public void setRepaintNeeded(boolean isDirty) -
shouldReturn
public static boolean shouldReturn(long[] nextCheck)
-