1 package org.simantics.sysdyn.ui.properties.widgets.expressions;
\r
3 import java.util.Map;
\r
5 import org.simantics.db.ReadGraph;
\r
6 import org.simantics.db.Resource;
\r
7 import org.simantics.db.common.request.ReadRequest;
\r
8 import org.simantics.db.exception.DatabaseException;
\r
9 import org.simantics.sysdyn.SysdynResource;
\r
10 import org.simantics.ui.SimanticsUI;
\r
12 public class LookupChartInfo {
\r
14 String lookupTable, expression;
\r
15 Double minX, maxX, minY, maxY;
\r
17 private static Double MINX = 0.0;
\r
18 private static Double MAXX = 10.0;
\r
19 private static Double MINY = 0.0;
\r
20 private static Double MAXY = 10.0;
\r
22 public LookupChartInfo(String expression, String lookupTable, final Resource variable, Map<String, Object> data) {
\r
23 this.lookupTable = lookupTable != null ? lookupTable : "";
\r
24 this.expression = expression != null ? expression : "";
\r
25 this.minX = (Double)data.get("minX");
\r
26 this.maxX = (Double)data.get("maxX");
\r
27 this.minY = (Double)data.get("minY");
\r
28 this.maxY = (Double)data.get("maxY");
\r
29 if(variable != null && (minX == null || maxX == null || minY == null || maxY == null)) {
\r
31 SimanticsUI.getSession().syncRequest(new ReadRequest() {
\r
33 public void run(ReadGraph graph) throws DatabaseException {
\r
34 SysdynResource sr = SysdynResource.getInstance(graph);
\r
35 Resource expression = graph.getPossibleObject(variable, sr.HasExpression);
\r
36 if(expression != null && graph.isInstanceOf(expression, sr.WithLookupExpression)) {
\r
37 minX = graph.getPossibleRelatedValue(expression, sr.HasMinX);
\r
38 if(minX == null) minX = MINX;
\r
39 maxX = graph.getPossibleRelatedValue(expression, sr.HasMaxX);
\r
40 if(maxX == null) maxX = MAXX;
\r
41 minY = graph.getPossibleRelatedValue(expression, sr.HasMinY);
\r
42 if(minY == null) minY = MINY;
\r
43 maxY = graph.getPossibleRelatedValue(expression, sr.HasMaxY);
\r
44 if(maxY == null) maxY = MAXY;
\r
51 } catch (DatabaseException e) {
\r
52 e.printStackTrace();
\r
57 private void defaultValues() {
\r