1 |
mojays |
2 |
package skrueger; |
2 |
|
|
|
3 |
|
|
import org.apache.log4j.Logger; |
4 |
|
|
|
5 |
|
|
import skrueger.geotools.StyledMapInterface; |
6 |
|
|
import skrueger.i8n.Translation; |
7 |
|
|
|
8 |
|
|
/** |
9 |
|
|
* This class holds meta information about an attribute/column. This |
10 |
|
|
* information is used by {@link StyledMapInterface}. |
11 |
|
|
* |
12 |
|
|
* @author <a href="mailto:[email protected]">Stefan Alfons Krüger</a> |
13 |
|
|
*/ |
14 |
|
|
public class AttributeMetaData { |
15 |
|
|
static private final Logger LOGGER = Logger |
16 |
|
|
.getLogger(AttributeMetaData.class); |
17 |
|
|
protected Translation title = new Translation(); |
18 |
|
|
protected Translation desc = new Translation(); |
19 |
|
|
protected boolean visible = false; |
20 |
|
|
protected String unit = ""; |
21 |
|
|
protected int colIdx; |
22 |
|
|
|
23 |
|
|
/** |
24 |
|
|
* Creates an {@link AttributeMetaData} object with the following information |
25 |
|
|
* @param colIdx The column index of this attribute in the underlying table/dbf/etc... |
26 |
|
|
* @param visible Shall this attribute be displayed or hidden from the user? |
27 |
|
|
* @param title {@link Translation} for Name |
28 |
|
|
* @param desc {@link Translation} for an attribute description |
29 |
|
|
* @param unit {@link String} of the unit that the information is in |
30 |
|
|
*/ |
31 |
|
|
public AttributeMetaData(final int colIdx, final Boolean visible, |
32 |
|
|
final Translation title, final Translation desc, final String unit) { |
33 |
|
|
|
34 |
|
|
this.colIdx = colIdx; |
35 |
|
|
this.title = title; |
36 |
|
|
this.desc = desc; |
37 |
|
|
if (colIdx == 0){ |
38 |
|
|
// The first attribut is THE_GEOM and shall never be visible! |
39 |
|
|
this.visible = false; |
40 |
|
|
}else |
41 |
|
|
this.visible = visible; |
42 |
|
|
this.unit = unit; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
/** |
46 |
alfonx |
93 |
* Creates a new visible {@link AttributeMetaData} with default (no) values. |
47 |
mojays |
2 |
*/ |
48 |
|
|
public AttributeMetaData(final Integer col, final String defaultName) { |
49 |
alfonx |
93 |
this(col, true, new Translation(defaultName), new Translation(), ""); |
50 |
mojays |
2 |
} |
51 |
|
|
|
52 |
|
|
public Boolean isVisible() { |
53 |
|
|
return visible; |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
public void setVisible(final Boolean visible) { |
57 |
|
|
this.visible = visible; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
/** @return the index of this attribute in the underlying table/dbf **/ |
61 |
|
|
public int getColIdx() { |
62 |
|
|
return colIdx; |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
public Translation getTitle() { |
66 |
|
|
return title; |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
public void setTitle(final Translation title) { |
70 |
|
|
this.title = title; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
public Translation getDesc() { |
74 |
|
|
return desc; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
public void setDesc(final Translation desc) { |
78 |
|
|
this.desc = desc; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
public String getUnit() { |
82 |
|
|
return unit; |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
public void setUnit(final String unit) { |
86 |
|
|
this.unit = unit; |
87 |
|
|
} |
88 |
|
|
} |