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) classCircuitBuilder.CBFrame
-
Field Summary
Fields Modifier and Type Field Description (package private) JmriJFrame_cbFramestatic java.awt.Color_editGroupColorprotected ControlPanelEditor_editorstatic java.awt.Color_highlightColorstatic java.awt.Color_pathColor(package private) java.util.ArrayList<Positionable>_saveSelectionGroup************************** Mouse ************************(package private) static intARROW(package private) static intNONE(package private) static intOBLOCK(package private) static intOPATH(package private) static intPORTAL(package private) static intSIGNAL(package private) static intSTRUT_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.StringcheckForPortalIcons(OBlock block, java.lang.String key)Check that there is at least one PortalIcon. called from various _editFrame'sprotected java.lang.StringcheckForPortals(OBlock block, java.lang.String key)protected java.lang.StringcheckForTrackIcons(OBlock block, java.lang.String key)protected voidcloseCBWindow()protected voidcloseCircuitBuilder(OBlock block)protected voiddeletePortalIcon(PortalIcon icon)protected booleandoMouseClicked(java.util.List<Positionable> selections, JmriMouseEvent event)booleandoMouseDragged(Positionable selection, JmriMouseEvent event)Prevent dragging when CircuitBuilder is in progress, except for PortalIcon.protected booleandoMousePressed(JmriMouseEvent event)If CircuitBuilder is in progress, restore what editor nulls.protected booleandoMousePressed(JmriMouseEvent event, Positionable selection)Make note of selection.booleandoMouseReleased(Positionable selection, boolean dragging)protected static voiddoSize(javax.swing.JComponent comp, int max, int min)booleandragPortal()Second call needed to only drag the portal icon and not entire selectionprotected voideditCircuit(java.lang.String title, boolean fromMenu)protected voideditCircuitError(java.lang.String sysName)protected voideditCircuitPaths(java.lang.String title, boolean fromMenu)protected voideditPortalDirection(java.lang.String title, boolean fromMenu)protected voideditPortalError(java.lang.String name)protected voideditPortalError(OBlock block, Portal portal, PortalIcon icon)protected voideditPortals(java.lang.String title, boolean fromMenu)protected voideditSignalFrame(java.lang.String title, boolean fromMenu)protected java.util.ArrayList<Positionable>getCircuitIcons(OBlock block)protected EditFramegetEditFrame()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 PortalgetSignalPortal(NamedBean mast)protected voidhidePortalIcons(boolean hideAll)protected booleaniconIntersectsBlock(Positionable icon, OBlock block)protected static booleanisTrack(Positionable pos)protected static javax.swing.JPanelmakeBoxPanel(boolean vertical, javax.swing.JComponent textField, java.lang.String label, java.lang.String tooltip)protected javax.swing.JMenumakeMenu()Makes menu for ControlPanelEditor.protected static javax.swing.JPanelmakeTextBoxPanel(boolean vertical, javax.swing.JTextField textField, java.lang.String label, boolean editable, java.lang.String tooltip)protected voidnewCircuit()************** Set up editing Frames ****************protected voidopenCBWindow()protected booleanportalIconMove(PortalIcon pos, int x, int y)protected voidputSignalPortal(NamedBean mast, Portal portal)protected booleanqueryConvertTrackIcons(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 booleanrectIntersectsBlock(java.awt.Rectangle iconRect, OBlock block)protected voidremoveBlock(OBlock block)Remove block, but keep the track icons.protected booleansaveSelectionGroup(java.util.ArrayList<Positionable> selectionGroup)Keep selections when editing.protected voidsetCurrentBlock(OBlock b)protected voidsetIconGroup(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)
-
-