1 |
package skrueger; |
package skrueger; |
2 |
|
|
3 |
import org.apache.log4j.Logger; |
import java.io.Serializable; |
4 |
|
import java.util.HashSet; |
5 |
import skrueger.geotools.StyledLayerInterface; |
import java.util.Set; |
6 |
import skrueger.i8n.Translation; |
|
7 |
|
import org.geotools.feature.NameImpl; |
8 |
/** |
import org.opengis.feature.type.Name; |
9 |
* This class holds meta information about an attribute/column. This |
|
10 |
* information is used by {@link StyledLayerInterface}. |
import skrueger.geotools.Copyable; |
11 |
* |
import skrueger.i8n.Translation; |
12 |
* @author <a href="mailto:[email protected]">Stefan Alfons Krüger</a> |
|
13 |
*/ |
public interface AttributeMetadataInterface extends Copyable<AttributeMetadataInterface>, |
14 |
public class AttributeMetaData { |
Comparable<AttributeMetadataInterface> { |
15 |
static private final Logger LOGGER = Logger |
|
16 |
.getLogger(AttributeMetaData.class); |
/** |
17 |
protected Translation title = new Translation(); |
* @return a translatable title for this attribute.. |
18 |
protected Translation desc = new Translation(); |
*/ |
19 |
protected boolean visible = false; |
public Translation getTitle(); |
20 |
protected String unit = ""; |
|
21 |
protected int colIdx; |
/** |
22 |
|
* Set a translatable title for this attribute.. |
23 |
/** |
*/ |
24 |
* Creates an {@link AttributeMetaData} object with the following information |
public void setTitle(Translation title); |
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 |
* Set an untranslated title for this attribute or pass a {@link Translation} encryped as a {@link String} |
28 |
* @param desc {@link Translation} for an attribute description |
*/ |
29 |
* @param unit {@link String} of the unit that the information is in |
public void setTitle(String title); |
30 |
*/ |
|
31 |
public AttributeMetaData(final int colIdx, final Boolean visible, |
/** |
32 |
final Translation title, final Translation desc, final String unit) { |
* @return a translatable description for this attribute |
33 |
|
*/ |
34 |
this.colIdx = colIdx; |
public Translation getDesc(); |
35 |
this.title = title; |
|
36 |
this.desc = desc; |
/** |
37 |
if (colIdx == 0){ |
* Set a translatable description for this attribute. |
38 |
// The first attribut is THE_GEOM and shall never be visible! |
*/ |
39 |
this.visible = false; |
public void setDesc(Translation desc); |
40 |
}else |
|
41 |
this.visible = visible; |
/** |
42 |
this.unit = unit; |
* Set an untranslated description for this attribute or pass a {@link Translation} encryped as a {@link String} |
43 |
} |
*/ |
44 |
|
public void setDesc(String desc); |
45 |
/** |
|
46 |
* Creates a new visible {@link AttributeMetaData} with default (no) values. |
|
47 |
*/ |
/** |
48 |
public AttributeMetaData(final Integer col, final String defaultName) { |
* The local name. E.g. the name of the DBF column as a {@link String}. |
49 |
this(col, true, new Translation(defaultName), new Translation(), ""); |
*/ |
50 |
} |
public String getLocalName(); |
51 |
|
|
52 |
public Boolean isVisible() { |
/** |
53 |
return visible; |
* A short form for #setName(new NameImpl(localName)) |
54 |
} |
*/ |
55 |
|
public void setLocalName(String localName); |
56 |
public void setVisible(final Boolean visible) { |
|
57 |
this.visible = visible; |
/** |
58 |
} |
* The fully qualified {@link Name} of the attribute, e.g. |
59 |
|
* <code>org.bla.plo:blub</code>. The second part equals the |
60 |
/** @return the index of this attribute in the underlying table/dbf **/ |
* {@link #getLocalName()} value. The first may be <code>null</code> or |
61 |
public int getColIdx() { |
* represent the layer name. |
62 |
return colIdx; |
*/ |
63 |
} |
public NameImpl getName(); |
64 |
|
|
65 |
public Translation getTitle() { |
/** |
66 |
return title; |
* set the fully qualified {@link Name} of this attribute. |
67 |
} |
*/ |
68 |
|
public void setName(NameImpl name); |
69 |
public void setTitle(final Translation title) { |
|
70 |
this.title = title; |
/** |
71 |
} |
* A list og objects that represent NODATA-values for this attribute. The |
72 |
|
* objects are supporsed to be correctly casted already. That means that the |
73 |
public Translation getDesc() { |
* NODATA objects listed here have must have the same type as the values of |
74 |
return desc; |
* this object. |
75 |
} |
*/ |
76 |
|
public HashSet<Object> getNodataValues(); |
77 |
public void setDesc(final Translation desc) { |
|
78 |
this.desc = desc; |
/** |
79 |
} |
* Takes any value object and checks it against the NODATA values. If the |
80 |
|
* value equals a NODATA value, <code>null</code> is returned. Otherwise the |
81 |
public String getUnit() { |
* same object is returned. |
82 |
return unit; |
* |
83 |
} |
* Note: This method is called often. |
84 |
|
*/ |
85 |
public void setUnit(final String unit) { |
public Object fiterNodata(Object value); |
86 |
this.unit = unit; |
|
87 |
} |
/** |
88 |
} |
* @return a non-translatable unit {@link String} for this attribute values. |
89 |
|
*/ |
90 |
|
public String getUnit(); |
91 |
|
|
92 |
|
/** |
93 |
|
* Set a unit {@link String} for this attribute values. |
94 |
|
*/ |
95 |
|
public void setUnit(String unit); |
96 |
|
|
97 |
|
/** |
98 |
|
* @return A value defining the position of this attribute whenever the |
99 |
|
* attributes are listed to an end-user. The higher the weight, the |
100 |
|
* lower the position. (heavy goes down, light goes up) |
101 |
|
*/ |
102 |
|
public double getWeight(); |
103 |
|
|
104 |
|
/** |
105 |
|
* set a value defining the position of this attribute whenever the |
106 |
|
* attributes are listed to an end-user. The higher the weight, the lower |
107 |
|
* the position. (heavy goes down, light goes up) |
108 |
|
*/ |
109 |
|
public void setWeight(double weight); |
110 |
|
|
111 |
|
/** |
112 |
|
* @return <code>false</code> if this attribute should not be selectable or |
113 |
|
* shown to the end-user. |
114 |
|
*/ |
115 |
|
public boolean isVisible(); |
116 |
|
|
117 |
|
/** |
118 |
|
* Set <code>false</code> if this attribute should not be shown to the |
119 |
|
* end-user. |
120 |
|
*/ |
121 |
|
public void setVisible(boolean visible); |
122 |
|
|
123 |
|
String getNoDataValuesFormatted(); |
124 |
|
|
125 |
|
} |