Class BaseView
- All Implemented Interfaces:
IFeedbackProvider,IFileDropHandler,ComponentListener,FocusListener,MouseListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
DrawingView,GeometrySliceDemoView,JsonView,LogView,MapView2D,NetworkLayoutDemoView,PlotView,SimulationView,VirtualView
A BaseView is a JInternalFrame hosted on the application's
Desktop. Most views contain an IContainer that provides a
"world" coordinate system and drawing/interaction support. Container-less
views (e.g. log or config panels) are also supported.
Persistence key (VIEWPROPNAME)
Each view owns a stable string prefix used as the namespace for its
persisted properties (position, size, visibility, etc.). The prefix is
derived automatically from the view's title at construction time by
sanitizeForKey(String). Subclasses that need a hand-chosen,
title-independent key should override getPropertyName().
Why not use the title directly? Titles may contain spaces and special characters that are awkward inside XML property keys, and they can change between releases. The sanitised form is stable and safe.
Persistence format
Properties are written using dotted keys: prefix.x,
prefix.y, prefix.w, prefix.h,
prefix.visible, prefix.maximized. When reading back,
the legacy non-dotted variants (e.g. prefixx, prefixvisible)
are also accepted so that files saved by older versions of the framework
continue to work.
File drag-and-drop
Drop support is activated by calling enableFileDrop(Predicate) in
the subclass constructor (after super(...)). That single call
installs a FileDropHandler on every appropriate surface — the
container canvas, the scroll-pane viewport (when present), and the frame
itself — and stores the filter. Subclasses then override
filesDropped(List) to handle the accepted files. No other wiring
is required.
public MyView(Object... keyVals) {
super(PropertyUtils.fromKeyValues(keyVals));
enableFileDrop(f -> f.getName().endsWith(".csv"));
}
@Override
public void filesDropped(List<File> files) {
openCsvFile(files.get(0));
}
Design notes
- All property parsing happens once in
BaseView.ViewInitConfig.from(java.util.Properties), keeping the constructor body straightforward. - Nested static helpers (
BaseView.FrameConfigurer,BaseView.ViewContentBuilder, etc.) keep each responsibility isolated without requiring separate compilation units.
- 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 IContainerOptional world-coordinate container;nullfor container-less views.protected final JDesktopPaneThe desktop pane that hosts this internal frame.protected JDialogLazily-shown dialog displaying view information.protected final PropertiesProperties supplied at construction time.protected JScrollPaneOptional scroll pane wrapping the container component.protected Point2D.Doubleprotected final ViewPopupMenuRight-click popup menu for this view.protected StringStable prefix used to namespace this view's persisted properties.protected VirtualWindowItemOptional thumbnail item shown in theVirtualView.Fields 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
ConstructorsConstructorDescriptionBaseView(ViewOptions options) Construct a view from an immutable typed configuration.Construct aBaseViewfrom alternating key/value property pairs.BaseView(Properties props) Construct aBaseViewfrom a pre-builtPropertiesobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWestPanel(JComponent panel) Adds a component to theWESTslot of this view's content pane, expanding the frame width to accommodate it.static voidapplyFocusFix(JMenu menu, BaseView view) Install a mouse-enter listener onmenuthat selectsviewwhen the mouse enters the menu.voidcenter()center this view within its parent frame.booleanRead a boolean property from this view's internal properties.voidvoidNo-op: FlatLaf repaints correctly on move without explicit desktop repaint calls.voidNo-op: FlatLaf repaints correctly on resize.voidprotected final voidActivate file drag-and-drop for this view, accepting all dropped files.protected final voidenableFileDrop(Predicate<File> filter) Activate file drag-and-drop for this view with a type filter.voidfilesDropped(List<File> files) Called on the EDT when one or more accepted files are dropped on this view.voidvoidHelper method to the the annotation layer from the container, if available.protected ComponentReturns the Component currently in the CENTER position of the content pane,Capture this view's current state into aPropertiesobject.Helper method to the get the connection layer from the container, if available.Helper method to the get the default layer from the container, if available.voidgetFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Default feedback implementation: no-op.Returns the current file filter, ornullif none is set.Returns the container hosted by this view.The component that best represents this view as a static image, for screenshot/clipboard capture (seeTakePicture).Returns a button that triggers the view info dialog when clicked.Slightly reduces the bottom inset to match legacy appearance.intgetIntProperty(String key) Read an integer property from this view's internal properties.getName()Returns the view title (legacy:Component.getName()maps to the title for backward compatibility).Returns the top-levelJFramethat hosts the desktop, resolving it lazily on first call.Returns the properties that were used to construct this view.Returns the stable property-key prefix used to namespace this view's persisted state.Returns the scroll pane, if this view was configured as scrollable.Returns an optional clip shape used by the rendering pipeline.Returns the toolbar for this view, ornullif none was configured.Override to supply structured information for the info dialog.Returns the right-click popup menu for this view.Returns the virtual-desktop thumbnail item associated with this view, ornullif the virtual desktop is not active.voidHandle a magnify (modifier + mouse) request.voidHandle the closing (dismissal) of a hover popup/tooltip.voidHandle a hover event.protected FeedbackPaneCreate and install a feedback pane with default colors (cyan on black, 9 pt font).protected FeedbackPaneinitFeedback(Color fg, Color bg, int fontSize) Create and install a feedback pane with custom colors and font size.booleanisOnTop()Returnstrueif this view is at the top of the desktop's z-order.booleanReturnstrueif this view wraps its container in a scroll pane.booleanReturnstrueif any part of this internal frame's bounds intersects the parent desktop's bounds, indicating that it is on-screen.voidvoidvoidClose the magnify window when the mouse leaves any view canvas.voidvoidvoidoffset(int dh, int dv) Move this view by the specified pixel offset.voidCalled exactly once, after the view has been fully constructed and registered with theViewManager.voidCalled when the application is about to exit.voidrefresh()Refresh the view by delegating to the container, if the view is currently visible.protected IContainerresolveContainer(Rectangle2D.Double worldSystem) Resolve theIContainerfor this view.booleanrightClicked(MouseEvent mouseEvent) Optional hook for subclasses: called on a right-click.voidsetAfterDraw(IDrawable afterDraw) Helper method to set the after-draw layer in the container, if available.voidsetBeforeDraw(IDrawable beforeDraw) Helper method to set the before-draw layer in the container, if available.voidsetBooleanProperty(String key, boolean val) Store a boolean property in this view's internal properties.voidsetFileFilter(Predicate<File> filter) Set the file filter used to screen dropped files.voidsetFromProperties(Properties properties) Restore this view's state from a properties map previously produced bygetConfigurationProperties().voidsetIntProperty(String key, int val) Store an integer property in this view's internal properties.voidsetVirtualItem(VirtualWindowItem virtualItem) Set the virtual-desktop thumbnail item.voidviewInfo()Show the view information dialog.Methods 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
-
VIEWPROPNAME
Stable prefix used to namespace this view's persisted properties.Set during construction from the sanitised view title. Subclasses that want an explicit, title-independent key should override
getPropertyName()rather than writing to this field. -
infoDialog
Lazily-shown dialog displaying view information. -
properties
Properties supplied at construction time. Also used as a lightweight per-view key-value store bysetBooleanProperty(java.lang.String, boolean)etc. -
desktop
The desktop pane that hosts this internal frame. -
container
Optional world-coordinate container;nullfor container-less views. -
scrollPane
Optional scroll pane wrapping the container component. -
viewPopupMenu
Right-click popup menu for this view. -
virtualItem
Optional thumbnail item shown in theVirtualView. Set externally by the virtual desktop machinery. -
statusWP
-
-
Constructor Details
-
BaseView
Construct aBaseViewfrom alternating key/value property pairs.- Parameters:
keyVals- alternatingPropertyUtilskey/value pairs
-
BaseView
Construct a view from an immutable typed configuration.The options are defensively copied before initialization. This overload is additive; existing key/value and
Propertiesconstructors retain their behavior.- Parameters:
options- view initialization options; must not benull- Throws:
NullPointerException- ifoptionsis null
-
BaseView
Construct aBaseViewfrom a pre-builtPropertiesobject.- Parameters:
props- configuration properties; must not benull
-
-
Method Details
-
resolveContainer
Resolve theIContainerfor this view.Resolution order:
- An
IContainerinstance stored directly in the properties underPropertyUtils.CONTAINER. - A
Classstored underPropertyUtils.CONTAINERCLASS, instantiated via its(Rectangle2D.Double)constructor. - A default
BaseContainer.
- Parameters:
worldSystem- the initial world coordinate rectangle- Returns:
- a non-null container
- An
-
onFirstRealize
public void onFirstRealize()Called exactly once, after the view has been fully constructed and registered with theViewManager.For eagerly-created views this occurs during normal startup. For lazily-created views (see
ViewConfiguration) it occurs the first time the user selects the view from the Views menu.The default implementation is a no-op. Subclasses may override to reconcile with shared application state or perform other one-time post-construction work.
-
getInsets
Slightly reduces the bottom inset to match legacy appearance.- Overrides:
getInsetsin classJComponent- Returns:
- adjusted insets
-
prepareForExit
public void prepareForExit()Called when the application is about to exit.Delegates to
IContainer.prepareForExit()if a container is present, allowing simulations or background tasks to stop cleanly. -
getParentFrame
Returns the top-levelJFramethat hosts the desktop, resolving it lazily on first call.- Returns:
- the parent frame, or
nullif not yet in a realized hierarchy
-
getIContainer
Returns the container hosted by this view.- Returns:
- the container, or
nullfor container-less views
-
enableFileDrop
protected final void enableFileDrop()Activate file drag-and-drop for this view, accepting all dropped files.Equivalent to
enableFileDrop(null). Every file the user drops on the view is forwarded tofilesDropped(java.util.List<java.io.File>)without any filtering.Call this from the subclass constructor after
super(...).- See Also:
-
enableFileDrop
Activate file drag-and-drop for this view with a type filter.Installs a single
FileDropHandlerinstance on every surface that can realistically receive a drop in this view:- Container canvas — the primary drawing surface for container-backed views.
- Scroll-pane and its viewport — present when the view was constructed with a scroll pane; without this, drops on the scroll-bar gutters would be silently ignored.
- The view frame itself — a fallback that covers container-less views (e.g. log or config panels) and any area of the frame chrome not covered by the surfaces above.
The supplied
filteris stored viasetFileFilter(java.util.function.Predicate<java.io.File>)and is evaluated byFileDropHandlerbeforefilesDropped(java.util.List<java.io.File>)is called. Files that do not match the filter are silently discarded; if every file in a drop is rejected, Swing renders the "no-drop" cursor so the user receives clear feedback.Usage pattern — call once from the subclass constructor, then override
filesDropped(java.util.List<java.io.File>):public MyView(Object... keyVals) { super(PropertyUtils.fromKeyValues(keyVals)); enableFileDrop(f -> f.getName().endsWith(".csv")); } @Override public void filesDropped(List<File> files) { openCsvFile(files.get(0)); }This method is
finalto guarantee that the surface coverage described above is always complete. Subclasses that need finer control (e.g. canvas-only drops) may callJComponent.setTransferHandler(javax.swing.TransferHandler)directly after calling this method.- Parameters:
filter- acceptance predicate applied to each dropped file; passnullto accept all files without screening
-
setFileFilter
Set the file filter used to screen dropped files.Prefer calling
enableFileDrop(Predicate)rather than this method directly;enableFileDropboth stores the filter and installs theFileDropHandleron all required surfaces. This setter is part of theIFileDropHandlercontract and is also useful when the filter needs to be swapped at runtime without reinstalling the handler.- Specified by:
setFileFilterin interfaceIFileDropHandler- Parameters:
filter- the acceptance predicate, ornullto accept all files
-
getFileFilter
Returns the current file filter, ornullif none is set.- Specified by:
getFileFilterin interfaceIFileDropHandler- Returns:
- the acceptance predicate
-
filesDropped
Called on the EDT when one or more accepted files are dropped on this view.The default implementation is a no-op. Subclasses that have called
enableFileDrop(Predicate)should override this method to handle the dropped files. The list is nevernulland is never empty; the filter (if any) has already been applied.- Specified by:
filesDroppedin interfaceIFileDropHandler- Parameters:
files- the accepted dropped files; nevernull, never empty
-
getName
Returns the view title (legacy:Component.getName()maps to the title for backward compatibility). -
getPropertyName
Returns the stable property-key prefix used to namespace this view's persisted state.By default this is derived automatically from the view title via
sanitizeForKey(String). Subclasses that require a fixed, title-independent key should override this method:@Override public String getPropertyName() { return "myMapView"; }- Returns:
- the persistence key prefix; never
null
-
getViewPopupMenu
Returns the right-click popup menu for this view.- Returns:
- the popup menu; never
null
-
isScrollable
public boolean isScrollable()Returnstrueif this view wraps its container in a scroll pane.- Returns:
trueif scrollable
-
getScrollPane
Returns the scroll pane, if this view was configured as scrollable.- Returns:
- the scroll pane, or
null
-
rightClicked
Optional hook for subclasses: called on a right-click. The default returnsfalse(not handled).- Parameters:
mouseEvent- the triggering event- Returns:
trueif the event was handled and should not be processed further
-
refresh
public void refresh()Refresh the view by delegating to the container, if the view is currently visible. -
isViewVisible
public boolean isViewVisible()Returnstrueif any part of this internal frame's bounds intersects the parent desktop's bounds, indicating that it is on-screen.- Returns:
trueif visible in the desktop
-
isOnTop
public boolean isOnTop()Returnstrueif this view is at the top of the desktop's z-order.- Returns:
trueif on top
-
getSpecialClip
Returns an optional clip shape used by the rendering pipeline. The default returnsnull.- Returns:
- a clip shape, or
null
-
offset
public void offset(int dh, int dv) Move this view by the specified pixel offset.- Parameters:
dh- horizontal offset in pixels (positive = right)dv- vertical offset in pixels (positive = down)
-
center
public void center()center this view within its parent frame.This is a no-op if the parent frame cannot be determined.
-
getToolBar
Returns the toolbar for this view, ornullif none was configured.- Returns:
- the toolbar
-
initFeedback
Create and install a feedback pane with default colors (cyan on black, 9 pt font).- Returns:
- the created feedback pane
-
initFeedback
Create and install a feedback pane with custom colors and font size.- Parameters:
fg- foreground colorbg- background colorfontSize- font size in points- Returns:
- the created feedback pane
- Throws:
IllegalStateException- if this view has no container
-
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.- Specified by:
getFeedbackStringsin interfaceIFeedbackProvider- Parameters:
container- the container.pp- the mouse location.wp- the corresponding world point.feedbackStrings- the List of feedback strings to add to.
-
getVirtualItem
Returns the virtual-desktop thumbnail item associated with this view, ornullif the virtual desktop is not active.- Returns:
- the virtual window item
-
setVirtualItem
Set the virtual-desktop thumbnail item.- Parameters:
virtualItem- the item to associate with this view
-
applyFocusFix
Install a mouse-enter listener onmenuthat selectsviewwhen the mouse enters the menu.This works around a focus issue on some platforms where the view's menu bar flashes or loses focus when a menu is opened. Selecting the internal frame explicitly prevents the flash.
- Parameters:
menu- the menu to attach the listener toview- the view to select on mouse entry
-
handleMagnify
Handle a magnify (modifier + mouse) request.Dispatches to the EDT if not already on it.
- Parameters:
me- the triggering mouse event
-
viewInfo
public void viewInfo()Show the view information dialog.If the subclass provides an
AbstractViewInfoviagetViewInfo()that is displayed in a dialog; otherwise a generic "no information available" message is shown. -
getInfoButton
Returns a button that triggers the view info dialog when clicked. This is primarily for views that don't have a toolbar where the user might expect to find an info button, but it can be used by any view.- Returns:
- the info button
-
getViewInfo
Override to supply structured information for the info dialog. The default returnsnull(no info available).- Returns:
- view info, or
null
-
getImageComponent
The component that best represents this view as a static image, for screenshot/clipboard capture (seeTakePicture).The default returns the container's drawable component, which is correct for ordinary item-based 2D views: for those, the container component already shows everything the view has to offer. Views whose visible content is not fully contained in that one component should override this.
PlotViewis the prototypical example: its title, legend, and axis labels live on the surroundingPlotPanel, not on the innerPlotCanvasthe container exposes, so capturing the container component alone would silently drop them.This exists so callers that want "an image of this view" — a toolbar's camera button, a menu action, a future export feature — have one consistent, view-owned question to ask, instead of each caller re-deriving its own answer (or a shared utility like
TakePicturehaving to special-case specific view/panel types itself).- Returns:
- the component to capture as this view's image; the container's component if one is present, otherwise this view itself
-
setFromProperties
Restore this view's state from a properties map previously produced bygetConfigurationProperties().Both the current dotted key format (
prefix.x) and the legacy non-dotted format (prefixx) are recognised, so files written by older versions of the framework load correctly.- Parameters:
properties- the source properties; may benull
-
getConfigurationProperties
Capture this view's current state into aPropertiesobject.Keys use the dotted format:
prefix.x,prefix.y,prefix.w,prefix.h,prefix.visible,prefix.maximized. The prefix isgetPropertyName().- Returns:
- a non-null properties object containing this view's state
-
getProperties
Returns the properties that were used to construct this view.- Returns:
- the construction-time properties; never
null
-
checkBooleanProperty
Read a boolean property from this view's internal properties.- Parameters:
key- the property key- Returns:
- the value, or
falseif absent or unparseable
-
setBooleanProperty
Store a boolean property in this view's internal properties.- Parameters:
key- the property keyval- the value
-
getIntProperty
Read an integer property from this view's internal properties.- Parameters:
key- the property key- Returns:
- the value, or
-1if absent or unparseable
-
setIntProperty
Store an integer property in this view's internal properties.- Parameters:
key- the property keyval- the value
-
focusGained
- Specified by:
focusGainedin interfaceFocusListener
-
focusLost
- Specified by:
focusLostin interfaceFocusListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
Close the magnify window when the mouse leaves any view canvas.- Specified by:
mouseExitedin interfaceMouseListener
-
componentHidden
- Specified by:
componentHiddenin interfaceComponentListener
-
componentShown
- Specified by:
componentShownin interfaceComponentListener
-
componentMoved
No-op: FlatLaf repaints correctly on move without explicit desktop repaint calls. Retained for API continuity.- Specified by:
componentMovedin interfaceComponentListener
-
componentResized
No-op: FlatLaf repaints correctly on resize. Retained for API continuity.- Specified by:
componentResizedin interfaceComponentListener
-
addWestPanel
Adds a component to theWESTslot of this view's content pane, expanding the frame width to accommodate it.Uses a double
invokeLaterto guarantee execution after all construction-timeinvokeLatercalls have been processed — includingBaseView's deferredsetVisibleandViewConfiguration's placement call. A singleinvokeLateris not sufficient because the placement work is itself queued at the same EDT level as a naive single defer.- Parameters:
panel- the component to place in the WEST slot; must not be null
-
getAnnotationLayer
Helper method to the the annotation layer from the container, if available.- Returns:
- the annotation layer, or null if no container or annotation layer is available
-
getConnectionLayer
Helper method to the get the connection layer from the container, if available.- Returns:
- the connection layer, or null if no container or connection layer is available
-
getDefaultLayer
Helper method to the get the default layer from the container, if available.- Returns:
- the default layer, or null if no container or default layer is available
-
setAfterDraw
Helper method to set the after-draw layer in the container, if available.- Parameters:
afterDraw- the drawable to set as the after-draw layer
-
setBeforeDraw
Helper method to set the before-draw layer in the container, if available.- Parameters:
beforeDraw- the drawable to set as the before-draw layer
-
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.
- Parameters:
he- the hover event
-
hoverClosed
Handle the closing (dismissal) of a hover popup/tooltip.Subclasses can override this method to respond when a hover previously reported via
hoverUpdate(edu.cnu.mdi.hover.HoverEvent)has ended. The default implementation is a no-op.- Parameters:
he- the hover event
-
getCenterComponent
Returns the Component currently in the CENTER position of the content pane,- Returns:
- The Component in the CENTER position, or null if empty or if the layout manager was changed from BorderLayout.
-