use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class CircuitBuilder method convertIcons.
protected void convertIcons(ArrayList<Positionable> iconList) {
if (iconList == null || iconList.size() == 0) {
return;
}
// use global member for finishConvert to remove and add converted icons,
_circuitIcons = iconList;
// since iconList will be modified, use a copy to find unconverted icons
ArrayList<Positionable> list = new ArrayList<Positionable>();
for (int i = 0; i < iconList.size(); i++) {
list.add(iconList.get(i));
}
if (list.size() > 0) {
TargetPane targetPane = (TargetPane) _editor.getTargetPanel();
targetPane.setHighlightColor(_highlightColor);
for (int i = 0; i < list.size(); i++) {
Positionable pos = list.get(i);
if (!(pos instanceof IndicatorTrack) && !(pos instanceof PortalIcon)) {
if (log.isDebugEnabled()) {
log.debug("convertIcons: #" + i + " pos= " + pos.getClass().getName());
}
convertIcon(pos);
}
}
targetPane.setHighlightColor(_editGroupColor);
_editor.highlight(null);
}
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class CircuitBuilder method okToAdd.
/**
* Can this track icon be added to the circuit? N.B. Be sure Positionable
* pos passes isTrack() call
*/
private boolean okToAdd(Positionable pos, OBlock editBlock) {
if (pos instanceof IndicatorTrack) {
OBlock block = ((IndicatorTrack) pos).getOccBlock();
if (block != null) {
if (!block.equals(editBlock)) {
int result = JOptionPane.showConfirmDialog(_editor, java.text.MessageFormat.format(Bundle.getMessage("iconBlockConflict"), block.getDisplayName(), editBlock.getDisplayName()), Bundle.getMessage("whichCircuit"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
// move icon from block to editBlock
java.util.List<Positionable> ic = _circuitMap.get(block);
ic.remove(pos);
((IndicatorTrack) pos).setOccBlockHandle(InstanceManager.getDefault(NamedBeanHandleManager.class).getNamedBeanHandle(editBlock.getSystemName(), editBlock));
return true;
}
return false;
}
}
}
return true;
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class CircuitBuilder method setPortalsPositionable.
/**
* ************************ end setup frames *****************************
*/
private void setPortalsPositionable(OBlock block, boolean set) {
List<Positionable> circuitIcons = _circuitMap.get(block);
Iterator<Positionable> iter = circuitIcons.iterator();
while (iter.hasNext()) {
Positionable p = iter.next();
if (p instanceof PortalIcon) {
p.setPositionable(set);
}
}
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class ControlPanelEditor method zoomRestore.
private void zoomRestore() {
List<Positionable> contents = getContents();
for (Positionable p : contents) {
p.setLocation(p.getX() + _fitX, p.getY() + _fitY);
}
setPaintScale(1.0);
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class CircuitBuilder method checkPortalIcon.
// end checkCircuits
private boolean checkPortalIcon(Portal portal, PortalIcon icon) {
OBlock a = portal.getToBlock();
OBlock b = portal.getFromBlock();
java.util.List<Positionable> aList = _circuitMap.get(a);
java.util.List<Positionable> bList = _circuitMap.get(b);
if (icon == null || aList == null || bList == null) {
return false;
}
boolean ok = false;
String status = icon.getStatus();
icon.setStatus(PortalIcon.VISIBLE);
Rectangle homeRect = new Rectangle();
Iterator<Positionable> iter = aList.iterator();
while (iter.hasNext()) {
Positionable pos = iter.next();
if (pos instanceof PortalIcon) {
continue;
}
homeRect = pos.getBounds(homeRect);
if (iconIntersectsRect(icon, homeRect)) {
ok = true;
break;
}
}
if (!ok) {
icon.setStatus(status);
return false;
}
ok = false;
iter = bList.iterator();
while (iter.hasNext()) {
Positionable pos = iter.next();
if (pos instanceof PortalIcon) {
continue;
}
homeRect = pos.getBounds(homeRect);
if (iconIntersectsRect(icon, homeRect)) {
ok = true;
break;
}
}
icon.setStatus(status);
return ok;
}
Aggregations