Class MultiplotPanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
- Direct Known Subclasses:
DiagnosticPlotPanel,GADiagnosticPlotPanel,PlotDeck
PlotPanels, showing exactly one at a time.
This component is intended for "diagnostic docks" in simulation views (e.g., a network decluttering view) where you want a small gallery of predefined plots rather than arbitrary user-loaded plots.
UI model
- A
Gallerymenu lists available plots; selecting an entry makes it active. - An optional
Filemenu providesSavefor the active plot. - The plot-specific
Edit Plotmenu (aSplotEditMenu) is rebuilt when the active plot changes.
Implementation notes
- Uses a
CardLayoutso plots are added once and then switched by card name, avoiding remove/add churn. - All UI mutations are executed on the Swing EDT. If a caller invokes methods from a non-EDT thread (e.g., a simulation thread), the work is safely marshaled to the EDT.
- The first plot added is automatically selected and displayed.
Threading
Public methods that mutate the UI will run on the EDT. If called off-EDT, they are
queued via SwingUtilities.invokeLater(Runnable).
- Author:
- heddle
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested 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
Fields 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, WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionMultiplotPanel(boolean includeFileMenu) Create a multi-plot panel.protectedMultiplotPanel(boolean includeFileMenu, boolean showSinglePlotGallery) Create a plot host with explicit single-plot Gallery behavior. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a plot panel to this multiplot panel.voidClear all data on all curves for all plots.Get the active plot panel, ornullif none.Returns the menu bar owned by this plot host.intvoidRemove all plots from this multiplot panel and show an empty placeholder.voidremovePlot(PlotPanel pp) Remove a plot panel from this multiplot panel.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, reshape, 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, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
MultiplotPanel
public MultiplotPanel(boolean includeFileMenu) Create a multi-plot panel.- Parameters:
includeFileMenu- if true, include aFilemenu withSave
-
MultiplotPanel
protected MultiplotPanel(boolean includeFileMenu, boolean showSinglePlotGallery) Create a plot host with explicit single-plot Gallery behavior.This overload is primarily useful to unified plot hosts such as
PlotDeck. Existing callers retain the historical behavior throughMultiplotPanel(boolean), which always displays Gallery.- Parameters:
includeFileMenu- if true, include aFilemenu withSaveshowSinglePlotGallery- if true, display Gallery even with zero or one registered plots; if false, display it only when at least two plots are available
-
-
Method Details
-
addPlot
Add a plot panel to this multiplot panel.The plot is registered in the Gallery menu and placed into the
CardLayout. If this is the first plot added, it becomes the active plot automatically.- Parameters:
title- title for the Gallery menu item (non-null)pp- the plot panel to add (non-null)
-
removePlot
Remove a plot panel from this multiplot panel.If the removed plot was active, another plot is selected if available; otherwise the panel becomes empty.
- Parameters:
pp- the plot panel to remove (non-null)
-
removeAllPlots
public void removeAllPlots()Remove all plots from this multiplot panel and show an empty placeholder.This removes the plots from the UI (it does not call
clearData()). -
clearAllPlots
public void clearAllPlots()Clear all data on all curves for all plots.Use with caution: this wipes the data from every plot canvas.
-
getActivePlotPanel
Get the active plot panel, ornullif none.- Returns:
- the active plot panel or null
-
getMenuBar
Returns the menu bar owned by this plot host.The returned component is live. It is exposed for embedding and inspection; callers should prefer the plot-host methods over directly removing MDI-managed menus.
- Returns:
- menu bar containing File, Gallery, and active-plot edit menus
-
getPlotCount
public int getPlotCount()- Returns:
- number of plots currently registered with this host
-