Skip to content

Commit 2a0d27c

Browse files
committed
fix(ui): address several layout and plotting glitches found during final test run
- Fixed column header labeling to respect active axes and avoid invalid index access - Ensured 3D axes mode is correctly reset when switching back to 2D plots - Adjusted DBV panel sizing and positioning to prevent edge clipping on wide screens - Cleaned up equation input UI: - Restricted parametric options to FN1 mode where they actually apply - Hid incomplete / unused polar controls to avoid user confusion - Simplified equations header layout - Updated default plot types for function and system plots to POINTS/POINTS3 to avoid misleading line rendering in initial views - Minor UI cleanup and comment adjustments after refactors Result: more consistent UI behavior, fewer visual glitches, and clearer defaults during interactive use.
1 parent fdbb026 commit 2a0d27c

4 files changed

Lines changed: 38 additions & 30 deletions

File tree

src/main/java/com/babai/ssplot/math/plot/PlotData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,13 @@ private String formatStats(String colName, int i) {
283283
public Vector<String> getHeaders() {
284284
var headers = new Vector<String>();
285285
var mappings = getDataColMapping();
286+
var axes = getAxes();
286287
for (int i = 0; i < getColumnCount(); i++) {
287288
boolean isKnownColumn = false;
288289
for (var entry : mappings.entrySet()) {
289290
var lbl = getAxisLabel(i);
290-
if (lbl.isPresent() || entry.getValue() == i) {
291-
headers.add(lbl.orElse(entry.getKey().toString() + " Data"));
291+
if (lbl.isPresent() || (entry.getValue() == i && i < axes.length)) {
292+
headers.add(lbl.orElse(axes[i].toString() + " Data"));
292293
isKnownColumn = true;
293294
break;
294295
}

src/main/java/com/babai/ssplot/math/plot/Plotter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ private void plotData(PlotData pdata, int lastIndex) {
8484
if (pdata.getColumnCount() == 3) {
8585
canv.setAxes3d(true);
8686
canv.setProjection(p);
87+
} else {
88+
canv.setAxes3d(false);
8789
}
8890
canv.setStroke(pdata.ptX);
8991
var ptype = pdata.getPlotType();

src/main/java/com/babai/ssplot/ui/MainFrame.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public MainFrame() {
9393
// Initialize logger
9494
logger = new StatLogger();
9595
logger.log(Text.tag("h1", "Welcome to SSPlot!"));
96+
logger.log(ABOUT_MSG);
9697

9798
var plt = new Plotter();
9899
if (isDark) {
@@ -140,8 +141,8 @@ public MainFrame() {
140141
int dbvWidth = Math.min(dbv.getWidth(),
141142
screenBounds.width - odeinput.getWidth() - ifrmPlot.getWidth());
142143
if (dbvWidth > Plotter.DEFAULT_W/2) {
143-
dbv.setSize(new Dimension(dbvWidth, odeinput.getHeight()));
144-
dbv.setLocation(screenBounds.width - dbvWidth, 0);
144+
dbv.setSize(new Dimension(dbvWidth + 10, odeinput.getHeight()));
145+
dbv.setLocation(screenBounds.width - dbvWidth - 10, 0);
145146
dbv.setVisible(true);
146147
} else {
147148
dbv.setVisible(false);

src/main/java/com/babai/ssplot/ui/SystemInputFrame.java

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ private JToolBar createToolbar() {
163163
private UIGrid createEqnInputUIPanel(final Axis[] axes) {
164164
StateVar<Boolean> isODEorDFE = curMode.whenAny(List.of(SystemMode.DFE, SystemMode.ODE));
165165
StateVar<Boolean> isFN = curMode.whenAny(List.of(SystemMode.FN1, SystemMode.FN2));
166+
StateVar<Boolean> isFN1 = curMode.when(m -> m == SystemMode.FN1);
166167

167168
// Equations entry enable conditions
168169
var eqnCondition = List.of(
@@ -184,26 +185,7 @@ private UIGrid createEqnInputUIPanel(final Axis[] axes) {
184185
.insets(3)
185186
.row()
186187
.spanx(4)
187-
.column(label("Equations").font(Text.headerFont))
188-
189-
.row()
190-
.column(label("Parametric (x = x(t), y = y(t)):").visible(isFN))
191-
.weightx(1)
192-
.fill(GridBagConstraints.HORIZONTAL)
193-
.column(
194-
hbox(
195-
checkBox().bindSelectionTo(isParametric)
196-
).visible(isFN)
197-
)
198-
199-
.row()
200-
.column(label("Polar (r = r(θ)):").visible(isFN))
201-
.weightx(1)
202-
.fill(GridBagConstraints.HORIZONTAL)
203-
.column(
204-
hbox(
205-
checkBox().bindSelectionTo(isPolar)
206-
).visible(isFN));
188+
.column(label("Equations").font(Text.headerFont));
207189

208190
for (int i = 0; i < axes.length; i++) {
209191
final int idx = i;
@@ -225,7 +207,29 @@ private UIGrid createEqnInputUIPanel(final Axis[] axes) {
225207
);
226208
}
227209

228-
pnlEquations.row()
210+
pnlEquations
211+
.row()
212+
.column(label("Parametric (x = x(t), ...):").visible(isFN1))
213+
.weightx(1)
214+
.fill(GridBagConstraints.HORIZONTAL)
215+
.column(
216+
hbox(
217+
checkBox().bindSelectionTo(isParametric)
218+
).visible(isFN1)
219+
)
220+
221+
.row()
222+
.column(label("Polar (r = r(θ)):")
223+
// .visible(isFN))
224+
.visible(false))
225+
.weightx(1)
226+
.fill(GridBagConstraints.HORIZONTAL)
227+
.column(
228+
hbox(
229+
checkBox().bindSelectionTo(isPolar)
230+
// ).visible(isFN));
231+
).visible(false))
232+
.row()
229233
.column(label("Solve At:").visible(isODEorDFE))
230234
.weightx(1)
231235
.fill(GridBagConstraints.HORIZONTAL)
@@ -402,17 +406,17 @@ public void setSystem(EquationSystem system) {
402406
curMode.set(system.mode());
403407
}
404408

405-
// TODO these methods sort of violate MVC, perhaps there should be some sort
406-
// of controller class?
409+
//
407410
// Plotting functions : Calculates PlotData from EquationSystem
408-
411+
//
412+
409413
private void plot2D() {
410414
var system = getSystem();
411415
var plotData = switch (curMode.get()) {
412416
case FN1 -> plotFunction2D();
413417
default -> plotTrajectory(system.solnPoint()[0], system.solnPoint()[1]);
414418
};
415-
plotData.setPlotType(PlotData.PlotType.LINES);
419+
plotData.setPlotType(PlotData.PlotType.POINTS);
416420
plotData.setAxes(Axis.Cartesian.X, Axis.Cartesian.Y);
417421
plotData.setDataCols(0, 1);
418422
updater.accept(plotData);
@@ -424,7 +428,7 @@ private void plot3D() {
424428
case FN2 -> plotFunction3D();
425429
default -> plotODE3D(system.solnPoint());
426430
};
427-
plotData.setPlotType(PlotData.PlotType.LINES3);
431+
plotData.setPlotType(PlotData.PlotType.POINTS3);
428432
plotData.setAxes(Axis.Cartesian.X, Axis.Cartesian.Y, Axis.Cartesian.Z);
429433
plotData.setDataCols(0, 1, 2);
430434
updater.accept(plotData);

0 commit comments

Comments
 (0)