1 package org.simantics.charts.ui;
\r
3 import java.util.Comparator;
\r
4 import java.util.HashSet;
\r
5 import java.util.TreeMap;
\r
7 import org.simantics.databoard.annotations.Optional;
\r
8 import org.simantics.databoard.util.Bean;
\r
9 import org.simantics.db.common.NamedResource;
\r
10 import org.simantics.trend.configuration.TrendItem;
\r
11 import org.simantics.trend.configuration.TrendItem.Renderer;
\r
12 import org.simantics.trend.configuration.YAxisMode;
\r
13 import org.simantics.utils.strings.AlphanumComparator;
\r
15 public class ChartData extends Bean {
\r
17 public @Optional String name;
\r
18 public @Optional Double timeIncrement;
\r
19 public @Optional Double timeStart;
\r
20 public @Optional Double timeLength;
\r
22 public boolean showMilestones;
\r
23 public boolean showGrid;
\r
24 public boolean trackExperimentTime;
\r
25 public YAxisMode axisMode;
\r
27 public boolean backgroundGradient;
\r
28 public @Optional float[] backgroundColor1;
\r
29 public @Optional float[] backgroundColor2;
\r
30 public @Optional float[] gridColor;
\r
32 public static class ItemKey {
\r
33 public final Renderer renderer;
\r
34 public final int index;
\r
35 public final NamedResource resource;
\r
36 public ItemKey(Renderer renderer, int index, NamedResource resource) {
\r
37 this.renderer = renderer;
\r
39 this.resource = resource;
\r
43 // Don't allow databoard to handle these since it just screws them up.
\r
44 public transient TreeMap<ItemKey, TrendItem> allItems = new TreeMap<>(ITEM_SORTER);
\r
45 public transient HashSet<ItemKey> hiddenItems = new HashSet<>();
\r
47 private static Comparator<ItemKey> ITEM_SORTER = new Comparator<ItemKey>() {
\r
49 public int compare(ItemKey o1, ItemKey o2) {
\r
50 int c = Integer.compare(o1.renderer.ordinal(), o2.renderer.ordinal());
\r
53 c = Integer.compare(o1.index, o2.index);
\r
56 return AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(o1.resource.getName(), o2.resource.getName());
\r
60 public void readFrom(ChartData other) {
\r
61 super.readFrom(other);
\r
62 this.allItems = new TreeMap<>(ITEM_SORTER);
\r
63 this.allItems.putAll(other.allItems);
\r
64 this.hiddenItems = new HashSet<>(other.hiddenItems);
\r
68 public boolean equals(Object obj) {
\r
69 boolean s = super.equals(obj);
\r
72 ChartData other = (ChartData) obj;
\r
73 return allItems.equals(other.allItems)
\r
74 && hiddenItems.equals(other.hiddenItems);
\r