From 2b42a1b0d9b0089a191df60ebaf0ebaf510075c1 Mon Sep 17 00:00:00 2001 From: lempinen Date: Mon, 31 May 2010 12:07:33 +0000 Subject: [PATCH] Lookup Popup git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15995 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/equation/ExpressionComposite.java | 2 +- .../equation/expressions/LookupChartInfo.java | 63 ++++++ .../expressions/LookupChartPanel.java | 14 +- .../expressions/LookupInputOutputTable.java | 17 +- .../ui/equation/expressions/LookupPopup.java | 195 +++++++++++++----- .../WithLookupExpressionViewFactor.java | 36 +++- .../org/simantics/sysdyn/SysdynResource.java | 12 ++ sysdyn_ontologies/sysdyn.graph | 17 ++ 8 files changed, 282 insertions(+), 74 deletions(-) create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionComposite.java index d89ec1a1..33ccb1e8 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionComposite.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionComposite.java @@ -107,7 +107,7 @@ public class ExpressionComposite extends Composite { case Lookup: evf = new LookupExpressionViewFactor(); break; case WithLookup: - evf = new WithLookupExpressionViewFactor(); break; + evf = new WithLookupExpressionViewFactor(variable); break; case Stock: evf = new StockExpressionViewFactor(); break; case Delay: diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java new file mode 100644 index 00000000..237eff3c --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java @@ -0,0 +1,63 @@ +package org.simantics.sysdyn.ui.equation.expressions; + +import java.util.Map; + +import org.simantics.db.ReadGraph; +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.ui.SimanticsUI; + +public class LookupChartInfo { + + String lookupTable, expression; + Double minX, maxX, minY, maxY; + + private static Double MINX = 0.0; + private static Double MAXX = 10.0; + private static Double MINY = 0.0; + private static Double MAXY = 10.0; + + public LookupChartInfo(String expression, String lookupTable, final Resource variable, Map data) { + this.lookupTable = lookupTable != null ? lookupTable : ""; + this.expression = expression != null ? expression : ""; + this.minX = (Double)data.get("minX"); + this.maxX = (Double)data.get("maxX"); + this.minY = (Double)data.get("minY"); + this.maxY = (Double)data.get("maxY"); + if(variable != null && (minX == null || maxX == null || minY == null || maxY == null)) { + try { + SimanticsUI.getSession().syncRequest(new ReadRequest() { + @Override + public void run(ReadGraph graph) throws DatabaseException { + SysdynResource sr = SysdynResource.getInstance(graph); + Resource expression = graph.getPossibleObject(variable, sr.HasExpression); + if(expression != null && graph.isInstanceOf(expression, sr.WithLookupExpression)) { + minX = graph.getPossibleRelatedValue(expression, sr.HasMinX); + if(minX == null) minX = MINX; + maxX = graph.getPossibleRelatedValue(expression, sr.HasMaxX); + if(maxX == null) maxX = MAXX; + minY = graph.getPossibleRelatedValue(expression, sr.HasMinY); + if(minY == null) minY = MINY; + maxY = graph.getPossibleRelatedValue(expression, sr.HasMaxY); + if(maxY == null) maxY = MAXY; + } else { + defaultValues(); + } + + } + }); + } catch (DatabaseException e) { + e.printStackTrace(); + } + } + } + + private void defaultValues() { + minX = MINX; + maxX = MAXX; + minY = MINY; + maxY = MAXY; + } +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java index da6b2372..c08fbf9f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java @@ -18,7 +18,7 @@ import org.jfree.data.xy.XYSeriesCollection; @SuppressWarnings("serial") public class LookupChartPanel extends ChartPanel { - + private XYItemEntity dragPrevEntity; private boolean drawing; private XYSeries series; @@ -31,7 +31,7 @@ public class LookupChartPanel extends ChartPanel { XYSeriesCollection collection = (XYSeriesCollection) ((XYPlot)chart.getPlot()).getDataset(); series = collection.getSeries(0); } - + public void setTable(LookupInputOutputTable table) { this.table = table; } @@ -87,7 +87,7 @@ public class LookupChartPanel extends ChartPanel { } public void mouseReleased(MouseEvent e) { - + dragPrevEntity = null; drawing = false; } @@ -128,10 +128,12 @@ public class LookupChartPanel extends ChartPanel { } public void addLocationToSeries(Point2D location) { - series.add(location.getX(), location.getY()); - table.addLocation(location); + if(series.indexOf(location.getX()) < 0) { + series.add(location.getX(), location.getY()); + table.addLocation(location); + } } - + public void removeItemFromSeries(int item){ Point2D location = new Point2D.Double(series.getX(item).doubleValue(),series.getY(item).doubleValue()); series.remove(item); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java index 4a63d818..585ac91c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java @@ -30,7 +30,6 @@ public class LookupInputOutputTable extends Composite { TableViewer tableViewer; List tableRows; - public LookupInputOutputTable(Composite parent, int style) { super(parent, style); @@ -40,14 +39,14 @@ public class LookupInputOutputTable extends Composite { GridDataFactory.fillDefaults().grab(true, true).applyTo(table); table.setHeaderVisible (true); table.setLinesVisible(true); - - TableColumn column = new TableColumn (table, SWT.LEFT); - column.setText (INPUT); - column.setWidth (60); - - column = new TableColumn (table, SWT.LEFT); - column.setText (OUTPUT); - column.setWidth (60); + table.getVerticalBar().setVisible(true); + TableColumn column1 = new TableColumn (table, SWT.LEFT); + column1.setText (INPUT); + column1.setWidth (85); + + TableColumn column2 = new TableColumn (table, SWT.LEFT); + column2.setText (OUTPUT); + column2.setWidth (85); // Create the viewer and connect it to the view tableViewer = new TableViewer (table); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java index 34fe9ad2..57b29045 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java @@ -9,18 +9,24 @@ import java.awt.geom.Point2D; import java.io.StringReader; import java.util.ArrayList; import java.util.Iterator; - import javax.swing.JComponent; import javax.swing.JPanel; - import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -41,38 +47,28 @@ import org.jfree.data.xy.XYDataItem; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.simantics.db.Resource; import org.simantics.g2d.chassis.SWTAWTComponent; import org.simantics.sysdyn.tableParser.ParseException; import org.simantics.sysdyn.tableParser.Token; import org.simantics.sysdyn.tableParser.TableParser; import org.simantics.sysdyn.ui.equation.expressions.LookupInputOutputTable.InputOutput; -/** - * should do something in format {{0,1},{1,2},{2,3}} - * @author TLTEEMU - * - */ - public class LookupPopup extends Dialog { JFreeChart chart; - LookupChartPanel chartPanel; - SWTAWTComponent c; - JPanel panel; - Resource variable; LookupInputOutputTable table; ArrayList dataPoints; - + Text input, output; Text minX, maxX, minY, maxY; + Label unit; + LookupChartInfo chartInfo; - protected LookupPopup(Shell parentShell, Resource variable, String tableAsString) { + protected LookupPopup(Shell parentShell, LookupChartInfo chartInfo) { super(parentShell); - this.variable = variable; + this.chartInfo = chartInfo; this.dataPoints = new ArrayList(); - TableParser parser = new TableParser(new StringReader("")); - parser.ReInit(new StringReader(tableAsString)); + parser.ReInit(new StringReader(chartInfo.lookupTable)); try { parser.table(); ArrayList xTokens = parser.getXTokens(); @@ -82,15 +78,25 @@ public class LookupPopup extends Dialog { Double.parseDouble(token.next.next.image))); } } catch (ParseException e1) { - } - + } @Override protected Control createDialogArea(Composite parent) { + KeyListener enterListener = new KeyListener() { + + @Override + public void keyReleased(KeyEvent e) {} - chartPanel = new LookupChartPanel(createChart()); + @Override + public void keyPressed(KeyEvent e) { + if(e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) + getButton(IDialogConstants.OK_ID).forceFocus(); + } + }; + + final LookupChartPanel chartPanel = new LookupChartPanel(createChart()); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); chartPanel.setDomainZoomable(false); @@ -108,19 +114,26 @@ public class LookupPopup extends Dialog { GridDataFactory.fillDefaults().grab(false, true).applyTo(yAxis); maxY = new Text(yAxis, SWT.BORDER | SWT.RIGHT); GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(maxY); + maxY.addKeyListener(enterListener); maxY.addModifyListener(getAxisBoundModifyListener()); maxY.setText("" + rangeAxis.getUpperBound()); Composite fillY = new Composite(yAxis, SWT.NONE); - GridDataFactory.fillDefaults().grab(false, true).applyTo(fillY); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(false, true).applyTo(fillY); + GridLayoutFactory.fillDefaults().applyTo(fillY); + unit = new Label(fillY, SWT.RIGHT); + GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(unit); + unit.setText(""); //TODO: how to get and update units? + unit.addKeyListener(enterListener); minY = new Text(yAxis, SWT.BORDER | SWT.RIGHT); GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(minY); + minY.addKeyListener(enterListener); minY.addModifyListener(getAxisBoundModifyListener()); minY.setText("" + rangeAxis.getLowerBound()); - c = new SWTAWTComponent(container, SWT.BORDER) { + SWTAWTComponent c = new SWTAWTComponent(container, SWT.BORDER) { @Override protected JComponent createSwingComponent() { - panel = new JPanel(); + JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1, 1)); panel.setPreferredSize(new java.awt.Dimension(500, 270)); panel.add(chartPanel); @@ -133,16 +146,16 @@ public class LookupPopup extends Dialog { Composite valueTableComposite = new Composite(container, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(valueTableComposite); - GridLayoutFactory.fillDefaults().applyTo(valueTableComposite); + GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(valueTableComposite); + GridLayoutFactory.fillDefaults().numColumns(3).applyTo(valueTableComposite); table = new LookupInputOutputTable(valueTableComposite, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, true).applyTo(table); + GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(table); chartPanel.setTable(table); table.getTableViewer().setCellModifier(new InputOutputCellModifier()); table.getTableViewer().getTable().addMouseListener(new MouseListener() { - + @Override public void mouseUp(org.eclipse.swt.events.MouseEvent e) { if(e.button == MouseEvent.BUTTON3) { @@ -160,6 +173,74 @@ public class LookupPopup extends Dialog { chartPanel.addLocationToSeries(location); } + input = new Text(valueTableComposite, SWT.BORDER | SWT.RIGHT); + GridDataFactory.fillDefaults().hint(60, SWT.DEFAULT).applyTo(input); + input.setText(""); + output = new Text(valueTableComposite, SWT.BORDER | SWT.RIGHT); + GridDataFactory.fillDefaults().hint(60, SWT.DEFAULT).applyTo(output); + output.setText(""); + + Button add = new Button(valueTableComposite, SWT.None); + add.setText("Add"); + add.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + try { + Double in = Double.parseDouble(input.getText()); + Double out = Double.parseDouble(output.getText()); + chartPanel.addLocationToSeries(new Point2D.Double(in, out)); + } catch (NumberFormatException e1) { + input.setText(""); + output.setText(""); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + }); + + FocusListener flistener = new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + Text text = (Text)e.widget; + text.setSelection(0, text.getCharCount()); + } + @Override + public void focusLost(FocusEvent e) { } + }; + + + KeyListener listener = new KeyListener() { + + @Override + public void keyPressed(KeyEvent e) { + if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { + try { + Double in = Double.parseDouble(input.getText()); + Double out = Double.parseDouble(output.getText()); + chartPanel.addLocationToSeries(new Point2D.Double(in, out)); + } catch (NumberFormatException e1) { + if(input.getText().isEmpty() && output.getText().isEmpty()) { + getButton(IDialogConstants.OK_ID).forceFocus(); + return; + } + } + input.setText(""); + output.setText(""); + input.setFocus(); + } + } + + @Override + public void keyReleased(KeyEvent e) { } + + }; + + input.addFocusListener(flistener); + input.addKeyListener(listener); + output.addFocusListener(flistener); + output.addKeyListener(listener); Label l = new Label(container, SWT.NONE); l.setText(""); @@ -168,23 +249,33 @@ public class LookupPopup extends Dialog { GridDataFactory.fillDefaults().grab(true, false).applyTo(xAxis); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(xAxis); minX = new Text(xAxis, SWT.BORDER | SWT.RIGHT); - GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(minX); + GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(minX); + minX.addKeyListener(enterListener); minX.addModifyListener(getAxisBoundModifyListener()); minX.setText("" + domainAxis.getLowerBound()); - Composite fillX = new Composite(xAxis, SWT.NONE); - GridDataFactory.fillDefaults().grab(true, false).applyTo(fillX); + Composite fillX = new Composite(xAxis, SWT.CENTER); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(fillX); GridLayoutFactory.fillDefaults().applyTo(fillX); l = new Label(fillX, SWT.NONE); + l.setText(chartInfo.expression); maxX = new Text(xAxis, SWT.BORDER | SWT.RIGHT); GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(maxX); + maxX.addKeyListener(enterListener); maxX.addModifyListener(getAxisBoundModifyListener()); maxX.setText("" + domainAxis.getUpperBound()); return null; } + protected void createButtonsForButtonBar(Composite parent) { + // create OK and Cancel buttons by default + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, + false); + createButton(parent, IDialogConstants.CANCEL_ID, + IDialogConstants.CANCEL_LABEL, false); + } - public String open(boolean moi) { + public LookupChartInfo open(Boolean bool) { Shell shell = this.getShell(); if (shell == null || shell.isDisposed()) { shell = null; @@ -192,17 +283,27 @@ public class LookupPopup extends Dialog { shell = this.getShell(); } constrainShellSize(); - shell.open(); + getButton(IDialogConstants.OK_ID).setFocus(); Display display = getParentShell().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } - return graphToModelicaTable(); + return chartInfo; } - + + @Override + public void okPressed() { + chartInfo.lookupTable = graphToModelicaTable(); + chartInfo.minX = Double.parseDouble(minX.getText()); + chartInfo.maxX = Double.parseDouble(maxX.getText()); + chartInfo.minY = Double.parseDouble(minY.getText()); + chartInfo.maxY = Double.parseDouble(maxY.getText()); + super.okPressed(); + } + @SuppressWarnings("unchecked") private String graphToModelicaTable() { StringBuilder b = new StringBuilder(); @@ -224,7 +325,7 @@ public class LookupPopup extends Dialog { private JFreeChart createChart() { XYDataset dataset = createDataset(); - chart = ChartFactory.createXYLineChart("Lookup", "X", "Y", + chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer @@ -239,11 +340,10 @@ public class LookupPopup extends Dialog { ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setAutoRange(false); - rangeAxis.setRange(0, 40); - + rangeAxis.setRange(chartInfo.minY, chartInfo.maxY); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setAutoRange(false); - domainAxis.setRange(0, 30); + domainAxis.setRange(chartInfo.minX, chartInfo.maxX); return chart; } @@ -284,9 +384,9 @@ public class LookupPopup extends Dialog { } }; } - + private class InputOutputCellModifier implements ICellModifier { - + XYSeries series; public InputOutputCellModifier() { @@ -310,12 +410,12 @@ public class LookupPopup extends Dialog { public void modify(Object element, String property, Object value) { if (element instanceof Item) element = ((Item) element).getData(); - + InputOutput io = (InputOutput)element; Double x = (Double)io.getInput(Double.class); int item = series.indexOf(x); series.remove(item); - + if (LookupInputOutputTable.INPUT.equals(property)) { Double newX = io.setInput((String)value); // if has the same x-value, revert back @@ -325,16 +425,11 @@ public class LookupPopup extends Dialog { } else if (LookupInputOutputTable.OUTPUT.equals(property)) { io.setOutput((String)value); } - + series.add((Double)io.getInput(Double.class), (Double)io.getOutput(Double.class)); - - table.refresh(); + table.refresh(); } } - - - - } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java index 288fd3b3..43218e06 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java @@ -48,12 +48,17 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { private Button asGraph; private ExpressionField lastSelectedText = expression; private Resource variable; + private LookupChartInfo chartInfo; + public WithLookupExpressionViewFactor(Resource variable) { + super(); + this.variable = variable; + } + @Override - public void createView(Composite parent, Map data) { - - final String equation = data.get("equation") != null ? (String)data.get("equation") : ""; - final String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : ""; + public void createView(Composite parent, final Map data) { + String equation = data.get("equation") != null ? (String)data.get("equation") : ""; + String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : ""; GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent); @@ -99,11 +104,17 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { asGraph.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if(e.widget == asGraph) { - LookupPopup pud = new LookupPopup(asGraph.getParent().getShell(), variable, lookup.getExpression()); - lookup.setExpression(pud.open(false)); + 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); + } } } }); + } @Override @@ -134,7 +145,6 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { } data.put("equation", results[0]); data.put("lookup", results[1]); - this.variable = variable; } } @@ -144,6 +154,7 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { final String currentLookupTable = lookup.getExpression(); if(currentExpression != null && currentLookupTable != null) { + data.putAll(data); data.put("equation", currentExpression); data.put("lookup", currentLookupTable); SimanticsUI.getSession().asyncRequest(new WriteRequest() { @@ -161,8 +172,11 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { g.claim(variable, sr.HasExpression, expression); g.claimValue(expression, sr.HasEquation, currentExpression); g.claimValue(expression, sr.HasLookup, currentLookupTable); + g.claimValue(expression, sr.HasMinX, chartInfo.minX); + g.claimValue(expression, sr.HasMaxX, chartInfo.maxX); + g.claimValue(expression, sr.HasMinY, chartInfo.minY); + g.claimValue(expression, sr.HasMaxY, chartInfo.maxY); } - }); } } @@ -192,6 +206,12 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { data.put("equation", this.expression.getExpression()); if(this.lookup != null && this.lookup.getExpression() != null) data.put("lookup", this.lookup.getExpression()); + if(this.chartInfo != null) { + data.put("minX", chartInfo.minX); + data.put("maxX", chartInfo.maxX); + data.put("minY", chartInfo.minY); + data.put("maxY", chartInfo.maxY); + } } @Override diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java index d24dac9a..c8231e16 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java @@ -37,6 +37,10 @@ public class SysdynResource { public final Resource HasHead; public final Resource HasInitialEquation; public final Resource HasLookup; + public final Resource HasMaxX; + public final Resource HasMaxY; + public final Resource HasMinX; + public final Resource HasMinY; public final Resource HasStartTime; public final Resource HasStopTime; public final Resource HasTail; @@ -85,6 +89,10 @@ public class SysdynResource { public static final String HasHead = "http://www.simantics.org/Sysdyn-1.0/HasHead"; public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn-1.0/HasInitialEquation"; public static final String HasLookup = "http://www.simantics.org/Sysdyn-1.0/HasLookup"; + public static final String HasMaxX = "http://www.simantics.org/Sysdyn-1.0/HasMaxX"; + public static final String HasMaxY = "http://www.simantics.org/Sysdyn-1.0/HasMaxY"; + public static final String HasMinX = "http://www.simantics.org/Sysdyn-1.0/HasMinX"; + public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY"; public static final String HasStartTime = "http://www.simantics.org/Sysdyn-1.0/HasStartTime"; public static final String HasStopTime = "http://www.simantics.org/Sysdyn-1.0/HasStopTime"; public static final String HasTail = "http://www.simantics.org/Sysdyn-1.0/HasTail"; @@ -143,6 +151,10 @@ public class SysdynResource { HasHead = getResourceOrNull(graph, URIs.HasHead); HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation); HasLookup = getResourceOrNull(graph, URIs.HasLookup); + HasMaxX = getResourceOrNull(graph, URIs.HasMaxX); + HasMaxY = getResourceOrNull(graph, URIs.HasMaxY); + HasMinX = getResourceOrNull(graph, URIs.HasMinX); + HasMinY = getResourceOrNull(graph, URIs.HasMinY); HasStartTime = getResourceOrNull(graph, URIs.HasStartTime); HasStopTime = getResourceOrNull(graph, URIs.HasStopTime); HasTail = getResourceOrNull(graph, URIs.HasTail); diff --git a/sysdyn_ontologies/sysdyn.graph b/sysdyn_ontologies/sysdyn.graph index 1b9d2388..1256c67e 100644 --- a/sysdyn_ontologies/sysdyn.graph +++ b/sysdyn_ontologies/sysdyn.graph @@ -190,6 +190,18 @@ HasInitialEquation