]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/preference/ChartTimeWindowTemplate.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / preference / ChartTimeWindowTemplate.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.charts.preference;
13
14 import org.simantics.charts.ontology.ChartResource;
15 import org.simantics.databoard.annotations.Optional;
16 import org.simantics.databoard.annotations.Range;
17 import org.simantics.databoard.annotations.Unit;
18 import org.simantics.databoard.util.Bean;
19
20 public class ChartTimeWindowTemplate extends Bean {
21
22         public static final ChartTimeWindowTemplate WholeHistory, Last60Seconds, Last10Minutes;
23         public static final String[][] radioGroup;
24         
25         public String id;
26         public String Label;
27         public String uri;
28         public @Unit("s") @Optional Double HasTimeWindowStart; 
29         public @Unit("s") @Optional Double TimeWindowLength;
30         public @Range("[0..100]")  @Optional Double TimeWindowIncrement;
31         
32         public static ChartTimeWindowTemplate getTemplate(String id)
33         {
34                 if (id.equals(WholeHistory.id)) return WholeHistory;
35                 if (id.equals(Last60Seconds.id)) return Last60Seconds;
36                 if (id.equals(Last10Minutes.id)) return Last10Minutes;
37                 return null;
38         }
39         
40         static {
41                 WholeHistory = new ChartTimeWindowTemplate();
42                 WholeHistory.id = "WholeHistory";
43                 WholeHistory.Label = "Whole History";
44                 WholeHistory.TimeWindowIncrement = 50.0;
45                 WholeHistory.uri = ChartResource.URIs.WholeHistoryChartTemplate;
46
47                 Last60Seconds = new ChartTimeWindowTemplate();
48                 Last60Seconds.id = "Last60Seconds";
49                 Last60Seconds.Label = "Last 60 Seconds";
50                 Last60Seconds.TimeWindowIncrement = 50.0;
51                 Last60Seconds.TimeWindowLength = 60.0;
52                 Last60Seconds.uri = ChartResource.URIs.Last60SecondsChartTemplate;
53
54                 Last10Minutes = new ChartTimeWindowTemplate();
55                 Last10Minutes.id = "Last10Minutes";
56                 Last10Minutes.Label = "Last 10 Minutes";
57                 Last10Minutes.TimeWindowIncrement = 50.0;
58                 Last10Minutes.TimeWindowLength = 600.0;
59                 Last10Minutes.uri = ChartResource.URIs.Last10MinutesChartTemplate;
60                 
61                 radioGroup = 
62                         new String[][] { 
63                                 { WholeHistory.Label, WholeHistory.id }, 
64                                 { Last60Seconds.Label, Last60Seconds.id }, 
65                                 { Last10Minutes.Label, Last10Minutes.id } 
66                         };
67         }
68         
69         public static void main(String[] args) throws Exception {
70                                 
71                 System.out.println( WholeHistory );
72                 System.out.println( Last60Seconds );
73                 System.out.println( Last10Minutes );
74                 
75         }
76         
77 }