jmri.jmrit.display.controlPanelEditor
Class ControlPanelEditor

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.Editor
                              extended by jmri.jmrit.display.controlPanelEditor.ControlPanelEditor
All Implemented Interfaces:
ClipboardOwner, DropTargetListener, ActionListener, ComponentListener, KeyListener, MouseListener, MouseMotionListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, ModifiedFlag
Direct Known Subclasses:
CircuitBuilder

public class ControlPanelEditor
extends Editor
implements DropTargetListener, ClipboardOwner

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. Extends the behavior it shares with PanelPro DnD implemented at JDK 1.2 for backward compatibility

Author:
Pete Cressman Copyright: Copyright (c) 2009, 2010, 2011
See Also:
Serialized Form

Nested Class Summary
protected static class ControlPanelEditor.PositionableListDnD
           
 
Nested classes/interfaces inherited from class jmri.jmrit.display.Editor
Editor.JFrameItem, Editor.TargetPane
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 boolean _debug
           
protected  JMenu _editMenu
           
protected  JMenu _fileMenu
           
protected  JMenu _iconMenu
           
protected  JMenuBar _menuBar
           
protected  JMenu _optionMenu
           
protected  JMenu _zoomMenu
           
static String POSITIONABLE_LIST_FLAVOR
           
static ResourceBundle rbcp
           
 
Fields inherited from class jmri.jmrit.display.Editor
_anchorX, _anchorY, _contents, _currentSelection, _dragging, _editable, _highlightcomponent, _lastX, _lastY, _paintScale, _pastePending, _scrollState, _selectionGroup, _selectRect, _targetPanel, BKG, CLOCK, defaultBackgroundColor, frameLocationX, frameLocationY, ICON_EDITORS, ICONS, LABELS, LIGHTS, MARKERS, MEMORIES, NUM_LEVELS, OPTION_CONTROLS, OPTION_HIDDEN, OPTION_POSITION, OPTION_TOOLTIP, POSITIONABLE_FLAVOR, rb, rbean, REPORTERS, SCROLL_BOTH, SCROLL_HORIZONTAL, SCROLL_NONE, SCROLL_VERTICAL, SECURITY, SENSORS, SIGNALS, TEMP, TURNOUTS, xLoc, yLoc
 
Fields inherited from class jmri.util.JmriJFrame
reuseFrameSavedPosition, reuseFrameSavedSized
 
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
ControlPanelEditor()
           
ControlPanelEditor(String name)
           
 
Method Summary
protected  void copyItem(Positionable p)
          Set up selections for a paste.
 void dragEnter(DropTargetDragEvent evt)
           
 void dragExit(DropTargetEvent evt)
          DropTargetListener
 void dragOver(DropTargetDragEvent evt)
           
 void drop(DropTargetDropEvent evt)
           
 void dropActionChanged(DropTargetDragEvent evt)
           
 ArrayList<Positionable> getClipGroup()
           
protected  Positionable getCopySelection(MouseEvent event)
           
protected  Positionable getCurrentSelection(MouseEvent event)
          Overriden methods of Editor
protected  void init(String name)
           
 void initView()
          After construction, initialize all the widgets to their saved config settings.
 void loadComplete()
           
 void lostOwnership(Clipboard clipboard, Transferable contents)
           
protected  void makeDataFlavors()
          DnD
protected  void makeEditMenu()
          Create an Edit menu to support cut/copy/paste.
protected  void makeIconMenu()
           
protected  void makeOptionMenu()
           
 void makePalette()
           
protected  void makeZoomMenu()
           
 void mouseClicked(MouseEvent event)
           
 void mouseDragged(MouseEvent event)
           
 void mouseEntered(MouseEvent event)
           
 void mouseExited(MouseEvent event)
           
 void mouseMoved(MouseEvent event)
           
 void mousePressed(MouseEvent event)
          Abstract Methods
 void mouseReleased(MouseEvent event)
           
protected  void paintTargetPanel(Graphics g)
          Called from TargetPanel's paint method for additional drawing by editor view
 void setAllEditable(boolean edit)
          Control whether target panel items are editable.
 void setCopyMenu(Positionable p, JPopupMenu popup)
          Add an action to copy the Positionable item and the group to which is may belong.
 void setNextLocation(Positionable obj)
          Set an object's location when it is created.
 void setTitle()
           
 void setUseGlobalFlag(boolean set)
          Set which flag should be used, global or local for Positioning and Control of individual items.
protected  void showPopUp(Positionable p, MouseEvent event)
          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.
protected  void targetWindowClosingEvent(WindowEvent e)
          The target window has been requested to close, don't delete it at this time.
 
Methods inherited from class jmri.jmrit.display.Editor
actionPerformed, addBackgroundEditor, addClock, addIconEditor, addLabel, addLeftTOEditor, addLight, addLightEditor, addLocoIcon, addMemoryEditor, addMemoryInputBox, addMemorySpinner, addMultiSensor, addMultiSensorEditor, addReporter, addReporterEditor, addRightTOEditor, addRpsReporter, addSensorEditor, addSignalHeadEditor, addSignalMastEditor, addSlipTOEditor, addTextEditor, addToTarget, addTrainIcon, addTreeToEditors, addTurnout, alignGroup, allControlling, allPositionable, changeView, clearBackgroundColor, deletePanel, displayLevelChange, dispose, disposeLoadData, drawSelectRect, getAnchorX, getAnchorY, getBackgroundColor, getContents, getFlag, getIconEditor, getIconEditors, getIconFrame, getItemX, getItemY, getPaintScale, getPanelScrollPane, getScrollable, getSelectedItems, getSignalHeadEditor, getTargetFrame, getTargetPanel, getTargetPanelSize, isEditable, keyPressed, keyReleased, keyTyped, loadFailed, loadFailed, loadOK, locoMarkerFromInput, locoMarkerFromRoster, makeAddIconFrame, makeSelectionGroup, modifySelectionGroup, moveItem, putIcon, putItem, putLocoIcon, putMemory, putSensor, putSignalHead, putSignalMast, removeFromContents, removeFromTarget, removeMarkers, removeSelections, selectLoco, setAllControlling, setAllPositionable, setAllShowTooltip, setAttributes, setBackgroundColor, setDefaultToolTip, setDisplayLevelMenu, setGlobalSetsLocalFlag, setHiddenMenu, setPaintScale, setPanelMenu, setPositionableMenu, setRemoveMenu, setScroll, setScroll, setSelectionsAttributes, setSelectionsHidden, setSelectionsPositionable, setSelectionsRotation, setSelectionsScale, setShowAlignmentMenu, setShowCoordinatesMenu, setShowHidden, setShowTooltipMenu, setTargetPanel, setTargetPanelSize, setTextAttributes, setToolTip, setUpBackground, showAlignPopup, showHidden, showTooltip, showToolTip, targetWindowClosing, useGlobalFlag
 
Methods inherited from class jmri.util.JmriJFrame
addHelpMenu, addNotify, componentHidden, componentMoved, componentResized, componentShown, dispose, generateWindowRef, getFrame, getFrameList, getMaximumSize, getModifiedFlag, getPreferredSize, getSavePosition, getSaveSize, getWindowFrameRef, handleModified, initComponents, markWindowModified, pack, setModifiedFlag, setSavePosition, setSaveSize, setShutDownTask, storeValues, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
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, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, 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, 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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

_debug

public boolean _debug

_menuBar

protected JMenuBar _menuBar

_editMenu

protected JMenu _editMenu

_fileMenu

protected JMenu _fileMenu

_optionMenu

protected JMenu _optionMenu

_iconMenu

protected JMenu _iconMenu

_zoomMenu

protected JMenu _zoomMenu

rbcp

public static final ResourceBundle rbcp

POSITIONABLE_LIST_FLAVOR

public static final String POSITIONABLE_LIST_FLAVOR
See Also:
Constant Field Values
Constructor Detail

ControlPanelEditor

public ControlPanelEditor()

ControlPanelEditor

public ControlPanelEditor(String name)
Method Detail

init

protected void init(String name)
Specified by:
init in class Editor

makeIconMenu

protected void makeIconMenu()

makeZoomMenu

protected void makeZoomMenu()

makeOptionMenu

protected void makeOptionMenu()

makeEditMenu

protected void makeEditMenu()
Create an Edit menu to support cut/copy/paste. An incredible hack to get some semblance of CCP between panels. The hack works for one of two problems. 1. Invoking a copy to the system clipboard causes a delayed repaint placed on the EventQueue whenever ScrollBars are invoked. This repaint ends with a null pointer exception at javax.swing.plaf.basic.BasicScrollPaneUI.paint(BasicScrollPaneUI.java:90) This error occurs regardless of the method used to put the copy in the clipboard - JDK 1.2 style or 1.4 TransferHandler Fixed! Get the plaf glue (BasicScrollPaneUI) and call installUI(_panelScrollPane) See copyToClipboard() below, line 527 (something the Java code should have done) No scrollbars - no problem. Hack does not fix this problem. 2. The clipboard provides a shallow copy of what was placed there. For things that have an icon Map (ArrayLists) the Tranferable data is shallow. The Hack to work around this is: Place a reference to the panel copying to the clipboad in the clipboard and let the pasting panel callback to the copying panel to get the data. See public ArrayList getClipGroup() {} below.


getClipGroup

public ArrayList<Positionable> getClipGroup()

lostOwnership

public void lostOwnership(Clipboard clipboard,
                          Transferable contents)
Specified by:
lostOwnership in interface ClipboardOwner

setAllEditable

public void setAllEditable(boolean edit)
Description copied from class: Editor
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).

Overrides:
setAllEditable in class Editor
Parameters:
edit - true for editable.

setUseGlobalFlag

public void setUseGlobalFlag(boolean set)
Description copied from class: Editor
Set which flag should be used, global or local for Positioning and Control of individual items. Items call getFlag() to return the appropriate flag it should use.

Overrides:
setUseGlobalFlag in class Editor

setTitle

public void setTitle()
Overrides:
setTitle in class Editor

makePalette

public void makePalette()
Overrides:
makePalette in class Editor

loadComplete

public void loadComplete()

initView

public void initView()
After construction, initialize all the widgets to their saved config settings.

Specified by:
initView in class Editor

getCurrentSelection

protected Positionable getCurrentSelection(MouseEvent event)
Overriden methods of Editor


getCopySelection

protected Positionable getCopySelection(MouseEvent event)

mousePressed

public void mousePressed(MouseEvent event)
Description copied from class: Editor
Abstract Methods

Specified by:
mousePressed in interface MouseListener
Specified by:
mousePressed in class Editor

mouseReleased

public void mouseReleased(MouseEvent event)
Specified by:
mouseReleased in interface MouseListener
Specified by:
mouseReleased in class Editor

mouseClicked

public void mouseClicked(MouseEvent event)
Specified by:
mouseClicked in interface MouseListener
Specified by:
mouseClicked in class Editor

mouseDragged

public void mouseDragged(MouseEvent event)
Specified by:
mouseDragged in interface MouseMotionListener
Specified by:
mouseDragged in class Editor

mouseMoved

public void mouseMoved(MouseEvent event)
Specified by:
mouseMoved in interface MouseMotionListener
Specified by:
mouseMoved in class Editor

mouseEntered

public void mouseEntered(MouseEvent event)
Specified by:
mouseEntered in interface MouseListener
Specified by:
mouseEntered in class Editor

mouseExited

public void mouseExited(MouseEvent event)
Specified by:
mouseExited in interface MouseListener
Specified by:
mouseExited in class Editor

targetWindowClosingEvent

protected void targetWindowClosingEvent(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 class Editor

paintTargetPanel

protected void paintTargetPanel(Graphics g)
Description copied from class: Editor
Called from TargetPanel's paint method for additional drawing by editor view

Specified by:
paintTargetPanel in class Editor

setNextLocation

public void setNextLocation(Positionable obj)
Set an object's location when it is created.

Specified by:
setNextLocation in class Editor

copyItem

protected void copyItem(Positionable p)
Set up selections for a paste. Note a copy of _selectionGroup is made that is NOT in the _contents. This disconnected ArrayList is added to the _contents when (if) a paste is made. The disconnected _selectionGroup can be dragged to a new location.

Specified by:
copyItem in class Editor

setCopyMenu

public void setCopyMenu(Positionable p,
                        JPopupMenu popup)
Add an action to copy the Positionable item and the group to which is may belong.


showPopUp

protected void showPopUp(Positionable p,
                         MouseEvent event)
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.

Specified by:
showPopUp in class Editor

makeDataFlavors

protected void makeDataFlavors()
DnD


dragExit

public void dragExit(DropTargetEvent evt)
DropTargetListener

Specified by:
dragExit in interface DropTargetListener

dragEnter

public void dragEnter(DropTargetDragEvent evt)
Specified by:
dragEnter in interface DropTargetListener

dragOver

public void dragOver(DropTargetDragEvent evt)
Specified by:
dragOver in interface DropTargetListener

dropActionChanged

public void dropActionChanged(DropTargetDragEvent evt)
Specified by:
dropActionChanged in interface DropTargetListener

drop

public void drop(DropTargetDropEvent evt)
Specified by:
drop in interface DropTargetListener


Copyright © 1997 - 2011 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: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads