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  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 split;
34  	private boolean active;
35  
36  	public SingleProperty() {
37  		color = Color.RED;
38  		header = "";
39  		min = 0;
40  		max = 0;
41  		split = 1;
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  		split = GDE.getSplitNumber();
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 getSplit() {
87  		return split;
88  	}
89  
90  	/**
91  	 * TODO add final to parameter and make work with this change.
92  	 *
93  	 * @param split
94  	 */
95  	public final void setSplit(int split) {
96  		if (split < 1) {
97  			split = 1;
98  		}
99  		this.split = split;
100 	}
101 
102 	public final boolean isActive() {
103 		return active;
104 	}
105 
106 	public final void setActive(final boolean active) {
107 		this.active = active;
108 	}
109 
110 	public final 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 final int compareTo(final SingleProperty sp) {
122 		return this.getHeader().compareToIgnoreCase(sp.getHeader());
123 	}
124 
125 	public final boolean equals(final String otherHeader) {
126 		return otherHeader.toLowerCase().equals(this.getHeader().toLowerCase());
127 	}
128 }