21import java.awt.Component;
22import java.awt.Dimension;
23import java.awt.event.ActionEvent;
24import java.awt.event.ActionListener;
25import java.util.ArrayList;
28import javax.swing.JLabel;
29import javax.swing.JOptionPane;
30import javax.swing.JPanel;
31import javax.swing.JSpinner;
32import javax.swing.SpinnerNumberModel;
33import javax.swing.UIManager;
34import javax.swing.event.ChangeEvent;
35import javax.swing.event.ChangeListener;
37import denoptim.graph.Vertex;
59 new ArrayList<Vertex>();
107 super(refForPlacement, use3rd);
113 this.setTitle(
"Select Vertex and AP");
123 JLabel navigationLabel1 =
new JLabel(
"vertex # ");
124 JLabel navigationLabel2 =
new JLabel(
"Current library size: ");
127 navigSpinner =
new JSpinner(
new SpinnerNumberModel(0, 0, 0, 1));
128 navigSpinner.setToolTipText(
"Move to vertex number # in the currently "
129 +
"loaded library.");
143 this.
btnExtra.setText(
"Select current vertex");
144 this.
btnExtra.setToolTipText(
"<html>Selects this fragment. "
145 +
"Multiple selections are allowed before hitting the "
146 +
"'Done' button.</html>");
147 this.
btnExtra.addActionListener(
new ActionListener() {
150 public void actionPerformed(ActionEvent e) {
165 JOptionPane.showMessageDialog(
btnDone,
"<html>"
166 +
"No attachment point (AP) selected.<br>"
167 +
"Please select an AP in the table."
170 JOptionPane.PLAIN_MESSAGE,
171 UIManager.getIcon(
"OptionPane.errorIcon"));
179 this.
btnDone.setText(
"Select current vertex");
180 this.
btnDone.setToolTipText(
"<html>Process the currently displayed "
181 +
"vertex<br>and the currently selected AP, "
183 this.
btnDone.removeActionListener(
184 this.
btnDone.getActionListeners()[0]);
185 this.
btnDone.addActionListener(
new ActionListener() {
188 public void actionPerformed(ActionEvent e) {
203 JOptionPane.showMessageDialog(
btnDone,
"<html>"
204 +
"No attachment point (AP) selected.<br>"
205 +
"Please select an AP in the table."
208 JOptionPane.PLAIN_MESSAGE,
209 UIManager.getIcon(
"OptionPane.errorIcon"));
234 public void load(List<Vertex> fragments,
int initialId)
246 @SuppressWarnings(
"unchecked")
251 result =
new ArrayList<ArrayList<Integer>>();
253 boolean alreadySelected =
false;
254 for (ArrayList<Integer> p :
255 ((ArrayList<ArrayList<Integer>>)
result))
257 if ((p.get(0) == vrtxId)
258 && (p.get(1) == apId))
260 alreadySelected =
true;
264 if (!alreadySelected)
266 ArrayList<Integer> pair =
new ArrayList<Integer>();
269 ((ArrayList<ArrayList<Integer>>)
result).add(pair);
282 this.enforceAPSelection = enforced;
298 JOptionPane.showMessageDialog(
this,
299 "No list of vertices loaded.",
301 JOptionPane.PLAIN_MESSAGE,
302 UIManager.getIcon(
"OptionPane.errorIcon"));
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void addToCentralPane(JComponent comp)
Adds a component to the central part of this dialog frame.
JButton btnExtra
The button that can be used for any action that does not close the dialog.
JButton btnDone
The button that is used to launch the processing of the data given to the open dialog,...
Object result
The result to be returned once the dialog is closed.
void addToNorthPane(JComponent comp)
Adds a component to the topmost part of this dialog frame.
void close()
Closes the dialog window.
void stateChanged(ChangeEvent event)
A modal dialog with a viewer that understands the different types of DENOPTIM vertex and allows to se...
final VrtxSpinnerChangeEvent vrtxSpinnerListener
void load(List< Vertex > fragments, int initialId)
Load the list of vertexes to choose from.
void appendToResult(int vrtxId, int apId)
JLabel totalVerticesLabel
void activateTabEditsListener(boolean var)
void setRequireApSelection(boolean enforced)
Allows to control whether confirming the selection of a vertex without having selected an attachment ...
int currApIdx
The index of the selected AP [0-(n-1)].
void clearCurrentSystem()
static final String PRESELECTEDAPSFIELD
Property used to pre-select APs.
static final long serialVersionUID
Version UID.
boolean enforceAPSelection
void loadCurrentVrtxIdxToViewer()
Loads the vertices corresponding to the field index.
int currVrtxIdx
The index of the currently loaded vertex [0–(n-1)}.
GUIVertexSelector(Component refForPlacement, boolean use3rd)
Constructor for an empty modal panel meant for selection of vertexes.
Vertex vertex
The currently loaded vertex.
void updateVrtxListSpinner()
static final String PRESELECTEDAPSFIELDSEP
Separator in property used to pre-select APs.
List< Vertex > vertexLibrary
The currently loaded list of vertices.
VertexViewPanel vertexViewer
A panel for visualizing vertices.
void clearCurrentSystem()
Removes the currently visualized molecule and AP table.
ArrayList< Integer > getSelectedAPIDs()
Identifies which attachment points are selected in the currently active viewer.
void activateTabEditsListener(boolean var)
Allows to activate and deactivate the listener.
void loadVertexToViewer(Vertex v)
Loads the given vertex to this viewer.