use of org.cytoscape.util.swing.ColorButton in project cytoscape-impl by cytoscape.
the class AbstractChartEditor method getAxisColorBtn.
protected ColorButton getAxisColorBtn() {
if (axisColorBtn == null) {
final Color color = chart.get(AXIS_COLOR, Color.class, Color.DARK_GRAY);
axisColorBtn = new ColorButton(color);
axisColorBtn.setVisible(hasAxes);
axisColorBtn.addPropertyChangeListener("color", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
final Color newColor = (Color) e.getNewValue();
chart.set(AXIS_COLOR, newColor);
}
});
}
return axisColorBtn;
}
use of org.cytoscape.util.swing.ColorButton in project cytoscape-impl by cytoscape.
the class ArrowAnnotationPanel method initComponents.
private void initComponents() {
setBorder(LookAndFeelUtil.createPanelBorder());
final JLabel nameLabel = new JLabel("Annotation Name:");
final JLabel label1 = new JLabel("Line Color:");
final JLabel label2 = new JLabel("Line Opacity:");
final JLabel label3 = new JLabel("Line Width:");
nameField = new JTextField(32);
if (annotation.getName() != null) {
nameField.setText(annotation.getName());
}
nameField.addMouseListener(new TextFieldMouseListener(nameField, preview));
final ColorButton lineColorButton = new ColorButton((Color) preview.getLineColor());
lineColorButton.setToolTipText("Select line color...");
final JSlider lineOpacitySlider = new JSlider(0, 100);
final JCheckBox lineColorCheck = new JCheckBox();
lineColorCheck.setSelected(annotation.getLineColor() != null);
lineColorCheck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (lineColorCheck.isSelected()) {
lineColorButton.setEnabled(true);
lineOpacitySlider.setEnabled(true);
preview.setLineColor(mixColor(lineColorButton.getColor(), lineOpacitySlider.getValue()));
} else {
lineColorButton.setEnabled(false);
lineOpacitySlider.setEnabled(false);
preview.setLineColor(null);
}
previewPanel.repaint();
}
});
lineColorButton.setEnabled(lineColorCheck.isSelected());
lineColorButton.addPropertyChangeListener("color", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
preview.setLineColor(mixColor((Color) evt.getNewValue(), lineOpacitySlider.getValue()));
previewPanel.repaint();
}
});
lineOpacitySlider.setMajorTickSpacing(100);
lineOpacitySlider.setMinorTickSpacing(25);
lineOpacitySlider.setPaintTicks(true);
lineOpacitySlider.setPaintLabels(true);
lineOpacitySlider.setValue(100);
lineOpacitySlider.setEnabled(lineColorCheck.isSelected());
lineOpacitySlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
preview.setLineColor(mixColor(preview.getLineColor(), lineOpacitySlider.getValue()));
previewPanel.repaint();
}
});
final JComboBox<String> lineWidthCombo = new JComboBox<>();
lineWidthCombo.setModel(new DefaultComboBoxModel<String>(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }));
lineWidthCombo.setSelectedIndex(1);
for (int i = 0; i < lineWidthCombo.getModel().getSize(); i++) {
if (((int) annotation.getLineWidth()) == Integer.parseInt((String) lineWidthCombo.getModel().getElementAt(i))) {
lineWidthCombo.setSelectedIndex(i);
break;
}
}
lineWidthCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
preview.setLineWidth(Integer.parseInt((String) (lineWidthCombo.getModel().getSelectedItem())));
previewPanel.repaint();
}
});
final JPanel sourcePanel = getArrowPanel(ArrowEnd.SOURCE);
final JPanel targetPanel = getArrowPanel(ArrowEnd.TARGET);
final GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
layout.setHorizontalGroup(layout.createParallelGroup(CENTER, true).addGroup(layout.createSequentialGroup().addGap(10, 20, Short.MAX_VALUE).addGroup(layout.createParallelGroup(TRAILING, true).addComponent(label1).addComponent(label2).addComponent(label3)).addPreferredGap(ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(Alignment.LEADING, true).addGroup(layout.createSequentialGroup().addComponent(lineColorCheck, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(lineColorButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addComponent(lineOpacitySlider, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(lineWidthCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGap(10, 20, Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addComponent(sourcePanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(ComponentPlacement.RELATED).addComponent(targetPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(CENTER, false).addComponent(label1).addComponent(lineColorCheck).addComponent(lineColorButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGroup(layout.createParallelGroup(LEADING, false).addComponent(label2).addComponent(lineOpacitySlider, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGroup(layout.createParallelGroup(CENTER, false).addComponent(label3).addComponent(lineWidthCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(LEADING, true).addComponent(sourcePanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(targetPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)));
iModifySAPreview();
}
Aggregations