Search in sources :

Example 1 with TextManager

use of org.gephi.visualization.text.TextManager 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 2 with TextManager

use of org.gephi.visualization.text.TextManager in project gephi by gephi.

the class VizController method initInstances.

public void initInstances() {
    vizConfig = new VizConfig();
    graphIO = new StandardGraphIO();
    engine = new CompatibilityEngine();
    vizEventManager = new StandardVizEventManager();
    scheduler = new CompatibilityScheduler();
    limits = new GraphLimits();
    dataBridge = new DataBridge();
    textManager = new TextManager();
    screenshotMaker = new ScreenshotMaker();
    currentModel = new VizModel(true);
    selectionManager = new SelectionManager();
    if (vizConfig.isUseGLJPanel()) {
    //No more supported
    } else if (Utilities.isMac()) {
        drawable = createCanvas();
    } else {
        drawable = createNewtCanvas();
    }
    drawable.initArchitecture();
    engine.initArchitecture();
    ((CompatibilityScheduler) scheduler).initArchitecture();
    ((StandardGraphIO) graphIO).initArchitecture();
    dataBridge.initArchitecture();
    textManager.initArchitecture();
    screenshotMaker.initArchitecture();
    vizEventManager.initArchitecture();
    selectionManager.initArchitecture();
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    pc.addWorkspaceListener(new WorkspaceListener() {

        @Override
        public void initialize(Workspace workspace) {
            if (workspace.getLookup().lookup(VizModel.class) == null) {
                workspace.add(new VizModel(workspace));
            }
        }

        @Override
        public void select(Workspace workspace) {
            engine.reinit();
        }

        @Override
        public void unselect(Workspace workspace) {
        }

        @Override
        public void close(Workspace workspace) {
        }

        @Override
        public void disable() {
            engine.reinit();
        }
    });
    if (pc.getCurrentWorkspace() != null) {
        engine.reinit();
    }
}
Also used : SelectionManager(org.gephi.visualization.api.selection.SelectionManager) CompatibilityEngine(org.gephi.visualization.opengl.CompatibilityEngine) TextManager(org.gephi.visualization.text.TextManager) StandardVizEventManager(org.gephi.visualization.events.StandardVizEventManager) CompatibilityScheduler(org.gephi.visualization.scheduler.CompatibilityScheduler) ProjectController(org.gephi.project.api.ProjectController) WorkspaceListener(org.gephi.project.api.WorkspaceListener) StandardGraphIO(org.gephi.visualization.swing.StandardGraphIO) ScreenshotMaker(org.gephi.visualization.screenshot.ScreenshotMaker) VizConfig(org.gephi.visualization.apiimpl.VizConfig) DataBridge(org.gephi.visualization.bridge.DataBridge) Workspace(org.gephi.project.api.Workspace)

Example 3 with TextManager

use of org.gephi.visualization.text.TextManager in project gephi by gephi.

the class OffscreenCanvas method init.

@Override
public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();
    initConfig(gl);
    engine.initDisplayLists(gl, GLU);
    TextManager textManager = VizController.getInstance().getTextManager();
    textManager.reinitRenderers();
}
Also used : TextManager(org.gephi.visualization.text.TextManager) GL2(com.jogamp.opengl.GL2)

Aggregations

TextManager (org.gephi.visualization.text.TextManager)3 GL2 (com.jogamp.opengl.GL2)1 Font (java.awt.Font)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 ProjectController (org.gephi.project.api.ProjectController)1 Workspace (org.gephi.project.api.Workspace)1 WorkspaceListener (org.gephi.project.api.WorkspaceListener)1 JColorButton (org.gephi.ui.components.JColorButton)1 VizModel (org.gephi.visualization.VizModel)1 SelectionManager (org.gephi.visualization.api.selection.SelectionManager)1 VizConfig (org.gephi.visualization.apiimpl.VizConfig)1 DataBridge (org.gephi.visualization.bridge.DataBridge)1