Package org.gephi.visualization.text

Examples of org.gephi.visualization.text.TextModelImpl


                public void propertyChange(PropertyChangeEvent evt) {
                    VizModel vizModel = VizController.getInstance().getVizModel();
                    Color backgroundColor = ((JColorBlackWhiteSwitcher) backgroundColorButton).getColor();
                    vizModel.setBackgroundColor(backgroundColor);

                    TextModelImpl textModel = VizController.getInstance().getVizModel().getTextModel();
                    boolean isDarkBackground = (backgroundColor.getRed() + backgroundColor.getGreen() + backgroundColor.getBlue()) / 3 < 128;
                    textModel.setNodeColor(isDarkBackground ? Color.WHITE : Color.BLACK);
                }
            });
            vizModel.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
View Full Code Here


                }
            });
            vizModel.getTextModel().addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl textModel = VizController.getInstance().getVizModel().getTextModel();
                    if (showLabelsButton.isSelected() != textModel.isShowNodeLabels()) {
                        showLabelsButton.setSelected(textModel.isShowNodeLabels());
                    }
                }
            });
            components[0] = showLabelsButton;
View Full Code Here

                }
            });
            vizModel.getTextModel().addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl textModel = VizController.getInstance().getVizModel().getTextModel();
                    if (showLabelsButton.isSelected() != textModel.isShowEdgeLabels()) {
                        showLabelsButton.setSelected(textModel.isShowEdgeLabels());
                    }
                }
            });
            components[2] = showLabelsButton;
View Full Code Here

        public String getName() {
            return NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.groupBarTitle");
        }

        public void setModelValues(VizModel vizModel) {
            TextModelImpl model = vizModel.getTextModel();
            ((JPopupButton) components[0]).setSelectedItem(model.getSizeMode());
            ((JPopupButton) components[1]).setSelectedItem(model.getColorMode());
            ((JButton) components[2]).setText(model.getNodeFont().getFontName() + ", " + model.getNodeFont().getSize());
            ((JSlider) components[3]).setValue((int) (model.getNodeSizeFactor() * 100f));
        }
View Full Code Here

            ((JSlider) components[3]).setValue((int) (model.getNodeSizeFactor() * 100f));
        }

        @Override
        public JComponent[] getToolbarComponents() {
            TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();

            //Mode
            final JPopupButton labelSizeModeButton = new JPopupButton();
            TextManager textManager = VizController.getInstance().getTextManager();
            for (final SizeMode sm : textManager.getSizeModes()) {
                labelSizeModeButton.addItem(sm, sm.getIcon());
            }
            labelSizeModeButton.setSelectedItem(model.getSizeMode());
            labelSizeModeButton.setChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    SizeMode sm = (SizeMode) e.getSource();
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    model.setSizeMode(sm);
                }
            });
            labelSizeModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/labelSizeMode.png")));
            labelSizeModeButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.sizeMode"));
            model.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    if (model.getSizeMode() != labelSizeModeButton.getSelectedItem()) {
                        labelSizeModeButton.setSelectedItem(model.getSizeMode());
                    }
                }
            });
            components[0] = labelSizeModeButton;

            //Color mode
            final JPopupButton labelColorModeButton = new JPopupButton();
            for (final ColorMode cm : textManager.getColorModes()) {
                labelColorModeButton.addItem(cm, cm.getIcon());
            }
            labelColorModeButton.setSelectedItem(textManager.getModel().getColorMode());
            labelColorModeButton.setChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    ColorMode cm = (ColorMode) e.getSource();
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    model.setColorMode(cm);
                }
            });
            labelColorModeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/labelColorMode.png")));
            labelColorModeButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.colorMode"));
            model.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    if (model.getColorMode() != labelColorModeButton.getSelectedItem()) {
                        labelColorModeButton.setSelectedItem(model.getColorMode());
                    }
                }
            });
            components[1] = labelColorModeButton;

            //Font
            final JButton fontButton = new JButton(model.getNodeFont().getFontName() + ", " + model.getNodeFont().getSize());
            fontButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.font"));
            fontButton.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);
                    }
                }
            });
            model.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    fontButton.setText(model.getNodeFont().getFontName() + ", " + model.getNodeFont().getSize());
                }
            });
            components[2] = fontButton;

            //Font size
            final JSlider fontSizeSlider = new JSlider(0, 100, (int) (model.getNodeSizeFactor() * 100f));
            fontSizeSlider.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.fontScale"));
            fontSizeSlider.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    model.setNodeSizeFactor(fontSizeSlider.getValue() / 100f);
                }
            });
            fontSizeSlider.setPreferredSize(new Dimension(100, 20));
            fontSizeSlider.setMaximumSize(new Dimension(100, 20));
            model.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    if (((int) (model.getNodeSizeFactor() * 100f)) != fontSizeSlider.getValue()) {
                        fontSizeSlider.setValue((int) (model.getNodeSizeFactor() * 100f));
                    }
                }
            });
            components[3] = fontSizeSlider;

            //Color
            final ColorChooser colorChooser = new ColorChooser(model.getNodeColor());
            colorChooser.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.defaultColor"));
            colorChooser.setPreferredSize(new Dimension(16, 16));
            colorChooser.setMaximumSize(new Dimension(16, 16));
            colorChooser.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals(ColorChooser.PROP_COLOR)) {
                        TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                        model.setNodeColor(colorChooser.getColor());
                    }
                }
            });
            model.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
                    if (!model.getNodeColor().equals(colorChooser.getColor())) {
                        colorChooser.setColor(model.getNodeColor());
                    }
                }
            });
            components[4] = colorChooser;

            //Attributes
            final JButton attributesButton = new JButton();
            attributesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/configureLabels.png")));
            attributesButton.setToolTipText(NbBundle.getMessage(VizBarController.class, "VizToolbar.Labels.attributes"));
            attributesButton.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();
View Full Code Here

        VizModel vizModel = VizController.getInstance().getVizModel();
        setEnable(!vizModel.isDefaultModel());
        if (vizModel.isDefaultModel()) {
            return;
        }
        TextModelImpl model = vizModel.getTextModel();

        //node
        nodeFontButton.setText(model.getNodeFont().getFontName() + ", " + model.getNodeFont().getSize());
        ((JColorButton) nodeColorButton).setColor(model.getNodeColor());
        if (showNodeLabelsCheckbox.isSelected() != model.isShowNodeLabels()) {
            showNodeLabelsCheckbox.setSelected(model.isShowNodeLabels());
        }
        if (nodeSizeSlider.getValue() / 100f != model.getNodeSizeFactor()) {
            nodeSizeSlider.setValue((int) (model.getNodeSizeFactor() * 100f));
        }

        //edge
        edgeFontButton.setText(model.getEdgeFont().getFontName() + ", " + model.getEdgeFont().getSize());
        ((JColorButton) edgeColorButton).setColor(model.getEdgeColor());
        if (showEdgeLabelsCheckbox.isSelected() != model.isShowEdgeLabels()) {
            showEdgeLabelsCheckbox.setSelected(model.isShowEdgeLabels());
        }
        if (edgeSizeSlider.getValue() / 100f != model.getEdgeSizeFactor()) {
            edgeSizeSlider.setValue((int) (model.getEdgeSizeFactor() * 100f));
        }

        //general
        if (hideNonSelectedCheckbox.isSelected() != model.isSelectedOnly()) {
            hideNonSelectedCheckbox.setSelected(model.isSelectedOnly());
        }
        if (sizeModeCombo.getSelectedItem() != model.getSizeMode()) {
            sizeModeCombo.setSelectedItem(model.getSizeMode());
        }
        if (colorModeCombo.getSelectedItem() != model.getColorMode()) {
            colorModeCombo.setSelectedItem(model.getColorMode());
        }
    }
View Full Code Here

        hideNonSelectedCheckbox.setEnabled(enable);
        labelColorMode.setEnabled(enable);
        labelSizeMode.setEnabled(enable);
        configureLabelsButton.setEnabled(enable);

        TextModelImpl model = VizController.getInstance().getVizModel().getTextModel();
        boolean edgeValue = model.isShowEdgeLabels();
        edgeFontButton.setEnabled(enable && edgeValue);
        edgeColorButton.setEnabled(enable && edgeValue);
        edgeSizeSlider.setEnabled(enable && edgeValue);
        labelEdgeColor.setEnabled(enable && edgeValue);
        labelEdgeFont.setEnabled(enable && edgeValue);
        labelEdgeSize.setEnabled(enable && edgeValue);
        boolean nodeValue = model.isShowNodeLabels();
        nodeFontButton.setEnabled(enable && nodeValue);
        nodeColorButton.setEnabled(enable && nodeValue);
        nodeSizeSlider.setEnabled(enable && nodeValue);
        labelNodeColor.setEnabled(enable && nodeValue);
        labelNodeFont.setEnabled(enable && nodeValue);
View Full Code Here

    private void defaultValues() {
        config = VizController.getInstance().getVizConfig();
        cameraPosition = Arrays.copyOf(config.getDefaultCameraPosition(), 3);
        cameraTarget = Arrays.copyOf(config.getDefaultCameraTarget(), 3);
        textModel = new TextModelImpl();
        use3d = config.isDefaultUse3d();
        lighting = use3d;
        culling = use3d;
        material = use3d;
        rotatingEnable = use3d;
View Full Code Here

        nodeFontButton.setFont(nodeFontButton.getFont().deriveFont(11));
    }

    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();
            }
View Full Code Here

TOP

Related Classes of org.gephi.visualization.text.TextModelImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.