Skip to content

Commit 6ef5bfd

Browse files
committed
Bug fixing.
1 parent 1241417 commit 6ef5bfd

5 files changed

Lines changed: 38 additions & 7 deletions

File tree

vcell-client/src/main/java/cbit/plot/gui/PlotRenderers.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ public void draw(Graphics2D g2,
239239
// vertical segment: (xB, yA) → (xB, yB)
240240
step.lineTo(xB, yB);
241241
}
242+
// VERTICAL SEGMENT from last upper point to first lower point
243+
// compute first lower point at the rightmost x
244+
double tLast = (time != null ? time[n - 1] : (n - 1) * dt);
245+
double vLastLower = lower[n - 1];
246+
double normLastLower = (vLastLower - yMinRounded) / (yMaxRounded - yMinRounded);
247+
int xLast = x0 + (int)Math.round((tLast / xMaxRounded) * plotWidth);
248+
int yLastLower = y0 - (int)Math.round(normLastLower * plotHeight);
249+
// vertical segment from last upper point to first lower point
250+
step.lineTo(xLast, yLastLower);
251+
242252
// ---- LOWER BOUNDARY (right → left) ----
243253
for (int i = n - 1; i > 0; i--) {
244254
// current point

vcell-client/src/main/java/cbit/vcell/solver/ode/gui/ClusterSpecificationPanel.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ private String buildTooltip(ODESolverResultSetColumnDescription cd, DisplayMode
155155
"<html>Number of clusters of size <b>" + name +
156156
"</b> <font color=\"#8B0000\">[molecules]</font></html>";
157157
case MEAN, OVERALL -> {
158-
ClusterStatistic stat = ClusterStatistic.valueOf(name);
158+
ClusterStatistic stat = ClusterStatistic.fromString(name);
159+
if(stat == null) {
160+
lg.error("Unknown column name in ClusterYAxisRenderer: " + name);
161+
yield name; // fallback to just showing the name without tooltip
162+
}
159163
yield "<html>" + stat.description +
160164
"<font color=\"#8B0000\"> [" + stat.unit + "]</font></html>";
161165
}
@@ -170,6 +174,10 @@ public void actionPerformed(ActionEvent e) {
170174
if (e.getSource() instanceof JRadioButton rb && SwingUtilities.isDescendingFrom(rb, ClusterSpecificationPanel.this)) {
171175
lg.debug("actionPerformed() called. Source is JRadioButton: {}", rb.getText());
172176
DisplayMode mode = DisplayMode.fromActionCommand(cmd);
177+
// set property to inform the list about current mode (needed for renderer)
178+
// moved here from valueChanged() because the tooltip of the y-axis choices needs to be updated
179+
// immediately when the mode changes, even before any selection is made in the list
180+
yAxisChoiceList.putClientProperty("ClusterDisplayMode", mode);
173181
populateYAxisChoices(mode);
174182
}
175183
}
@@ -192,8 +200,9 @@ public void valueChanged(ListSelectionEvent e) {
192200
java.util.List<ColumnDescription> selected = getYAxisChoice().getSelectedValuesList();
193201
DisplayMode mode = getCurrentDisplayMode();
194202
ODESolverResultSet srs = getResultSetForMode(mode);
195-
// set property to inform the list about current mode (needed for renderer)
196-
yAxisChoiceList.putClientProperty("ClusterDisplayMode", mode);
203+
// moved this to actionPerformed() where it belongs, it was being called too late here
204+
// // set property to inform the list about current mode (needed for renderer)
205+
// yAxisChoiceList.putClientProperty("ClusterDisplayMode", mode);
197206
// fire the event upward
198207
firePropertyChange("ClusterSelection", null, new ClusterSelection(mode, selected, srs));
199208
}

vcell-client/src/main/java/cbit/vcell/solver/ode/gui/ClusterVisualizationPanel.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public void propertyChange(PropertyChangeEvent evt) {
8484
redrawLegend(sel); // redraw legend (one plot, multiple curves)
8585
redrawPlot(sel); // redraw plot (one plot, multiple curves)
8686
redrawDataTable(sel); // redraw data table
87+
if(sel.mode == ClusterSpecificationPanel.DisplayMode.COUNTS) {
88+
getClusterPlotPanel().setStepAvg(true);
89+
} else {
90+
getClusterPlotPanel().setStepAvg(false);
91+
}
8792
} catch (ExpressionException e) {
8893
throw new RuntimeException(e);
8994
}
@@ -144,8 +149,10 @@ public void componentShown(ComponentEvent e) {
144149
lg.debug("componentShown() called, height = " + clusterPlotPanel.getHeight());
145150
}
146151
});
147-
clusterPlotPanel.setStepAvg(false);
148-
clusterPlotPanel.setStepBand(true);
152+
153+
// uncomment these to override the defaulta AbstractPlotPanel renderer options
154+
// clusterPlotPanel.setStepAvg(false);
155+
// clusterPlotPanel.setStepBand(true);
149156

150157
} catch (java.lang.Throwable ivjExc) {
151158
handleException(ivjExc);

vcell-client/src/main/java/cbit/vcell/solver/ode/gui/MoleculeSpecificationPanel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ public void actionPerformed(ActionEvent e) {
156156

157157
if (DisplayMode.isDisplayModeActionCommand(cmd)) {
158158
java.util.List<DisplayMode> displayModes = getSelectedDisplayModes();
159+
// in ClusterSpecificationPanel need the mode for the renderer, so we had to put it in a ClientProperty
160+
// but in MoleculeSpecificationPanel we don't have that requirement
161+
// note that it's bad style to just query the checkboxes directly from within a renderer
159162
populateYAxisChoices(displayModes);
160163
} else if (StatisticSelection.isStatisticSelectionActionCommand(cmd)) {
161164
MoleculeSelection sel = new MoleculeSelection(

vcell-client/src/main/java/cbit/vcell/solver/ode/gui/MoleculeVisualizationPanel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ public void componentShown(ComponentEvent e) {
147147
lg.debug("componentShown() called, height = " + moleculePlotPanel.getHeight());
148148
}
149149
});
150-
moleculePlotPanel.setStepAvg(false);
151-
moleculePlotPanel.setStepBand(true);
150+
151+
// uncomment these to override the defaulta AbstractPlotPanel renderer options, feel free to add more
152+
// moleculePlotPanel.setStepAvg(true);
153+
// moleculePlotPanel.setStepBand(true);
152154

153155
} catch (java.lang.Throwable ivjExc) {
154156
handleException(ivjExc);

0 commit comments

Comments
 (0)