use of jmri.jmrit.display.PositionableJComponent in project JMRI by JMRI.
the class ControlPanelEditor method makeFileMenu.
private void makeFileMenu() {
_fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
_menuBar.add(_fileMenu, 0);
_fileMenu.add(new jmri.jmrit.display.NewPanelAction(Bundle.getMessage("MenuItemNew")));
_fileMenu.add(new jmri.configurexml.StoreXmlUserAction(Bundle.getMessage("MenuItemStore")));
JMenuItem storeIndexItem = new JMenuItem(Bundle.getMessage("MIStoreImageIndex"));
_fileMenu.add(storeIndexItem);
storeIndexItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
jmri.jmrit.catalog.ImageIndexEditor.storeImageIndex();
}
});
JMenuItem editItem = new JMenuItem(Bundle.getMessage("renamePanelMenu", "..."));
PositionableJComponent z = new PositionableJComponent(this);
z.setScale(getPaintScale());
editItem.addActionListener(CoordinateEdit.getNameEditAction(z));
_fileMenu.add(editItem);
editItem = new JMenuItem(Bundle.getMessage("editIndexMenu"));
_fileMenu.add(editItem);
editItem.addActionListener(new ActionListener() {
ControlPanelEditor panelEd;
@Override
public void actionPerformed(ActionEvent e) {
ImageIndexEditor ii = ImageIndexEditor.instance(panelEd);
ii.pack();
ii.setVisible(true);
}
ActionListener init(ControlPanelEditor pe) {
panelEd = pe;
return this;
}
}.init(this));
editItem = new JMenuItem(Bundle.getMessage("PEView"));
_fileMenu.add(editItem);
editItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
changeView("jmri.jmrit.display.panelEditor.PanelEditor");
if (_itemPalette != null) {
_itemPalette.dispose();
}
}
});
_fileMenu.addSeparator();
JMenuItem deleteItem = new JMenuItem(Bundle.getMessage("DeletePanel"));
_fileMenu.add(deleteItem);
deleteItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (deletePanel()) {
dispose(true);
}
}
});
_fileMenu.addSeparator();
editItem = new JMenuItem(Bundle.getMessage("CloseEditor"));
_fileMenu.add(editItem);
editItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllEditable(false);
}
});
}
use of jmri.jmrit.display.PositionableJComponent in project JMRI by JMRI.
the class SwitchboardEditor method makeFileMenu.
private void makeFileMenu() {
_fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
_menuBar.add(_fileMenu, 0);
_fileMenu.add(new jmri.jmrit.display.NewPanelAction(Bundle.getMessage("MenuItemNew")));
_fileMenu.add(new jmri.configurexml.StoreXmlUserAction(Bundle.getMessage("MenuItemStore")));
JMenuItem storeIndexItem = new JMenuItem(Bundle.getMessage("MIStoreImageIndex"));
_fileMenu.add(storeIndexItem);
storeIndexItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
jmri.jmrit.catalog.ImageIndexEditor.storeImageIndex();
}
});
JMenuItem editItem = new JMenuItem(Bundle.getMessage("renamePanelMenu", "..."));
PositionableJComponent z = new PositionableJComponent(this);
z.setScale(getPaintScale());
editItem.addActionListener(CoordinateEdit.getNameEditAction(z));
_fileMenu.add(editItem);
_fileMenu.addSeparator();
JMenuItem deleteItem = new JMenuItem(Bundle.getMessage("DeletePanel"));
_fileMenu.add(deleteItem);
deleteItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (deletePanel()) {
dispose(true);
}
}
});
_fileMenu.addSeparator();
editItem = new JMenuItem(Bundle.getMessage("CloseEditor"));
_fileMenu.add(editItem);
editItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllEditable(false);
// hide Editor pane
setVisible(false);
}
});
}
use of jmri.jmrit.display.PositionableJComponent in project JMRI by JMRI.
the class ControlPanelEditor method pasteFromClipboard.
private void pasteFromClipboard() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
DataFlavor[] flavors = clipboard.getAvailableDataFlavors();
for (DataFlavor flavor : flavors) {
if (_positionableListDataFlavor.equals(flavor)) {
try {
@SuppressWarnings("unchecked") List<Positionable> clipGroup = (List<Positionable>) clipboard.getData(_positionableListDataFlavor);
if (clipGroup != null && clipGroup.size() > 0) {
Positionable pos = clipGroup.get(0);
int minX = pos.getLocation().x;
int minY = pos.getLocation().y;
// locate group at mouse point
for (int i = 1; i < clipGroup.size(); i++) {
pos = clipGroup.get(i);
minX = Math.min(minX, pos.getLocation().x);
minY = Math.min(minY, pos.getLocation().y);
}
if (_pastePending) {
abortPasteItems();
}
_selectionGroup = new ArrayList<Positionable>();
for (int i = 0; i < clipGroup.size(); i++) {
pos = clipGroup.get(i);
// make positionable belong to this editor
pos.setEditor(this);
pos.setLocation(pos.getLocation().x + _anchorX - minX, pos.getLocation().y + _anchorY - minY);
// now set display level in the pane.
pos.setDisplayLevel(pos.getDisplayLevel());
putItem(pos);
pos.updateSize();
pos.setVisible(true);
_selectionGroup.add(pos);
if (pos instanceof PositionableIcon) {
jmri.NamedBean bean = pos.getNamedBean();
if (bean != null) {
((PositionableIcon) pos).displayState(bean.getState());
}
} else if (pos instanceof MemoryIcon) {
((MemoryIcon) pos).displayState();
} else if (pos instanceof PositionableJComponent) {
((PositionableJComponent) pos).displayState();
}
log.debug("Paste Added at ({}, {})", pos.getLocation().x, pos.getLocation().y);
}
}
return;
} catch (IOException ioe) {
log.warn("Editor Paste caught IOException", ioe);
} catch (UnsupportedFlavorException ufe) {
log.warn("Editor Paste caught UnsupportedFlavorException", ufe);
}
}
}
}
use of jmri.jmrit.display.PositionableJComponent in project JMRI by JMRI.
the class ControlPanelEditor method makeZoomMenu.
protected void makeZoomMenu() {
_zoomMenu = new JMenu(Bundle.getMessage("MenuZoom"));
_menuBar.add(_zoomMenu, 0);
JMenuItem addItem = new JMenuItem(Bundle.getMessage("NoZoom"));
_zoomMenu.add(addItem);
addItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
zoomRestore();
}
});
addItem = new JMenuItem(Bundle.getMessage("Zoom", "..."));
_zoomMenu.add(addItem);
PositionableJComponent z = new PositionableJComponent(this);
z.setScale(getPaintScale());
addItem.addActionListener(CoordinateEdit.getZoomEditAction(z));
addItem = new JMenuItem(Bundle.getMessage("ZoomFit"));
_zoomMenu.add(addItem);
addItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
zoomToFit();
}
});
}
Aggregations