Class PlotView
- All Implemented Interfaces:
IFeedbackProvider,IFileDropHandler,ComponentListener,FocusListener,MouseListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
PlotView hosts a CardLayout deck with two cards:
CARD_PLOT— the standardPlotPanel/PlotCanvasrendering.CARD_HISTO2D— an optional 2-D histogram panel, enabled only when the loaded data contains aHisto2Ddataset.
File drag-and-drop
Drop support for .plot.json and .splot.json files is
activated in the constructor via
BaseView.enableFileDrop(java.util.function.Predicate).
Subclasses that need to accept additional file types should call
enableFileDrop with a broader predicate and extend
filesDropped(java.util.List<java.io.File>) accordingly.
Plot lifecycle
All panel swaps (open, drag-and-drop, external programmatic switch) flow
through setPlotPanel(edu.cnu.mdi.splot.plot.PlotPanel), which is the single choke-point responsible
for keeping the canvas reference, the edit menu, and the View menu
in sync.
- 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 PlotCanvasprotected PlotPanelstatic final Stringstatic final StringFields 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 final PlotPanelcreateDecoratedPlotPanel(PlotCanvas canvas) Create a panel using this view's configured feedback policy.voidfilesDropped(List<File> files) Handle plot files dropped on this view through drag-and-drop.The component that best represents this view as a static image, for screenshot/clipboard capture (seeTakePicture).Get the plot canvasGet an information object describing this view, used in the UI and for help.voidToggles between the Plot and Histo2D cards.voidswitchToPlotPanel(PlotPanel plotPanel) Switch to a different plot panel (and its canvas)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, getFeedbackStrings, getFileFilter, getIContainer, getInfoButton, getInsets, getIntProperty, getName, getParentFrame, getProperties, getPropertyName, getScrollPane, getSpecialClip, getToolBar, getViewPopupMenu, getVirtualItem, handleMagnify, hoverClosed, hoverUpdate, initFeedback, initFeedback, isOnTop, isScrollable, isViewVisible, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, offset, onFirstRealize, prepareForExit, 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
-
CARD_PLOT
- See Also:
-
CARD_HISTO2D
- See Also:
-
_plotCanvas
-
_plotPanel
-
-
Constructor Details
-
PlotView
public PlotView()Create aPlotViewwith the default title"sPlot". -
PlotView
Create aPlotViewfrom alternating key/value property pairs.The view is built in four steps:
- A
CardLayoutdeck is created holding the standard plot card (CARD_PLOT) and the 2-D histogram card (CARD_HISTO2D). - File drag-and-drop is enabled for
.plot.jsonand.splot.jsonfiles viaBaseView.enableFileDrop(Predicate). The handler is installed once on all appropriate surfaces (canvas, viewport, and frame); it does not need to be re-installed when the plot panel is replaced bysetPlotPanel(edu.cnu.mdi.splot.plot.PlotPanel). - Plot and edit menus are added to the menu bar.
- The View menu state is synchronised with the current panel's capabilities.
- Parameters:
keyVals- alternatingPropertyUtilskey/value pairs
- A
-
-
Method Details
-
getViewInfo
Get an information object describing this view, used in the UI and for help.- Overrides:
getViewInfoin classBaseView- 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).PlotView's title, legend, and axis labels live on
_plotPanel, not on the innerPlotCanvasthe container exposes, so the default (container-based) implementation would silently drop them. Returns whichever card is currently showing, so a capture taken while the 2-D histogram card is visible captures that instead of the (hidden) plot.- Overrides:
getImageComponentin classBaseView- Returns:
- the component to capture as this view's image; the container's component if one is present, otherwise this view itself
-
showCard
Toggles between the Plot and Histo2D cards.- Parameters:
cardName- Use PlotView.CARD_PLOT or PlotView.CARD_HISTO2D
-
createDecoratedPlotPanel
Create a panel using this view's configured feedback policy. -
switchToPlotPanel
Switch to a different plot panel (and its canvas)- Parameters:
plotPanel- the new plot panel
-
getPlotCanvas
Get the plot canvas- Returns:
- th plot canvas
-
filesDropped
Handle plot files dropped on this view through drag-and-drop.Only the first file in the list is used; the filter set by
BaseView.enableFileDrop(Predicate)in the constructor already guarantees every entry ends with.plot.jsonor.splot.json, so no second format check is required here.The parent directory of the dropped file is remembered (see
FileDialogs.rememberDirectory(java.lang.String, java.nio.file.Path)) so that the next "Open" dialog opens in the same location.- Specified by:
filesDroppedin interfaceIFileDropHandler- Overrides:
filesDroppedin classBaseView- Parameters:
files- the accepted dropped files; nevernull, never empty
-