Package hec.map

Class MapPanel

All Implemented Interfaces:
ActionListener, AdjustmentListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class MapPanel extends JPanel implements AdjustmentListener, ActionListener
Geo-referenced mapping widget that contains a MapCanvas, horizontal and vertical scrollbars, and a toolpanel.

Since:
9/20/99
See Also:
  • Field Details

    • _horizScrollbar

      protected RMAJScrollBar _horizScrollbar
      Description
    • _vertScrollbar

      protected RMAJScrollBar _vertScrollbar
      Description
    • _viewport

      protected MapCanvas _viewport
      Description
    • _defaultToolsPanel

      protected MapToolPanel _defaultToolsPanel
      Description
    • _currentToolsPanel

      protected MapToolPanel _currentToolsPanel
      Description
    • _mouseAdapters

      protected Map _mouseAdapters
      Description
    • OBS_ZOOMIN

      public static final String OBS_ZOOMIN
      Zoom in change type string
      See Also:
    • OBS_ZOOMBYFACTOR

      public static final String OBS_ZOOMBYFACTOR
      Zoom in by factor change type string
      See Also:
    • OBS_SCROLLED

      public static final String OBS_SCROLLED
      scrolled change type string
      See Also:
    • OBS_SHOWALL

      public static final String OBS_SHOWALL
      showall change type string
      See Also:
    • OBS_ORIGIN_SET

      public static final String OBS_ORIGIN_SET
      set origin change type string
      See Also:
    • _maxExtents

      protected WorldRect _maxExtents
      the maximum extents
    • _extents

      protected WorldRect _extents
      the current extents
    • _scale

      protected MapScale _scale
      scale object that contains world to local coordinate transformation data
    • _glyphList

      protected List _glyphList
      list of map glyphs
    • _managerGlyphList

      protected List _managerGlyphList
      list of manager glyphs
    • _backgroundGlyphList

      protected List _backgroundGlyphList
      list of background glyphs
    • _combinedGlyphList

      protected List _combinedGlyphList
      list of all glyphs
    • _orderList

      protected List _orderList
      list of the ordering of the glyphs
    • _paintThread

      protected Thread _paintThread
      the thread that handles painting
    • _paintEnabled

      protected boolean _paintEnabled
      flag indicating whether painting should occur
    • _userInterface

      protected UserInterface _userInterface
      the user interface to display messages to
    • _observerList

      protected Vector _observerList
      the list of observers
    • _changed

      protected boolean _changed
      Description
    • _isAdjusting

      protected boolean _isAdjusting
      flag indicating the viewport is being adjusted
    • _oldVerticalValue

      protected int _oldVerticalValue
      Description
    • _oldHorizontalValue

      protected int _oldHorizontalValue
      Description
    • useRenderer

      protected boolean useRenderer
  • Constructor Details

    • MapPanel

      public MapPanel(boolean buildControls)
      Create a new MapPanel object

      Parameters:
      buildControls - flag indicating whether to add the default tools and scrollbars
    • MapPanel

      public MapPanel()
      Create a new MapPanel object with default tools and scrollbars
    • MapPanel

      public MapPanel(JFrame frame)
      Create a new MapPanel object with default tools and scrollbars

      Parameters:
      frame - currently not used
  • Method Details

    • addMapToolClassLoader

      public void addMapToolClassLoader(MapToolClassLoader classLoader)
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • addPaintCompleteListener

      public void addPaintCompleteListener(PaintCompleteListener listener)
    • removePaintCompleteListener

      public void removePaintCompleteListener(PaintCompleteListener listener)
    • getGlyphLevel

      public int getGlyphLevel(MapGlyph glyph)
      Gets the Glyph Level for glyph

      Parameters:
      glyph - a MapGlyph current displayed in the MapPanel

      Returns:
      glyph's index into the MapPanel layers
    • init

      protected void init(boolean buildControls)
      initialize the controls for the MapPanel

      Parameters:
      buildControls - true to create the scrollbars and map tools
    • setGlassPane

      public void setGlassPane(JPanel glassPane)
    • getGlassPane

      public JPanel getGlassPane()
    • addListeners

      protected void addListeners()
    • showHideScrollbars

      protected void showHideScrollbars()
    • setLegendRenderer

      public void setLegendRenderer(LegendRenderer renderer)
    • createViewport

      public MapCanvas createViewport()
    • setPaintEnabled

      public boolean setPaintEnabled(boolean state)
      Sets whether painting is enabled for the mappanel

      Parameters:
      state - The new PaintEnabled value

      Returns:
      the previous paint enabled state
    • isPaintEnabled

      public boolean isPaintEnabled()
      Gets whether painting is enabled for the MapPanel

      Returns:
      true if painting is enabled
    • createDefaultMapTools

      public MapToolPanel createDefaultMapTools()
      create the default map tool panel

      Returns:
      the new MapToolPanel
    • getMapToolPanel

      public MapToolPanel getMapToolPanel()
    • setMapTools

      public void setMapTools(MapToolPanel tools)
      Sets the current MapTools of the MapPanel object

      Parameters:
      tools - The new MapToolsPanel
    • addMaps

      public void addMaps(List maps) throws IOException
      the the Maps in maps to the MapPanel

      Parameters:
      maps - The feature to be added to the Maps attribute

      Throws:
      IOException - Description
    • resetManagerMaps

      public void resetManagerMaps(List mapVec)
      set the Manager MapObjectInterface list

      Parameters:
      mapVec - List of Manager MapObjectInterface objects
    • resetBackgroundMaps

      public void resetBackgroundMaps(List mapVec)
      set the Background MapObjectInterface list

      Parameters:
      mapVec - List of Background MapObjectInterface objects
    • addBackgroundMaps

      public void addBackgroundMaps(List mapVec) throws IOException
      add Background MapObjectInterfaces to the list of Background maps

      Parameters:
      mapVec - List of MapObjectInterface Background Maps

      Throws:
      IOException - Description
    • addManagerMaps

      public void addManagerMaps(List mapVec) throws IOException
      add Manager MapObjectInterfaces to the list of Manager maps

      Parameters:
      mapVec - List of MapObjectInterface Manager Maps

      Throws:
      IOException - Description
    • setGlyphList

      public void setGlyphList(List newGlyphList)
      add static Map MapObjectInterfaces to the list of Maps

      Parameters:
      newGlyphList - List of MapObjectInterface Maps
    • setGlyphList

      public void setGlyphList(List newGlyphList, boolean saveToWksp)
      add static Map MapObjectInterfaces to the list of Maps

      Parameters:
      newGlyphList - List of MapObjectInterface Maps
      saveToWksp - true to save the newGlyphList to the workspace
    • resetManagerOrder

      public void resetManagerOrder(List positionList)
      set the order of the List of Manager MapObjectInterface objects

      Parameters:
      positionList - the list of MapPosition objects
    • setManagerOrder

      public void setManagerOrder(List positionList)
      Sets the ManagerOrder attribute of the MapPanel object calls setManagerOrder(positionList, true)

      Parameters:
      positionList - The new ManagerOrder value
    • setManagerOrder

      public void setManagerOrder(List positionList, boolean saveToWksp)
      Sets the ManagerOrder attribute of the MapPanel object

      Parameters:
      positionList - The new ManagerOrder value
      saveToWksp - true to save the order to the workspace
    • setManagerGlyphList

      public void setManagerGlyphList(List list)
      set the List of Manager MapObjectInterface objects. This is just a reference assignment.

      Parameters:
      list - The new ManagerGlyph List
    • setBackgroundGlyphList

      public void setBackgroundGlyphList(List list)
      set the List of Background MapObjectInterface objects. This is just a reference assignment.

      Parameters:
      list - The new BackgroundGlyph List
    • cloneCombinedGlyphList

      public List cloneCombinedGlyphList()
      return a copy of the CombinedGlyphList.

      Returns:
      a copy of the Combined Glyph List
    • cloneGlyphList

      public List cloneGlyphList()
      return a copy of the Map glyph list

      Returns:
      a copy of the map glyph list
    • cloneManagerGlyphList

      public List cloneManagerGlyphList()
      return a copy of the ManagerGLyph list

      Returns:
      a copy of the ManagerGlyph list
    • cloneBackgroundGlyphList

      public List cloneBackgroundGlyphList()
      return a copy of the background glyph list

      Returns:
      a copy of the background glyph list
    • findToolButtonFor

      public JToggleButton findToolButtonFor(String name)
      find the ToolButton for the specified MouseAdapter class

      Parameters:
      name - the class name of the MouseAdapter

      Returns:
      the Button or null
    • setMouseAdapter

      public boolean setMouseAdapter(String className)
    • getMapMouseAdapter

      public MapMouseAdapter getMapMouseAdapter()
      Gets the current MapMouseAdapter

      Returns:
      The current MapMouseAdapter
    • paintImage

      public void paintImage()
      paints the cached image for the MapCanvas
    • paintMap

      public void paintMap()
      redraw the map. This is the method to call when a glyph has changes that need to be reflected on the MapPanel
    • paintMap

      public void paintMap(int x, int y, int width, int height)
      redraw the map. This is the method to call when a glyph has changes that need to be reflected on the MapPanel /** Repaints the specified rectangle of this component.

      Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width
      height - the height
    • waitforPaintComplete

      public void waitforPaintComplete()
      causes the Thread that calls this method to wait until the MapCanvas has finished image creation and displayed it.
    • glyphList

      public List glyphList()
      return the list of Map Glyphs. This List is not a copy.

      Returns:
      the list of MapGlyphs
    • managerGlyphList

      public List managerGlyphList()
      return the List of Manager Glyphs. This method should not be public, but is so for historical reasons. User code that needs to find a particular glyph of a class type should use findGlyphOfClass(String className)

      Returns:
      Description
    • backGroundGlyphList

      public List backGroundGlyphList()
      return the List of Background Glyphs. This method should not be public, but is so for historical reasons. User code that needs to find a particular glyph of a class type should use findGlyphOfClass(String className)

      Returns:
      Description
    • hasMap

      public boolean hasMap(MapObjectInterface map)
      check to see if there is already a glyph for map already loaded in this MapPanel.

      Parameters:
      map - the map to check

      Returns:
      true if map is already loaded in this MapPanel
    • addMap

      public boolean addMap(MapObjectInterface map)
      add a Map to the MapPanel

      Parameters:
      map - the new Map to add
    • addMap

      public boolean addMap(MapObjectInterface map, boolean fireEvent)
      Adds a feature to the Map attribute of the MapPanel object

      Parameters:
      map - The feature to be added to the Map attribute
      fireEvent - The feature to be added to the Map attribute
    • addMap

      public boolean addMap(MapObjectInterface map, boolean fireEvent, boolean toBottom)
    • addBackgroundMap

      public boolean addBackgroundMap(MapObjectInterface map)
      add a background map to the MapPanel

      Parameters:
      map - the new background map
    • addManagerMap

      public boolean addManagerMap(MapObjectInterface map)
      add a new ManagerMap to the MapPanel

      Parameters:
      map - the new Manager Map
    • canAddManagerMap

      protected boolean canAddManagerMap(MapObjectInterface map)
    • addManagerMap

      public boolean addManagerMap(MapObjectInterface map, boolean fireEvent)
      Adds a feature to the ManagerMap attribute of the MapPanel object

      Parameters:
      map - The feature to be added to the ManagerMap attribute
      fireEvent - The feature to be added to the ManagerMap attribute
    • addManagerMap

      public boolean addManagerMap(MapObjectInterface map, MapGlyph mapGlyph, boolean fireEvent)
    • addMaptools

      protected void addMaptools(MapObjectInterface2 map)
    • addManagerMapGlyph

      protected void addManagerMapGlyph(MapGlyph mapGlyph)
    • fireGlyphVectorChanged

      protected void fireGlyphVectorChanged()
      Method Description
    • buildGlyphList

      public List buildGlyphList()
      causes the combined glyph list to be rebuilt.

      Returns:
      the new combined glyph list
    • addMapGlyphListener

      public void addMapGlyphListener(MapGlyphListener l)
      add a MapGlyph Listener to the MapPanel. These listeners get notified when any of the lists of MapGlyphs gets changed

      Parameters:
      l - the new MapGlyphListener
    • removeMapGlyphListener

      public void removeMapGlyphListener(MapGlyphListener l)
      remove the MapGlyphListener l from the listener list

      Parameters:
      l - the MapGlyphListener to remove
    • growRegionExtents

      public void growRegionExtents(WorldRect rect)
      grow the map extents to include rect

      Parameters:
      rect - the WorldRect to grow the extents to
    • removeAllMaps

      public void removeAllMaps()
      remove all maps from the MapPanel
    • zoomIn

      public void zoomIn(LocalRect rc)
      zoom the viewport to rc

      Parameters:
      rc - the new viewport rectangle
    • zoomByFactor

      public void zoomByFactor(double factor)
      zoom in by factor

      Parameters:
      factor - the new zoom factor
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      called when a user presses a toolbar button.

      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - Description
    • adjustmentValueChanged

      public void adjustmentValueChanged(AdjustmentEvent event)
      called when a scrollbar is moved

      Specified by:
      adjustmentValueChanged in interface AdjustmentListener
      Parameters:
      event - Description
    • resetScrollbars

      public void resetScrollbars()
      reset the horizontal and vertical scroll bars
    • scrollUp

      public void scrollUp()
      scroll the vertical scrollbar up one block increment

    • scrollLeft

      public void scrollLeft()
      scroll the horizontal scrollbar to the left one block increment

    • scrollRight

      public void scrollRight()
      scroll the horizontal scrollbar to the right one block increment

    • scrollDown

      public void scrollDown()
      scroll the vertical scrollbar down one block increment

    • scrollTowardMin

      protected void scrollTowardMin(JScrollBar scrollbar)
    • scrollTowardMax

      protected void scrollTowardMax(JScrollBar scrollbar)
    • scale

      public MapScale scale()
      get the MapPanel's MapScale

      Returns:
      the MapScale
    • scale

      public MapScale scale(MapGlyph glyph)
    • getCoordinateReferenceSystem

      public CoordinateReferenceSystem getCoordinateReferenceSystem()
    • viewport

      public MapCanvas viewport()
      get the MapPanel's MapCanvas

      Returns:
      the MapCanvas
    • getExtents

      public WorldRect getExtents()
      Gets a copy of the current Extents of the MapPanel

      Returns:
      The Extents
    • setExtents

      public void setExtents(WorldRect e)
    • setExtents

      public void setExtents(WorldRect e, boolean resetWkspExtents)
      Sets the Extents of the MapPanel

      Parameters:
      e - The new Extents
    • getMaxExtents

      public WorldRect getMaxExtents()
      Gets the Max Extents of the MapPanel

      Returns:
      The Max Extents
    • setMaxExtents

      public void setMaxExtents(WorldRect e)
      Sets the Max Extents of the MapPanel

      Parameters:
      e - The new Max Extents
    • getViewportSize

      public Dimension getViewportSize()
      Gets the Viewport Size of the MapCanvas

      Returns:
      The Viewport Size
    • addGlyphs

      public void addGlyphs(List glyphs) throws IOException
      no op method

      Parameters:
      glyphs - The feature to be added to the Glyphs attribute

      Throws:
      IOException - Description
    • showAll

      public void showAll()
      zoom the MapPanel to the max extents
    • setOrigin

      public void setOrigin(WorldPt p, boolean computeScaling)
    • findGlyphForMapObject

      public MapGlyph findGlyphForMapObject(MapObjectInterface map)
      search the Manager and Background glyph lists for the MapGlyph that holds the MapObject

      Parameters:
      map - the MapObject to find the glyph for

      Returns:
      the MapGlyph that holds the MapObject or null if none found
    • findGlyphForMapObjectClass

      public MapGlyph findGlyphForMapObjectClass(String classname)
      search the Manager and Background glyph lists for the MapGlyph that holds the MapObject of class classname

      Parameters:
      classname - the class name of the MapObject to find

      Returns:
      the first MapGlyph of class type classname
    • findGlyphOfClass

      public MapGlyph findGlyphOfClass(String classname)
      search the Manager and Background glyph lists for the MapGlyph of class classname

      Parameters:
      classname - the class name of the MapGlyph to find

      Returns:
      the first MapGlyph of class type classname
    • findGlyphOfClass

      public MapGlyph findGlyphOfClass(String classname, boolean searchChildren)
    • findGlyphOfClass

      public <T extends MapGlyph> T findGlyphOfClass(Class<T> c, boolean searchChildren)
      search the Manager and Background glyph lists for the MapGlyph of class classname

      Parameters:
      c - the class of the MapGlyph to find

      Returns:
      the first MapGlyph of class type classname
    • findGlyphsOfClass

      public List findGlyphsOfClass(String classname)
      search the Manager and Background glyph lists for any MapGlyphs of class classname

      Parameters:
      classname - the class name of the MapGlyph to find

      Returns:
      all the MapGlyphs of class type classname
    • getGrowToExtents

      public boolean getGrowToExtents()
      return whether the MapPanel will grow to it extents

      Returns:
      The GrowToExtents value

      See Also:
    • updateExtents

      public void updateExtents()
      Update region extents based on current setting of the workspace
    • getCurrentExtents

      public WorldRect getCurrentExtents()
      Gets the CurrentExtents attribute of the MapPanel object

      Returns:
      The CurrentExtents value
    • setUserInterface

      public void setUserInterface(UserInterface ui)
      Sets the UserInterface for the MapPanel object

      Parameters:
      ui - The new UserInterface value
    • getUserInterface

      public UserInterface getUserInterface()
      Gets the UserInterface used by the MapPanel object

      Returns:
      The UserInterface value
    • printStatus

      public void printStatus(String msg)
      print a statuc message to the UserInterface object of this MapPanel

      Parameters:
      msg - Description
    • addObserver

      public void addObserver(Observer o)
      add an Observer to the observerList

      Parameters:
      o - the Observer to add
    • deleteObserver

      public void deleteObserver(Observer o)
      remove the Observer o from the observer list

      Parameters:
      o - Description
    • notifyObservers

      public void notifyObservers(String chgMsg)
      notify the Observers of a change

      Parameters:
      chgMsg - Description
    • removeManagerMap

      public void removeManagerMap(MapObjectInterface mapObject)
      Parameters:
      mapObject -
    • removeMaps

      public void removeMaps()
      remove the maps in this MapPanel

    • removeMap

      public boolean removeMap(MapObjectInterface map)
      remove the map from this MapPanel

      Parameters:
      map - the Map to remove
    • removeMap

      public boolean removeMap(MapIdentifier mapId)
      remove the map identified by mapid from the MapPanel

      Parameters:
      mapId -

      Returns:
      truen if the map was removed
    • getVisibleMaps

      public List getVisibleMaps()
      get a List of the Maps that are visible (isShown() == true)

      Returns:
      a non-null List of hec.map.MapObjects
    • getVerticalScrollBarWidth

      public int getVerticalScrollBarWidth()
    • getHorizontalScrollBarHeight

      public int getHorizontalScrollBarHeight()
    • getViewportPanel

      public JPanel getViewportPanel()