1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.diyefi.openlogviewer.propertypanel;
24
25 import java.awt.Color;
26 import org.diyefi.openlogviewer.genericlog.GenericDataElement;
27
28 public class SingleProperty implements Comparable<SingleProperty> {
29 private Color color;
30 private String header;
31 private double min;
32 private double max;
33 private int trackIndex;
34 private boolean active;
35
36 public SingleProperty() {
37 color = Color.GRAY;
38 header = "";
39 min = 0;
40 max = 0;
41 trackIndex = 0;
42 active = false;
43 }
44
45 public SingleProperty(final GenericDataElement gde) {
46 color = gde.getDisplayColor();
47 header = gde.getName();
48 min = gde.getDisplayMinValue();
49 max = gde.getDisplayMaxValue();
50 trackIndex = gde.getTrackIndex();
51 active = false;
52 }
53
54 public final Color getColor() {
55 return color;
56 }
57
58 public final void setColor(final Color color) {
59 this.color = color;
60 }
61
62 public final String getHeader() {
63 return header;
64 }
65
66 public final void setHeader(final String header) {
67 this.header = header;
68 }
69
70 public final double getMax() {
71 return max;
72 }
73
74 public final void setMax(final double max) {
75 this.max = max;
76 }
77
78 public final double getMin() {
79 return min;
80 }
81
82 public final void setMin(final double min) {
83 this.min = min;
84 }
85
86 public final int getTrackIndex() {
87 return trackIndex;
88 }
89
90 public final void setTrackIndex(final int newIndex) {
91 if (newIndex < 0) {
92 trackIndex = 0;
93 } else {
94 trackIndex = newIndex;
95 }
96 }
97
98 public final boolean isActive() {
99 return active;
100 }
101
102 public final void setActive(final boolean active) {
103 this.active = active;
104 }
105
106 public final String toString() {
107 final String seperator = ",";
108 final StringBuilder output = new StringBuilder(header);
109 output.append("=");
110 output.append(color.getRed());
111 output.append(seperator);
112 output.append(color.getGreen());
113 output.append(seperator);
114 output.append(color.getBlue());
115 output.append(seperator);
116 output.append(min);
117 output.append(seperator);
118 output.append(max);
119 output.append(seperator);
120 output.append(trackIndex);
121 output.append(seperator);
122 output.append(Boolean.toString(active));
123 return output.toString();
124 }
125
126 public final int compareTo(final SingleProperty sp) {
127 return this.getHeader().compareToIgnoreCase(sp.getHeader());
128 }
129
130
131
132
133
134
135
136
137
138
139 public final boolean equals(final String otherHeader) {
140 return getHeader().equalsIgnoreCase(otherHeader);
141 }
142 }