Skip to content

Commit bc54d2b

Browse files
committed
Bugfixes. Engine Changed to Rhino. For details see CHANGELOG
1 parent 51820e8 commit bc54d2b

11 files changed

Lines changed: 190 additions & 140 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ Version 2.0 (31.08.2023)
44
3. UI improvements
55
4. Can change plot names from DataViewer
66
5. Menu reorganization
7+
Version 2.1 (04.09.2023)
8+
1. Switched Default Parsing Engine to Mozilla Rhino
9+
2. Added scribble pad/notes area to the logs pane

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.babai.ssplot</groupId>
1010
<artifactId>SSPlot</artifactId>
11-
<version>2.0</version>
11+
<version>2.1</version>
1212

1313
<name>SSPlot</name>
1414
<url>http://www.github.com/babaissarkar/ssplot</url>
@@ -61,6 +61,16 @@
6161
<artifactId>flatlaf-intellij-themes</artifactId>
6262
<version>3.2</version>
6363
</dependency>
64+
<dependency>
65+
<groupId>org.mozilla</groupId>
66+
<artifactId>rhino</artifactId>
67+
<version>1.7.14</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.mozilla</groupId>
71+
<artifactId>rhino-engine</artifactId>
72+
<version>1.7.14</version>
73+
</dependency>
6474
</dependencies>
6575

6676
<build>
@@ -76,6 +86,8 @@
7686
<include>com.formdev:flatlaf</include>
7787
<include>com.formdev:flatlaf-intellij-themes</include>
7888
<include>org.scilab.forge:jlatexmath</include>
89+
<include>org.mozilla:rhino</include>
90+
<include>org.mozilla:rhino-engine</include>
7991
</includes>
8092
</artifactSet>
8193
<transformers>

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

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,27 @@ public class DBViewer extends JInternalFrame implements ActionListener {
7171
private ODEInputFrame input = null;
7272

7373
private static PlotData zeroData;
74-
static {
75-
Vector<Double> zeros = new Vector<Double>();
76-
zeros.add(0.0);
77-
zeros.add(0.0);
78-
79-
Vector<Vector<Double>> zeros2d = new Vector<Vector<Double>>();
80-
for (int i = 0; i < 5; i++) {
81-
zeros2d.add(zeros);
82-
}
83-
zeroData = new PlotData(zeros2d);
84-
}
74+
// static {
75+
// Vector<Double> zeros = new Vector<Double>();
76+
// zeros.add(0.0);
77+
// zeros.add(0.0);
78+
//
79+
// Vector<Vector<Double>> zeros2d = new Vector<Vector<Double>>();
80+
// for (int i = 0; i < 5; i++) {
81+
// zeros2d.add(zeros);
82+
// }
83+
// zeroData = new PlotData(zeros2d);
84+
// }
8585

86-
public DBViewer() {
87-
this(zeroData);
86+
public DBViewer(ODEInputFrame input, PlotView pv) {
87+
// this(zeroData, input, pv);
88+
this(null, input, pv);
8889
}
8990

90-
public DBViewer(PlotData data) {
91+
public DBViewer(PlotData data, ODEInputFrame input, PlotView pv) {
92+
setODEInputFrame(input);
93+
setView(pv);
94+
9195
plotlist = new Vector<PlotData>();
9296

9397
/* GUI */
@@ -106,9 +110,9 @@ public DBViewer(PlotData data) {
106110
if (id != -1) {
107111
PlotData curData = plotlist.get(id);
108112
setDataOnly(curData);
109-
if ((input != null) && (curData.sysData != null)) {
110-
input.setSystemData(curData.sysData);
111-
}
113+
// if ((input != null) && (curData.sysData != null)) {
114+
// input.setSystemData(curData.sysData);
115+
// }
112116
}
113117
jcbPlotlist.setSelectedIndex(id);
114118
}
@@ -164,7 +168,7 @@ public DBViewer(PlotData data) {
164168
if (data != null) {
165169
setData(data);
166170
} else {
167-
setBounds(500, 100, 700, 600);
171+
setBounds(500, 100, 600, 600);
168172
}
169173

170174
JScrollPane scroll = new JScrollPane(table,
@@ -253,12 +257,14 @@ private void setDataOnly(PlotData pdata) {
253257
columns.getColumn(i).setPreferredWidth(20);
254258
}
255259

260+
// I should remove this part
256261
if (80*colNo > 500) {
257-
setBounds(500, 100, 80*colNo+200, 600);
262+
setBounds(500, 100, 50*colNo+200, 600);
258263
} else {
259264
setBounds(500, 100, 500+200, 600);
260265
}
261-
}
266+
267+
}
262268

263269
/** @return the dataset */
264270
public PlotData getData() {
@@ -286,13 +292,17 @@ public PlotData getData() {
286292

287293
// PlotData pdata = new PlotData(newdataset);
288294
int id = jcbPlotlist.getSelectedIndex();
289-
PlotData curData = plotlist.get(id);
290-
curData.data = newdataset;
291-
curData.setDataCols(getCol1(), getCol2());
292-
updateList();
293-
jcbPlotlist.setSelectedIndex(id);
294-
295-
return curData;
295+
if (id != -1) {
296+
PlotData curData = plotlist.get(id);
297+
curData.data = newdataset;
298+
curData.setDataCols(getCol1(), getCol2());
299+
updateList();
300+
jcbPlotlist.setSelectedIndex(id);
301+
return curData;
302+
} else {
303+
System.err.println("No data found!");
304+
return zeroData;
305+
}
296306
}
297307

298308
/** @return the number of rows in the dataset */
@@ -449,11 +459,13 @@ private void updateList() {
449459
for (PlotData pdata : plotlist) {
450460
jcbPlotlist.addItem(pdata.getTitle());
451461
}
462+
jcbPlotlist.setSelectedIndex(jcbPlotlist.getItemCount()-1);
452463
}
453464

454465
public void clear() {
455466
plotlist.clear();
456-
updateList();
467+
// updateList();
468+
this.setData(zeroData);
457469
}
458470

459471
public void setODEInputFrame(ODEInputFrame odeinput) {

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
import javax.swing.JOptionPane;
4848
import javax.swing.JRadioButtonMenuItem;
4949
import javax.swing.JSplitPane;
50+
import javax.swing.JTabbedPane;
51+
import javax.swing.JTextArea;
5052
import javax.swing.KeyStroke;
5153
import javax.swing.SwingUtilities;
5254
import javax.swing.UIManager;
@@ -110,14 +112,14 @@ public MainFrame() {
110112
odeinput.setClosable(true);
111113
odeinput.setIconifiable(true);
112114

113-
dbv = new DBViewer();
114-
dbv.setView(pv);
115+
dbv = new DBViewer(odeinput, pv);
116+
// dbv.setView(pv);
115117
dbv.addListener(this);
116118
dbv.setClosable(true);
117119
dbv.setResizable(true);
118120
dbv.setIconifiable(true);
119121
dbv.setMaximizable(true);
120-
dbv.setODEInputFrame(odeinput);
122+
// dbv.setODEInputFrame(odeinput);
121123

122124
pv.addMouseListener(
123125
new MouseAdapter() {
@@ -307,33 +309,24 @@ public void mousePressed(MouseEvent ev) {
307309

308310
mnuWindow.add(jmiShowDBV);
309311
mnuWindow.add(jmiShowEqn);
310-
mnuWindow.add(jmiShowLogs);
311-
312-
JSplitPane mainPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
313-
// mainPane.setLeftComponent(pv);
314-
// mainPane.setRightComponent(this.getLogger().getComponent());
315-
mainPane2.setDividerLocation(600);
312+
// mnuWindow.add(jmiShowLogs);
316313

317314
JDesktopPane mainPane = new JDesktopPane();
318315
mainPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
319316

320317
ifrmPlot.setSize(Plotter.DEFAULT_W+50, Plotter.DEFAULT_H + 80);
321318

322-
ifrmLogs.setSize(560, 150);
323-
ifrmLogs.setLocation(Plotter.DEFAULT_W + 100, 10);
324-
ifrmLogs.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
319+
// ifrmLogs.setSize(560, 150);
320+
// ifrmLogs.setLocation(Plotter.DEFAULT_W + 100, 10);
321+
// ifrmLogs.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
325322

326323
dbv.setSize(500, 500);
327324
dbv.setLocation(Plotter.DEFAULT_W + 100, 180);
328325
dbv.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
329326

330327
odeinput.setSize(600, Plotter.DEFAULT_H + 80);
331-
odeinput.setLocation(Plotter.DEFAULT_W + 100, 10);
328+
odeinput.setLocation(Plotter.DEFAULT_W + 100, 0);
332329

333-
//put PV inside a panel
334-
// JPanel pnlPV = new JPanel();
335-
// pnlPV.add(pv);
336-
// JScrollPane sp2 = new JScrollPane(pnlPV, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
337330
ifrmPlot.add(pv);
338331
ifrmLogs.add(this.getLogger().getComponent());
339332

@@ -375,12 +368,18 @@ public void mousePressed(MouseEvent ev) {
375368
odeinput.pack();
376369

377370
ifrmPlot.setVisible(true);
378-
// dbv.setVisible(true);
379-
// ifrmLogs.setVisible(true);
380371
odeinput.setVisible(true);
381372

373+
JTabbedPane statusPane = new JTabbedPane();
374+
statusPane.addTab("Logs", ifrmLogs.getContentPane());
375+
JTextArea txtNotes = new JTextArea();
376+
txtNotes.setText("You can write anything here.");
377+
statusPane.addTab("Notes", txtNotes);
378+
379+
JSplitPane mainPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
380+
mainPane2.setDividerLocation(550);
382381
mainPane2.setTopComponent(mainPane);
383-
mainPane2.setBottomComponent(ifrmLogs.getContentPane());
382+
mainPane2.setBottomComponent(statusPane);
384383

385384
this.setJMenuBar(jmb);
386385
this.getContentPane().setLayout(new BorderLayout());
@@ -506,13 +505,15 @@ public void actionPerformed(ActionEvent ae) {
506505
} else if (ae.getSource() == jmAbout) {
507506
String str ="""
508507
<h1>SSPlot</h1>
509-
Created by : Subhraman Sarkar, 2021<br>
508+
Version : 2.1.0<br>
509+
Created by : Subhraman Sarkar, 2021-2023<br>
510510
Available under the LGPL 2.1 license or, (at your choice)
511511
any later version.<br>
512512
Homepage : <a href='https://github.com/babaissarkar/ssplot'>
513513
https://github.com/babaissarkar/ssplot</a>
514514
""";
515515
logger.log(str);
516+
JOptionPane.showMessageDialog(this, "See Logs.");
516517
} else if (ae.getSource() == jmQuit) {
517518
System.exit(0);
518519
// } else if (ae.getSource() == jmTitle) {
@@ -557,6 +558,7 @@ public void actionPerformed(ActionEvent ae) {
557558

558559
public void setPlotData(PlotData pdata) {
559560
pv.setCurPlot(pdata);
561+
pv.setCurPlotType(pdata.getPltype());
560562
dbv.setData(pdata);
561563
}
562564

0 commit comments

Comments
 (0)