jmri.jmrit.display
Class PanelEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by jmri.util.JmriJFrame
                          extended by jmri.jmrit.display.PanelEditor
All Implemented Interfaces:
WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, ModifiedFlag

public class PanelEditor
extends JmriJFrame

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):

Note that higher numbers appear behind lower numbers.

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.

Author:
Bob Jacobsen Copyright: Copyright (c) 2002, 2003, 2007, Dennis Miller 2004, Howard G. Penny Copyright: Copyright (c) 2005
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static Integer BKG
           
static Integer CLOCK
           
 ArrayList contents
           
static Integer ICONS
           
static Integer LABELS
           
static Integer MARKERS
           
static Integer MEMORIES
           
static Integer REPORTERS
           
static Integer SECURITY
           
static Integer SENSORS
           
static Integer SIGNALS
           
 JLayeredPane target
           
static Integer TURNOUTS
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
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
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PanelEditor()
           
PanelEditor(String name)
           
 
Method Summary
 LocoIcon addLocoIcon(String name)
           
 void addMultiSensor(MultiSensorIcon l)
           
 void deletePanel()
          Invoked by DeletePanel menu item Validate user intent before deleting
 void dispose()
          Clean up when its time to make it all go away
 JFrame getFrame()
          Get the frame containing the resulting panel (not the editor)
 JLayeredPane getTarget()
           
 boolean hasPanelMenu()
           
 boolean isControlling()
           
 boolean isEditable()
           
 boolean isPositionable()
           
 boolean isShowCoordinates()
           
 JmriJFrame makeFrame(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 putClock(AnalogClock2Display c)
           
 void putLabel(PositionableLabel l)
           
 void putLocoIcon(LocoIcon l)
           
 void putMultiSensor(MultiSensorIcon l)
           
 void putSensor(SensorIcon l)
           
 void putSignal(SignalHeadIcon l)
           
 void putTurnout(TurnoutIcon l)
           
 void setAllControlling(boolean state)
          Control whether target panel items are controlling layout items.
 void setAllEditable(boolean state)
          Control whether target panel items are editable.
 void setAllPositionable(boolean state)
          Control whether target panel items are positionable.
 void setFrame(JFrame f)
          Set the frame containing the resulting panel (not the editor).
 void setPanelMenu(boolean state)
          Control whether target panel shows a menu
 void setShowCoordinates(boolean state)
          Control whether target panel items will show their coordinates in their popup memu.
 void setTarget(JLayeredPane f)
          Set the JLayeredPane containing the objects to be edited.
 void setTitle()
           
 void windowClosing(WindowEvent e)
          Handle close of editor window.
 
Methods inherited from class jmri.util.JmriJFrame
addHelpMenu, addNotify, getFrame, getFrameList, getMaximumSize, getModifiedFlag, getPreferredSize, handleModified, initComponents, markWindowModified, setModifiedFlag, setShutDownTask, storeValues, windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, 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, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

BKG

public static final Integer BKG

ICONS

public static final Integer ICONS

LABELS

public static final Integer LABELS

MEMORIES

public static final Integer MEMORIES

REPORTERS

public static final Integer REPORTERS

SECURITY

public static final Integer SECURITY

TURNOUTS

public static final Integer TURNOUTS

SIGNALS

public static final Integer SIGNALS

SENSORS

public static final Integer SENSORS

CLOCK

public static final Integer CLOCK

MARKERS

public static final Integer MARKERS

target

public JLayeredPane target

contents

public ArrayList contents
Constructor Detail

PanelEditor

public PanelEditor()

PanelEditor

public PanelEditor(String name)
Method Detail

putTurnout

public void putTurnout(TurnoutIcon l)

addLocoIcon

public LocoIcon addLocoIcon(String name)

putLocoIcon

public void putLocoIcon(LocoIcon l)

putSensor

public void putSensor(SensorIcon l)

addMultiSensor

public void addMultiSensor(MultiSensorIcon l)

putMultiSensor

public void putMultiSensor(MultiSensorIcon l)

putSignal

public void putSignal(SignalHeadIcon l)

putClock

public void putClock(AnalogClock2Display c)

putLabel

public void putLabel(PositionableLabel l)

setTarget

public void setTarget(JLayeredPane f)
Set the JLayeredPane containing the objects to be edited.


getTarget

public JLayeredPane getTarget()

getFrame

public JFrame getFrame()
Get the frame containing the resulting panel (not the editor)


setFrame

public void setFrame(JFrame f)
Set the frame containing the resulting panel (not the editor). This should only be invoked once; there is no support for attaching an editor to a different frame once it's established.


deletePanel

public void deletePanel()
Invoked by DeletePanel menu item Validate user intent before deleting


dispose

public void dispose()
Clean up when its time to make it all go away

Overrides:
dispose in class JmriJFrame

windowClosing

public void windowClosing(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 interface WindowListener
Overrides:
windowClosing in class JmriJFrame

setTitle

public void setTitle()

setAllPositionable

public void setAllPositionable(boolean state)
Control whether target panel items are positionable. Does this by invoke the Positionable.setPositionable(boolean) function of each item on the target panel.

Parameters:
state - true for positionable.

setAllEditable

public void setAllEditable(boolean state)
Control whether target panel items are editable. Does this by invoke the Positionable.setEditable(boolean) function of each item on the target panel. This also controls the relevant pop-up menu items (which are the primary way that items are edited).

Parameters:
state - true for editable.

setShowCoordinates

public void setShowCoordinates(boolean state)
Control whether target panel items will show their coordinates in their popup memu.

Parameters:
state - true for show coodinates.

setAllControlling

public void setAllControlling(boolean state)
Control whether target panel items are controlling layout items. Does this by invoke the Positionable.setControlling(boolean) function of each item on the target panel. This also controls the relevant pop-up menu items.

Parameters:
state - true for controlling.

setPanelMenu

public void setPanelMenu(boolean state)
Control whether target panel shows a menu

Parameters:
state - true for controlling.

isEditable

public boolean isEditable()

isPositionable

public boolean isPositionable()

isShowCoordinates

public boolean isShowCoordinates()

isControlling

public boolean isControlling()

hasPanelMenu

public boolean hasPanelMenu()

makeFrame

public JmriJFrame makeFrame(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



Copyright © 1997 - 2008 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: SourceForge_Logo