use of jmri.jmrit.display.IndicatorTrack in project JMRI by JMRI.
the class ControlPanelEditor method mouseClicked.
@Override
public void mouseClicked(MouseEvent event) {
if (jmri.util.swing.SwingSettings.getNonStandardMouseEvent()) {
long time = System.currentTimeMillis();
if (time - _clickTime < 20) {
return;
}
_clickTime = time;
}
// ends tooltip if displayed
setToolTip(null);
log.debug("mouseClicked at ({},{})", event.getX(), event.getY());
Positionable selection = getCurrentSelection(event);
if (_shapeDrawer.doMouseClicked(event)) {
return;
}
if (event.isPopupTrigger() || event.isMetaDown() || event.isAltDown()) {
if (selection != null) {
_highlightcomponent = null;
showPopUp(selection, event);
}
} else if (selection != null) {
if (!_circuitBuilder.doMouseClicked(getSelectedItems(event), event)) {
selection.doMouseClicked(event);
}
if (selection instanceof IndicatorTrack) {
WarrantTableAction.mouseClickedOnBlock(((IndicatorTrack) selection).getOccBlock());
}
}
if (!isEditable()) {
deselectSelectionGroup();
_currentSelection = null;
_highlightcomponent = null;
}
// needed for ToolTip
_targetPanel.repaint();
}
use of jmri.jmrit.display.IndicatorTrack in project JMRI by JMRI.
the class CircuitBuilder method setIconGroup.
/**
* Edit frame closing, set block's icons
*/
private void setIconGroup(OBlock block, java.util.List<Positionable> selections) {
java.util.List<Positionable> oldIcons = _circuitMap.get(block);
if (oldIcons != null) {
for (int i = 0; i < oldIcons.size(); i++) {
Positionable pos = oldIcons.get(i);
if (pos instanceof IndicatorTrack) {
((IndicatorTrack) pos).setOccBlockHandle(null);
}
_iconMap.remove(pos);
}
}
// the selectionGroup for all edit frames is full collection of icons
// comprising the block. Gather them and store in the block's hashMap
ArrayList<Positionable> icons = new ArrayList<Positionable>();
if (selections != null) {
if (log.isDebugEnabled()) {
log.debug("setIconGroup: selectionGroup has " + selections.size() + " icons.");
}
NamedBeanHandle<OBlock> handle = InstanceManager.getDefault(NamedBeanHandleManager.class).getNamedBeanHandle(block.getSystemName(), block);
for (int i = 0; i < selections.size(); i++) {
Positionable pos = selections.get(i);
if (pos instanceof IndicatorTrack) {
((IndicatorTrack) pos).setOccBlockHandle(handle);
}
icons.add(pos);
_iconMap.put(pos, block);
}
java.util.List<Portal> portals = block.getPortals();
for (int i = 0; i < portals.size(); i++) {
PortalIcon icon = _portalIconMap.get(portals.get(i).getName());
if (icon != null) {
_iconMap.put(icon, block);
}
}
}
_circuitMap.put(block, icons);
if (log.isDebugEnabled()) {
log.debug("setIconGroup: block " + block.getDisplayName() + " has " + icons.size() + " icons.");
}
}
use of jmri.jmrit.display.IndicatorTrack in project JMRI by JMRI.
the class CircuitBuilder method removeBlock.
/**
* Remove block, but keep the track icons. Set block reference in icon null
*/
protected void removeBlock(OBlock block) {
java.util.List<Positionable> list = _circuitMap.get(block);
if (list != null) {
for (int i = 0; i < list.size(); i++) {
Positionable pos = list.get(i);
if (pos instanceof IndicatorTrack) {
((IndicatorTrack) pos).setOccBlockHandle(null);
} else if (pos instanceof PortalIcon) {
pos.remove();
}
_darkTrack.add(pos);
}
}
_circuitMap.remove(block);
block.dispose();
}
use of jmri.jmrit.display.IndicatorTrack in project JMRI by JMRI.
the class EditCircuitPaths method changePathName.
private void changePathName() {
String name = _pathName.getText();
OPath path = _pathList.getSelectedValue();
if (name == null || name.trim().length() == 0 || path == null) {
JOptionPane.showMessageDialog(this, Bundle.getMessage("changePathName", Bundle.getMessage("buttonChangeName")), Bundle.getMessage("makePath"), JOptionPane.INFORMATION_MESSAGE);
return;
}
String oldName = path.getName();
OPath oldPath = _block.getPathByName(name);
if (oldPath != null) {
JOptionPane.showMessageDialog(this, Bundle.getMessage("duplicatePathName", name, _block.getDisplayName()), Bundle.getMessage("makePath"), JOptionPane.INFORMATION_MESSAGE);
return;
}
path.setName(name);
// Change the path name in the track icons
java.util.List<Positionable> list = _parent.getCircuitGroup();
// cannot do remove/add path on the fly due to conncurrent access with Iterator
ArrayList<IndicatorTrack> changeGroup = new ArrayList<IndicatorTrack>();
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof IndicatorTrack) {
IndicatorTrack icon = (IndicatorTrack) list.get(i);
ArrayList<String> paths = icon.getPaths();
if (paths != null) {
for (int j = 0; j < paths.size(); j++) {
if (oldName.equals(paths.get(j))) {
changeGroup.add(icon);
}
}
}
}
}
for (int i = 0; i < changeGroup.size(); i++) {
IndicatorTrack track = changeGroup.get(i);
track.removePath(oldName);
track.addPath(name);
}
_pathChange = false;
_pathListModel.dataChange();
}
use of jmri.jmrit.display.IndicatorTrack in project JMRI by JMRI.
the class EditCircuitPaths method changePathNameInIcons.
private void changePathNameInIcons(String name, OPath path) {
// add or remove path name from IndicatorTrack icons
Iterator<Positionable> iter = _parent.getCircuitGroup().iterator();
while (iter.hasNext()) {
Positionable pos = iter.next();
if (_pathGroup.contains(pos)) {
if (pos instanceof IndicatorTrack) {
((IndicatorTrack) pos).addPath(name);
}
} else {
if (pos instanceof IndicatorTrack) {
((IndicatorTrack) pos).removePath(name);
} else {
PortalIcon pi = (PortalIcon) pos;
// pi.setStatus(PortalIcon.VISIBLE);
Portal p = pi.getPortal();
p.removePath(path);
}
}
}
}
Aggregations