1 package org.simantics.jfreechart.chart.properties;
\r
3 import java.util.Collection;
\r
4 import java.util.HashMap;
\r
5 import java.util.Map;
\r
7 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
\r
8 import org.simantics.db.ReadGraph;
\r
9 import org.simantics.db.Resource;
\r
10 import org.simantics.db.exception.DatabaseException;
\r
11 import org.simantics.sysdyn.JFreeChartResource;
\r
13 public class ChartVariableFactory extends ReadFactoryImpl<Resource, ChartVariable>{
\r
15 private Map<String,ChartVariable> map;
\r
17 public ChartVariableFactory(Collection<ChartVariable> data) {
\r
18 map = new HashMap<String, ChartVariable>();
\r
19 for (ChartVariable v : data) {
\r
20 map.put(v.getRvi(), v);
\r
25 public ChartVariable perform(ReadGraph graph, Resource input)
\r
26 throws DatabaseException {
\r
27 String rvi = graph.getPossibleRelatedValue(input, JFreeChartResource.getInstance(graph).variableRVI);
\r
30 return map.get(rvi);
\r