Search in sources :

Example 1 with MemorySpinnerIcon

use of jmri.jmrit.display.MemorySpinnerIcon in project JMRI by JMRI.

the class MemorySpinnerIconXml method load.

/**
     * Load, starting with the memoryicon element, then all the value-icon pairs
     *
     * @param element Top level Element to unpack.
     * @param o       Editor as an Object
     */
@Override
public void load(Element element, Object o) {
    // create the objects
    Editor p = (Editor) o;
    MemorySpinnerIcon l = new MemorySpinnerIcon(p);
    l.setMemory(element.getAttribute("memory").getValue());
    loadTextInfo(l, element);
    p.putItem(l);
    // load individual item's option settings after editor has set its global settings
    loadCommonAttributes(l, Editor.MEMORIES, element);
}
Also used : MemorySpinnerIcon(jmri.jmrit.display.MemorySpinnerIcon) Editor(jmri.jmrit.display.Editor)

Example 2 with MemorySpinnerIcon

use of jmri.jmrit.display.MemorySpinnerIcon in project JMRI by JMRI.

the class MemoryItemPanel method makeDndIconPanel.

@Override
protected void makeDndIconPanel(java.util.HashMap<String, NamedIcon> iconMap, String displayKey) {
    if (_update) {
        return;
    }
    JPanel panel = new JPanel();
    panel.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints c = new java.awt.GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = java.awt.GridBagConstraints.CENTER;
    c.weightx = 1.0;
    panel.add(new JLabel(Bundle.getMessage("ReadWriteMemory")), c);
    c.gridy = 1;
    _writeMem = new MemoryInputIcon(5, _editor);
    //        JPanel p0 = makeDragIcon(_writeMem, Type.READWRITE);
    panel.add(makeDragIcon(_writeMem, Type.READWRITE), c);
    _spinner = new JSpinner(new SpinnerNumberModel(0, 0, 100, 1));
    JTextField field = ((JSpinner.DefaultEditor) _spinner.getEditor()).getTextField();
    field.setColumns(2);
    field.setText("5");
    _spinner.setMaximumSize(_spinner.getPreferredSize());
    _spinner.addChangeListener(this);
    c.gridy = 2;
    panel.add(_spinner, c);
    c.gridy = 3;
    c.anchor = java.awt.GridBagConstraints.NORTH;
    panel.add(new JLabel(Bundle.getMessage("NumColsLabel")), c);
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = java.awt.GridBagConstraints.CENTER;
    panel.add(new JLabel(Bundle.getMessage("ReadMemory")), c);
    c.gridy = 1;
    _readMem = new MemoryIcon(NamedIcon.getIconByName("resources/icons/misc/X-red.gif"), _editor);
    panel.add(makeDragIcon(_readMem, Type.READONLY), c);
    c.gridx = 2;
    c.gridy = 0;
    panel.add(new JLabel(Bundle.getMessage("SpinnerMemory")), c);
    c.gridy = 1;
    _spinMem = new MemorySpinnerIcon(_editor);
    panel.add(makeDragIcon(_spinMem, Type.SPINNER), c);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 4;
    panel.add(new JLabel(Bundle.getMessage("ComboMemory")), c);
    c.gridy = 3;
    _comboMem = new MemoryComboIcon(_editor, null);
    panel.add(makeDragIcon(_comboMem, Type.COMBO), c);
    _dragIconPanel = panel;
    _dragIconPanel.invalidate();
}
Also used : JPanel(javax.swing.JPanel) MemoryIcon(jmri.jmrit.display.MemoryIcon) MemorySpinnerIcon(jmri.jmrit.display.MemorySpinnerIcon) JLabel(javax.swing.JLabel) MemoryInputIcon(jmri.jmrit.display.MemoryInputIcon) JTextField(javax.swing.JTextField) MemoryComboIcon(jmri.jmrit.display.MemoryComboIcon) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner)

Example 3 with MemorySpinnerIcon

use of jmri.jmrit.display.MemorySpinnerIcon in project JMRI by JMRI.

the class MemorySpinnerIconXml method store.

/**
     * Default implementation for storing the contents of a MemorySpinnerIcon
     *
     * @param o Object to store, of type MemorySpinnerIcon
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    MemorySpinnerIcon p = (MemorySpinnerIcon) o;
    Element element = new Element("memoryicon");
    // include attributes
    element.setAttribute("memory", p.getNamedMemory().getName());
    storeCommonAttributes(p, element);
    storeTextInfo(p, element);
    element.setAttribute("class", "jmri.jmrit.display.configurexml.MemorySpinnerIconXml");
    return element;
}
Also used : MemorySpinnerIcon(jmri.jmrit.display.MemorySpinnerIcon) Element(org.jdom2.Element)

Aggregations

MemorySpinnerIcon (jmri.jmrit.display.MemorySpinnerIcon)3 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JSpinner (javax.swing.JSpinner)1 JTextField (javax.swing.JTextField)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 Editor (jmri.jmrit.display.Editor)1 MemoryComboIcon (jmri.jmrit.display.MemoryComboIcon)1 MemoryIcon (jmri.jmrit.display.MemoryIcon)1 MemoryInputIcon (jmri.jmrit.display.MemoryInputIcon)1 Element (org.jdom2.Element)1