use of javax.swing.event.ChangeEvent in project gephi by gephi.
the class StatisticsFrontEnd method run.
private void run() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel();
//Create Statistics
StatisticsController controller = Lookup.getDefault().lookup(StatisticsController.class);
StatisticsControllerUI controllerUI = Lookup.getDefault().lookup(StatisticsControllerUI.class);
StatisticsBuilder builder = controller.getBuilder(statisticsUI.getStatisticsClass());
currentStatistics = builder.getStatistics();
if (currentStatistics != null) {
if (currentStatistics instanceof DynamicStatistics && !graphModel.isDynamic()) {
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(NbBundle.getMessage(StatisticsFrontEnd.class, "StatisticsFrontEnd.notDynamicGraph"), NotifyDescriptor.WARNING_MESSAGE));
return;
}
LongTaskListener listener = new LongTaskListener() {
@Override
public void taskFinished(LongTask task) {
showReport();
}
};
JPanel settingsPanel = statisticsUI.getSettingsPanel();
if (currentStatistics instanceof DynamicStatistics) {
DynamicSettingsPanel dynamicPanel = new DynamicSettingsPanel();
statisticsUI.setup(currentStatistics);
dynamicPanel.setup((DynamicStatistics) currentStatistics);
JPanel dynamicSettingsPanel = DynamicSettingsPanel.createCounpoundPanel(dynamicPanel, settingsPanel);
final DialogDescriptor dd = new DialogDescriptor(dynamicSettingsPanel, NbBundle.getMessage(StatisticsTopComponent.class, "StatisticsFrontEnd.settingsPanel.title", builder.getName()));
if (dynamicSettingsPanel instanceof ValidationPanel) {
ValidationPanel vp = (ValidationPanel) dynamicSettingsPanel;
vp.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
dd.setValid(!((ValidationPanel) e.getSource()).isProblem());
}
});
}
if (DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) {
dynamicPanel.unsetup((DynamicStatistics) currentStatistics);
statisticsUI.unsetup();
controllerUI.execute(currentStatistics, listener);
}
} else if (settingsPanel != null) {
statisticsUI.setup(currentStatistics);
final DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(StatisticsTopComponent.class, "StatisticsFrontEnd.settingsPanel.title", builder.getName()));
if (settingsPanel instanceof ValidationPanel) {
ValidationPanel vp = (ValidationPanel) settingsPanel;
vp.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
dd.setValid(!((ValidationPanel) e.getSource()).isProblem());
}
});
}
if (DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) {
statisticsUI.unsetup();
controllerUI.execute(currentStatistics, listener);
}
} else {
statisticsUI.setup(currentStatistics);
controllerUI.execute(currentStatistics, listener);
}
}
}
use of javax.swing.event.ChangeEvent in project gephi by gephi.
the class DesktopToolController method getToolbar.
@Override
public JComponent getToolbar() {
//Get tools ui
HashMap<ToolUI, Tool> toolMap = new HashMap<>();
List<ToolUI> toolsUI = new ArrayList<>();
for (Tool tool : tools) {
ToolUI ui = tool.getUI();
if (ui != null) {
toolsUI.add(ui);
toolMap.put(ui, tool);
}
}
//Sort by priority
Collections.sort(toolsUI, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Integer p1 = ((ToolUI) o1).getPosition();
Integer p2 = ((ToolUI) o2).getPosition();
return p1.compareTo(p2);
}
});
//Create toolbar
final Toolbar toolbar = new Toolbar();
for (final ToolUI toolUI : toolsUI) {
final Tool tool = toolMap.get(toolUI);
JToggleButton btn;
if (toolUI.getIcon() != null) {
btn = new JToggleButton(toolUI.getIcon());
} else {
btn = new JToggleButton(new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/tool.png")));
}
btn.setToolTipText(toolUI.getName() + " - " + toolUI.getDescription());
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Let the user unselect a tool (by clicking on it again) without having to select other tool:
if (tool == currentTool) {
toolbar.clearSelection();
unselect();
} else {
try {
select(tool);
propertiesBar.select(toolUI.getPropertiesBar(tool));
} catch (UnselectToolException unselectToolException) {
toolbar.clearSelection();
unselect();
}
}
}
});
toolbar.add(btn);
}
//SelectionManager events
VizController.getInstance().getSelectionManager().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
SelectionManager selectionManager = VizController.getInstance().getSelectionManager();
if (selectionManager.isRectangleSelection() && currentTool != null) {
toolbar.clearSelection();
unselect();
} else if (selectionManager.isSelectionEnabled() && currentTool != null && currentTool.getSelectionType() == ToolSelectionType.NONE) {
toolbar.clearSelection();
unselect();
} else if (selectionManager.isDraggingEnabled() && currentTool != null) {
toolbar.clearSelection();
unselect();
}
}
});
return toolbar;
}
use of javax.swing.event.ChangeEvent in project gephi by gephi.
the class SelectionBar method createPopup.
public JPopupMenu createPopup() {
SelectionManager manager = VizController.getInstance().getSelectionManager();
final MouseSelectionPopupPanel popupPanel = new MouseSelectionPopupPanel();
popupPanel.setDiameter(manager.getMouseSelectionDiameter());
popupPanel.setProportionnalToZoom(manager.isMouseSelectionZoomProportionnal());
popupPanel.setChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
SelectionManager manager = VizController.getInstance().getSelectionManager();
manager.setMouseSelectionDiameter(popupPanel.getDiameter());
manager.setMouseSelectionZoomProportionnal(popupPanel.isProportionnalToZoom());
}
});
JPopupMenu menu = new JPopupMenu();
menu.add(popupPanel);
return menu;
}
use of javax.swing.event.ChangeEvent in project gephi by gephi.
the class CreateTimeIntervalUI method buildValidationPanel.
private void buildValidationPanel() {
validationPanel = new ValidationPanel();
validationPanel.setInnerComponent(this);
ValidationGroup group = validationPanel.getValidationGroup();
group.add(dateFormatComboBox, new Validator<String>() {
@Override
public boolean validate(Problems prblms, String string, String t) {
boolean valid = validateDateFormat(t);
if (!valid) {
prblms.add(NbBundle.getMessage(CreateTimeIntervalUI.class, "CreateTimeIntervalUI.invalid.dateformat"));
}
return valid;
}
});
Validator<String> emptyOrNumberValidator = new Validator<String>() {
@Override
public boolean validate(Problems prblms, String string, String t) {
boolean valid = validateNumberOrEmpty(t);
if (!valid) {
prblms.add(NbBundle.getMessage(CreateTimeIntervalUI.class, "CreateTimeIntervalUI.invalid.number"));
}
return valid;
}
};
group.add(defaultStartNumberText, emptyOrNumberValidator);
group.add(defaultEndNumberText, emptyOrNumberValidator);
validationPanel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
refreshOkButton();
}
});
}
use of javax.swing.event.ChangeEvent in project binnavi by google.
the class ArrayTypePanel method createControls.
private void createControls() {
setLayout(new BorderLayout());
final JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
add(contentPanel, BorderLayout.CENTER);
final GridBagLayout gbl_m_contentPanel = new GridBagLayout();
gbl_m_contentPanel.columnWidths = new int[] { 0, 0, 0 };
gbl_m_contentPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 };
gbl_m_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl_m_contentPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
contentPanel.setLayout(gbl_m_contentPanel);
final JLabel lblSize = new JLabel("Number of elements:");
final GridBagConstraints gbc_lblSize = new GridBagConstraints();
gbc_lblSize.anchor = GridBagConstraints.WEST;
gbc_lblSize.insets = new Insets(0, 0, 5, 5);
gbc_lblSize.gridx = 0;
gbc_lblSize.gridy = 1;
contentPanel.add(lblSize, gbc_lblSize);
numberElements = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
numberElements.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_numberElements = new GridBagConstraints();
gbc_numberElements.anchor = GridBagConstraints.WEST;
gbc_numberElements.insets = new Insets(0, 0, 5, 0);
gbc_numberElements.gridx = 1;
gbc_numberElements.gridy = 1;
contentPanel.add(numberElements, gbc_numberElements);
final JLabel lblFillWith = new JLabel("Element type:");
final GridBagConstraints gbc_lblFillWith = new GridBagConstraints();
gbc_lblFillWith.anchor = GridBagConstraints.WEST;
gbc_lblFillWith.insets = new Insets(0, 0, 5, 5);
gbc_lblFillWith.gridx = 0;
gbc_lblFillWith.gridy = 0;
contentPanel.add(lblFillWith, gbc_lblFillWith);
baseTypes = new TypeComboBox(new TypeListModel(typeManager.getTypes(), new TypeListModel.PrototypesFilter()));
baseTypes.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_baseTypes = new GridBagConstraints();
gbc_baseTypes.insets = new Insets(0, 0, 5, 0);
gbc_baseTypes.fill = GridBagConstraints.HORIZONTAL;
gbc_baseTypes.gridx = 1;
gbc_baseTypes.gridy = 0;
contentPanel.add(baseTypes, gbc_baseTypes);
final JLabel lblPreview = new JLabel("Preview:");
final GridBagConstraints gbc_lblPreview = new GridBagConstraints();
gbc_lblPreview.anchor = GridBagConstraints.WEST;
gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
gbc_lblPreview.gridx = 0;
gbc_lblPreview.gridy = 2;
contentPanel.add(lblPreview, gbc_lblPreview);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(null);
final GridBagConstraints gbc_scrollPane = new GridBagConstraints();
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
gbc_scrollPane.fill = GridBagConstraints.BOTH;
gbc_scrollPane.gridx = 1;
gbc_scrollPane.gridy = 2;
contentPanel.add(scrollPane, gbc_scrollPane);
preview = new JTextArea();
preview.setEditable(false);
scrollPane.setViewportView(preview);
}
Aggregations