Skip to content

Commit 1d6b2e4

Browse files
committed
separating the cluster results panel
1 parent ff17e3a commit 1d6b2e4

File tree

4 files changed

+914
-14
lines changed

4 files changed

+914
-14
lines changed

vcell-client/src/main/java/cbit/vcell/client/data/ODEDataViewer.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import javax.swing.event.ChangeListener;
1818

1919
import cbit.vcell.simdata.LangevinSolverResultSet;
20-
import cbit.vcell.solver.ode.gui.LangevinClustersResultsPanel;
20+
import cbit.vcell.solver.ode.gui.*;
2121
import org.vcell.solver.nfsim.NFSimMolecularConfigurations;
2222
import org.vcell.util.document.VCDataIdentifier;
2323
import org.vcell.util.gui.DialogUtils;
@@ -38,8 +38,6 @@
3838
import cbit.vcell.solver.Simulation;
3939
import cbit.vcell.solver.SimulationModelInfo;
4040
import cbit.vcell.solver.ode.ODESolverResultSet;
41-
import cbit.vcell.solver.ode.gui.ODESolverPlotSpecificationPanel;
42-
import cbit.vcell.solver.ode.gui.OutputSpeciesResultsPanel;
4341
import cbit.vcell.util.ColumnDescription;
4442
/**
4543
* Insert the type's description here.
@@ -50,13 +48,16 @@ public class ODEDataViewer extends DataViewer {
5048
IvjEventHandler ivjEventHandler = new IvjEventHandler();
5149
private ODESolverPlotSpecificationPanel ivjODESolverPlotSpecificationPanel1 = null;
5250
private PlotPane ivjPlotPane1 = null;
51+
private ClusterSpecificationPanel clusterSpecificationPanel = null;
52+
private ClusterVisualizationPanel clusterVisualizationPanel = null;
53+
5354
private JTabbedPane ivjJTabbedPane = null;
5455
private ODESolverResultSet fieldOdeSolverResultSet = null;
5556
public boolean hasLangevinBatchResults = false;
5657
private LangevinSolverResultSet fieldLangevinSolverResultSet = null;
5758
private NFSimMolecularConfigurations nFSimMolecularConfigurations = null;
5859
private javax.swing.JPanel viewData = null;
59-
private LangevinClustersResultsPanel viewClustersPanel = null;
60+
private JPanel viewClustersPanel = null;
6061
private OutputSpeciesResultsPanel outputSpeciesResultsPanel = null;
6162
private VCDataIdentifier fieldVcDataIdentifier = null;
6263

@@ -303,14 +304,42 @@ private javax.swing.JTabbedPane getJTabbedPane() {
303304
private JPanel getViewClusters() {
304305
if (viewClustersPanel == null) {
305306
try {
306-
viewClustersPanel = new LangevinClustersResultsPanel(this);
307-
viewClustersPanel.addPropertyChangeListener(ivjEventHandler);
307+
viewClustersPanel = new JPanel();
308+
viewClustersPanel.setName("ViewClusters");
309+
viewClustersPanel.setLayout(new java.awt.BorderLayout());
310+
viewClustersPanel.add(getClusterSpecificationPanel(), "West");
311+
viewClustersPanel.add(getClusterVisualizationPanel(), "Center");
312+
// viewClustersPanel = new LangevinClustersResultsPanel(this);
313+
// viewClustersPanel.addPropertyChangeListener(ivjEventHandler);
308314
} catch (java.lang.Throwable ivjExc) {
309315
handleException(ivjExc);
310316
}
311317
}
312318
return viewClustersPanel;
313319
}
320+
public ClusterSpecificationPanel getClusterSpecificationPanel() {
321+
if (clusterSpecificationPanel == null) {
322+
try {
323+
clusterSpecificationPanel = new ClusterSpecificationPanel(this);
324+
clusterSpecificationPanel.setName("ClusterSpecificationPanel");
325+
} catch (java.lang.Throwable ivjExc) {
326+
handleException(ivjExc);
327+
}
328+
}
329+
return clusterSpecificationPanel;
330+
}
331+
public ClusterVisualizationPanel getClusterVisualizationPanel() {
332+
if (clusterVisualizationPanel == null) {
333+
try {
334+
clusterVisualizationPanel = new ClusterVisualizationPanel(this);
335+
clusterVisualizationPanel.setName("ClusterVisualizationPanel");
336+
} catch (java.lang.Throwable ivjExc) {
337+
handleException(ivjExc);
338+
}
339+
}
340+
return clusterVisualizationPanel;
341+
}
342+
314343
private JPanel getViewData() {
315344
if (viewData == null) {
316345
try {
@@ -452,7 +481,7 @@ public void setVcDataIdentifier(VCDataIdentifier vcDataIdentifier) {
452481
setOdeDataContext();
453482
firePropertyChange("vcDataIdentifier", oldValue, vcDataIdentifier);
454483
outputSpeciesResultsPanel.refreshData();
455-
viewClustersPanel.refreshData();
484+
getClusterSpecificationPanel().refreshData();
456485
}
457486

458487
public void setOdeDataContext() {
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
package cbit.vcell.solver.ode.gui;
2+
3+
import cbit.vcell.client.data.ODEDataViewer;
4+
import cbit.vcell.client.desktop.biomodel.DocumentEditorSubPanel;
5+
import cbit.vcell.simdata.LangevinSolverResultSet;
6+
import cbit.vcell.solver.SimulationModelInfo;
7+
import cbit.vcell.solver.ode.ODESolverResultSet;
8+
import cbit.vcell.util.ColumnDescription;
9+
import org.vcell.util.gui.CollapsiblePanel;
10+
11+
import javax.swing.*;
12+
import javax.swing.border.EmptyBorder;
13+
import javax.swing.event.ChangeEvent;
14+
import javax.swing.event.ChangeListener;
15+
import javax.swing.event.ListSelectionEvent;
16+
import javax.swing.event.ListSelectionListener;
17+
import java.awt.*;
18+
import java.awt.event.ActionEvent;
19+
import java.awt.event.ActionListener;
20+
import java.beans.PropertyChangeEvent;
21+
import java.beans.PropertyChangeListener;
22+
23+
public class ClusterSpecificationPanel extends DocumentEditorSubPanel {
24+
25+
private final ODEDataViewer owner;
26+
ClusterSpecificationPanel.IvjEventHandler ivjEventHandler = new ClusterSpecificationPanel.IvjEventHandler();
27+
28+
private DefaultListModel defaultListModelY = null;
29+
30+
private CollapsiblePanel displayOptionsCollapsiblePanel = null;
31+
private JScrollPane jScrollPaneYAxis = null;
32+
private JList yAxisChoiceList = null;
33+
34+
35+
private enum DisplayMode { COUNTS, MEAN, OVERALL };
36+
LangevinSolverResultSet langevinSolverResultSet = null;
37+
SimulationModelInfo simulationModelInfo = null;
38+
39+
40+
class IvjEventHandler implements ActionListener, PropertyChangeListener, ChangeListener, ListSelectionListener {
41+
@Override
42+
public void actionPerformed(ActionEvent e) {
43+
System.out.println("ClusterSpecificationPanel.IvjEventHandler.actionPerformed() called");
44+
System.out.println(" Source: " + e.getSource() + ", Action Command: " + e.getActionCommand());
45+
Object source = e.getSource();
46+
String cmd = e.getActionCommand();
47+
48+
if (source instanceof JRadioButton) {
49+
JRadioButton rb = (JRadioButton) source;
50+
System.out.println(" Source is JRadioButton with text: " + rb.getText());
51+
switch (cmd) {
52+
case "COUNTS":
53+
populateYAxisChoices(DisplayMode.COUNTS);
54+
break;
55+
case "MEAN":
56+
populateYAxisChoices(DisplayMode.MEAN);
57+
break;
58+
case "OVERALL":
59+
populateYAxisChoices(DisplayMode.OVERALL);
60+
break;
61+
}
62+
}
63+
}
64+
@Override
65+
public void propertyChange(PropertyChangeEvent evt) {
66+
System.out.println("ClusterSpecificationPanel.IvjEventHandler.propertyChange() called");
67+
System.out.println(" Source: " + evt.getSource() + ", Property Name: " + evt.getPropertyName() + ", Old Value: " + evt.getOldValue() + ", New Value: " + evt.getNewValue());
68+
}
69+
@Override
70+
public void stateChanged(ChangeEvent e) {
71+
System.out.println("ClusterSpecificationPanel.IvjEventHandler.stateChanged() called");
72+
System.out.println(" Source: " + e.getSource() + ", Class: " + e.getSource().getClass().getName());
73+
}
74+
75+
@Override
76+
public void valueChanged(ListSelectionEvent e) {
77+
System.out.println("ClusterSpecificationPanel.IvjEventHandler.valueChanged() called");
78+
System.out.println(" Source: " + e.getSource() + ", Class: " + e.getSource().getClass().getName());
79+
Object source = e.getSource();
80+
81+
}
82+
};
83+
84+
private void populateYAxisChoices(DisplayMode mode) {
85+
DefaultListModel model = getDefaultListModelY();
86+
model.clear();
87+
getYAxisChoice().setEnabled(false);
88+
89+
ODESolverResultSet srs = null;
90+
ColumnDescription[] cd = null;
91+
92+
if (langevinSolverResultSet == null) {
93+
model.addElement("<no data>");
94+
return;
95+
}
96+
switch (mode) {
97+
case COUNTS:
98+
// we may never get non-trivial clusters if there's no binding reaction
99+
srs = langevinSolverResultSet.getClusterCounts();
100+
cd = srs.getColumnDescriptions();
101+
break;
102+
case MEAN:
103+
srs = langevinSolverResultSet.getClusterMean();
104+
cd = srs.getColumnDescriptions();
105+
break;
106+
case OVERALL:
107+
srs = langevinSolverResultSet.getClusterOverall();
108+
cd = srs.getColumnDescriptions();
109+
break;
110+
}
111+
if(cd == null || cd.length == 1) {
112+
model.addElement("<no data>"); // if only "t" column is present, treat as no data
113+
return;
114+
}
115+
for (ColumnDescription columnDescription : cd) {
116+
if(columnDescription.getName().equals("t")) {
117+
continue; // skip time column
118+
}
119+
model.addElement(columnDescription.getName());
120+
getYAxisChoice().setEnabled(true);
121+
}
122+
}
123+
124+
public ClusterSpecificationPanel(ODEDataViewer odeDataViewer) {
125+
super();
126+
this.owner = odeDataViewer;
127+
initialize();
128+
}
129+
130+
private void initialize() {
131+
System.out.println("ClusterSpecificationPanel.initialize() called");
132+
setPreferredSize(new Dimension(213, 600));
133+
setLayout(new GridBagLayout());
134+
setSize(248, 604);
135+
setMinimumSize(new Dimension(125, 300));
136+
137+
JLabel xAxisLabel = new JLabel("X Axis:");
138+
GridBagConstraints gbc = new GridBagConstraints();
139+
gbc.anchor = GridBagConstraints.WEST;
140+
gbc.gridx = 0; gbc.gridy = 0;
141+
gbc.insets = new Insets(4, 4, 0, 4);
142+
add(xAxisLabel, gbc);
143+
144+
JTextField xAxisTextBox = new JTextField("t");
145+
xAxisTextBox.setEnabled(false);
146+
xAxisTextBox.setEditable(false);
147+
gbc = new GridBagConstraints();
148+
gbc.gridx = 0; gbc.gridy = 1;
149+
gbc.fill = GridBagConstraints.HORIZONTAL;
150+
gbc.weightx = 1.0;
151+
gbc.insets = new Insets(0, 4, 4, 4);
152+
add(xAxisTextBox, gbc);
153+
154+
JLabel yAxisLabel = new JLabel("Y Axis:");
155+
gbc = new GridBagConstraints();
156+
gbc.anchor = GridBagConstraints.WEST;
157+
gbc.insets = new Insets(4, 4, 0, 4);
158+
gbc.gridx = 0; gbc.gridy = 2;
159+
add(yAxisLabel, gbc);
160+
161+
gbc = new GridBagConstraints();
162+
gbc.fill = GridBagConstraints.BOTH;
163+
gbc.insets = new Insets(4, 4, 5, 4);
164+
gbc.gridx = 0;
165+
gbc.gridy = 3;
166+
add(getDisplayOptionsPanel(), gbc);
167+
168+
gbc = new GridBagConstraints();
169+
gbc.gridx = 0; gbc.gridy = 4;
170+
gbc.fill = GridBagConstraints.BOTH;
171+
gbc.weightx = 1.0;
172+
gbc.weighty = 1.0;
173+
gbc.insets = new Insets(0, 4, 4, 4);
174+
add(getJScrollPaneYAxis(), gbc);
175+
176+
initConnections();
177+
}
178+
179+
private CollapsiblePanel getDisplayOptionsPanel() {
180+
if(displayOptionsCollapsiblePanel == null) {
181+
displayOptionsCollapsiblePanel = new CollapsiblePanel("Display Options", true);
182+
JPanel content = displayOptionsCollapsiblePanel.getContentPanel();
183+
content.setLayout(new GridBagLayout());
184+
185+
ButtonGroup group = new ButtonGroup();
186+
JRadioButton rbCounts = new JRadioButton("Cluster Counts");
187+
JRadioButton rbMean = new JRadioButton("Cluster Mean");
188+
JRadioButton rbOverall = new JRadioButton("Cluster Overall");
189+
190+
rbCounts.setActionCommand("COUNTS");
191+
rbMean.setActionCommand("MEAN");
192+
rbOverall.setActionCommand("OVERALL");
193+
194+
rbCounts.addActionListener(ivjEventHandler);
195+
rbMean.addActionListener(ivjEventHandler);
196+
rbOverall.addActionListener(ivjEventHandler);
197+
198+
group.add(rbCounts);
199+
group.add(rbMean);
200+
group.add(rbOverall);
201+
202+
rbCounts.setSelected(true);
203+
204+
GridBagConstraints gbc = new GridBagConstraints();
205+
gbc.gridx = 0;
206+
gbc.anchor = GridBagConstraints.WEST;
207+
gbc.insets = new Insets(2, 4, 2, 4);
208+
gbc.gridy = 0;
209+
content.add(rbCounts, gbc);
210+
gbc.gridy = 1;
211+
content.add(rbMean, gbc);
212+
gbc.gridy = 2;
213+
content.add(rbOverall, gbc);
214+
}
215+
return displayOptionsCollapsiblePanel;
216+
}
217+
218+
private JScrollPane getJScrollPaneYAxis() {
219+
if(jScrollPaneYAxis == null) {
220+
jScrollPaneYAxis = new JScrollPane();
221+
jScrollPaneYAxis.setName("JScrollPaneYAxis");
222+
jScrollPaneYAxis.setViewportView(getYAxisChoice());
223+
}
224+
return jScrollPaneYAxis;
225+
}
226+
private JList getYAxisChoice() {
227+
if ((yAxisChoiceList == null)) {
228+
yAxisChoiceList = new JList();
229+
yAxisChoiceList.setName("YAxisChoice");
230+
yAxisChoiceList.setBounds(0, 0, 160, 120);
231+
yAxisChoiceList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
232+
}
233+
return yAxisChoiceList;
234+
}
235+
236+
private void initConnections() {
237+
getDisplayOptionsPanel().addPropertyChangeListener(ivjEventHandler);
238+
getYAxisChoice().addListSelectionListener(ivjEventHandler);
239+
this.addPropertyChangeListener(ivjEventHandler);
240+
getYAxisChoice().setModel(getDefaultListModelY());
241+
}
242+
243+
private DefaultListModel getDefaultListModelY() {
244+
if (defaultListModelY == null) {
245+
defaultListModelY = new DefaultListModel();
246+
}
247+
return defaultListModelY;
248+
}
249+
250+
private void handleException(java.lang.Throwable exception) {
251+
System.out.println("--------- UNCAUGHT EXCEPTION ---------");
252+
exception.printStackTrace(System.out);
253+
}
254+
255+
@Override
256+
protected void onSelectedObjectsChange(Object[] selectedObjects) {
257+
System.out.println("ClusterSpecificationPanel.onSelectedObjectsChange() called with " + selectedObjects.length + " objects");
258+
}
259+
260+
public void refreshData() {
261+
simulationModelInfo = owner.getSimulationModelInfo();
262+
langevinSolverResultSet = owner.getLangevinSolverResultSet();
263+
System.out.println("ClusterSpecificationPanel.refreshData() called");
264+
265+
// find the selected radio button inside the collapsible panel
266+
JPanel content = displayOptionsCollapsiblePanel.getContentPanel();
267+
for (Component c : content.getComponents()) {
268+
if (c instanceof JRadioButton rb && rb.isSelected()) {
269+
ivjEventHandler.actionPerformed(new ActionEvent(rb, ActionEvent.ACTION_PERFORMED, rb.getActionCommand()));
270+
break;
271+
}
272+
}
273+
}
274+
275+
}

0 commit comments

Comments
 (0)