Search in sources :

Example 26 with DialogDescriptor

use of org.openide.DialogDescriptor in project gephi by gephi.

the class LabelSettingsPanel method setup.

public void setup() {
    VizModel vizModel = VizController.getInstance().getVizModel();
    TextModelImpl model = vizModel.getTextModel();
    vizModel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("init")) {
                refreshSharedConfig();
            }
        }
    });
    // NodePanel
    showNodeLabelsCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            boolean value = showNodeLabelsCheckbox.isSelected();
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (value != model.isShowNodeLabels()) {
                model.setShowNodeLabels(value);
                setEnable(true);
            }
        }
    });
    nodeFontButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            Font font = JFontChooser.showDialog(WindowManager.getDefault().getMainWindow(), model.getNodeFont());
            if (font != null && font != model.getNodeFont()) {
                model.setNodeFont(font);
            }
        }
    });
    ((JColorButton) nodeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (!model.getNodeColor().equals(((JColorButton) nodeColorButton).getColor())) {
                model.setNodeColor(((JColorButton) nodeColorButton).getColor());
            }
        }
    });
    nodeSizeSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (model.getNodeSizeFactor() != nodeSizeSlider.getValue() / 100f) {
                model.setNodeSizeFactor(nodeSizeSlider.getValue() / 100f);
            }
        }
    });
    // EdgePanel
    showEdgeLabelsCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            boolean value = showEdgeLabelsCheckbox.isSelected();
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (value != model.isShowEdgeLabels()) {
                model.setShowEdgeLabels(value);
                setEnable(true);
            }
        }
    });
    edgeFontButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            Font font = JFontChooser.showDialog(WindowManager.getDefault().getMainWindow(), model.getEdgeFont());
            if (font != null && font != model.getEdgeFont()) {
                model.setEdgeFont(font);
            }
        }
    });
    ((JColorButton) edgeColorButton).addPropertyChangeListener(JColorButton.EVENT_COLOR, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (!model.getEdgeColor().equals(((JColorButton) edgeColorButton).getColor())) {
                model.setEdgeColor(((JColorButton) edgeColorButton).getColor());
            }
        }
    });
    edgeSizeSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            model.setEdgeSizeFactor(edgeSizeSlider.getValue() / 100f);
        }
    });
    // General
    final TextManager textManager = VizController.getInstance().getTextManager();
    final DefaultComboBoxModel sizeModeModel = new DefaultComboBoxModel(textManager.getSizeModes());
    sizeModeCombo.setModel(sizeModeModel);
    final DefaultComboBoxModel colorModeModel = new DefaultComboBoxModel(textManager.getColorModes());
    colorModeCombo.setModel(colorModeModel);
    sizeModeCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (model.getSizeMode() != sizeModeModel.getSelectedItem()) {
                model.setSizeMode((SizeMode) sizeModeModel.getSelectedItem());
            }
        }
    });
    colorModeCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (model.getColorMode() != colorModeModel.getSelectedItem()) {
                model.setColorMode((ColorMode) colorModeModel.getSelectedItem());
            }
        }
    });
    hideNonSelectedCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            if (model.isSelectedOnly() != hideNonSelectedCheckbox.isSelected()) {
                model.setSelectedOnly(hideNonSelectedCheckbox.isSelected());
            }
        }
    });
    // Attributes
    configureLabelsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
            LabelAttributesPanel panel = new LabelAttributesPanel();
            panel.setup(model);
            DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(VizBarController.class, "LabelAttributesPanel.title"), true, NotifyDescriptor.OK_CANCEL_OPTION, null, null);
            if (DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) {
                panel.unsetup();
                return;
            }
        }
    });
    // Evt
    model.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            refreshSharedConfig();
        }
    });
    refreshSharedConfig();
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) ItemEvent(java.awt.event.ItemEvent) TextManager(org.gephi.visualization.text.TextManager) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) ColorMode(org.gephi.visualization.text.ColorMode) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Font(java.awt.Font) JColorButton(org.gephi.ui.components.JColorButton) VizModel(org.gephi.visualization.VizModel) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) SizeMode(org.gephi.visualization.text.SizeMode) TextModelImpl(org.gephi.visualization.text.TextModelImpl) DialogDescriptor(org.openide.DialogDescriptor) ItemListener(java.awt.event.ItemListener) PropertyChangeListener(java.beans.PropertyChangeListener) ChangeListener(javax.swing.event.ChangeListener)

Example 27 with DialogDescriptor

use of org.openide.DialogDescriptor in project gephi-plugins-bootcamp by gephi.

the class InteractiveSparkline method execute.

@Override
public void execute() {
    // Show interactive sparkline window:
    // Dimension is automatically updated by SparklineComponent
    SparklineParameters parameters = new SparklineParameters(200, 20, SparklineParameters.DEFAULT_LINE_COLOR, new Color(225, 255, 255), Color.RED, Color.GREEN);
    parameters.setHighlightTextColor(SparklineParameters.DEFAULT_TEXT_COLOR);
    parameters.setHighlightTextBoxColor(SparklineParameters.DEFAULT_TEXT_BOX_COLOR);
    // True makes it interactive to mouse
    SparklineComponent sparklineUI = new SparklineComponent(xValues, yValues, parameters, true);
    // Initial size
    sparklineUI.setPreferredSize(new Dimension(200, 20));
    // Using Netbeans RCP Dialogs API:
    DialogDescriptor dd = new DialogDescriptor(sparklineUI, column.getTitle());
    dd.setModal(false);
    // No buttons
    dd.setOptions(new Object[0]);
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
}
Also used : SparklineComponent(org.gephi.utils.sparklines.SparklineComponent) SparklineParameters(org.gephi.utils.sparklines.SparklineParameters) Color(java.awt.Color) DialogDescriptor(org.openide.DialogDescriptor) Dimension(java.awt.Dimension)

Aggregations

DialogDescriptor (org.openide.DialogDescriptor)27 JPanel (javax.swing.JPanel)15 FileObject (org.openide.filesystems.FileObject)9 JButton (javax.swing.JButton)8 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)8 ActionEvent (java.awt.event.ActionEvent)7 ActionListener (java.awt.event.ActionListener)7 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)7 Container (org.gephi.io.importer.api.Container)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 NotifyDescriptor (org.openide.NotifyDescriptor)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 File (java.io.File)4 IOException (java.io.IOException)4 LongTask (org.gephi.utils.longtask.spi.LongTask)4 BorderLayout (java.awt.BorderLayout)3 Component (java.awt.Component)3 Dialog (java.awt.Dialog)3