1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.browser.contributions;
\r
14 import java.util.ArrayList;
\r
15 import java.util.Collection;
\r
17 import org.simantics.browsing.ui.common.node.AbstractNode;
\r
18 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;
\r
19 import org.simantics.db.ReadGraph;
\r
20 import org.simantics.db.Resource;
\r
21 import org.simantics.db.common.request.ObjectsWithType;
\r
22 import org.simantics.db.common.request.PossibleObjectWithType;
\r
23 import org.simantics.db.exception.DatabaseException;
\r
24 import org.simantics.layer0.Layer0;
\r
25 import org.simantics.sysdyn.JFreeChartResource;
\r
26 import org.simantics.sysdyn.SysdynResource;
\r
27 import org.simantics.sysdyn.ui.browser.nodes.BarChartNode;
\r
28 import org.simantics.sysdyn.ui.browser.nodes.LineChartNode;
\r
29 import org.simantics.sysdyn.ui.browser.nodes.ChartsFolder;
\r
30 import org.simantics.sysdyn.ui.browser.nodes.PieChartNode;
\r
31 import org.simantics.sysdyn.ui.browser.nodes.SensitivityChartNode;
\r
34 * Class for creating chart nodes for model browser
\r
35 * @author Teemu Lempinen
\r
38 public class Charts extends ViewpointContributor<ChartsFolder> {
\r
41 public Collection<?> getContribution(ReadGraph graph, ChartsFolder folder) throws DatabaseException {
\r
42 Layer0 L0 = Layer0.getInstance(graph);
\r
43 JFreeChartResource JFREE = JFreeChartResource.getInstance(graph);
\r
44 SysdynResource SR = SysdynResource.getInstance(graph);
\r
46 ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();
\r
47 for(Resource chart : graph.syncRequest(
\r
48 new ObjectsWithType(folder.data,
\r
51 Resource plot = graph.syncRequest(new PossibleObjectWithType(chart, L0.ConsistsOf, JFREE.Plot));
\r
53 if(graph.isInstanceOf(plot, SR.Charts_SensitivityPlot)) {
\r
54 result.add(new SensitivityChartNode(chart));
\r
55 } else if(graph.isInstanceOf(plot, JFREE.XYPlot)) {
\r
56 result.add(new LineChartNode(chart));
\r
57 } else if(graph.isInstanceOf(plot, JFREE.CategoryPlot)) {
\r
58 result.add(new BarChartNode(chart));
\r
59 } else if(graph.isInstanceOf(plot, JFREE.PiePlot)) {
\r
60 result.add(new PieChartNode(chart));
\r