]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.trend/src/org/simantics/trend/configuration/TrendItem.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.trend / src / org / simantics / trend / configuration / TrendItem.java
index c53b6939e65c12a6d8683c1f24c44eb37e726b35..6b7792c115d448120b4b09a9922db139a0d5f504 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.trend.configuration;\r
-\r
-import org.simantics.databoard.annotations.Identifier;\r
-import org.simantics.databoard.annotations.Optional;\r
-import org.simantics.databoard.util.Bean;\r
-import org.simantics.utils.strings.AlphanumComparator;\r
-\r
-/**\r
- * @author Toni Kalajainen\r
- */\r
-public class TrendItem extends Bean {\r
-       \r
-       // Sorting and color index\r
-       public int index;\r
-       \r
-       // Chart Label\r
-       public @Optional String label;  \r
-       // Normal Label (eg. The label in CSV file)\r
-       public @Optional String simpleLabel;\r
-       // Variable reference in user friendly format\r
-       public @Optional String variableReference;\r
-       \r
-       // GroupId in the history\r
-       public @Identifier String groupId;\r
-       // ItemId in the group\r
-       public @Identifier String groupItemId;\r
-       // Variable id in format understood by org.simantics.simulation.data.Datasource\r
-       public @Identifier String variableId;\r
-       \r
-       public Scale scale;\r
-       \r
-       // TODO Rename Binary to Bar\r
-       public enum Renderer { Analog, Binary } public Renderer renderer;\r
-       \r
-       public @Optional String unit;\r
-       \r
-       public DrawMode drawMode = DrawMode.getDefault();\r
-\r
-       // If true, the item shall not be shown in the chart.\r
-       public boolean hidden = false;\r
-\r
-       // Defines a custom stroke to be used when rendering this item.\r
-       public @Optional Float customStrokeWidth;\r
-\r
-       // Defines a custom color to be used when rendering this item.\r
-       // If not defined, color is calculated based on #index.\r
-       public @Optional float[] customColor;\r
-\r
-       public enum DrawMode {\r
-               DeviationAndLine,\r
-               DeviationAndAverage,\r
-               DeviationAndSample,\r
-               Average,\r
-               Line,\r
-               Sample,\r
-               Deviation;\r
-               public static DrawMode getDefault() {\r
-                       return DeviationAndLine; \r
-               }\r
-       }\r
-       \r
-       public TrendItem() {\r
-       }\r
-\r
-       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale) {\r
-               this(index, label, subscriptionId, variableId, scale, Renderer.Analog);\r
-       }\r
-\r
-       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale, Renderer renderer) {\r
-               this.index = index;\r
-               this.label = label;\r
-               this.variableId = variableId;\r
-               this.scale = scale;\r
-               this.renderer = renderer;\r
-               this.groupId = subscriptionId;\r
-               this.groupItemId = variableId;\r
-       }       \r
-\r
-       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale, Renderer renderer, double min, double max) {\r
-               this.index = index;\r
-               this.label = label;\r
-               this.variableId = variableId;\r
-               this.scale = new Scale.Manual(min, max);\r
-               this.renderer = renderer;\r
-               this.groupId = subscriptionId;\r
-               this.groupItemId = variableId;\r
-       }\r
-       \r
-       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale, Renderer renderer, double min, double max, DrawMode drawMode) {\r
-               this.index = index;\r
-               this.label = label;\r
-               this.variableId = variableId;\r
-               this.scale = new Scale.Manual(min, max);\r
-               this.renderer = renderer;\r
-               this.groupId = subscriptionId;\r
-               this.groupItemId = variableId;\r
-               this.drawMode = drawMode;\r
-       }\r
-       \r
-       @Override\r
-       public int compareTo(Bean o) {\r
-               if ( o instanceof TrendItem == false ) return 0;\r
-               TrendItem other = (TrendItem) o;\r
-               \r
-               int c = renderer.ordinal() - other.renderer.ordinal();\r
-               if ( c!=0 ) return c;\r
-               \r
-               c = index - other.index;\r
-               if ( c!=0 ) return c;\r
-               \r
-               String myLabel1 = label!=null?label:"";\r
-               String otLabel1 = other.label!=null?other.label:"";\r
-               c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel1, otLabel1);\r
-               if ( c!=0 ) return c;\r
-               \r
-               String myLabel2 = simpleLabel!=null?simpleLabel:"";\r
-               String otLabel2 = other.simpleLabel!=null?other.simpleLabel:"";\r
-               c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel2, otLabel2);\r
-               if ( c!=0 ) return c;\r
-               \r
-               String mySid = groupId!=null?groupId:""; \r
-               String otSid = other.groupId!=null?other.groupId:""; \r
-               c = mySid.compareTo(otSid);\r
-               if ( c!=0 ) return c;\r
-\r
-               String myGiid = groupItemId!=null?groupItemId:""; \r
-               String otGiid = other.groupItemId!=null?other.groupItemId:""; \r
-               c = myGiid.compareTo(otGiid);\r
-               if ( c!=0 ) return c;\r
-\r
-               String myVid = variableId!=null?variableId:""; \r
-               String otVid = other.variableId!=null?other.variableId:""; \r
-               c = myVid.compareTo(otVid);\r
-               if ( c!=0 ) return c;\r
-               \r
-               return c;               \r
-       }\r
-       \r
-}\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.trend.configuration;
+
+import org.simantics.databoard.annotations.Identifier;
+import org.simantics.databoard.annotations.Optional;
+import org.simantics.databoard.util.Bean;
+import org.simantics.utils.strings.AlphanumComparator;
+
+/**
+ * @author Toni Kalajainen
+ */
+public class TrendItem extends Bean {
+       
+       // Sorting and color index
+       public int index;
+       
+       // Chart Label
+       public @Optional String label;  
+       // Normal Label (eg. The label in CSV file)
+       public @Optional String simpleLabel;
+       // Variable reference in user friendly format
+       public @Optional String variableReference;
+       
+       // GroupId in the history
+       public @Identifier String groupId;
+       // ItemId in the group
+       public @Identifier String groupItemId;
+       // Variable id in format understood by org.simantics.simulation.data.Datasource
+       public @Identifier String variableId;
+       
+       public Scale scale;
+       
+       // TODO Rename Binary to Bar
+       public enum Renderer { Analog, Binary } public Renderer renderer;
+       
+       public @Optional String unit;
+       
+       public DrawMode drawMode = DrawMode.getDefault();
+
+       // If true, the item shall not be shown in the chart.
+       public boolean hidden = false;
+
+       // Defines a custom stroke to be used when rendering this item.
+       public @Optional Float customStrokeWidth;
+
+       // Defines a custom color to be used when rendering this item.
+       // If not defined, color is calculated based on #index.
+       public @Optional float[] customColor;
+
+       public enum DrawMode {
+               DeviationAndLine,
+               DeviationAndAverage,
+               DeviationAndSample,
+               Average,
+               Line,
+               Sample,
+               Deviation;
+               public static DrawMode getDefault() {
+                       return DeviationAndLine; 
+               }
+       }
+       
+       public TrendItem() {
+       }
+
+       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale) {
+               this(index, label, subscriptionId, variableId, scale, Renderer.Analog);
+       }
+
+       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale, Renderer renderer) {
+               this.index = index;
+               this.label = label;
+               this.variableId = variableId;
+               this.scale = scale;
+               this.renderer = renderer;
+               this.groupId = subscriptionId;
+               this.groupItemId = variableId;
+       }       
+
+       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale, Renderer renderer, double min, double max) {
+               this.index = index;
+               this.label = label;
+               this.variableId = variableId;
+               this.scale = new Scale.Manual(min, max);
+               this.renderer = renderer;
+               this.groupId = subscriptionId;
+               this.groupItemId = variableId;
+       }
+       
+       public TrendItem(int index, String label, String subscriptionId, String variableId, Scale scale, Renderer renderer, double min, double max, DrawMode drawMode) {
+               this.index = index;
+               this.label = label;
+               this.variableId = variableId;
+               this.scale = new Scale.Manual(min, max);
+               this.renderer = renderer;
+               this.groupId = subscriptionId;
+               this.groupItemId = variableId;
+               this.drawMode = drawMode;
+       }
+       
+       @Override
+       public int compareTo(Bean o) {
+               if ( o instanceof TrendItem == false ) return 0;
+               TrendItem other = (TrendItem) o;
+               
+               int c = renderer.ordinal() - other.renderer.ordinal();
+               if ( c!=0 ) return c;
+               
+               c = index - other.index;
+               if ( c!=0 ) return c;
+               
+               String myLabel1 = label!=null?label:"";
+               String otLabel1 = other.label!=null?other.label:"";
+               c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel1, otLabel1);
+               if ( c!=0 ) return c;
+               
+               String myLabel2 = simpleLabel!=null?simpleLabel:"";
+               String otLabel2 = other.simpleLabel!=null?other.simpleLabel:"";
+               c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel2, otLabel2);
+               if ( c!=0 ) return c;
+               
+               String mySid = groupId!=null?groupId:""; 
+               String otSid = other.groupId!=null?other.groupId:""; 
+               c = mySid.compareTo(otSid);
+               if ( c!=0 ) return c;
+
+               String myGiid = groupItemId!=null?groupItemId:""; 
+               String otGiid = other.groupItemId!=null?other.groupItemId:""; 
+               c = myGiid.compareTo(otGiid);
+               if ( c!=0 ) return c;
+
+               String myVid = variableId!=null?variableId:""; 
+               String otVid = other.variableId!=null?other.variableId:""; 
+               c = myVid.compareTo(otVid);
+               if ( c!=0 ) return c;
+               
+               return c;               
+       }
+       
+}
+