Search in sources :

Example 76 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class SlipTurnoutIconXml method loadTurnoutIcon.

private void loadTurnoutIcon(String state, int rotation, SlipTurnoutIcon l, Element element, Editor ed) {
    NamedIcon icon = loadIcon(l, state, element, "SlipTurnout \"" + l.getNameString() + "\" icon \"" + state + "\" ", ed);
    String textValue = null;
    if (icon != null) {
        if (state.equals("lowerWestToUpperEast")) {
            l.setLowerWestToUpperEastIcon(icon);
        } else if (state.equals("upperWestToLowerEast")) {
            l.setUpperWestToLowerEastIcon(icon);
        } else if (state.equals("lowerWestToLowerEast")) {
            l.setLowerWestToLowerEastIcon(icon);
        } else if (state.equals("upperWestToUpperEast")) {
            l.setUpperWestToUpperEastIcon(icon);
        } else if (state.equals("unknown")) {
            l.setUnknownIcon(icon);
        } else if (state.equals("inconsistent")) {
            l.setInconsistentIcon(icon);
        }
    } else {
        return;
    }
    Element elem = element.getChild(state);
    if (elem != null) {
        Element e = elem.getChild("text");
        if (e != null) {
            textValue = e.getText();
        }
    }
    if (textValue != null) {
        if (state.equals("lowerWestToUpperEast")) {
            l.setLWUEText(textValue);
        } else if (state.equals("upperWestToLowerEast")) {
            l.setUWLEText(textValue);
        } else if (state.equals("lowerWestToLowerEast")) {
            l.setLWLEText(textValue);
        } else if (state.equals("upperWestToUpperEast")) {
            l.setUWUEText(textValue);
        }
    }
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Element(org.jdom2.Element)

Example 77 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class CircuitBuilder method convertTO.

private void convertTO() {
    IndicatorTurnoutIcon t = new IndicatorTurnoutIcon(_editor);
    t.setOccBlockHandle(InstanceManager.getDefault(NamedBeanHandleManager.class).getNamedBeanHandle(_currentBlock.getSystemName(), _currentBlock));
    t.setTurnout(((TurnoutIcon) _oldIcon).getNamedTurnout());
    t.setFamily(_trackTOPanel.getFamilyName());
    HashMap<String, HashMap<String, NamedIcon>> iconMap = _trackTOPanel.getIconMaps();
    Iterator<Entry<String, HashMap<String, NamedIcon>>> it = iconMap.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, HashMap<String, NamedIcon>> entry = it.next();
        String status = entry.getKey();
        Iterator<Entry<String, NamedIcon>> iter = entry.getValue().entrySet().iterator();
        while (iter.hasNext()) {
            Entry<String, NamedIcon> ent = iter.next();
            t.setIcon(status, ent.getKey(), new NamedIcon(ent.getValue()));
        }
    }
    t.setLevel(Editor.TURNOUTS);
    t.setScale(_oldIcon.getScale());
    t.rotate(_oldIcon.getDegrees());
    finishConvert(t);
}
Also used : Entry(java.util.Map.Entry) NamedIcon(jmri.jmrit.catalog.NamedIcon) HashMap(java.util.HashMap) IndicatorTurnoutIcon(jmri.jmrit.display.IndicatorTurnoutIcon)

Example 78 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class ControlPanelEditor method makePortalIconMap.

private void makePortalIconMap() {
    _portalIconMap = new HashMap<String, NamedIcon>();
    _portalIconMap.put(PortalIcon.VISIBLE, new NamedIcon("resources/icons/throttles/RoundRedCircle20.png", "resources/icons/throttles/RoundRedCircle20.png"));
    _portalIconMap.put(PortalIcon.PATH, new NamedIcon("resources/icons/greenSquare.gif", "resources/icons/greenSquare.gif"));
    _portalIconMap.put(PortalIcon.HIDDEN, new NamedIcon("resources/icons/Invisible.gif", "resources/icons/Invisible.gif"));
    _portalIconMap.put(PortalIcon.TO_ARROW, new NamedIcon("resources/icons/track/toArrow.gif", "resources/icons/track/toArrow.gif"));
    _portalIconMap.put(PortalIcon.FROM_ARROW, new NamedIcon("resources/icons/track/fromArrow.gif", "resources/icons/track/fromArrow.gif"));
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon)

Example 79 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class SignalMastItemPanel method makeDndIconPanel.

@Override
protected void makeDndIconPanel(HashMap<String, NamedIcon> iconMap, String displayKey) {
    if (_update) {
        return;
    }
    _dragIconPanel.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
    NamedIcon icon = getDragIcon();
    JPanel panel = new JPanel();
    String borderName = ItemPalette.convertText("dragToPanel");
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), borderName));
    JLabel label;
    try {
        label = getDragger(new DataFlavor(Editor.POSITIONABLE_FLAVOR), icon);
        label.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
    } catch (java.lang.ClassNotFoundException cnfe) {
        cnfe.printStackTrace();
        label = new JLabel();
    }
    label.setName(borderName);
    panel.add(label);
    int width = Math.max(100, panel.getPreferredSize().width);
    panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height));
    panel.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
    _dragIconPanel.add(panel);
}
Also used : JPanel(javax.swing.JPanel) NamedIcon(jmri.jmrit.catalog.NamedIcon) JLabel(javax.swing.JLabel) DragJLabel(jmri.jmrit.catalog.DragJLabel) DataFlavor(java.awt.datatransfer.DataFlavor)

Example 80 with NamedIcon

use of jmri.jmrit.catalog.NamedIcon in project JMRI by JMRI.

the class AnalogClock2Display method init.

final void init() {
    // Load the JMRI logo and clock face
    // Icons are the original size version kept for to allow for mulitple resizing
    // and scaled Icons are the version scaled for the panel size
    jmriIcon = new NamedIcon("resources/logo.gif", "resources/logo.gif");
    scaledIcon = new NamedIcon("resources/logo.gif", "resources/logo.gif");
    clockIcon = new NamedIcon("resources/clock2.gif", "resources/clock2.gif");
    logo = jmriIcon.getImage();
    clockFace = clockIcon.getImage();
    // Create an unscaled set of hands to get the original size (height)to use
    // in the scaling calculations
    hourHand = new Polygon(hourX, hourY, 11);
    hourHeight = hourHand.getBounds().getSize().height;
    minuteHand = new Polygon(minuteX, minuteY, 11);
    minuteHeight = minuteHand.getBounds().getSize().height;
    amPm = "AM";
    // request callback to update time
    clock.addMinuteChangeListener(new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            update();
        }
    });
    // request callback to update changes in properties
    clock.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

        @Override
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            update();
        }
    });
    // set to default size
    setSize(clockIcon.getIconHeight());
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Polygon(java.awt.Polygon)

Aggregations

NamedIcon (jmri.jmrit.catalog.NamedIcon)128 Entry (java.util.Map.Entry)28 Element (org.jdom2.Element)27 HashMap (java.util.HashMap)23 JPanel (javax.swing.JPanel)13 Editor (jmri.jmrit.display.Editor)13 Attribute (org.jdom2.Attribute)13 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 JLabel (javax.swing.JLabel)11 JButton (javax.swing.JButton)10 DataFlavor (java.awt.datatransfer.DataFlavor)6 CatalogTreeNode (jmri.jmrit.catalog.CatalogTreeNode)6 DragJLabel (jmri.jmrit.catalog.DragJLabel)6 Sensor (jmri.Sensor)5 CatalogTreeLeaf (jmri.jmrit.catalog.CatalogTreeLeaf)5 RosterEntry (jmri.jmrit.roster.RosterEntry)5 Point (java.awt.Point)4 JComponent (javax.swing.JComponent)4 JDialog (javax.swing.JDialog)4