From 774592bb7207c6dd3b5c6a26ac7d90c76797c2f2 Mon Sep 17 00:00:00 2001 From: lempinen Date: Thu, 17 Jun 2010 11:50:17 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16185 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/properties/EquationTab.java | 13 +- .../widgets/ExpressionTypeWidget.java | 26 +-- .../properties/widgets/ExpressionWidget.java | 13 +- .../ui/properties/widgets/NameWidget.java | 2 - .../ui/properties/widgets/UnitWidget.java | 2 - .../widgets/expressions/BasicExpression.java | 24 ++- .../widgets/expressions/StockExpression.java | 22 ++- .../expressions/WithLookupExpression.java | 148 +++++++++++++++--- 8 files changed, 193 insertions(+), 57 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java index 9a0972ee..e398245a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java @@ -11,7 +11,6 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; @@ -32,8 +31,6 @@ import org.simantics.sysdyn.ui.properties.widgets.UnitWidget; public class EquationTab extends PropertyTabContributorImpl { - static public final Font FONT = new Font(null, "Courier New", 12, SWT.NORMAL); - NameWidget nameWidget; ExpressionTypeWidget expressionTypeWidget; UnitWidget unitWidget; @@ -50,7 +47,6 @@ public class EquationTab extends PropertyTabContributorImpl { Label label = new Label(composite, SWT.SINGLE ); - label.setFont(EquationTab.FONT); label.setText("Type:"); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); @@ -58,7 +54,6 @@ public class EquationTab extends PropertyTabContributorImpl { label = new Label(composite, SWT.SINGLE ); - label.setFont(EquationTab.FONT); label.setText("Unit:"); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label); @@ -71,7 +66,8 @@ public class EquationTab extends PropertyTabContributorImpl { Composite expressionComposite = new Composite(composite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).span(5, 1).applyTo(expressionComposite); expressionWidget = new ExpressionWidget(expressionComposite, support, SWT.NONE); - + expressionWidget.setVariableTable(shortcutTabWidget.getVariableTable()); + addListeners(); } @@ -116,7 +112,6 @@ public class EquationTab extends PropertyTabContributorImpl { @Override public void mouseUp(MouseEvent e) { - expressionWidget.getExpression().focus(); } }); @@ -137,7 +132,7 @@ public class EquationTab extends PropertyTabContributorImpl { @Override public void modifyText(ModifyEvent e) { - expressionWidget.validateFields(shortcutTabWidget.getVariableTable().getItems()); + expressionWidget.validateFields(); } }); @@ -150,7 +145,7 @@ public class EquationTab extends PropertyTabContributorImpl { @Override public void focusGained(FocusEvent e) { - expressionWidget.validateFields(shortcutTabWidget.getVariableTable().getItems()); + expressionWidget.validateFields(); } }); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionTypeWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionTypeWidget.java index ef1da39d..1fae3e03 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionTypeWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionTypeWidget.java @@ -15,7 +15,6 @@ import org.simantics.db.Resource; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.sysdyn.SysdynResource; -import org.simantics.sysdyn.ui.properties.EquationTab; import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes.ExpressionType; import org.simantics.ui.SimanticsUI; import org.simantics.utils.ui.ISelectionUtils; @@ -28,7 +27,6 @@ public class ExpressionTypeWidget implements Widget { support.register(this); typeCombo = new Combo(parent, style); - typeCombo.setFont(EquationTab.FONT); int columns = 6; GC gc = new GC (typeCombo); @@ -49,7 +47,7 @@ public class ExpressionTypeWidget implements Widget { @Override public void run(ReadGraph graph) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); - + final ExpressionType[] expressionTypes; if(graph.isInstanceOf(variable, sr.Auxiliary)) expressionTypes = ExpressionTypes.auxiliaryExpressions; @@ -59,25 +57,27 @@ public class ExpressionTypeWidget implements Widget { expressionTypes = ExpressionTypes.valveExpressions; else expressionTypes = new ExpressionType[] {}; - - + + typeCombo.getDisplay().asyncExec(new Runnable() { - + @Override public void run() { - setExpressionTypes(expressionTypes); - setExpressionType(et); + if(!typeCombo.isDisposed()){ + setExpressionTypes(expressionTypes); + setExpressionType(et); + } } }); } - + }); - + } } } - + private void setExpressionTypes(ExpressionType[] expressionTypes) { if(expressionTypes != null) { for(ExpressionType et : expressionTypes) { @@ -92,8 +92,8 @@ public class ExpressionTypeWidget implements Widget { typeCombo.select(index); } } - - + + public void addSelectionListener(SelectionListener listener) { this.typeCombo.addSelectionListener(listener); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java index 3aa6b563..46307bbb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java @@ -3,13 +3,13 @@ package org.simantics.sysdyn.ui.properties.widgets; import java.util.HashMap; import java.util.Map; -import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; @@ -39,11 +39,11 @@ public class ExpressionWidget implements Widget { private IExpression expression; private ModifyListener modifyListener; private FocusListener focusListener; + private Table variableTable; public ExpressionWidget(Composite parent, WidgetSupport support, int style) { support.register(this); - GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(parent); this.parent = parent; this.data = new HashMap(); } @@ -105,6 +105,7 @@ public class ExpressionWidget implements Widget { exp.addFocusListener(focusListener); this.expression = exp; this.parent.layout(); + validateFields(); } } @@ -112,7 +113,13 @@ public class ExpressionWidget implements Widget { return expression; } - public void validateFields(TableItem[] connectedVariables) { + public void setVariableTable(Table table) { + this.variableTable = table; + } + + public void validateFields() { + if(this.variableTable == null) return; + TableItem[] connectedVariables = this.variableTable.getItems(); try { final Resource configuration = SimanticsUI.getSession().syncRequest(new Read() { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java index 4f645252..ed83f234 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/NameWidget.java @@ -31,7 +31,6 @@ import org.simantics.sysdyn.manager.SysdynModelManager; import org.simantics.sysdyn.representation.Configuration; import org.simantics.sysdyn.representation.IElement; import org.simantics.sysdyn.representation.Variable; -import org.simantics.sysdyn.ui.properties.EquationTab; import org.simantics.ui.SimanticsUI; import org.simantics.utils.ui.ISelectionUtils; @@ -46,7 +45,6 @@ public class NameWidget implements Widget { public NameWidget(Composite parent, WidgetSupport support, int style) { support.register(this); nameText = new org.eclipse.swt.widgets.Text(parent, style); - nameText.setFont(EquationTab.FONT); GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/UnitWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/UnitWidget.java index c5ef7732..a6ca29fa 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/UnitWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/UnitWidget.java @@ -27,7 +27,6 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.Listener; import org.simantics.db.request.Read; import org.simantics.sysdyn.SysdynResource; -import org.simantics.sysdyn.ui.properties.EquationTab; import org.simantics.ui.SimanticsUI; import org.simantics.utils.ui.ExceptionUtils; import org.simantics.utils.ui.ISelectionUtils; @@ -43,7 +42,6 @@ public class UnitWidget implements Widget { support.register(this); unitCombo = new Combo(parent, style); - unitCombo.setFont(EquationTab.FONT); int columns = 6; GC gc = new GC (unitCombo); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java index ac5b56bc..b7373e0a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java @@ -5,9 +5,12 @@ import java.util.List; import java.util.Map; import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyListener; @@ -22,30 +25,41 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; import org.simantics.sysdyn.SysdynResource; -import org.simantics.sysdyn.ui.properties.EquationTab; import org.simantics.ui.SimanticsUI; public class BasicExpression implements IExpression { - ExpressionField expression; - Resource expressionType; + private ExpressionField expression; + protected Resource expressionType; + private Point caretPosition; // Bug or something in source viewer's text widget. Cursor goes to 0, 0 on focus lost @Override public void createExpressionFields(Composite parent, Map data) { + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent); String equation = data.get("equation") != null ? (String)data.get("equation") : ""; Label l = new Label(parent, SWT.NONE); - l.setFont(EquationTab.FONT); l.setText("="); expression = new ExpressionField(parent, SWT.BORDER); expression.setExpression(equation); GridDataFactory.fillDefaults().grab(true, true).applyTo(expression); + + expression.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() { + + @Override + public void focusLost(FocusEvent e) { + caretPosition = expression.getSelection(); + } + }); } @Override public void focus() { - if(this.expression != null) this.expression.focus(); + if(this.expression != null && caretPosition != null) { + this.expression.focus(); + expression.getSourceViewer().getTextWidget().setSelection(caretPosition.x, caretPosition.x + caretPosition.y); + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java index 398858ee..0fe2f8de 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java @@ -6,9 +6,12 @@ import java.util.List; import java.util.Map; import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyListener; @@ -24,33 +27,31 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; import org.simantics.sysdyn.SysdynResource; -import org.simantics.sysdyn.ui.properties.EquationTab; import org.simantics.ui.SimanticsUI; public class StockExpression implements IExpression { private Text integral; private ExpressionField expression; + private Point caretPosition; // Bug or something in source viewer's text widget. Cursor goes to 0, 0 on focus lost @Override public void createExpressionFields(Composite parent, Map data) { + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent); String initialEquation = data.get("initialEquation") != null ? (String)data.get("initialEquation") : ""; String integralEquation = data.get("integral") != null ? (String)data.get("integral") : ""; Label label = new Label(parent, SWT.NONE); - label.setFont(EquationTab.FONT); label.setText("Integral"); integral = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); integral.setEditable(false); - integral.setFont(EquationTab.FONT); integral.setText(integralEquation); GridDataFactory.fillDefaults().grab(true, true).applyTo(integral); label = new Label(parent, SWT.NONE); - label.setFont(EquationTab.FONT); label.setText("Initial\nValue"); expression = new ExpressionField(parent, SWT.BORDER); @@ -58,11 +59,22 @@ public class StockExpression implements IExpression { GridDataFactory.fillDefaults().grab(true, true).applyTo(expression); + expression.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() { + + @Override + public void focusLost(FocusEvent e) { + caretPosition = expression.getSelection(); + } + }); + } @Override public void focus() { - if(this.expression != null) this.expression.focus(); + if(this.expression != null && caretPosition != null) { + this.expression.focus(); + expression.getSourceViewer().getTextWidget().setSelection(caretPosition.x, caretPosition.x + caretPosition.y); + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java index ea0bbc74..44d69cf2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java @@ -1,17 +1,29 @@ package org.simantics.sysdyn.ui.properties.widgets.expressions; +import java.awt.BasicStroke; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Point2D; +import java.io.StringReader; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import javax.swing.Timer; + import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.SWT; +import org.eclipse.swt.awt.SWT_AWT; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -19,6 +31,13 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -27,7 +46,9 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; import org.simantics.sysdyn.SysdynResource; -import org.simantics.sysdyn.ui.properties.EquationTab; +import org.simantics.sysdyn.tableParser.ParseException; +import org.simantics.sysdyn.tableParser.TableParser; +import org.simantics.sysdyn.tableParser.Token; import org.simantics.ui.SimanticsUI; public class WithLookupExpression implements IExpression { @@ -38,6 +59,10 @@ public class WithLookupExpression implements IExpression { private ExpressionField lastSelectedText = expression; private Resource variable; private LookupChartInfo chartInfo; + private Timer updateChartTimer; + + ChartPanel smallPanel; + Frame smallFrame; public WithLookupExpression(Resource variable) { this.variable = variable; @@ -45,12 +70,21 @@ public class WithLookupExpression implements IExpression { @Override public void createExpressionFields(Composite parent, final Map data) { + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parent); + + updateChartTimer = new Timer(1000, new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + updateChart(); + } + }); + updateChartTimer.setRepeats(false); String equation = data.get("equation") != null ? (String)data.get("equation") : ""; String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : ""; Label l = new Label(parent, SWT.NONE); - l.setFont(EquationTab.FONT); l.setText("With\nLookup"); expression = new ExpressionField(parent, SWT.BORDER); @@ -65,9 +99,11 @@ public class WithLookupExpression implements IExpression { } }); + Composite chartContainer = new Composite(parent, SWT.NONE); + createChart(chartContainer, data); + l = new Label(parent, SWT.NONE); - l.setFont(EquationTab.FONT); l.setText("Lookup\ntable"); lookup = new ExpressionField(parent, SWT.BORDER); @@ -81,23 +117,19 @@ public class WithLookupExpression implements IExpression { lastSelectedText = lookup; } }); - - asGraph = new Button(parent, SWT.None); - asGraph.setText("As graph"); - asGraph.setFont(EquationTab.FONT); - asGraph.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if(chartInfo == null) chartInfo = new LookupChartInfo(expression.getExpression(), lookup.getExpression(), variable, data); - LookupPopup pud = new LookupPopup(asGraph.getParent().getShell(), chartInfo); - LookupChartInfo newInfo = pud.open(false); - if(pud.getReturnCode() == org.eclipse.jface.window.Window.OK) { - chartInfo = newInfo; - lookup.setExpression(chartInfo.lookupTable); - lookup.focus(); - } + + lookup.getSourceViewer().getTextWidget().addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + if(!updateChartTimer.isRunning()) + updateChartTimer.start(); + else + updateChartTimer.restart(); } }); - + + updateChart(); } @Override @@ -223,5 +255,85 @@ public class WithLookupExpression implements IExpression { this.expression.getSourceViewer().getTextWidget().addFocusListener(listener); this.lookup.getSourceViewer().getTextWidget().addFocusListener(listener); } + + private void createChart(Composite composite, final Map data) { + GridLayoutFactory.fillDefaults().applyTo(composite); + GridDataFactory.fillDefaults().span(1, 2).hint(150, SWT.DEFAULT).applyTo(composite); + final Composite chartComposite = new Composite(composite, + SWT.NO_BACKGROUND | SWT.EMBEDDED); + GridDataFactory.fillDefaults().grab(true, true).applyTo(chartComposite); + smallFrame = SWT_AWT.new_Frame(chartComposite); + + XYDataset dataset = new XYSeriesCollection(new XYSeries("Lookup Table")); + JFreeChart chart = createChart(dataset); + smallPanel = new ChartPanel(chart); + smallFrame.add(smallPanel); + + asGraph = new Button(composite, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.END, SWT.BEGINNING).applyTo(asGraph); + asGraph.setText("Configure visually"); + asGraph.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if(chartInfo == null) chartInfo = new LookupChartInfo(expression.getExpression(), lookup.getExpression(), variable, data); + LookupPopup pud = new LookupPopup(asGraph.getParent().getShell(), chartInfo); + LookupChartInfo newInfo = pud.open(false); + if(pud.getReturnCode() == org.eclipse.jface.window.Window.OK) { + chartInfo = newInfo; + lookup.setExpression(chartInfo.lookupTable); + updateChart(); + lookup.focus(); + } + } + }); + } + + private static JFreeChart createChart(XYDataset dataset) { + JFreeChart chart = ChartFactory.createXYLineChart( + null, + null, + null, + dataset, + PlotOrientation.VERTICAL, + true, + true, + false + ); + chart.removeLegend(); + chart.getXYPlot().getDomainAxis().setTickLabelsVisible(false); + chart.getXYPlot().getDomainAxis().setAxisLineVisible(false); + chart.getXYPlot().getDomainAxis().setTickMarksVisible(false); + chart.getXYPlot().getRangeAxis().setTickLabelsVisible(false); + chart.getXYPlot().getRangeAxis().setAxisLineVisible(false); + chart.getXYPlot().getRangeAxis().setTickMarksVisible(false); + chart.getXYPlot().getRenderer().setSeriesStroke(0, new BasicStroke(3.0f)); + return chart; + } + + private void updateChart() { + ArrayList dataPoints = new ArrayList(); + TableParser parser = new TableParser(new StringReader("")); + parser.ReInit(new StringReader(lookup.getExpression())); + try { + parser.table(); + ArrayList xTokens = parser.getXTokens(); + for(Token token : xTokens) { + dataPoints.add(new Point2D.Double( + Double.parseDouble(token.image), + Double.parseDouble(token.next.next.image))); + } + } catch (ParseException e1) { + return; + } + + if(dataPoints.size() == 0) return; + + XYSeries series = new XYSeries("Lookup Table"); + for(Point2D point : dataPoints) { + series.add(point.getX(), point.getY()); + } + XYSeriesCollection dataset = new XYSeriesCollection(series); + smallPanel.getChart().getXYPlot().setDataset(dataset); + } + } -- 2.47.1