use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class PanelEditor method mouseMoved.
@Override
public void mouseMoved(MouseEvent event) {
//if (_debug) log.debug("mouseMoved at ("+event.getX()+","+event.getY()+")");
if (_dragging || event.isPopupTrigger()) {
return;
}
List<Positionable> selections = getSelectedItems(event);
Positionable selection = null;
if (selections.size() > 0) {
if (event.isShiftDown() && selections.size() > 1) {
selection = selections.get(1);
} else {
selection = selections.get(0);
}
}
if (isEditable() && selection != null && selection.getDisplayLevel() > BKG) {
_highlightcomponent = new Rectangle(selection.getX(), selection.getY(), selection.maxWidth(), selection.maxHeight());
_targetPanel.repaint();
} else {
_highlightcomponent = null;
_targetPanel.repaint();
}
if (selection != null && selection.getDisplayLevel() > BKG && selection.showTooltip()) {
showToolTip(selection, event);
//selection.highlightlabel(true);
_targetPanel.repaint();
} else {
setToolTip(null);
_highlightcomponent = null;
_targetPanel.repaint();
}
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class PanelEditor method removeMultiItems.
private void removeMultiItems() {
boolean itemsInCopy = false;
if (_selectionGroup == _multiItemCopyGroup) {
itemsInCopy = true;
}
for (Positionable comp : _selectionGroup) {
comp.remove();
}
//As we have removed all the items from the panel we can remove the group.
_selectionGroup = null;
//clear the copy group as the originals no longer exist.
if (itemsInCopy) {
_multiItemCopyGroup = null;
}
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class ControlPanelServlet method getXmlPanel.
@Override
protected String getXmlPanel(String name) {
log.debug("Getting {} for {}", getPanelType(), name);
try {
ControlPanelEditor editor = (ControlPanelEditor) getEditor(name);
Element panel = new Element("panel");
JFrame frame = editor.getTargetFrame();
panel.setAttribute("name", name);
panel.setAttribute("height", Integer.toString(frame.getContentPane().getHeight()));
panel.setAttribute("width", Integer.toString(frame.getContentPane().getWidth()));
panel.setAttribute("panelheight", Integer.toString(editor.getTargetPanel().getHeight()));
panel.setAttribute("panelwidth", Integer.toString(editor.getTargetPanel().getWidth()));
panel.setAttribute("showtooltips", (editor.showTooltip()) ? "yes" : "no");
panel.setAttribute("controlling", (editor.allControlling()) ? "yes" : "no");
if (editor.getBackgroundColor() != null) {
Element color = new Element("backgroundColor");
color.setAttribute("red", Integer.toString(editor.getBackgroundColor().getRed()));
color.setAttribute("green", Integer.toString(editor.getBackgroundColor().getGreen()));
color.setAttribute("blue", Integer.toString(editor.getBackgroundColor().getBlue()));
panel.addContent(color);
}
// include contents
List<Positionable> contents = editor.getContents();
log.debug("N elements: {}", contents.size());
for (Positionable sub : contents) {
if (sub != null) {
try {
Element e = ConfigXmlManager.elementFromObject(sub);
if (e != null) {
if ("signalmasticon".equals(e.getName())) {
//insert icon details into signalmast
e.addContent(getSignalMastIconsElement(e.getAttributeValue("signalmast")));
}
try {
e.setAttribute(JSON.ID, sub.getNamedBean().getSystemName());
} catch (NullPointerException ex) {
if (sub.getNamedBean() == null) {
log.debug("{} {} does not have an associated NamedBean", e.getName(), e.getAttribute(JSON.NAME));
} else {
log.debug("{} {} does not have a SystemName", e.getName(), e.getAttribute(JSON.NAME));
}
}
parsePortableURIs(e);
panel.addContent(e);
}
} catch (Exception ex) {
log.error("Error storing panel element: " + ex, ex);
}
}
}
Document doc = new Document(panel);
XMLOutputter out = new XMLOutputter();
out.setFormat(Format.getPrettyFormat().setLineSeparator(System.getProperty("line.separator")).setTextMode(Format.TextMode.TRIM));
return out.outputString(doc);
} catch (NullPointerException ex) {
log.warn("Requested ControlPanel [" + name + "] does not exist.");
return "ERROR Requested panel [" + name + "] does not exist.";
}
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class CircuitBuilder method makeSelectionGroup.
/**
* ************* end convert icons ******************
*/
/**
* ************** select - deselect track icons ***********************
*/
/**
* select block's track icons for editing -***could be
* _circuitMap.get(block) is sufficient
*/
private ArrayList<Positionable> makeSelectionGroup(OBlock block, boolean showPortal) {
ArrayList<Positionable> group = new ArrayList<Positionable>();
List<Positionable> circuitIcons = _circuitMap.get(block);
Iterator<Positionable> iter = circuitIcons.iterator();
while (iter.hasNext()) {
Positionable p = iter.next();
if (p instanceof PortalIcon) {
if (showPortal) {
((PortalIcon) p).setStatus(PortalIcon.VISIBLE);
group.add(p);
}
} else {
group.add(p);
}
}
return group;
}
use of jmri.jmrit.display.Positionable in project JMRI by JMRI.
the class ControlPanelEditor method copyItem.
/**
* Set up selections for a paste. Note a copy of _selectionGroup is made
* that is NOT in the _contents. This disconnected ArrayList is added to the
* _contents when (if) a paste is made. The disconnected _selectionGroup can
* be dragged to a new location.
*/
@Override
protected void copyItem(Positionable p) {
if (log.isDebugEnabled()) {
// avoid string concatination if not debug
log.debug("Enter copyItem: _selectionGroup {}", _selectionGroup != null ? "size=" + _selectionGroup.size() : "null");
}
// If popup menu hit again, Paste selections and make another copy
if (_pastePending) {
pasteItems();
}
if (_selectionGroup != null && !_selectionGroup.contains(p)) {
deselectSelectionGroup();
}
if (_selectionGroup == null) {
_selectionGroup = new ArrayList<Positionable>();
_selectionGroup.add(p);
}
ArrayList<Positionable> selectionGroup = new ArrayList<Positionable>();
for (Positionable comp : _selectionGroup) {
Positionable pos = comp.deepClone();
selectionGroup.add(pos);
}
// group is now disconnected
_selectionGroup = selectionGroup;
_pastePending = true;
// if (_debug) log.debug("Exit copyItem: _selectionGroup.size()= "+_selectionGroup.size());
}
Aggregations