Search in sources :

Example 21 with JColorButton

use of org.gephi.ui.components.JColorButton in project gephi by gephi.

the class EdgeSettingsPanel method initComponents.

/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    showEdgesCheckbox = new javax.swing.JCheckBox();
    labelEdgeColor = new javax.swing.JLabel();
    edgeColorButton = new JColorButton(Color.BLACK, false, true);
    sourceNodeColorCheckbox = new javax.swing.JCheckBox();
    selectionColorPanel = new javax.swing.JPanel();
    selectionColorCheckbox = new javax.swing.JCheckBox();
    edgeInSelectionColorChooser = new net.java.dev.colorchooser.ColorChooser();
    edgeOutSelectionColorChooser = new net.java.dev.colorchooser.ColorChooser();
    edgeBothSelectionColorChooser = new net.java.dev.colorchooser.ColorChooser();
    labelIn = new javax.swing.JLabel();
    labelOut = new javax.swing.JLabel();
    labelBoth = new javax.swing.JLabel();
    scalePanel = new javax.swing.JPanel();
    labelScale = new javax.swing.JLabel();
    scaleSlider = new javax.swing.JSlider();
    // NOI18N
    showEdgesCheckbox.setFont(new java.awt.Font("Tahoma", 1, 11));
    // NOI18N
    showEdgesCheckbox.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.showEdgesCheckbox.text"));
    // NOI18N
    labelEdgeColor.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.labelEdgeColor.text"));
    // NOI18N
    edgeColorButton.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.edgeColorButton.text"));
    // NOI18N
    sourceNodeColorCheckbox.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.sourceNodeColorCheckbox.text"));
    sourceNodeColorCheckbox.setBorder(null);
    sourceNodeColorCheckbox.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    sourceNodeColorCheckbox.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    sourceNodeColorCheckbox.setMargin(new java.awt.Insets(2, 0, 2, 2));
    selectionColorPanel.setOpaque(false);
    selectionColorPanel.setLayout(new java.awt.GridBagLayout());
    // NOI18N
    selectionColorCheckbox.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.selectionColorCheckbox.text"));
    // NOI18N
    selectionColorCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.selectionColorCheckbox.toolTipText"));
    selectionColorCheckbox.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    selectionColorCheckbox.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    selectionColorCheckbox.setMaximumSize(new java.awt.Dimension(160, 18));
    selectionColorCheckbox.setMinimumSize(new java.awt.Dimension(160, 18));
    selectionColorCheckbox.setPreferredSize(new java.awt.Dimension(160, 18));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    selectionColorPanel.add(selectionColorCheckbox, gridBagConstraints);
    edgeInSelectionColorChooser.setMinimumSize(new java.awt.Dimension(14, 14));
    edgeInSelectionColorChooser.setPreferredSize(new java.awt.Dimension(14, 14));
    // NOI18N
    edgeInSelectionColorChooser.setToolTipText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.edgeInSelectionColorChooser.toolTipText"));
    javax.swing.GroupLayout edgeInSelectionColorChooserLayout = new javax.swing.GroupLayout(edgeInSelectionColorChooser);
    edgeInSelectionColorChooser.setLayout(edgeInSelectionColorChooserLayout);
    edgeInSelectionColorChooserLayout.setHorizontalGroup(edgeInSelectionColorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 12, Short.MAX_VALUE));
    edgeInSelectionColorChooserLayout.setVerticalGroup(edgeInSelectionColorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 12, Short.MAX_VALUE));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
    selectionColorPanel.add(edgeInSelectionColorChooser, gridBagConstraints);
    edgeOutSelectionColorChooser.setMinimumSize(new java.awt.Dimension(14, 14));
    edgeOutSelectionColorChooser.setPreferredSize(new java.awt.Dimension(14, 14));
    // NOI18N
    edgeOutSelectionColorChooser.setToolTipText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.edgeOutSelectionColorChooser.toolTipText"));
    javax.swing.GroupLayout edgeOutSelectionColorChooserLayout = new javax.swing.GroupLayout(edgeOutSelectionColorChooser);
    edgeOutSelectionColorChooser.setLayout(edgeOutSelectionColorChooserLayout);
    edgeOutSelectionColorChooserLayout.setHorizontalGroup(edgeOutSelectionColorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 12, Short.MAX_VALUE));
    edgeOutSelectionColorChooserLayout.setVerticalGroup(edgeOutSelectionColorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 12, Short.MAX_VALUE));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
    selectionColorPanel.add(edgeOutSelectionColorChooser, gridBagConstraints);
    edgeBothSelectionColorChooser.setMinimumSize(new java.awt.Dimension(14, 14));
    edgeBothSelectionColorChooser.setPreferredSize(new java.awt.Dimension(14, 14));
    // NOI18N
    edgeBothSelectionColorChooser.setToolTipText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.edgeBothSelectionColorChooser.toolTipText"));
    javax.swing.GroupLayout edgeBothSelectionColorChooserLayout = new javax.swing.GroupLayout(edgeBothSelectionColorChooser);
    edgeBothSelectionColorChooser.setLayout(edgeBothSelectionColorChooserLayout);
    edgeBothSelectionColorChooserLayout.setHorizontalGroup(edgeBothSelectionColorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 12, Short.MAX_VALUE));
    edgeBothSelectionColorChooserLayout.setVerticalGroup(edgeBothSelectionColorChooserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 12, Short.MAX_VALUE));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
    selectionColorPanel.add(edgeBothSelectionColorChooser, gridBagConstraints);
    // NOI18N
    labelIn.setFont(new java.awt.Font("Tahoma", 0, 10));
    // NOI18N
    labelIn.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.labelIn.text"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
    selectionColorPanel.add(labelIn, gridBagConstraints);
    // NOI18N
    labelOut.setFont(new java.awt.Font("Tahoma", 0, 10));
    // NOI18N
    labelOut.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.labelOut.text"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 0);
    selectionColorPanel.add(labelOut, gridBagConstraints);
    // NOI18N
    labelBoth.setFont(new java.awt.Font("Tahoma", 0, 10));
    // NOI18N
    labelBoth.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.labelBoth.text"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
    selectionColorPanel.add(labelBoth, gridBagConstraints);
    scalePanel.setOpaque(false);
    scalePanel.setLayout(new java.awt.GridBagLayout());
    // NOI18N
    labelScale.setText(org.openide.util.NbBundle.getMessage(EdgeSettingsPanel.class, "EdgeSettingsPanel.labelScale.text"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(3, 5, 2, 0);
    scalePanel.add(labelScale, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    scalePanel.add(scaleSlider, gridBagConstraints);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(19, 19, 19).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(labelEdgeColor).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(edgeColorButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)).addComponent(sourceNodeColorCheckbox)).addGap(28, 28, 28).addComponent(scalePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).addComponent(selectionColorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(showEdgesCheckbox))).addContainerGap(146, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup().addContainerGap().addComponent(showEdgesCheckbox).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(labelEdgeColor)).addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup().addGap(32, 32, 32).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(edgeColorButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(13, 13, 13).addComponent(sourceNodeColorCheckbox)).addComponent(scalePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE).addComponent(selectionColorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)))).addContainerGap()));
}
Also used : JColorButton(org.gephi.ui.components.JColorButton)

Example 22 with JColorButton

use of org.gephi.ui.components.JColorButton in project gephi by gephi.

the class EdgeSettingsPanel method refreshSharedConfig.

private void refreshSharedConfig() {
    VizModel vizModel = VizController.getInstance().getVizModel();
    setEnable(!vizModel.isDefaultModel());
    if (vizModel.isDefaultModel()) {
        return;
    }
    if (showEdgesCheckbox.isSelected() != vizModel.isShowEdges()) {
        showEdgesCheckbox.setSelected(vizModel.isShowEdges());
    }
    float[] edgeCol = vizModel.getEdgeUniColor();
    ((JColorButton) edgeColorButton).setColor(new Color(edgeCol[0], edgeCol[1], edgeCol[2], edgeCol[3]));
    if (sourceNodeColorCheckbox.isSelected() != !vizModel.isEdgeHasUniColor()) {
        sourceNodeColorCheckbox.setSelected(!vizModel.isEdgeHasUniColor());
    }
    if (selectionColorCheckbox.isSelected() != vizModel.isEdgeSelectionColor()) {
        selectionColorCheckbox.setSelected(vizModel.isEdgeSelectionColor());
    }
    Color in = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), vizModel.getEdgeInSelectionColor(), 1f);
    Color out = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), vizModel.getEdgeOutSelectionColor(), 1f);
    Color both = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB), vizModel.getEdgeBothSelectionColor(), 1f);
    if (!edgeInSelectionColorChooser.getColor().equals(in)) {
        edgeInSelectionColorChooser.setColor(in);
    }
    if (!edgeBothSelectionColorChooser.getColor().equals(both)) {
        edgeBothSelectionColorChooser.setColor(both);
    }
    if (!edgeOutSelectionColorChooser.getColor().equals(out)) {
        edgeOutSelectionColorChooser.setColor(out);
    }
    if (scaleSlider.getValue() / 10f + 0.1f != vizModel.getEdgeScale()) {
        scaleSlider.setValue((int) ((vizModel.getEdgeScale() - 0.1f) * 10));
    }
}
Also used : JColorButton(org.gephi.ui.components.JColorButton) VizModel(org.gephi.visualization.VizModel) Color(java.awt.Color)

Aggregations

JColorButton (org.gephi.ui.components.JColorButton)22 VizModel (org.gephi.visualization.VizModel)6 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 ItemEvent (java.awt.event.ItemEvent)3 ItemListener (java.awt.event.ItemListener)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 PropertyChangeListener (java.beans.PropertyChangeListener)3 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)3 ChangeEvent (javax.swing.event.ChangeEvent)3 ChangeListener (javax.swing.event.ChangeListener)3 Color (java.awt.Color)2 Font (java.awt.Font)2 TextModelImpl (org.gephi.visualization.text.TextModelImpl)2 BorderLayout (java.awt.BorderLayout)1 CardLayout (java.awt.CardLayout)1 Dimension (java.awt.Dimension)1 JButton (javax.swing.JButton)1 Edge (org.gephi.graph.api.Edge)1 Graph (org.gephi.graph.api.Graph)1