|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
jmri.util.JmriJFrame
jmri.jmrit.display.Editor
public abstract class Editor
This is the Model and a Controller for panel editor Views. (Panel Editor, Layout Editor or any subsequent editors) The Model is simply a list of Positionable objects added to a "target panel". Control of the display attributes of the Positionable objects is done here. However, control of mouse events is passed to the editor views, so control is also done by the editor views.
The "contents" List keeps track of all the objects added to the target frame for later manipulation. This class only locates and moves "target panel" items, and does not control their appearance - that is left for the editor views.
The Editor has tri-state "flags" to control the display of Positionable object attributes globally - i.e. "on" or "off" for all - or as a third state, permits the display control "locally" by corresponding flags in each Positionable object
The title of the target and the editor panel are kept consistent via the {#setTitle} method.
Mouse events are initially handled here, rather than in the individual displayed objects, so that selection boxes for moving multiple objects can be provided.
This class also implements an effective ToolTipManager replacement, because the standard Swing one can't deal with the coordinate changes used to zoom a panel. It works by controlling the contents of the _tooltip instance variable, and triggering repaint of the target window when the tooltip changes. The window painting then explicitly draws the tooltip for the underlying object.
| Nested Class Summary | |
|---|---|
static class |
Editor.JFrameItem
|
class |
Editor.TargetPane
Special internal class to allow drawing of layout to a JLayeredPane This is the 'target' pane where the layout is displayed |
| 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 | |
|---|---|
protected int |
_anchorX
|
protected int |
_anchorY
|
protected ArrayList<Positionable> |
_contents
|
protected Positionable |
_currentSelection
|
protected boolean |
_dragging
|
protected boolean |
_editable
|
protected Rectangle |
_highlightcomponent
|
protected int |
_lastX
|
protected int |
_lastY
|
protected double |
_paintScale
|
protected boolean |
_pastePending
|
protected int |
_scrollState
|
protected ArrayList<Positionable> |
_selectionGroup
|
protected Rectangle |
_selectRect
|
protected JLayeredPane |
_targetPanel
|
static int |
BKG
|
static int |
CLOCK
|
protected Color |
defaultBackgroundColor
|
int |
frameLocationX
|
int |
frameLocationY
|
static String[] |
ICON_EDITORS
Icon editors for adding content |
static int |
ICONS
|
static int |
LABELS
|
static int |
LIGHTS
|
static int |
MARKERS
|
static int |
MEMORIES
|
static int |
NUM_LEVELS
|
static int |
OPTION_CONTROLS
|
static int |
OPTION_HIDDEN
|
static int |
OPTION_POSITION
|
static int |
OPTION_TOOLTIP
|
static String |
POSITIONABLE_FLAVOR
|
static ResourceBundle |
rb
|
static ResourceBundle |
rbean
|
static int |
REPORTERS
|
static int |
SCROLL_BOTH
|
static int |
SCROLL_HORIZONTAL
|
static int |
SCROLL_NONE
|
static int |
SCROLL_VERTICAL
|
static int |
SECURITY
|
static int |
SENSORS
|
static int |
SIGNALS
|
static int |
TEMP
|
static int |
TURNOUTS
|
protected int |
xLoc
|
protected int |
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 | |
|---|---|
Editor()
|
|
Editor(String name)
|
|
| Method Summary | |
|---|---|
void |
actionPerformed(ActionEvent event)
Wait TOOLTIPSHOWDELAY then show tooltip. |
protected void |
addBackgroundEditor()
|
protected void |
addClock()
|
protected void |
addIconEditor()
|
protected PositionableLabel |
addLabel(String text)
|
protected void |
addLeftTOEditor()
|
protected LightIcon |
addLight()
Add a Light indicator to the target |
protected void |
addLightEditor()
|
LocoIcon |
addLocoIcon(String name)
|
protected void |
addMemoryEditor()
|
protected MemoryInputIcon |
addMemoryInputBox()
|
protected MemorySpinnerIcon |
addMemorySpinner()
|
MultiSensorIcon |
addMultiSensor()
|
protected Editor.JFrameItem |
addMultiSensorEditor()
|
protected ReporterIcon |
addReporter()
|
protected void |
addReporterEditor()
|
protected void |
addRightTOEditor()
|
protected void |
addRpsReporter()
|
protected void |
addSensorEditor()
|
protected void |
addSignalHeadEditor()
|
protected void |
addSignalMastEditor()
|
protected void |
addSlipTOEditor()
|
protected void |
addTextEditor()
Add a label to the target |
protected void |
addToTarget(Positionable l)
|
TrainIcon |
addTrainIcon(String name)
|
void |
addTreeToEditors(CatalogTree tree)
Called by ImageIndexEditor after it has stored new image files and new default icons. |
protected TurnoutIcon |
addTurnout(IconAdder editor)
|
protected void |
alignGroup(boolean alignX)
|
boolean |
allControlling()
|
boolean |
allPositionable()
|
protected Editor |
changeView(String className)
|
void |
clearBackgroundColor()
|
protected abstract void |
copyItem(Positionable p)
set up item(s) to be copied by paste |
boolean |
deletePanel()
On return of 'true', caller should call dispose() |
void |
displayLevelChange(Positionable l)
|
void |
dispose(boolean clear)
|
void |
disposeLoadData()
|
protected void |
drawSelectRect(int x,
int y)
|
int |
getAnchorX()
|
int |
getAnchorY()
|
Color |
getBackgroundColor()
|
List<Positionable> |
getContents()
|
boolean |
getFlag(int whichOption,
boolean localFlag)
|
IconAdder |
getIconEditor(String name)
|
List<IconAdder> |
getIconEditors()
Icon Editors utils |
Editor.JFrameItem |
getIconFrame(String name)
|
protected int |
getItemX(Positionable p,
int deltaX)
|
protected int |
getItemY(Positionable p,
int deltaY)
|
double |
getPaintScale()
Get/Set scale for TargetPane drawing |
protected JScrollPane |
getPanelScrollPane()
|
String |
getScrollable()
|
protected List<Positionable> |
getSelectedItems(MouseEvent event)
Return a List of all items whose bounding rectangle contain the mouse position. |
protected IconAdder |
getSignalHeadEditor()
|
JFrame |
getTargetFrame()
|
JComponent |
getTargetPanel()
|
protected Dimension |
getTargetPanelSize()
|
protected abstract void |
init(String name)
|
abstract void |
initView()
After construction, initialize all the widgets to their saved config settings. |
boolean |
isEditable()
|
void |
keyPressed(KeyEvent e)
|
void |
keyReleased(KeyEvent e)
|
void |
keyTyped(KeyEvent e)
|
void |
loadFailed()
|
NamedIcon |
loadFailed(String msg,
String url)
|
boolean |
loadOK()
|
protected void |
locoMarkerFromInput()
|
protected void |
locoMarkerFromRoster()
Marker Menu |
protected Editor.JFrameItem |
makeAddIconFrame(String name,
boolean add,
boolean table,
IconAdder editor)
|
void |
makePalette()
|
protected void |
makeSelectionGroup(MouseEvent event)
|
protected void |
modifySelectionGroup(Positionable selection,
MouseEvent event)
|
abstract void |
mouseClicked(MouseEvent event)
|
abstract void |
mouseDragged(MouseEvent event)
|
abstract void |
mouseEntered(MouseEvent event)
|
abstract void |
mouseExited(MouseEvent event)
|
abstract void |
mouseMoved(MouseEvent event)
|
abstract void |
mousePressed(MouseEvent event)
Abstract Methods |
abstract void |
mouseReleased(MouseEvent event)
|
protected void |
moveItem(Positionable p,
int deltaX,
int deltaY)
Relocate item |
protected abstract void |
paintTargetPanel(Graphics g)
Called from TargetPanel's paint method for additional drawing by editor view |
protected Positionable |
putIcon()
Add an icon to the target |
void |
putItem(Positionable l)
|
void |
putLocoIcon(LocoIcon l,
String name)
|
protected MemoryIcon |
putMemory()
|
protected SensorIcon |
putSensor()
Add a sensor indicator to the target |
protected SignalHeadIcon |
putSignalHead()
Add a signal head to the target |
protected SignalMastIcon |
putSignalMast()
Add a signal mast to the target |
boolean |
removeFromContents(Positionable l)
|
protected void |
removeFromTarget(Positionable l)
cleanup |
protected void |
removeMarkers()
Remove marker icons from panel |
protected void |
removeSelections(Positionable p)
|
protected LocoIcon |
selectLoco(String rosterEntryTitle)
|
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 panel items are positionable. |
void |
setAllShowTooltip(boolean state)
|
protected void |
setAttributes(PositionablePopupUtil newUtil,
Positionable pos)
|
void |
setBackgroundColor(Color col)
|
void |
setDefaultToolTip(ToolTip dtt)
|
void |
setDisplayLevelMenu(Positionable p,
JPopupMenu popup)
Display display 'z' level of the Positionable item and provide a dialog memu item to edit it. |
void |
setGlobalSetsLocalFlag(boolean set)
Does global flag sets Positionable and Control for individual items |
void |
setHiddenMenu(Positionable p,
JPopupMenu popup)
Add a checkbox to set visibility of the Positionable item |
protected abstract void |
setNextLocation(Positionable obj)
Set an object's location when it is created. |
protected void |
setPaintScale(double newScale)
|
void |
setPanelMenu(boolean state)
Control whether target panel shows a menu |
void |
setPositionableMenu(Positionable p,
JPopupMenu popup)
Add a checkbox to lock the position of the Positionable item |
void |
setRemoveMenu(Positionable p,
JPopupMenu popup)
Add an action to remove the Positionable item. |
protected void |
setScroll(int state)
|
void |
setScroll(String strState)
|
protected void |
setSelectionsAttributes(PositionablePopupUtil util,
Positionable p)
|
protected void |
setSelectionsHidden(boolean enabled,
Positionable p)
|
protected boolean |
setSelectionsPositionable(boolean enabled,
Positionable p)
|
protected void |
setSelectionsRotation(int k,
Positionable p)
|
protected void |
setSelectionsScale(double s,
Positionable p)
|
boolean |
setShowAlignmentMenu(Positionable p,
JPopupMenu popup)
Offer actions to align the selected Positionable items either Horizontally (at avearage y coord) or Vertically (at avearage x coord). |
boolean |
setShowCoordinatesMenu(Positionable p,
JPopupMenu popup)
Display the X & Y coordinates of the Positionable item and provide a dialog memu item to edit them. |
void |
setShowHidden(boolean state)
Control whether target panel hidden items are visible or not. |
void |
setShowTooltipMenu(Positionable p,
JPopupMenu popup)
Add a checkbox to display a tooltip for the Positionable item and if showable, provide a dialog menu to edit it. |
protected void |
setTargetPanel(JLayeredPane targetPanel,
JmriJFrame frame)
An Editor may or may not choose to use 'this' as its frame or the interior class 'TargetPane' for its targetPanel |
protected void |
setTargetPanelSize(int w,
int h)
|
protected boolean |
setTextAttributes(Positionable p,
JPopupMenu popup)
|
void |
setTitle()
|
protected void |
setToolTip(ToolTip tt)
|
PositionableLabel |
setUpBackground(String name)
Adding content to the panel |
void |
setUseGlobalFlag(boolean set)
Set which flag should be used, global or local for Positioning and Control of individual items. |
protected boolean |
showAlignPopup(Positionable p)
|
boolean |
showHidden()
|
protected abstract void |
showPopUp(Positionable p,
MouseEvent event)
Editor Views should make calls to this class (Editor) to set popup menu items. |
boolean |
showTooltip()
|
void |
showToolTip(Positionable selection,
MouseEvent event)
Mouse Methods |
protected void |
targetWindowClosing(boolean save)
The target window has been requested to close, don't delete it at this time. |
protected abstract void |
targetWindowClosingEvent(WindowEvent e)
|
boolean |
useGlobalFlag()
|
| 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.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.awt.MenuContainer |
|---|
getFont, postEvent |
| Field Detail |
|---|
public static final int BKG
public static final int TEMP
public static final int ICONS
public static final int LABELS
public static final int MEMORIES
public static final int REPORTERS
public static final int SECURITY
public static final int TURNOUTS
public static final int LIGHTS
public static final int SIGNALS
public static final int SENSORS
public static final int CLOCK
public static final int MARKERS
public static final int NUM_LEVELS
public static final int SCROLL_NONE
public static final int SCROLL_BOTH
public static final int SCROLL_HORIZONTAL
public static final int SCROLL_VERTICAL
public static final ResourceBundle rb
public static final ResourceBundle rbean
public static final String POSITIONABLE_FLAVOR
protected ArrayList<Positionable> _contents
protected JLayeredPane _targetPanel
protected int _scrollState
protected boolean _editable
public static final int OPTION_POSITION
public static final int OPTION_CONTROLS
public static final int OPTION_HIDDEN
public static final int OPTION_TOOLTIP
protected int _lastX
protected int _lastY
protected Rectangle _selectRect
protected Rectangle _highlightcomponent
protected boolean _dragging
protected ArrayList<Positionable> _selectionGroup
protected Positionable _currentSelection
protected int xLoc
protected int yLoc
protected int _anchorX
protected int _anchorY
protected double _paintScale
protected Color defaultBackgroundColor
protected boolean _pastePending
public static final String[] ICON_EDITORS
public int frameLocationX
public int frameLocationY
| Constructor Detail |
|---|
public Editor()
public Editor(String name)
| Method Detail |
|---|
public void loadFailed()
public NamedIcon loadFailed(String msg,
String url)
public void disposeLoadData()
public boolean loadOK()
public List<Positionable> getContents()
public void setDefaultToolTip(ToolTip dtt)
protected void setTargetPanel(JLayeredPane targetPanel,
JmriJFrame frame)
protected void setTargetPanelSize(int w,
int h)
protected Dimension getTargetPanelSize()
public final JComponent getTargetPanel()
protected final JScrollPane getPanelScrollPane()
public final JFrame getTargetFrame()
public Color getBackgroundColor()
public void setBackgroundColor(Color col)
public void clearBackgroundColor()
public final double getPaintScale()
protected final void setPaintScale(double newScale)
protected void setToolTip(ToolTip tt)
public void actionPerformed(ActionEvent event)
actionPerformed in interface ActionListenerpublic void setAllEditable(boolean state)
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).
state - true for editable.public boolean isEditable()
public void setUseGlobalFlag(boolean set)
public boolean useGlobalFlag()
public boolean getFlag(int whichOption,
boolean localFlag)
localFlag - is the current setting of the itempublic void setGlobalSetsLocalFlag(boolean set)
public void setAllPositionable(boolean state)
state - true for all items positionable.public boolean allPositionable()
public void setAllControlling(boolean state)
Positionable.setControlling(boolean) function of
each item on the target panel. This also controls the relevant pop-up menu items.
state - true for controlling.public boolean allControlling()
public void setShowHidden(boolean state)
Positionable.setHidden(boolean) function of
each item on the target panel.
state - true for Visible.public boolean showHidden()
public void setAllShowTooltip(boolean state)
public boolean showTooltip()
public void setPanelMenu(boolean state)
state - true for controlling.protected void setScroll(int state)
public void setScroll(String strState)
public String getScrollable()
protected void targetWindowClosing(boolean save)
protected Editor changeView(String className)
public void setPositionableMenu(Positionable p,
JPopupMenu popup)
public boolean setShowCoordinatesMenu(Positionable p,
JPopupMenu popup)
public boolean setShowAlignmentMenu(Positionable p,
JPopupMenu popup)
public void setDisplayLevelMenu(Positionable p,
JPopupMenu popup)
public void setHiddenMenu(Positionable p,
JPopupMenu popup)
public void setShowTooltipMenu(Positionable p,
JPopupMenu popup)
public void setRemoveMenu(Positionable p,
JPopupMenu popup)
protected void locoMarkerFromRoster()
protected LocoIcon selectLoco(String rosterEntryTitle)
protected void locoMarkerFromInput()
protected void removeMarkers()
public PositionableLabel setUpBackground(String name)
protected PositionableLabel addLabel(String text)
public void displayLevelChange(Positionable l)
public TrainIcon addTrainIcon(String name)
public LocoIcon addLocoIcon(String name)
public void putLocoIcon(LocoIcon l,
String name)
public void putItem(Positionable l)
protected void addToTarget(Positionable l)
public Editor.JFrameItem getIconFrame(String name)
name - Icon editor's namepublic IconAdder getIconEditor(String name)
protected void addTextEditor()
protected void addRightTOEditor()
protected void addLeftTOEditor()
protected void addSlipTOEditor()
protected void addSensorEditor()
protected IconAdder getSignalHeadEditor()
protected void addSignalHeadEditor()
protected void addSignalMastEditor()
protected void addMemoryEditor()
protected void addReporterEditor()
protected void addLightEditor()
protected void addBackgroundEditor()
protected Editor.JFrameItem addMultiSensorEditor()
protected void addIconEditor()
protected SensorIcon putSensor()
protected TurnoutIcon addTurnout(IconAdder editor)
protected SignalHeadIcon putSignalHead()
protected SignalMastIcon putSignalMast()
protected MemoryIcon putMemory()
protected MemorySpinnerIcon addMemorySpinner()
protected MemoryInputIcon addMemoryInputBox()
protected LightIcon addLight()
protected ReporterIcon addReporter()
protected Positionable putIcon()
public MultiSensorIcon addMultiSensor()
protected void addClock()
protected void addRpsReporter()
public List<IconAdder> getIconEditors()
public void addTreeToEditors(CatalogTree tree)
public void setTitle()
protected Editor.JFrameItem makeAddIconFrame(String name,
boolean add,
boolean table,
IconAdder editor)
public void makePalette()
protected void removeFromTarget(Positionable l)
public boolean removeFromContents(Positionable l)
public boolean deletePanel()
public void dispose(boolean clear)
public void showToolTip(Positionable selection,
MouseEvent event)
protected int getItemX(Positionable p,
int deltaX)
protected int getItemY(Positionable p,
int deltaY)
protected void moveItem(Positionable p,
int deltaX,
int deltaY)
protected List<Positionable> getSelectedItems(MouseEvent event)
protected void makeSelectionGroup(MouseEvent event)
protected void modifySelectionGroup(Positionable selection,
MouseEvent event)
protected boolean setTextAttributes(Positionable p,
JPopupMenu popup)
protected void setAttributes(PositionablePopupUtil newUtil,
Positionable pos)
protected void setSelectionsAttributes(PositionablePopupUtil util,
Positionable p)
protected void setSelectionsHidden(boolean enabled,
Positionable p)
protected boolean setSelectionsPositionable(boolean enabled,
Positionable p)
protected void removeSelections(Positionable p)
protected void setSelectionsScale(double s,
Positionable p)
protected void setSelectionsRotation(int k,
Positionable p)
protected boolean showAlignPopup(Positionable p)
protected void alignGroup(boolean alignX)
protected void drawSelectRect(int x,
int y)
public final int getAnchorX()
public final int getAnchorY()
public void keyTyped(KeyEvent e)
keyTyped in interface KeyListenerpublic void keyPressed(KeyEvent e)
keyPressed in interface KeyListenerpublic void keyReleased(KeyEvent e)
keyReleased in interface KeyListenerpublic abstract void mousePressed(MouseEvent event)
mousePressed in interface MouseListenerpublic abstract void mouseReleased(MouseEvent event)
mouseReleased in interface MouseListenerpublic abstract void mouseClicked(MouseEvent event)
mouseClicked in interface MouseListenerpublic abstract void mouseDragged(MouseEvent event)
mouseDragged in interface MouseMotionListenerpublic abstract void mouseMoved(MouseEvent event)
mouseMoved in interface MouseMotionListenerpublic abstract void mouseEntered(MouseEvent event)
mouseEntered in interface MouseListenerpublic abstract void mouseExited(MouseEvent event)
mouseExited in interface MouseListenerprotected abstract void init(String name)
protected abstract void targetWindowClosingEvent(WindowEvent e)
protected abstract void paintTargetPanel(Graphics g)
protected abstract void setNextLocation(Positionable obj)
protected abstract void showPopUp(Positionable p,
MouseEvent event)
public abstract void initView()
protected abstract void copyItem(Positionable p)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||