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);
}
});
}
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;
}
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;
}
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;
}
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();
}
});
}
Aggregations