Class MapView2D
- All Implemented Interfaces:
IFeedbackProvider,IFileDropHandler,ComponentListener,FocusListener,MouseListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
DemoMapView
Responsibilities
- Managing the active
IMapProjectionand the world coordinate system exposed to theIContainer. - Orchestrating the rendering pipeline (background → ocean → graticule →
countries → cities) via an after-draw
IDrawable. - Providing per-frame feedback strings (projection name, lat/lon, picked
country and city) to the
FeedbackPane. - Exposing public API (
setProjection(edu.cnu.mdi.mapping.projection.EProjection),getCityRenderer(), etc.) soMapControlPanelcan drive changes without accessing private state.
Shared vs. per-view data
Country and city data were previously stored in static fields, which
created a hidden singleton: all MapView2D instances shared — and
could inadvertently overwrite — the same dataset. The fields are now instance
fields so that multiple views can independently hold different datasets. The
static setter methods (setCountries(java.util.List<edu.cnu.mdi.mapping.loader.GeoJsonCountryLoader.CountryFeature>), setCities(java.util.List<edu.cnu.mdi.mapping.loader.GeoJsonCityLoader.CityFeature>)) are
retained for backwards compatibility; they set the data on the
most-recently-constructed instance through a static reference that is updated
in the constructor. Callers that only ever create one view are unaffected.
Side panel layout
The control panel (MapControlPanel) and feedback pane
(FeedbackPane) are placed together in a combined east-side strip
whose preferred width in pixels is controlled by getSidePanelWidth().
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIconNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MapControlPanelDefault side control panel.protected static final StringUnicode degree symbol used by geographic feedback text.protected static final StringFeedback-pane prefix used for latitude values.protected final Point2D.DoubleReusable lat/lon workspace for the feedback method.protected static final StringFeedback-pane prefix used for longitude values.Fields inherited from class edu.cnu.mdi.view.BaseView
container, desktop, infoDialog, properties, scrollPane, statusWP, viewPopupMenu, VIEWPROPNAME, virtualItemFields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTYFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCustomSidePanelComponent(JPanel component) Adds an application-supplied component to the side panel, below the map control panel and above the feedback pane.voidaddShapefile(ShapeFeatureRenderer renderer) Appends aShapeFeatureRendererto the end of the extra-layer list.voidaddShapefile(ShapeFeatureRenderer renderer, String name) Adds a named shapefile renderer as an editable MDI layer.protected voidRemoves all custom application components from the side panel.voidRemoves all extra layers added via addLayer.protected voiddrawCustomMapContent(Graphics2D g2, IContainer container) Placeholder method for subclasses to override and draw custom map content after the standard layers.voiddrawSymbol(Graphics2D g, double lat, double lon, SymbolType type, int size, Color lineColor, Color fillColor) Draws a map symbol at the given latitude and longitude using the active projection to convert to screen coordinates.voidfilesDropped(List<File> files) Loads each dropped.shpfile as a new layer, exactly as though it had been chosen via the Shapefiles menu's "Open Shapefile..." action: the display name is the filename without its extension (ShapefileMenu.baseName(Path)), the style is chosen from the first feature's geometry type (ShapefileMenu.defaultStyle(int)), and a successful load is recorded in the same "Recent Shapefiles" list the menu uses (ShapefileMenu.recordRecentlyOpened(File)).intReturns the number of cities currently loaded in this view.Returns the standard city layer.protected CityPointRendererReturns the activeCityPointRenderer.getCountryAtPoint(Point pp, IContainer container) Returns the name of the country under the given screen-space point, ornullif no country is found.Returns the country-boundary layer.intReturns the number of countries currently loaded in this view.Returns the country-fill layer.protected CountryRendererReturns the current country renderer.Returns the map theme that should be used when creating a new projection.doublegetElevation(double lat, double lon) Returns interpolated elevation or bathymetry at a geographic location.Returns the ETOPO5 layer.protected Etopo5RendererReturns the ETOPO5 renderer.voidgetFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Default feedback implementation: no-op.Returns the standard graticule layer.protected GraticuleRendererReturns the active graticule renderer.Returns the imported shapefile layers.Returns the standard map control panel, ornullif a subclass has replaced it with a custom component.protected StringgetMapHoverText(Point point, IContainer sourceContainer) Builds the unified country and shapefile text shown by the hover popup.protected IMapProjectionReturns the active map projection.Returns the currently active map projection.protected intGets the preferred width of the east-side strip containing the map control panel, custom application panels, and feedback pane.Override to supply structured information for the info dialog.voidHandle a hover event.protected booleanReturns whether the Shapefile menu should be included in this view's menu bar.protected LayerinstallEtopo5Layer(Etopo5Loader loader, boolean initiallyShown) Installs ETOPO5 terrain and bathymetry into the standard ETOPO5 layer.booleanReturns whether delayed mouse-over feedback windows are enabled.static List<ShapeFeature> loadShapefileLayer(MapView2D mapView, Path path, String name, ShapeFeatureStyle style) Convenience method that loads a shapefile from the given path, creates aShapeFeatureRendererwith the specified style, and adds it as a new layer with the given name.voidlocalToLatLonDeg(Point pp, Point2D.Double latLon) Converts a screen-space point to latitude and longitude in degrees.booleanonLand(Point pp, IContainer container) Returns whether the given screen-space point is on land (inside a country polygon).voidReleases resources held by theMapContainerwhen the view is closing.voidremoveLayer(ShapeFeatureRenderer renderer) Removes the shapefile layer hosting the supplied renderer.voidsetCities(List<GeoJsonCityLoader.CityFeature> cities) Sets the city features used by this view.voidsetCountries(List<GeoJsonCountryLoader.CountryFeature> countries) Sets the country features rendered by the standard country-fill and country-boundary layers.protected voidsetGraticuleAdaptive(boolean adaptive) Enables or disables zoom-adaptive graticule spacing, persisting the choice across projection switches and refreshing the view.protected voidsetGraticuleLabels(boolean labels) Enables or disables graticule edge labels, persisting the choice across projection switches and refreshing the view.voidsetHoveringEnabled(boolean enabled) Enables or disables delayed mouse-over feedback windows.protected voidsetMapControlPanel(JPanel newControlPanel) Replaces the standard map control panel with a subclass/application supplied component.voidsetProjection(EProjection projectionType) Switches the active projection to one of MDI's built-in projection types, rebuilding all dependent renderers and resetting the container's world coordinate system.voidsetProjection(IMapProjection newProjection) Switches the active projection to an application-supplied projection.protected booleanReturns whether the standard graticule layer should be included in this view.Methods inherited from class edu.cnu.mdi.view.BaseView
addWestPanel, applyFocusFix, center, checkBooleanProperty, componentHidden, componentMoved, componentResized, componentShown, enableFileDrop, enableFileDrop, focusGained, focusLost, getAnnotationLayer, getCenterComponent, getConfigurationProperties, getConnectionLayer, getDefaultLayer, getFileFilter, getIContainer, getImageComponent, getInfoButton, getInsets, getIntProperty, getName, getParentFrame, getProperties, getPropertyName, getScrollPane, getSpecialClip, getToolBar, getViewPopupMenu, getVirtualItem, handleMagnify, hoverClosed, initFeedback, initFeedback, isOnTop, isScrollable, isViewVisible, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, offset, onFirstRealize, refresh, resolveContainer, rightClicked, setAfterDraw, setBeforeDraw, setBooleanProperty, setFileFilter, setFromProperties, setIntProperty, setVirtualItem, viewInfoMethods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
LAT_PREFIX
Feedback-pane prefix used for latitude values.- See Also:
-
LON_PREFIX
Feedback-pane prefix used for longitude values.- See Also:
-
DEG
Unicode degree symbol used by geographic feedback text.- See Also:
-
controlPanel
Default side control panel. May benullif a subclass replaces the control panel with a custom component. -
latLon
Reusable lat/lon workspace for the feedback method.
-
-
Constructor Details
-
MapView2D
Creates a map view. Variable-lengthkeyValsare passed through toBaseViewfor framework-level configuration (title, toolbar flags, container factory, etc.).The view initializes with the
MapConstants.DEFAULT_PROJECTIONand a lightMapTheme. Geographic data (setCountries(java.util.List<edu.cnu.mdi.mapping.loader.GeoJsonCountryLoader.CountryFeature>),setCities(java.util.List<edu.cnu.mdi.mapping.loader.GeoJsonCityLoader.CityFeature>)) must be loaded and set before the first render to avoid a blank map.- Parameters:
keyVals- framework key-value pairs forwarded toBaseView
-
-
Method Details
-
getCountryRenderer
Returns the current country renderer.- Returns:
- current renderer, or
nullbefore country data are loaded
-
installEtopo5Layer
Installs ETOPO5 terrain and bathymetry into the standard ETOPO5 layer.- Parameters:
loader- loaded ETOPO5 datainitiallyShown- initial layer visibility- Returns:
- the ETOPO5 layer
-
useStandardGraticules
protected boolean useStandardGraticules()Returns whether the standard graticule layer should be included in this view.Subclasses that don't want the standard graticule can override this to return
falseand then provide their own graticule implementation as an extra layer.- Returns:
trueto include the standard graticule,falseto omit it
-
getSidePanelWidth
protected int getSidePanelWidth()Gets the preferred width of the east-side strip containing the map control panel, custom application panels, and feedback pane.Subclasses may override this to request a wider or narrower side panel. The override should not depend on subclass instance fields, because this method is called during
MapView2Dconstruction before the subclass constructor body has run. Returning a literal or subclass static constant is safe.- Returns:
- preferred side-panel width in pixels
-
getElevation
public double getElevation(double lat, double lon) Returns interpolated elevation or bathymetry at a geographic location.Elevation remains available even when the ETOPO5 layer is hidden. Layer visibility is a presentation choice and should not affect calculations such as radar line-of-sight or land-height feedback.
- Parameters:
lat- latitude in degreeslon- longitude in degrees- Returns:
- elevation in metres, or
NaNif ETOPO5 is not installed or either coordinate is non-finite
-
setCountries
Sets the country features rendered by the standard country-fill and country-boundary layers.- Parameters:
countries- country features; must not benull
-
setCities
Sets the city features used by this view.The features are rendered by the standard Cities MDI layer. If the active projection already exists, the city renderer is rebuilt immediately.
- Parameters:
cities- list of city features; must not benull
-
getProjection
Returns the currently active map projection.- Returns:
- the active
IMapProjection; nevernullafter construction
-
setProjection
Switches the active projection to one of MDI's built-in projection types, rebuilding all dependent renderers and resetting the container's world coordinate system.The new projection is created by
ProjectionFactoryusing the theme currently selected in the control panel, so the visual style is preserved across projection changes.Country and city data must have been set (via
setCountries(java.util.List<edu.cnu.mdi.mapping.loader.GeoJsonCountryLoader.CountryFeature>)andsetCities(java.util.List<edu.cnu.mdi.mapping.loader.GeoJsonCityLoader.CityFeature>)) before calling this method; if either list isnullthe corresponding renderer is skipped.This method preserves the existing MDI enum-based projection API. For application-supplied projections, use
setProjection(IMapProjection).- Parameters:
projectionType- the new built-in projection type; must not benull
-
getCityRenderer
Returns the activeCityPointRenderer.May be
nullifsetCities(List)has not been called yet.MapControlPanelnull-checks before using this.- Returns:
- the city renderer, or
null
-
getGraticuleRenderer
Returns the active graticule renderer.Used by
MapControlPanelto toggle adaptive spacing and edge labels. The instance is replaced whenever the projection changes (seesetProjection(edu.cnu.mdi.mapping.projection.EProjection)), so callers should re-read it rather than caching the reference; the view re-applies the persisted toggle state to each newly built renderer, so the user's choices survive a projection switch.- Returns:
- the graticule renderer; never
nullafter construction
-
setGraticuleAdaptive
protected void setGraticuleAdaptive(boolean adaptive) Enables or disables zoom-adaptive graticule spacing, persisting the choice across projection switches and refreshing the view.- Parameters:
adaptive-truefor adaptive spacing;falsefor the fixed step
-
setGraticuleLabels
protected void setGraticuleLabels(boolean labels) Enables or disables graticule edge labels, persisting the choice across projection switches and refreshing the view.- Parameters:
labels-trueto draw coordinate labels along the viewport edges
-
getMapProjection
Returns the active map projection.Equivalent to
getProjection()but package-accessible without an explicit cast; used byMapControlPanel.- Returns:
- the active projection; never
nullafter construction
-
getCountryCount
public int getCountryCount()Returns the number of countries currently loaded in this view.Used by
MapViewInfo.getTechnicalNotes()to produce a dynamic count rather than a hardcoded string.- Returns:
- country count, or 0 if data has not been set
-
getCityCount
public int getCityCount()Returns the number of cities currently loaded in this view.Used by
MapViewInfo.getTechnicalNotes()to produce a dynamic count rather than a hardcoded string.- Returns:
- city count, or 0 if data has not been set
-
addShapefile
Appends aShapeFeatureRendererto the end of the extra-layer list. Extra layers are drawn after country polygons and before city markers, in the order they were added.Typical use:
List<ShapeFeature> rivers = new ShapefileFeatureLoader().load(Path.of("ne_10m_rivers_lake_centerlines.shp")); ShapeFeatureStyle style = new ShapeFeatureStyle().strokeColor(new Color(0x6B9FD4)).strokeWidth(0.8f); mapView.addLayer(new ShapeFeatureRenderer(rivers, mapView.getProjection(), style));- Parameters:
renderer- the layer to add; must not benull
-
addShapefile
Adds a named shapefile renderer as an editable MDI layer.- Parameters:
renderer- shapefile renderername- layer display name
-
loadShapefileLayer
public static List<ShapeFeature> loadShapefileLayer(MapView2D mapView, Path path, String name, ShapeFeatureStyle style) Convenience method that loads a shapefile from the given path, creates aShapeFeatureRendererwith the specified style, and adds it as a new layer with the given name.Exceptions are caught and logged to the console; the method does not throw.
- Parameters:
mapView- the view to add the layer to; must not benullpath- filesystem path to the shapefile; must not benullname- display name shown in the Shapefiles menu; must not benullstyle- rendering style for the shapefile features; must not benull
-
removeLayer
Removes the shapefile layer hosting the supplied renderer.- Parameters:
renderer- renderer whose layer should be removed
-
clearLayers
public void clearLayers()Removes all extra layers added via addLayer. The base layers (countries, cities, graticule) are unaffected. -
drawSymbol
public void drawSymbol(Graphics2D g, double lat, double lon, SymbolType type, int size, Color lineColor, Color fillColor) Draws a map symbol at the given latitude and longitude using the active projection to convert to screen coordinates.Used by
MapControlPanelto draw the projection center marker. Can also be used by application code to draw symbols on top of the map without managing coordinate transforms.- Parameters:
g- graphics context to draw on; must not benulllat- latitude in degrees; must be between -90 and 90lon- longitude in degrees; must be between -180 and 180type- symbol type; must not benullsize- symbol size in pixels; must be positivelineColor- color for symbol outlines and lines; must not benullfillColor- color for symbol fills; must not benull
-
getLayers
Returns the imported shapefile layers.- Returns:
- unmodifiable layer list
-
getViewInfo
Override to supply structured information for the info dialog. The default returnsnull(no info available).Returns a
MapViewInfobound tothisview so that the info dialog can display live dataset counts rather than hardcoded strings.- Overrides:
getViewInfoin classBaseView- Returns:
- view info, or
null
-
getCountryAtPoint
Returns the name of the country under the given screen-space point, ornullif no country is found.Delegates to
CountryRenderer.pickCountry(java.awt.Point, edu.cnu.mdi.container.IContainer)and formats the result as"Admin Name (ISO3)"when a hit is found.- Parameters:
pp- screen-space point to test; must not benullcontainer- container providing the coordinate transform- Returns:
- formatted country name string, or
null
-
onLand
Returns whether the given screen-space point is on land (inside a country polygon).Delegates to
CountryRenderer.pickCountry(java.awt.Point, edu.cnu.mdi.container.IContainer)and returnstrueif a hit is found.- Parameters:
pp- screen-space point to test; must not benullcontainer- container providing the coordinate transform- Returns:
trueif the point is on land,falseotherwise
-
localToLatLonDeg
Converts a screen-space point to latitude and longitude in degrees.Delegates to
MapContainer.localToLatLon(java.awt.Point, java.awt.geom.Point2D.Double)for the actual conversion.- Parameters:
pp- screen-space point to convert; must not benulllatLon- output parameter to receive the latitude and longitude in degrees; must not benull
-
getFeedbackStrings
public void getFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Default feedback implementation: no-op. Subclasses override to provide coordinate or status strings.Appends the following strings (in order) to
feedbackStrings:- Number of countries loaded.
- Number of cities loaded.
- Active projection name.
- Screen coordinates of the cursor.
- World (projection-space) coordinates.
- Latitude and longitude in degrees (only when cursor is on map).
- Picked country name and ISO code (only when cursor is on a country polygon).
- Styled feedback text from any extra layers (
ShapeFeatureRenderer) whoseIPickable.pick(java.awt.Point, edu.cnu.mdi.container.IContainer)returns a non-null result. Each layer contributes at most one string; all hit layers are reported. - Picked city name and population (only when cursor is near a city dot).
- Specified by:
getFeedbackStringsin interfaceIFeedbackProvider- Overrides:
getFeedbackStringsin classBaseView- Parameters:
container- the container.pp- the mouse location.wp- the corresponding world point.feedbackStrings- the List of feedback strings to add to.
-
prepareForExit
public void prepareForExit()Releases resources held by theMapContainerwhen the view is closing.- Overrides:
prepareForExitin classBaseView
-
filesDropped
Loads each dropped.shpfile as a new layer, exactly as though it had been chosen via the Shapefiles menu's "Open Shapefile..." action: the display name is the filename without its extension (ShapefileMenu.baseName(Path)), the style is chosen from the first feature's geometry type (ShapefileMenu.defaultStyle(int)), and a successful load is recorded in the same "Recent Shapefiles" list the menu uses (ShapefileMenu.recordRecentlyOpened(File)).Only invoked when
BaseView.enableFileDrop(Predicate)was called in the constructor, which it is unless the subclass opted out of shapefile functionality viaincludeShapeFileMenu(). A failure to load one dropped file is logged and does not prevent the rest of the batch from loading.- Specified by:
filesDroppedin interfaceIFileDropHandler- Overrides:
filesDroppedin classBaseView- Parameters:
files- the accepted dropped files; nevernull, never empty
-
includeShapeFileMenu
protected boolean includeShapeFileMenu()Returns whether the Shapefile menu should be included in this view's menu bar. Subclasses that don't support shapefile layers can override this to returnfalseto exclude the menu and its associated functionality.- Returns:
trueto include the Shapefile menu,falseto omit it
-
drawCustomMapContent
Placeholder method for subclasses to override and draw custom map content after the standard layers. Not called by default since most views won't need it, but available for extensibility when needed.This is not registered as an after-draw
IDrawablesince that would require a separate registration and coordinate transform for each subclass; instead, subclasses can call this method directly from their own after-draw implementation after callingsuper.drawCustomMapContent(g2).- Parameters:
g2- the Graphics2D context to draw on
-
getCurrentMapTheme
Returns the map theme that should be used when creating a new projection.If the standard
MapControlPanelis installed, this delegates to that panel. If a subclass has replaced the control panel, this falls back to the active projection's theme, and finally to the light theme.- Returns:
- the current map theme
-
setProjection
Switches the active projection to an application-supplied projection.This is the extensibility path for projections that are not represented by
EProjection. The supplied projection must be fully initialized, including itsMapTheme. The view rebuilds its graticule, country, city, and extra-layer renderers and resets the world coordinate system using the projection's ownIMapProjection.getXYBounds().- Parameters:
newProjection- the new projection; must not benull
-
setMapControlPanel
Replaces the standard map control panel with a subclass/application supplied component.This method is intended for subclasses such as Mosaic views that want their own projection selector and display controls. It is safe to call from the subclass constructor after
super(...)returns.- Parameters:
newControlPanel- the replacement control panel; must not benull
-
getMapControlPanel
Returns the standard map control panel, ornullif a subclass has replaced it with a custom component.- Returns:
- the map control panel, or
null
-
addCustomSidePanelComponent
Adds an application-supplied component to the side panel, below the map control panel and above the feedback pane.This is intended for domain-specific controls such as Mosaic buttons for Monte Carlo points, prepatches, theta patches, final patches, and patch labels.
- Parameters:
component- the component to add; ignored ifnull
-
getEtopo5Layer
Returns the ETOPO5 layer.- Returns:
- ETOPO5 layer, or
nullif not installed
-
getEtopo5Renderer
Returns the ETOPO5 renderer.- Returns:
- renderer, or
nullif not installed
-
getCountryFillLayer
Returns the country-fill layer.- Returns:
- country-fill layer
-
getCountryBoundaryLayer
Returns the country-boundary layer.- Returns:
- country-boundary layer
-
getCityLayer
Returns the standard city layer.- Returns:
- city layer, or
nullif city data have not been set
-
getGraticuleLayer
Returns the standard graticule layer.- Returns:
- the graticule layer; never
nullafter construction
-
hoverUpdate
Handle a hover event.Subclasses can override this method to respond to hover events, which are triggered by mouse movement with no buttons down. The default implementation is a no-op.
When the user hovers over the map, this method displays a small window with the country name and any configured shapefile feedback fields found under the cursor. The information is shown in the
HoverInfoWindowprovided by theMapContainer.- Overrides:
hoverUpdatein classBaseView- Parameters:
he- the hover event
-
getMapHoverText
Builds the unified country and shapefile text shown by the hover popup. Registered shapefile feedback fields are included in layer order.- Parameters:
point- cursor location in container coordinatessourceContainer- container used for hit testing- Returns:
- plain, possibly multi-line hover text, or
nullfor no hit
-
isHoveringEnabled
public boolean isHoveringEnabled()Returns whether delayed mouse-over feedback windows are enabled. Hover feedback is disabled by default.- Returns:
truewhen hover feedback is enabled
-
setHoveringEnabled
public void setHoveringEnabled(boolean enabled) Enables or disables delayed mouse-over feedback windows. The feature is disabled by default. Disabling it immediately hides any popup that is currently visible.- Parameters:
enabled-trueto enable map hovering
-
clearCustomSidePanelComponents
protected void clearCustomSidePanelComponents()Removes all custom application components from the side panel.
-