]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/editor/ChartData.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / editor / ChartData.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.charts.editor;\r
13 \r
14 import org.simantics.databoard.annotations.Optional;\r
15 import org.simantics.db.Resource;\r
16 import org.simantics.history.Collector;\r
17 import org.simantics.history.HistoryManager;\r
18 import org.simantics.simulation.data.Datasource;\r
19 import org.simantics.simulation.experiment.IExperiment;\r
20 \r
21 /**\r
22  * @author Tuukka Lehtonen\r
23  */\r
24 public final class ChartData {\r
25 \r
26     /**\r
27      * The model for which this ChartData is valid, i.e. the model that contains\r
28      * {@link #run} if {@link #run} is non<code>non-null</code>\r
29      */\r
30     @Optional\r
31     public Resource       model;\r
32 \r
33     /**\r
34      * If just reading data from file system, not the database, this may be\r
35      * <code>null</code>.\r
36      */\r
37     @Optional\r
38     public Resource       run;\r
39 \r
40     /**\r
41      * Used for giving the chart access to the active experiment state.\r
42      */\r
43     @Optional\r
44     public IExperiment    experiment;\r
45 \r
46     /**\r
47      * May be null if the chart data is not connected to a running experiment.\r
48      */\r
49     @Optional\r
50     public Datasource     datasource;\r
51 \r
52     @Optional\r
53     public HistoryManager history;\r
54 \r
55     /**\r
56      * Optional collector, Chart uses this to flush data right before drawing it\r
57      */\r
58     @Optional\r
59     public Collector      collector;\r
60 \r
61     public ChartData(Resource model, Resource run, IExperiment experiment, Datasource datasource, HistoryManager history, Collector collector) {\r
62         this.model = model;\r
63         this.run = run;\r
64         this.experiment = experiment;\r
65         this.datasource = datasource;\r
66         this.history = history;\r
67         this.collector = collector;\r
68     }\r
69     \r
70     public void readFrom(ChartData other) {\r
71         if (other==null) {\r
72                 this.model = null;\r
73                 this.run = null;\r
74                 this.experiment = null;\r
75                 this.datasource = null;\r
76                 this.history = null;\r
77                 this.collector = null;\r
78         } else {\r
79                 this.model = other.model;\r
80                 this.run = other.run;\r
81                 this.experiment = other.experiment;\r
82                 this.datasource = other.datasource;\r
83                 this.history = other.history;\r
84                 this.collector = other.collector;\r
85         }\r
86     }\r
87 \r
88     /**\r
89      * Dispose by closing history\r
90      */\r
91     public void dispose() {\r
92         model = null;\r
93         run = null;\r
94         experiment = null;\r
95         datasource = null;\r
96         if (history != null) {\r
97                 history.close();\r
98                 history = null;\r
99         }\r
100     }\r
101 \r
102 }\r