View Javadoc

1   /* OpenLogViewer
2    *
3    * Copyright 2011
4    *
5    * This file is part of the OpenLogViewer project.
6    *
7    * OpenLogViewer software is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation, either version 3 of the License, or
10   * (at your option) any later version.
11   *
12   * OpenLogViewer software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with any OpenLogViewer software.  If not, see http://www.gnu.org/licenses/
19   *
20   * I ask that if you make any changes to this file you fork the code on github.com!
21   *
22   */
23  package org.diyefi.openlogviewer.propertypanel;
24  
25  import java.awt.Color;
26  import org.diyefi.openlogviewer.genericlog.GenericDataElement;
27  
28  /**
29   *
30   * @author Bryan Harris
31   */
32  public class SingleProperty implements Comparable {
33  
34      private Color color;
35      private String header;
36      private double min;
37      private double max;
38      private int split;
39      private boolean active;
40  
41      public SingleProperty() {
42          color = Color.RED;
43          header = "";
44          min = 0;
45          max = 0;
46          split = 1;
47          active = false;
48      }
49  
50      public SingleProperty(GenericDataElement GDE) {
51          color = GDE.getColor();
52          header = GDE.getName();
53          min = GDE.getMinValue();
54          max = GDE.getMaxValue();
55          split = GDE.getSplitNumber();
56          active = false;
57      }
58  
59      public Color getColor() {
60          return color;
61      }
62  
63      public void setColor(Color color) {
64          this.color = color;
65      }
66  
67      public String getHeader() {
68          return header;
69      }
70  
71      public void setHeader(String header) {
72          this.header = header;
73      }
74  
75      public double getMax() {
76          return max;
77      }
78  
79      public void setMax(double max) {
80          this.max = max;
81      }
82  
83      public double getMin() {
84          return min;
85      }
86  
87      public void setMin(double min) {
88          this.min = min;
89      }
90  
91      public int getSplit() {
92          return split;
93      }
94  
95      public void setSplit(int split) {
96          if(split < 1){
97              split = 1;
98          }
99          this.split = split;
100     }
101 
102     public boolean isActive() {
103         return active;
104     }
105 
106     public void setActive(boolean active) {
107         this.active = active;
108     }
109 
110     public String toString() {
111         return header + "="
112                 + color.getRed()
113                 + "," + color.getGreen()
114                 + "," + color.getBlue()
115                 + "," + min
116                 + "," + max
117                 + "," + split
118                 + "," + Boolean.toString(active);
119     }
120 
121     public int compareTo(Object o) {
122         if (o instanceof SingleProperty) {
123             SingleProperty sp = (SingleProperty) o;
124             return this.getHeader().compareToIgnoreCase(sp.getHeader());
125         } else {
126             return -1;
127         }
128     }
129 
130     public boolean equals(String header) {
131         return header.toLowerCase().equals(this.getHeader().toLowerCase());
132     }
133 }