Search in sources :

Example 1 with ColorPane

use of org.cytoscape.internal.prefs.lib.ColorPane in project cytoscape-impl by cytoscape.

the class AbstractPrefsPanel method inject.

// ------------------------------------------------------------------
// For each type of control we have used,
// here we push a value into the control (inject).
// and pull the value out (scrape)
protected void inject(String value, JComponent control) {
    if (control instanceof JCheckBox) {
        JCheckBox ck = (JCheckBox) control;
        boolean val = value.toLowerCase().startsWith("t");
        ck.setSelected(val);
    }
    if (control instanceof JTextField) {
        JTextField fld = (JTextField) control;
        fld.setText(value);
    }
    if (control instanceof JComboBox) {
        JComboBox s = (JComboBox) control;
        s.setSelectedItem(value);
    }
    if (control instanceof ColorPane) {
        ColorPane s = (ColorPane) control;
        try {
            s.setColor(new Color(Integer.parseInt(value)));
        } catch (NumberFormatException e) {
        }
    }
    if (control instanceof JSlider) {
        JSlider s = (JSlider) control;
        try {
            int i = Integer.parseInt(value);
            s.setValue(i);
        } catch (NumberFormatException e) {
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) JComboBox(javax.swing.JComboBox) Color(java.awt.Color) ColorPane(org.cytoscape.internal.prefs.lib.ColorPane) JSlider(javax.swing.JSlider) JTextField(javax.swing.JTextField)

Example 2 with ColorPane

use of org.cytoscape.internal.prefs.lib.ColorPane in project cytoscape-impl by cytoscape.

the class PrefsColor method makeColorColumn.

VBox makeColorColumn(String description, Color[] colors, String selection) {
    VBox box = new VBox(false, false);
    int row = 0;
    for (Color color : colors) {
        ColorPane c = new ColorPane(row++, 0, color, null);
        c.setEnabled(false);
        c.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                select(box, description);
            }
        });
        box.add(c);
    }
    box.setBorder(description.equals(selection) ? red4 : orange4);
    box.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            select(box, description);
        }
    });
    allVisPalettes.put(description, box);
    return box;
}
Also used : MouseEvent(java.awt.event.MouseEvent) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) ColorPane(org.cytoscape.internal.prefs.lib.ColorPane) VBox(org.cytoscape.internal.prefs.lib.VBox)

Aggregations

Color (java.awt.Color)2 ColorPane (org.cytoscape.internal.prefs.lib.ColorPane)2 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JSlider (javax.swing.JSlider)1 JTextField (javax.swing.JTextField)1 VBox (org.cytoscape.internal.prefs.lib.VBox)1