Class PanelEditor
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- javax.swing.JFrame
-
- jmri.util.JmriJFrame
-
- jmri.jmrit.display.JmriJFrameWithPermissions
-
- jmri.jmrit.display.Editor
-
- jmri.jmrit.display.panelEditor.PanelEditor
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.ComponentListener
,java.awt.event.ItemListener
,java.awt.event.KeyListener
,java.awt.event.WindowListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.beans.VetoableChangeListener
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
,javax.swing.RootPaneContainer
,javax.swing.WindowConstants
,BeanInterface
,ModifiedFlag
,JmriMouseListener
,JmriMouseMotionListener
,WindowInterface
- Direct Known Subclasses:
LayoutEditor
public class PanelEditor extends Editor implements java.awt.event.ItemListener
Provides a simple editor for adding jmri.jmrit.display items to a captive JFrame.GUI is structured as a band of common parameters across the top, then a series of things you can add.
All created objects are put specific levels depending on their type (higher levels are in front):
- BKG background
- ICONS icons and other drawing symbols
- LABELS text labels
- TURNOUTS turnouts and other variable track items
- SENSORS sensors and other independently modified objects
The "contents" List keeps track of all the objects added to the target frame for later manipulation.
If you close the Editor window, the target is left alone and the editor window is just hidden, not disposed. If you close the target, the editor and target are removed, and dispose is run. To make this logic work, the PanelEditor is descended from a JFrame, not a JPanel. That way it can control its own visibility.
The title of the target and the editor panel are kept consistent via the {#setTitle} method.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PanelEditor.ComboBoxItem
-
Nested classes/interfaces inherited from class jmri.jmrit.display.Editor
Editor.JFrameItem, Editor.TargetPane, Editor.UrlErrorDialog
-
Nested classes/interfaces inherited from class jmri.util.JmriJFrame
JmriJFrame.ScreenDimensions
-
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
-
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from interface jmri.util.swing.WindowInterface
WindowInterface.Hint
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<Positionable>
_multiItemCopyGroup
protected boolean
addItemViaMouseClick
protected boolean
pasteItemFlag
-
Fields inherited from class jmri.jmrit.display.Editor
_anchorX, _anchorY, _currentSelection, _dragging, _editable, _highlightcomponent, _iconEditorFrame, _lastX, _lastY, _paintScale, _pastePending, _scrollState, _selectionGroup, _selectRect, _targetPanel, BKG, BOTHPOPUPS, CLOCK, defaultBackgroundColor, EDITPOPUPONLY, frameLocationX, frameLocationY, HIGHLIGHT_COLOR, ICONS, LABELS, LIGHTS, MARKERS, MEMORIES, NUM_LEVELS, OPTION_CONTROLS, OPTION_HIDDEN, OPTION_POSITION, OPTION_TOOLTIP, POSITIONABLE_FLAVOR, REPORTERS, SCROLL_BOTH, SCROLL_HORIZONTAL, SCROLL_NONE, SCROLL_VERTICAL, SECURITY, SENSORS, SIGNALS, TEMP, TURNOUTS, VIEWPOPUPONLY, xLoc, yLoc
-
Fields inherited from class jmri.util.JmriJFrame
allowInFrameServlet, properties, reuseFrameSavedPosition, reuseFrameSavedSized, windowInterface
-
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
-
Constructor Summary
Constructors Constructor Description PanelEditor()
PanelEditor(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addItemPopUp(PanelEditor.ComboBoxItem item, javax.swing.JMenu menu)
protected void
backgroundPopUp(JmriMouseEvent event)
protected void
copyItem(Positionable p)
Set up item(s) to be copied by paste.protected void
init(java.lang.String name)
void
initView()
After construction, initialize all the widgets to their saved config settings.void
itemStateChanged(java.awt.event.ItemEvent e)
JmriJFrame
makeFrame(java.lang.String name)
Create sequence of panels, etc, for layout: JFrame contains its ContentPane which contains a JPanel with BoxLayout (p1) which contains a JScollPane (js) which contains the targetPane.void
mouseClicked(JmriMouseEvent event)
Invoked when the mouse button has been clicked (pressed and released) on a component.void
mouseDragged(JmriMouseEvent event)
Invoked when a mouse button is pressed on a component and then dragged.void
mouseEntered(JmriMouseEvent event)
Invoked when the mouse enters a component.void
mouseExited(JmriMouseEvent event)
Invoked when the mouse exits a component.void
mouseMoved(JmriMouseEvent event)
Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.void
mousePressed(JmriMouseEvent event)
Invoked when a mouse button has been pressed on a component.void
mouseReleased(JmriMouseEvent event)
Invoked when a mouse button has been released on a component.protected void
paintTargetPanel(java.awt.Graphics g)
Called from TargetPanel's paint method for additional drawing by editor viewprotected void
pasteItem(JmriMouseEvent e)
protected void
pasteItemPopUp(JmriMouseEvent event)
void
putItem(Positionable l)
void
setBackgroundMenu(javax.swing.JPopupMenu popup)
protected void
setNextLocation(Positionable obj)
Set an object's location when it is created.void
setRemoveMenu(Positionable p, javax.swing.JPopupMenu popup)
Add an action to remove the Positionable item.protected void
showAddItemPopUp(JmriMouseEvent event, javax.swing.JPopupMenu popup)
protected void
showMultiSelectPopUp(JmriMouseEvent event, Positionable p)
protected void
showPopUp(Positionable p, JmriMouseEvent event, java.util.List<Positionable> selections)
Create popup for a Positionable object.protected void
targetWindowClosingEvent(java.awt.event.WindowEvent e)
The target window has been requested to close, don't delete it at this time.void
windowClosing(java.awt.event.WindowEvent e)
Handle close of editor window.-
Methods inherited from class jmri.jmrit.display.Editor
actionPerformed, addAudioEditor, addBackgroundEditor, addBlockContentsEditor, addClock, addGlobalVariableEditor, addGlobalVariableInputBox, addGlobalVariableSpinner, addIconEditor, addLabel, addLeftTOEditor, addLight, addLightEditor, addLocoIcon, addLogixNGEditor, addMemoryEditor, addMemoryInputBox, addMemorySpinner, addMultiSensor, addMultiSensorEditor, addReporter, addReporterEditor, addRightTOEditor, addRpsReporter, addSensorEditor, addSignalHeadEditor, addSignalMastEditor, addSlipTOEditor, addTextEditor, addToPopUpMenu, addToTarget, addTrainIcon, addTurnout, allControlling, allPositionable, changeView, clearBackgroundColor, deletePanel, deselectSelectionGroup, displayLevelChange, dispose, disposeLoadData, dockSelections, drawSelectRect, getAnchorX, getAnchorY, getBackgroundColor, getClassNames, getContents, getFlag, getIconEditor, getIconFrame, getIdContents, getItemX, getItemY, getLastX, getLastY, getPaintScale, getPanelScrollPane, getPositionablesByClassName, getScrollable, getSelectedItems, getSelectRect, getSignalHeadEditor, getTargetFrame, getTargetPanel, getTargetPanelSize, getUsageReport, isEditable, isPanelMenuVisible, keyPressed, keyReleased, keyTyped, loadFailed, loadFailed, loadOK, locoMarkerFromInput, locoMarkerFromRoster, makeAddIconFrame, makeSelectionGroup, modifySelectionGroup, moveItem, newPanelDefaults, positionalAddClass, positionalIdChange, positionalRemoveClass, putAudio, putBlockContents, putGlobalVariable, putIcon, putLocoIcon, putLogixNG, putMemory, putSensor, putSignalHead, putSignalMast, removeFromContents, removeFromTarget, removeMarkers, removeSelections, selectLoco, selectLoco, setAllControlling, setAllEditable, setAllPositionable, setAllShowToolTip, setAttributes, setBackgroundColor, setDefaultToolTip, setDisplayLevelMenu, setEditClassesMenu, setEditIdMenu, setEmptyHiddenMenu, setGlobalSetsLocalFlag, setHiddenMenu, setLogixNGPositionableMenu, setPaintScale, setPanelMenuVisible, setPositionableMenu, setScroll, setScroll, setSelectionsAttributes, setSelectionsDisplayLevel, setSelectionsDockingLocation, setSelectionsHidden, setSelectionsPositionable, setSelectionsRotation, setSelectionsScale, setShowAlignmentMenu, setShowCoordinatesMenu, setShowHidden, setShowToolTipMenu, setTargetPanel, setTargetPanelSize, setTitle, setToolTip, setUpBackground, setUseGlobalFlag, setValueEditDisabledMenu, showAlignPopup, showHidden, showToolTip, showToolTip, targetWindowClosing, useGlobalFlag, vetoableChange
-
Methods inherited from class jmri.jmrit.display.JmriJFrameWithPermissions
getContentPane, getJMenuBar, revalidate, setContentPane, setJMenuBar, setKeepSize, setVisible
-
Methods inherited from class jmri.util.JmriJFrame
addHelpMenu, componentHidden, componentMoved, componentResized, componentShown, generateWindowRef, getAllowInFrameServlet, getEscapeKeyAction, getEscapeKeyClosesWindow, getFrame, getFrame, getFrameList, getFrameList, getIndexedProperty, getMaximumSize, getModifiedFlag, getPreferredSize, getProperty, getPropertyNames, getSavePosition, getSaveSize, getScreenDimensions, getWindowFrameRef, getWindowInterface, handleModified, hasIndexedProperty, hasProperty, initComponents, makePrivateWindow, markWindowModified, multipleInstances, pack, setAllowInFrameServlet, setEscapeKeyAction, setEscapeKeyClosesWindow, setFrameLocation, setIndexedProperty, setModifiedFlag, setProperty, setSavePosition, setSaveSize, setShutDownTask, setWindowInterface, show, show, storeValues, undecorate, windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getDefaultCloseOperation, getGlassPane, getGraphics, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
_multiItemCopyGroup
protected java.util.ArrayList<Positionable> _multiItemCopyGroup
-
addItemViaMouseClick
protected boolean addItemViaMouseClick
-
pasteItemFlag
protected boolean pasteItemFlag
-
-
Constructor Detail
-
PanelEditor
public PanelEditor()
-
PanelEditor
public PanelEditor(java.lang.String name)
-
-
Method Detail
-
initView
public void initView()
After construction, initialize all the widgets to their saved config settings.
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)
- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
-
windowClosing
public void windowClosing(java.awt.event.WindowEvent e)
Handle close of editor window.Overload/override method in JmriJFrame parent, which by default is permanently closing the window. Here, we just want to make it invisible, so we don't dispose it (yet).
- Specified by:
windowClosing
in interfacejava.awt.event.WindowListener
- Overrides:
windowClosing
in classJmriJFrame
-
makeFrame
public JmriJFrame makeFrame(java.lang.String name)
Create sequence of panels, etc, for layout: JFrame contains its ContentPane which contains a JPanel with BoxLayout (p1) which contains a JScollPane (js) which contains the targetPane.- Parameters:
name
- the frame name.- Returns:
- the frame.
-
targetWindowClosingEvent
protected void targetWindowClosingEvent(java.awt.event.WindowEvent e)
The target window has been requested to close, don't delete it at this time. Deletion must be accomplished via the Delete this panel menu item.- Specified by:
targetWindowClosingEvent
in classEditor
-
paintTargetPanel
protected void paintTargetPanel(java.awt.Graphics g)
Called from TargetPanel's paint method for additional drawing by editor view- Specified by:
paintTargetPanel
in classEditor
- Parameters:
g
- the context to paint within
-
setNextLocation
protected void setNextLocation(Positionable obj)
Set an object's location when it is created.- Specified by:
setNextLocation
in classEditor
- Parameters:
obj
- the object to locate
-
showPopUp
protected void showPopUp(Positionable p, JmriMouseEvent event, java.util.List<Positionable> selections)
Create popup for a Positionable object. Popup items common to all positionable objects are done before and after the items that pertain only to specific Positionable types.- Parameters:
p
- the item containing or requiring the context menuevent
- the event triggering the menuselections
- the list of all Positionables at this position
-
mousePressed
public void mousePressed(JmriMouseEvent event)
Description copied from interface:JmriMouseListener
Invoked when a mouse button has been pressed on a component.- Specified by:
mousePressed
in interfaceJmriMouseListener
- Specified by:
mousePressed
in classEditor
- Parameters:
event
- the event to be processed
-
mouseReleased
public void mouseReleased(JmriMouseEvent event)
Description copied from interface:JmriMouseListener
Invoked when a mouse button has been released on a component.- Specified by:
mouseReleased
in interfaceJmriMouseListener
- Specified by:
mouseReleased
in classEditor
- Parameters:
event
- the event to be processed
-
mouseDragged
public void mouseDragged(JmriMouseEvent event)
Description copied from interface:JmriMouseMotionListener
Invoked when a mouse button is pressed on a component and then dragged.MOUSE_DRAGGED
events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).Due to platform-dependent Drag&Drop implementations,
MOUSE_DRAGGED
events may not be delivered during a native Drag&Drop operation.- Specified by:
mouseDragged
in interfaceJmriMouseMotionListener
- Specified by:
mouseDragged
in classEditor
- Parameters:
event
- the event to be processed
-
mouseMoved
public void mouseMoved(JmriMouseEvent event)
Description copied from interface:JmriMouseMotionListener
Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.- Specified by:
mouseMoved
in interfaceJmriMouseMotionListener
- Specified by:
mouseMoved
in classEditor
- Parameters:
event
- the event to be processed
-
mouseClicked
public void mouseClicked(JmriMouseEvent event)
Description copied from interface:JmriMouseListener
Invoked when the mouse button has been clicked (pressed and released) on a component.- Specified by:
mouseClicked
in interfaceJmriMouseListener
- Specified by:
mouseClicked
in classEditor
- Parameters:
event
- the event to be processed
-
mouseEntered
public void mouseEntered(JmriMouseEvent event)
Description copied from interface:JmriMouseListener
Invoked when the mouse enters a component.- Specified by:
mouseEntered
in interfaceJmriMouseListener
- Specified by:
mouseEntered
in classEditor
- Parameters:
event
- the event to be processed
-
mouseExited
public void mouseExited(JmriMouseEvent event)
Description copied from interface:JmriMouseListener
Invoked when the mouse exits a component.- Specified by:
mouseExited
in interfaceJmriMouseListener
- Specified by:
mouseExited
in classEditor
- Parameters:
event
- the event to be processed
-
copyItem
protected void copyItem(Positionable p)
Description copied from class:Editor
Set up item(s) to be copied by paste.
-
pasteItemPopUp
protected void pasteItemPopUp(JmriMouseEvent event)
-
backgroundPopUp
protected void backgroundPopUp(JmriMouseEvent event)
-
showMultiSelectPopUp
protected void showMultiSelectPopUp(JmriMouseEvent event, Positionable p)
-
showAddItemPopUp
protected void showAddItemPopUp(JmriMouseEvent event, javax.swing.JPopupMenu popup)
-
addItemPopUp
protected void addItemPopUp(PanelEditor.ComboBoxItem item, javax.swing.JMenu menu)
-
putItem
public void putItem(Positionable l) throws Positionable.DuplicateIdException
- Overrides:
putItem
in classEditor
- Throws:
Positionable.DuplicateIdException
-
pasteItem
protected void pasteItem(JmriMouseEvent e)
-
setRemoveMenu
public void setRemoveMenu(Positionable p, javax.swing.JPopupMenu popup)
Add an action to remove the Positionable item.- Overrides:
setRemoveMenu
in classEditor
- Parameters:
p
- the item to set the menu forpopup
- the menu to add for p
-
setBackgroundMenu
public void setBackgroundMenu(javax.swing.JPopupMenu popup)
-
-