Search in sources :

Example 6 with ControlPanelEditor

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;
}
Also used : ControlPanelEditor(jmri.jmrit.display.controlPanelEditor.ControlPanelEditor) Rectangle(java.awt.Rectangle) Ellipse2D(java.awt.geom.Ellipse2D)

Example 7 with ControlPanelEditor

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;
}
Also used : ControlPanelEditor(jmri.jmrit.display.controlPanelEditor.ControlPanelEditor) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) ConnectionConfig(jmri.jmrix.ConnectionConfig) URL(jmri.server.json.JSON.URL) ProfileManager(jmri.profile.ProfileManager) DccLocoAddress(jmri.DccLocoAddress) JmriJFrame(jmri.util.JmriJFrame) PANEL(jmri.server.json.JSON.PANEL) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Editor(jmri.jmrit.display.Editor) JsonException(jmri.server.json.JsonException) SWITCHBOARD_PANEL(jmri.server.json.JSON.SWITCHBOARD_PANEL) ArrayList(java.util.ArrayList) TYPE(jmri.server.json.JSON.TYPE) JsonServerPreferences(jmri.jmris.json.JsonServerPreferences) ConnectionConfigManager(jmri.jmrix.ConnectionConfigManager) Locale(java.util.Locale) Profile(jmri.profile.Profile) SwitchboardEditor(jmri.jmrit.display.switchboardEditor.SwitchboardEditor) PanelEditor(jmri.jmrit.display.panelEditor.PanelEditor) JsonNode(com.fasterxml.jackson.databind.JsonNode) NAME(jmri.server.json.JSON.NAME) InstanceManager(jmri.InstanceManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HttpServletResponse(javax.servlet.http.HttpServletResponse) JsonHttpService(jmri.server.json.JsonHttpService) Metadata(jmri.Metadata) LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) WebServerPreferences(jmri.web.server.WebServerPreferences) SystemConnectionMemo(jmri.jmrix.SystemConnectionMemo) CONTROL_PANEL(jmri.server.json.JSON.CONTROL_PANEL) ConnectionNameFromSystemName(jmri.util.ConnectionNameFromSystemName) DATA(jmri.server.json.JSON.DATA) USERNAME(jmri.server.json.JSON.USERNAME) JSON(jmri.server.json.JSON) NodeIdentity(jmri.util.node.NodeIdentity) ZeroConfService(jmri.util.zeroconf.ZeroConfService) LAYOUT_PANEL(jmri.server.json.JSON.LAYOUT_PANEL) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 8 with ControlPanelEditor

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.";
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) ControlPanelEditor(jmri.jmrit.display.controlPanelEditor.ControlPanelEditor) JFrame(javax.swing.JFrame) Element(org.jdom2.Element) Positionable(jmri.jmrit.display.Positionable) Document(org.jdom2.Document)

Example 9 with ControlPanelEditor

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;
}
Also used : ControlPanelEditor(jmri.jmrit.display.controlPanelEditor.ControlPanelEditor) Rectangle(java.awt.Rectangle) Rectangle2D(java.awt.geom.Rectangle2D)

Example 10 with ControlPanelEditor

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;
}
Also used : ControlPanelEditor(jmri.jmrit.display.controlPanelEditor.ControlPanelEditor) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Rectangle(java.awt.Rectangle)

Aggregations

ControlPanelEditor (jmri.jmrit.display.controlPanelEditor.ControlPanelEditor)15 Rectangle (java.awt.Rectangle)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ConfigureManager (jmri.ConfigureManager)3 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)3 Element (org.jdom2.Element)3 Point (java.awt.Point)2 Ellipse2D (java.awt.geom.Ellipse2D)2 File (java.io.File)2 JFrame (javax.swing.JFrame)2 Sensor (jmri.Sensor)2 SensorManager (jmri.SensorManager)2 NamedIcon (jmri.jmrit.catalog.NamedIcon)2 Positionable (jmri.jmrit.display.Positionable)2 SwitchboardEditor (jmri.jmrit.display.switchboardEditor.SwitchboardEditor)2 JmriJFrame (jmri.util.JmriJFrame)2 Attribute (org.jdom2.Attribute)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1