Search in sources :

Example 1 with RichTooltip

use of org.gephi.ui.components.richtooltip.RichTooltip in project gephi by gephi.

the class LayoutPanel method initEvents.

private void initEvents() {
    layoutCombobox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (layoutCombobox.getSelectedItem().equals(NO_SELECTION) && model.getSelectedLayout() != null) {
                setSelectedLayout(null);
            } else if (layoutCombobox.getSelectedItem() instanceof LayoutBuilderWrapper) {
                LayoutBuilder builder = ((LayoutBuilderWrapper) layoutCombobox.getSelectedItem()).getLayoutBuilder();
                if (model.getSelectedLayout() == null || model.getSelectedBuilder() != builder) {
                    setSelectedLayout(builder);
                }
            }
        }
    });
    infoLabel.addMouseListener(new MouseAdapter() {

        RichTooltip richTooltip;

        @Override
        public void mouseEntered(MouseEvent e) {
            if (infoLabel.isEnabled() && model != null && model.getSelectedLayout() != null) {
                richTooltip = buildTooltip(model.getSelectedBuilder());
                richTooltip.showTooltip(infoLabel, e.getLocationOnScreen());
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (richTooltip != null) {
                richTooltip.hideTooltip();
                richTooltip = null;
            }
        }
    });
    presetsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JPopupMenu menu = new JPopupMenu();
            List<Preset> presets = layoutPresetPersistence.getPresets(model.getSelectedLayout());
            if (presets != null && !presets.isEmpty()) {
                for (final Preset p : presets) {
                    JMenuItem item = new JMenuItem(p.toString());
                    item.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            layoutPresetPersistence.loadPreset(p, model.getSelectedLayout());
                            refreshProperties();
                            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.loadPreset", model.getSelectedBuilder().getName(), p.toString()));
                        }
                    });
                    menu.add(item);
                }
            } else {
                menu.add("<html><i>" + NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.nopreset") + "</i></html>");
            }
            JMenuItem saveItem = new JMenuItem(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset"));
            saveItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String lastPresetName = NbPreferences.forModule(LayoutPanel.class).get("LayoutPanel.lastPresetName", "");
                    NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input"), NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.presetsButton.savePreset.input.name"));
                    question.setInputText(lastPresetName);
                    if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
                        String input = question.getInputText();
                        if (input != null && !input.isEmpty()) {
                            layoutPresetPersistence.savePreset(input, model.getSelectedLayout());
                            StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(LayoutPanel.class, "LayoutPanel.status.savePreset", model.getSelectedBuilder().getName(), input));
                            NbPreferences.forModule(LayoutPanel.class).put("LayoutPanel.lastPresetName", input);
                        }
                    }
                }
            });
            menu.add(new JSeparator());
            menu.add(saveItem);
            menu.show(layoutToolbar, 0, -menu.getPreferredSize().height);
        }
    });
}
Also used : LayoutBuilder(org.gephi.layout.spi.LayoutBuilder) ItemEvent(java.awt.event.ItemEvent) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) Preset(org.gephi.desktop.layout.LayoutPresetPersistence.Preset) MouseAdapter(java.awt.event.MouseAdapter) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) NotifyDescriptor(org.openide.NotifyDescriptor) RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener) ArrayList(java.util.ArrayList) List(java.util.List) JMenuItem(javax.swing.JMenuItem)

Example 2 with RichTooltip

use of org.gephi.ui.components.richtooltip.RichTooltip in project gephi by gephi.

the class TimelineTooltip method buildTooltip.

private RichTooltip buildTooltip() {
    RichTooltip richTooltip = new RichTooltip();
    //Min
    richTooltip.addDescriptionSection(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.min") + ": " + getMin());
    //Max
    richTooltip.addDescriptionSection(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.max") + ": " + getMax());
    //Title
    richTooltip.setTitle(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.position") + ": " + getPosition());
    //Img
    richTooltip.setMainImage(ImageUtilities.loadImage("org/gephi/desktop/timeline/resources/info.png"));
    //Chart
    if (getY() != null) {
        richTooltip.addFooterSection(model.getChart().getColumn());
        richTooltip.addFooterSection(NbBundle.getMessage(TimelineTooltip.class, "TimelineTooltip.chart") + ": " + getY());
        //Img
        richTooltip.setFooterImage(ImageUtilities.loadImage("org/gephi/desktop/timeline/resources/chart.png"));
    }
    return richTooltip;
}
Also used : RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip)

Example 3 with RichTooltip

use of org.gephi.ui.components.richtooltip.RichTooltip in project gephi by gephi.

the class RangePanel method buildTooltip.

private RichTooltip buildTooltip() {
    if (histogram.countValues() == 0) {
        return null;
    }
    NumberFormat formatter = DecimalFormat.getNumberInstance();
    formatter.setMaximumFractionDigits(3);
    String average = formatter.format(histogram.getAverage());
    String averageInRange = formatter.format(histogram.getAverageInRange());
    RichTooltip richTooltip = new RichTooltip();
    richTooltip.setTitle("Statistics (In-Range)");
    richTooltip.addDescriptionSection("<html><b># of Values:</b> " + histogram.countValues() + " (" + histogram.countInRange() + ")");
    richTooltip.addDescriptionSection("<html><b>Average:</b> " + average + " (" + averageInRange + ")");
    richTooltip.addDescriptionSection("<html><b>Median:</b> " + histogram.getMedian() + " (" + histogram.getMedianInRange() + ")");
    return richTooltip;
}
Also used : RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip) NumberFormat(java.text.NumberFormat)

Example 4 with RichTooltip

use of org.gephi.ui.components.richtooltip.RichTooltip in project gephi by gephi.

the class LayoutPanel method buildTooltip.

private RichTooltip buildTooltip(LayoutBuilder builder) {
    String description = "";
    LayoutUI layoutUI = null;
    try {
        layoutUI = builder.getUI();
        if (layoutUI.getDescription() != null) {
            description = layoutUI.getDescription();
        }
        if (layoutUI.getQualityRank() < 0 || layoutUI.getSpeedRank() < 0) {
            layoutUI = null;
        }
    } catch (Exception e) {
        layoutUI = null;
    }
    RichTooltip richTooltip = new RichTooltip(builder.getName(), description);
    if (layoutUI != null) {
        LayoutDescriptionImage layoutDescriptionImage = new LayoutDescriptionImage(layoutUI);
        richTooltip.setMainImage(layoutDescriptionImage.getImage());
    }
    return richTooltip;
}
Also used : RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip) LayoutUI(org.gephi.layout.spi.LayoutUI)

Example 5 with RichTooltip

use of org.gephi.ui.components.richtooltip.RichTooltip in project gephi by gephi.

the class RendererManager method buildTooltip.

private void buildTooltip() {
    final RichTooltip richTooltip = new RichTooltip();
    richTooltip.setTitle(NbBundle.getMessage(RendererManager.class, "PreviewSettingsTopComponent.rendererManagerTab"));
    richTooltip.addDescriptionSection(NbBundle.getMessage(RendererManager.class, "RendererManager.description1"));
    richTooltip.addDescriptionSection(NbBundle.getMessage(RendererManager.class, "RendererManager.description2"));
    infoLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            richTooltip.showTooltip(RendererManager.this, e.getLocationOnScreen());
        }

        @Override
        public void mouseExited(MouseEvent e) {
            richTooltip.hideTooltip();
        }
    });
}
Also used : RichTooltip(org.gephi.ui.components.richtooltip.RichTooltip) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter)

Aggregations

RichTooltip (org.gephi.ui.components.richtooltip.RichTooltip)6 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 Image (java.awt.Image)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 NumberFormat (java.text.NumberFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JSeparator (javax.swing.JSeparator)1 Preset (org.gephi.desktop.layout.LayoutPresetPersistence.Preset)1 LayoutBuilder (org.gephi.layout.spi.LayoutBuilder)1 LayoutUI (org.gephi.layout.spi.LayoutUI)1 NotifyDescriptor (org.openide.NotifyDescriptor)1