Class CircuitBuilder
- java.lang.Object
-
- jmri.jmrit.display.controlPanelEditor.CircuitBuilder
-
public class CircuitBuilder extends java.lang.Object
ControlPanelEditor CircuitBuilder tools.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
CircuitBuilder.CBFrame
-
Field Summary
Fields Modifier and Type Field Description (package private) JmriJFrame
_cbFrame
static java.awt.Color
_editGroupColor
protected ControlPanelEditor
_editor
static java.awt.Color
_highlightColor
static java.awt.Color
_pathColor
(package private) java.util.ArrayList<Positionable>
_saveSelectionGroup
************************** Mouse ************************(package private) static int
ARROW
(package private) static int
NONE
(package private) static int
OBLOCK
(package private) static int
OPATH
(package private) static int
PORTAL
(package private) static int
SIGNAL
(package private) static int
STRUT_SIZE
-
Constructor Summary
Constructors Constructor Description CircuitBuilder()
***************************************************************CircuitBuilder(ControlPanelEditor ed)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
checkForPortalIcons(OBlock block, java.lang.String key)
Check that there is at least one PortalIcon. called from various _editFrame'sprotected java.lang.String
checkForPortals(OBlock block, java.lang.String key)
protected java.lang.String
checkForTrackIcons(OBlock block, java.lang.String key)
protected void
closeCBWindow()
protected void
closeCircuitBuilder(OBlock block)
protected void
deletePortalIcon(PortalIcon icon)
protected boolean
doMouseClicked(java.util.List<Positionable> selections, JmriMouseEvent event)
boolean
doMouseDragged(Positionable selection, JmriMouseEvent event)
Prevent dragging when CircuitBuilder is in progress, except for PortalIcon.protected boolean
doMousePressed(JmriMouseEvent event)
If CircuitBuilder is in progress, restore what editor nulls.protected boolean
doMousePressed(JmriMouseEvent event, Positionable selection)
Make note of selection.boolean
doMouseReleased(Positionable selection, boolean dragging)
protected static void
doSize(javax.swing.JComponent comp, int max, int min)
boolean
dragPortal()
Second call needed to only drag the portal icon and not entire selectionprotected void
editCircuit(java.lang.String title, boolean fromMenu)
protected void
editCircuitError(java.lang.String sysName)
protected void
editCircuitPaths(java.lang.String title, boolean fromMenu)
protected void
editPortalDirection(java.lang.String title, boolean fromMenu)
protected void
editPortalError(java.lang.String name)
protected void
editPortalError(OBlock block, Portal portal, PortalIcon icon)
protected void
editPortals(java.lang.String title, boolean fromMenu)
protected void
editSignalFrame(java.lang.String title, boolean fromMenu)
protected java.util.ArrayList<Positionable>
getCircuitIcons(OBlock block)
protected EditFrame
getEditFrame()
protected java.util.List<PortalIcon>
getPortalIcons(Portal portal)
protected java.util.HashMap<NamedBean,java.util.ArrayList<PositionableIcon>>
getSignalIconMap()
protected java.util.List<PositionableIcon>
getSignalIconMap(NamedBean mast)
protected Portal
getSignalPortal(NamedBean mast)
protected void
hidePortalIcons(boolean hideAll)
protected boolean
iconIntersectsBlock(Positionable icon, OBlock block)
protected static boolean
isTrack(Positionable pos)
protected static javax.swing.JPanel
makeBoxPanel(boolean vertical, javax.swing.JComponent textField, java.lang.String label, java.lang.String tooltip)
protected javax.swing.JMenu
makeMenu()
Makes menu for ControlPanelEditor.protected static javax.swing.JPanel
makeTextBoxPanel(boolean vertical, javax.swing.JTextField textField, java.lang.String label, boolean editable, java.lang.String tooltip)
protected void
newCircuit()
************** Set up editing Frames ****************protected void
openCBWindow()
protected boolean
portalIconMove(PortalIcon pos, int x, int y)
protected void
putSignalPortal(NamedBean mast, Portal portal)
protected boolean
queryConvertTrackIcons(OBlock block, java.lang.String key)
Check if the block being edited has all its track icons converted to indicator icons If icons need conversion. ask if user wants to convert themprotected boolean
rectIntersectsBlock(java.awt.Rectangle iconRect, OBlock block)
protected void
removeBlock(OBlock block)
Remove block, but keep the track icons.protected boolean
saveSelectionGroup(java.util.ArrayList<Positionable> selectionGroup)
Keep selections when editing.protected void
setCurrentBlock(OBlock b)
protected void
setIconGroup(OBlock block)
Edit frame closing, set block's icons to support OBlock's state changes
-
-
-
Field Detail
-
STRUT_SIZE
static int STRUT_SIZE
-
_cbFrame
JmriJFrame _cbFrame
-
_editor
protected ControlPanelEditor _editor
-
_editGroupColor
public static final java.awt.Color _editGroupColor
-
_pathColor
public static final java.awt.Color _pathColor
-
_highlightColor
public static final java.awt.Color _highlightColor
-
_saveSelectionGroup
java.util.ArrayList<Positionable> _saveSelectionGroup
************************** Mouse ************************
-
NONE
static int NONE
-
OBLOCK
static int OBLOCK
-
PORTAL
static int PORTAL
-
OPATH
static int OPATH
-
ARROW
static int ARROW
-
SIGNAL
static int SIGNAL
-
-
Constructor Detail
-
CircuitBuilder
public CircuitBuilder()
***************************************************************
-
CircuitBuilder
public CircuitBuilder(ControlPanelEditor ed)
-
-
Method Detail
-
makeMenu
protected javax.swing.JMenu makeMenu()
Makes menu for ControlPanelEditor. Called by ControlPanelEditor at init before contents have been loaded.- Returns:
- the menu, created if needed
-
openCBWindow
protected void openCBWindow()
-
getEditFrame
protected EditFrame getEditFrame()
-
newCircuit
protected void newCircuit()
************** Set up editing Frames ****************
-
editCircuit
protected void editCircuit(java.lang.String title, boolean fromMenu)
-
editCircuitError
protected void editCircuitError(java.lang.String sysName)
-
editPortals
protected void editPortals(java.lang.String title, boolean fromMenu)
-
editPortalError
protected void editPortalError(java.lang.String name)
-
editPortalError
protected void editPortalError(OBlock block, Portal portal, PortalIcon icon)
-
editPortalDirection
protected void editPortalDirection(java.lang.String title, boolean fromMenu)
-
editSignalFrame
protected void editSignalFrame(java.lang.String title, boolean fromMenu)
-
editCircuitPaths
protected void editCircuitPaths(java.lang.String title, boolean fromMenu)
-
setCurrentBlock
protected void setCurrentBlock(OBlock b)
-
hidePortalIcons
protected void hidePortalIcons(boolean hideAll)
-
setIconGroup
protected void setIconGroup(OBlock block)
Edit frame closing, set block's icons to support OBlock's state changes- Parameters:
block
- OBlock to set icon selections into data maps
-
closeCircuitBuilder
protected void closeCircuitBuilder(OBlock block)
-
iconIntersectsBlock
protected boolean iconIntersectsBlock(Positionable icon, OBlock block)
-
rectIntersectsBlock
protected boolean rectIntersectsBlock(java.awt.Rectangle iconRect, OBlock block)
-
getCircuitIcons
@Nonnull protected java.util.ArrayList<Positionable> getCircuitIcons(OBlock block)
-
getPortalIcons
@Nonnull protected java.util.List<PortalIcon> getPortalIcons(@Nonnull Portal portal)
-
getSignalIconMap
@Nonnull protected java.util.List<PositionableIcon> getSignalIconMap(@Nonnull NamedBean mast)
-
getSignalIconMap
protected java.util.HashMap<NamedBean,java.util.ArrayList<PositionableIcon>> getSignalIconMap()
-
getSignalPortal
protected Portal getSignalPortal(@Nonnull NamedBean mast)
-
putSignalPortal
protected void putSignalPortal(@Nonnull NamedBean mast, Portal portal)
-
removeBlock
protected void removeBlock(OBlock block)
Remove block, but keep the track icons. Sets block reference in icon to null.- Parameters:
block
- the block to remove
-
checkForPortals
protected java.lang.String checkForPortals(@Nonnull OBlock block, java.lang.String key)
-
checkForPortalIcons
protected java.lang.String checkForPortalIcons(@Nonnull OBlock block, java.lang.String key)
Check that there is at least one PortalIcon. called from various _editFrame's- Parameters:
block
- check icons of this blockkey
- properties key- Returns:
- true if at least one PortalIcon found
-
checkForTrackIcons
protected java.lang.String checkForTrackIcons(@Nonnull OBlock block, java.lang.String key)
-
deletePortalIcon
protected void deletePortalIcon(PortalIcon icon)
-
queryConvertTrackIcons
protected boolean queryConvertTrackIcons(@Nonnull OBlock block, java.lang.String key)
Check if the block being edited has all its track icons converted to indicator icons If icons need conversion. ask if user wants to convert them- Parameters:
block
- OBlock to checkkey
- properties key- Returns:
- true if all track icons are IndicatorTrack icons
-
isTrack
protected static boolean isTrack(Positionable pos)
-
portalIconMove
protected boolean portalIconMove(PortalIcon pos, int x, int y)
- Parameters:
pos
- PortalIcon attempting a move. allow or disallowx
- new x positiony
- new y position- Returns:
- allow, or not
-
saveSelectionGroup
protected boolean saveSelectionGroup(java.util.ArrayList<Positionable> selectionGroup)
Keep selections when editing. Editor calls at entry to mousePressed(). CircuitBuilder keeps is own concept of what is "selected".- Parameters:
selectionGroup
- the selection group to save- Returns:
- true if retaining a reference to a frame
-
doMousePressed
protected boolean doMousePressed(JmriMouseEvent event, Positionable selection)
Make note of selection.- Parameters:
event
- the triggering eventselection
- the selection- Returns:
- true
-
doMousePressed
protected boolean doMousePressed(JmriMouseEvent event)
If CircuitBuilder is in progress, restore what editor nulls.- Parameters:
event
- the triggering event- Returns:
- true if the selection group is restored; false otherwise
-
doMouseReleased
public boolean doMouseReleased(Positionable selection, boolean dragging)
-
doMouseClicked
protected boolean doMouseClicked(java.util.List<Positionable> selections, JmriMouseEvent event)
-
doMouseDragged
public boolean doMouseDragged(Positionable selection, JmriMouseEvent event)
Prevent dragging when CircuitBuilder is in progress, except for PortalIcon.- Parameters:
selection
- the item(s) being draggedevent
- the triggering event- Returns:
- true to prevent dragging; false otherwise
-
dragPortal
public boolean dragPortal()
Second call needed to only drag the portal icon and not entire selection- Returns:
- true if portal frame is open
-
closeCBWindow
protected void closeCBWindow()
-
doSize
protected static void doSize(javax.swing.JComponent comp, int max, int min)
-
makeTextBoxPanel
protected static javax.swing.JPanel makeTextBoxPanel(boolean vertical, javax.swing.JTextField textField, java.lang.String label, boolean editable, java.lang.String tooltip)
-
makeBoxPanel
protected static javax.swing.JPanel makeBoxPanel(boolean vertical, javax.swing.JComponent textField, java.lang.String label, java.lang.String tooltip)
-
-