-package org.simantics.history.csv;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-/**\r
- * Specifies the interpolation method to use when producing exported samples in\r
- * {@link CSVFormatter}.\r
- * \r
- * @author Tuukka Lehtonen\r
- * @see CSVFormatter\r
- */\r
-public enum ExportInterpolation {\r
-\r
- /**\r
- * Directly take the last sample whose time stamp is less than or equal to\r
- * the sampling time.\r
- */\r
- PREVIOUS_SAMPLE("Previous sample", "previous"),\r
-\r
- /**\r
- * <pre>\r
- * v<sub>1</sub> v<sub>s</sub> v<sub>2</sub>\r
- * |----------------|--------------------|\r
- * t<sub>1</sub> t<sub>s</sub> t<sub>2</sub>\r
- * </pre>\r
- * \r
- * Here t<sub>1</sub> and t<sub>2</sub> are time stamps of those two\r
- * successive samples for which t<sub>1</sub> ≤ t<sub>s</sub> ≤\r
- * t<sub>2</sub>.\r
- * \r
- * <p>\r
- * The sampling result is then:\r
- * <code>v<sub>s</sub> = v<sub>1</sub>+(v<sub>2</sub>-v<sub>1</sub>)*(t<sub>s</sub>-t<sub>1</sub>)/(t<sub>2</sub>-t<sub>1</sub>).\r
- */\r
- LINEAR_INTERPOLATION("Linear interpolation", "lerp");\r
-\r
- public String label;\r
- public String preference;\r
- ExportInterpolation(String label, String preference) {\r
- this.label = label;\r
- this.preference = preference;\r
- }\r
- public static List<ExportInterpolation> list() {\r
- return toList(LINEAR_INTERPOLATION, PREVIOUS_SAMPLE);\r
- }\r
- public static ExportInterpolation fromIndex(int index) {\r
- return list().get(index);\r
- }\r
- public static ExportInterpolation fromPreference(String preference) {\r
- for(ExportInterpolation s : list()) {\r
- if(s.preference.equals(preference)) return s;\r
- }\r
- return list().get(0);\r
- }\r
- public int index() {\r
- return list().indexOf(this);\r
- }\r
- public static ExportInterpolation getDefault() {\r
- return LINEAR_INTERPOLATION;\r
- }\r
- public String toPreference() {\r
- return preference;\r
- }\r
- private static <T> List<T> toList(T ... ts) {\r
- ArrayList<T> result = new ArrayList<T>();\r
- for(T t : ts) result.add(t);\r
- return result;\r
- }\r
-}\r
+package org.simantics.history.csv;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Specifies the interpolation method to use when producing exported samples in
+ * {@link CSVFormatter}.
+ *
+ * @author Tuukka Lehtonen
+ * @see CSVFormatter
+ */
+public enum ExportInterpolation {
+
+ /**
+ * Directly take the last sample whose time stamp is less than or equal to
+ * the sampling time.
+ */
+ PREVIOUS_SAMPLE("Previous sample", "previous"),
+
+ /**
+ * <pre>
+ * v<sub>1</sub> v<sub>s</sub> v<sub>2</sub>
+ * |----------------|--------------------|
+ * t<sub>1</sub> t<sub>s</sub> t<sub>2</sub>
+ * </pre>
+ *
+ * Here t<sub>1</sub> and t<sub>2</sub> are time stamps of those two
+ * successive samples for which t<sub>1</sub> ≤ t<sub>s</sub> ≤
+ * t<sub>2</sub>.
+ *
+ * <p>
+ * The sampling result is then:
+ * <code>v<sub>s</sub> = v<sub>1</sub>+(v<sub>2</sub>-v<sub>1</sub>)*(t<sub>s</sub>-t<sub>1</sub>)/(t<sub>2</sub>-t<sub>1</sub>).
+ */
+ LINEAR_INTERPOLATION("Linear interpolation", "lerp");
+
+ public String label;
+ public String preference;
+ ExportInterpolation(String label, String preference) {
+ this.label = label;
+ this.preference = preference;
+ }
+ public static List<ExportInterpolation> list() {
+ return toList(LINEAR_INTERPOLATION, PREVIOUS_SAMPLE);
+ }
+ public static ExportInterpolation fromIndex(int index) {
+ return list().get(index);
+ }
+ public static ExportInterpolation fromPreference(String preference) {
+ for(ExportInterpolation s : list()) {
+ if(s.preference.equals(preference)) return s;
+ }
+ return list().get(0);
+ }
+ public int index() {
+ return list().indexOf(this);
+ }
+ public static ExportInterpolation getDefault() {
+ return LINEAR_INTERPOLATION;
+ }
+ public String toPreference() {
+ return preference;
+ }
+ private static <T> List<T> toList(T ... ts) {
+ ArrayList<T> result = new ArrayList<T>();
+ for(T t : ts) result.add(t);
+ return result;
+ }
+}