use of jmri.jmrit.display.controlPanelEditor.ControlPanelEditor in project JMRI by JMRI.
the class DrawEllipse method makeFigure.
/**
* Create a new PositionableShape
*/
@Override
protected boolean makeFigure(MouseEvent event) {
ControlPanelEditor ed = _parent.getEditor();
Rectangle r = ed.getSelectRect();
if (r != null) {
_width = r.width;
_height = r.height;
Ellipse2D.Double rr = new Ellipse2D.Double(0, 0, _width, _height);
PositionableEllipse ps = new PositionableEllipse(ed, rr);
ps.setLocation(r.x, r.y);
ps.updateSize();
setDisplayParams(ps);
ps.setEditFrame(this);
ed.putItem(ps);
}
return true;
}
use of jmri.jmrit.display.controlPanelEditor.ControlPanelEditor in project JMRI by JMRI.
the class JsonUtilHttpService method getPanels.
public JsonNode getPanels(Locale locale, String format) {
ArrayNode root = mapper.createArrayNode();
// list loaded Panels (ControlPanelEditor, PanelEditor, LayoutEditor, SwitchboardEditor)
// list ControlPanelEditors
Editor.getEditors(ControlPanelEditor.class).stream().map((editor) -> this.getPanel(locale, editor, format)).filter((panel) -> (panel != null)).forEach((panel) -> {
root.add(panel);
});
// list LayoutEditors and PanelEditors
Editor.getEditors(PanelEditor.class).stream().map((editor) -> this.getPanel(locale, editor, format)).filter((panel) -> (panel != null)).forEach((panel) -> {
root.add(panel);
});
// list SwitchboardEditors
Editor.getEditors(SwitchboardEditor.class).stream().map((editor) -> this.getPanel(locale, editor, format)).filter((panel) -> (panel != null)).forEach((panel) -> {
root.add(panel);
});
return root;
}
use of jmri.jmrit.display.controlPanelEditor.ControlPanelEditor 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.controlPanelEditor.ControlPanelEditor in project JMRI by JMRI.
the class DrawRectangle method makeFigure.
/**
* Create a new PositionableShape
*/
@Override
protected boolean makeFigure(MouseEvent event) {
ControlPanelEditor ed = _parent.getEditor();
Rectangle r = ed.getSelectRect();
if (r != null) {
_width = r.width;
_height = r.height;
Rectangle2D.Double rr = new Rectangle2D.Double(0, 0, _width, _height);
PositionableShape ps = new PositionableRectangle(ed, rr);
ps.setLocation(r.x, r.y);
ps.updateSize();
setDisplayParams(ps);
ps.setEditFrame(this);
ed.putItem(ps);
}
return true;
}
use of jmri.jmrit.display.controlPanelEditor.ControlPanelEditor in project JMRI by JMRI.
the class DrawRoundRect method makeFigure.
/**
* Create a new PositionableShape
*/
@Override
protected boolean makeFigure(MouseEvent event) {
ControlPanelEditor ed = _parent.getEditor();
Rectangle r = ed.getSelectRect();
if (r != null) {
RoundRectangle2D.Double rr = new RoundRectangle2D.Double(0, 0, r.width, r.height, 40, 40);
PositionableRoundRect ps = new PositionableRoundRect(ed, rr);
ps.setLocation(r.x, r.y);
ps.updateSize();
setDisplayParams(ps);
ps.setEditFrame(this);
ed.putItem(ps);
}
return true;
}
Aggregations