use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class EditCircuitFrame method updateIconList.
protected void updateIconList(java.util.List<Positionable> icons) {
//if (log.isDebugEnabled()) log.debug(
int segments = 0;
int turnouts = 0;
if (icons != null) {
if (log.isDebugEnabled()) {
log.debug("updateIconList: icons.size()= {}", icons.size());
}
for (int i = 0; i < icons.size(); i++) {
Positionable pos = icons.get(i);
if (pos instanceof IndicatorTurnoutIcon) {
turnouts++;
} else if (pos instanceof IndicatorTrackIcon) {
segments++;
} else if (pos instanceof TurnoutIcon) {
turnouts++;
} else {
segments++;
}
}
}
_numTrackSeg.setText(String.valueOf(segments));
_numTurnouts.setText(String.valueOf(turnouts));
}
use of jmri.jmrit.display.Positionable 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.Positionable in project JMRI by JMRI.
the class ControlPanelEditor method copyToClipboard.
/*
* The editor instance is dragged. When dropped this editor will reference
* the list of positionables (_clipGroup) for pasting
*/
private void copyToClipboard() {
if (_selectionGroup != null) {
ArrayList<Positionable> dragGroup = new ArrayList<Positionable>();
for (Positionable comp : _selectionGroup) {
Positionable pos = comp.deepClone();
dragGroup.add(pos);
// cloned item gets added to _targetPane during cloning
removeFromTarget(pos);
}
log.debug("copyToClipboard: cloned _selectionGroup, size= {}", _selectionGroup.size());
_clipGroup = dragGroup;
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new PositionableListDnD(_clipGroup), this);
log.debug("copyToClipboard: setContents _selectionGroup, size= {}", _selectionGroup.size());
} else {
_clipGroup = null;
}
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class SwitchboardEditor method keyPressed.
/**
* KeyListener of Editor.
*
* @param e the key event heard
*/
@Override
public void keyPressed(KeyEvent e) {
int x = 0;
int y = 0;
switch(e.getKeyCode()) {
case KeyEvent.VK_UP:
case KeyEvent.VK_KP_UP:
case KeyEvent.VK_NUMPAD8:
y = -1;
break;
case KeyEvent.VK_DOWN:
case KeyEvent.VK_KP_DOWN:
case KeyEvent.VK_NUMPAD2:
y = 1;
break;
case KeyEvent.VK_LEFT:
case KeyEvent.VK_KP_LEFT:
case KeyEvent.VK_NUMPAD4:
x = -1;
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_KP_RIGHT:
case KeyEvent.VK_NUMPAD6:
x = 1;
break;
case KeyEvent.VK_D:
case KeyEvent.VK_DELETE:
case KeyEvent.VK_MINUS:
//_shapeDrawer.delete();
break;
case KeyEvent.VK_A:
case KeyEvent.VK_INSERT:
case KeyEvent.VK_PLUS:
//_shapeDrawer.add(e.isShiftDown());
break;
default:
return;
}
if (e.isShiftDown()) {
x *= 5;
y *= 5;
}
if (_selectionGroup != null) {
for (Positionable comp : _selectionGroup) {
moveItem(comp, x, y);
}
}
repaint();
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class ControlPanelEditor method setCopyMenu.
/**
* Add an action to copy the Positionable item and the group to which is may
* belong.
*/
public void setCopyMenu(Positionable p, JPopupMenu popup) {
JMenuItem edit = new JMenuItem(Bundle.getMessage("MenuItemDuplicate"));
edit.addActionListener(new ActionListener() {
Positionable comp;
@Override
public void actionPerformed(ActionEvent e) {
copyItem(comp);
}
ActionListener init(Positionable pos) {
comp = pos;
return this;
}
}.init(p));
popup.add(edit);
}
Aggregations