/[schmitzm]/trunk/src/skrueger/AttributeMetadataImpl.java
ViewVC logotype

Annotation of /trunk/src/skrueger/AttributeMetadataImpl.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 472 - (hide annotations)
Wed Oct 14 22:48:50 2009 UTC (15 years, 4 months ago) by alfonx
Original Path: branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java
File size: 6592 byte(s)
* AS-Feature: Added Double-Labeling to AtlasStyler
* AV-BugFix: Clicking points didn't work in GT2.6 and JMapPane because the dWithin filter broke?!


				// This is a tweak. The NearPointFilterGenerator doesn't work
				// any more in GT2.6... So we use a small BBOX.
				// Well, it's not the
				// NearPointFilterGenerator, but GeoTools that fails. I already
				// invested 3h in this... I guess the bug is in
				// ExtractBoundsFilterVisitor.visit(ProperyName) retuning null.
				// It should return the BBOX of value the named property.

				// Hashtable<MapLayer, FeatureCollection<SimpleFeatureType,
				// SimpleFeature>> result = findVisibleFeatures(
				// new NearPointFilterGenerator(geoCoord, dist,
				// getContext().getCoordinateReferenceSystem()),
				// state, envelope);

				final Envelope smallBox = new Envelope(geoCoord.getX() - dist,
						geoCoord.getY() -dist, geoCoord.getX()+dist, geoCoord.getY()+dist);

				Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = findVisibleFeatures(
						new BoundingBoxFilterGenerator(smallBox, getContext()
								.getCoordinateReferenceSystem()), state,
						envelope);


1 alfonx 244 /*******************************************************************************
2     * Copyright (c) 2009 Martin O. J. Schmitz.
3     *
4     * This file is part of the SCHMITZM library - a collection of utility
5 alfonx 256 * classes based on Java 1.6, focusing (not only) on Java Swing
6 alfonx 244 * and the Geotools library.
7     *
8     * The SCHMITZM project is hosted at:
9     * http://wald.intevation.org/projects/schmitzm/
10     *
11     * This program is free software; you can redistribute it and/or
12     * modify it under the terms of the GNU Lesser General Public License
13     * as published by the Free Software Foundation; either version 3
14     * of the License, or (at your option) any later version.
15     *
16     * This program is distributed in the hope that it will be useful,
17     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19     * GNU General Public License for more details.
20     *
21     * You should have received a copy of the GNU Lesser General Public License (license.txt)
22     * along with this program; if not, write to the Free Software
23     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24     * or try this link: http://www.gnu.org/licenses/lgpl.html
25     *
26     * Contributors:
27     * Martin O. J. Schmitz - initial API and implementation
28     * Stefan A. Krüger - additional utility classes
29     ******************************************************************************/
30     package skrueger;
31    
32     import org.apache.log4j.Logger;
33 alfonx 464 import org.geotools.feature.NameImpl;
34     import org.opengis.feature.type.AttributeDescriptor;
35     import org.opengis.feature.type.Name;
36 alfonx 244
37 alfonx 420 import skrueger.geotools.Copyable;
38 mojays 325 import skrueger.geotools.StyledLayerInterface;
39 alfonx 244 import skrueger.i8n.Translation;
40    
41     /**
42 alfonx 464 * This class holds meta information about an attribute/column. This information
43     * is used by {@link StyledLayerInterface}.
44     *
45 alfonx 244 * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>
46     */
47 alfonx 464 public class AttributeMetadata implements Copyable<AttributeMetadata> {
48 alfonx 244 static private final Logger LOGGER = Logger
49 alfonx 463 .getLogger(AttributeMetadata.class);
50 alfonx 464
51 alfonx 244 protected Translation title = new Translation();
52     protected Translation desc = new Translation();
53 alfonx 464 protected boolean visible = true;
54 alfonx 244 protected String unit = "";
55     protected int colIdx;
56 alfonx 470 private Name name;
57 alfonx 464
58 alfonx 244 /**
59 alfonx 464 * Creates an {@link AttributeMetadata} object with the following
60     * information
61     *
62     * @param colIdx
63     * The column index of this attribute in the underlying
64     * table/dbf/etc...
65     * @param visible
66     * Shall this attribute be displayed or hidden from the user?
67     * @param title
68     * {@link Translation} for Name
69     * @param desc
70     * {@link Translation} for an attribute description
71     * @param unit
72     * {@link String} of the unit that the information is in
73 alfonx 244 */
74 alfonx 464 public AttributeMetadata(final Name name, final Boolean visible,
75 alfonx 244 final Translation title, final Translation desc, final String unit) {
76 alfonx 464
77     this.setName(name);
78 alfonx 244 this.title = title;
79     this.desc = desc;
80 alfonx 472
81 alfonx 464 // The THE_GEOM and shall never be visible!
82 alfonx 472 if (name.getLocalPart().equalsIgnoreCase("the_geom"))
83     this.visible = false;
84     else
85     this.visible = visible;
86    
87 alfonx 244 this.unit = unit;
88     }
89    
90     /**
91 alfonx 464 * Creates an {@link AttributeMetadata} object with the following
92     * information
93     *
94     * @param visible
95     * Shall this attribute be displayed or hidden from the user?
96     * @param title
97     * {@link Translation} for Name
98     * @param desc
99     * {@link Translation} for an attribute description
100     * @param unit
101     * {@link String} of the unit that the information is in
102 alfonx 244 */
103 alfonx 464 public AttributeMetadata(final String localName, final Boolean visible,
104     final Translation title, final Translation desc, final String unit) {
105     this(new NameImpl(localName), true, title, desc, "");
106 alfonx 244 }
107    
108 alfonx 464 /**
109     * Creates a new visible {@link AttributeMetadata} with default (no) values.
110     */
111     public AttributeMetadata(final String localName, final String defaultTitle) {
112     this(localName, true, new Translation(defaultTitle), new Translation(),
113     "");
114     }
115    
116     /**
117     * Creates a new visible {@link AttributeMetadata} with default (no) values.
118     */
119     public AttributeMetadata(final Name name, final String defaultTitle) {
120     this(name, true, new Translation(defaultTitle), new Translation(), "");
121     }
122    
123     /**
124     * Creates a new visible {@link AttributeMetadata} with default (no) values.
125     */
126     public AttributeMetadata(final Name name) {
127     this(name, true, new Translation(name.getLocalPart()),
128     new Translation(), "");
129     }
130    
131     /**
132     * Creates a new visible {@link AttributeMetadata} with default (no) values.
133     */
134     public AttributeMetadata(final String localName) {
135     this(localName, true, new Translation(localName), new Translation(), "");
136     }
137    
138     /** Only used for {@link Copyable<AttributeMetaData>#copy()} **/
139 alfonx 463 private AttributeMetadata() {
140 alfonx 420 }
141    
142 alfonx 464 public AttributeMetadata(AttributeDescriptor attDesc) {
143     this(attDesc.getName());
144     }
145    
146 alfonx 420 public boolean isVisible() {
147 alfonx 244 return visible;
148     }
149    
150     public void setVisible(final Boolean visible) {
151     this.visible = visible;
152     }
153    
154 alfonx 472 //
155     // /** @return the index of this attribute in the underlying table/dbf **/
156     // public int getColIdx() {
157     // return colIdx;
158     // }
159    
160 alfonx 244 public Translation getTitle() {
161     return title;
162     }
163    
164     public void setTitle(final Translation title) {
165     this.title = title;
166     }
167    
168     public Translation getDesc() {
169     return desc;
170     }
171    
172     public void setDesc(final Translation desc) {
173     this.desc = desc;
174     }
175    
176     public String getUnit() {
177     return unit;
178     }
179    
180     public void setUnit(final String unit) {
181     this.unit = unit;
182     }
183 alfonx 420
184     @Override
185 alfonx 463 public AttributeMetadata copyTo(AttributeMetadata amd) {
186 alfonx 420 getTitle().copyTo(amd.getTitle());
187     getDesc().copyTo(amd.getDesc());
188     amd.setUnit(getUnit());
189     amd.setVisible(isVisible());
190 alfonx 472 amd.setName(new NameImpl(getName().getNamespaceURI(), getName()
191     .getLocalPart()));
192 alfonx 464
193 alfonx 420 return amd;
194     }
195    
196     @Override
197 alfonx 463 public AttributeMetadata copy() {
198 alfonx 472 return copyTo(new AttributeMetadata());
199 alfonx 420 }
200    
201 alfonx 464 /**
202     * The local Name. E.g. the name of the DBF column as a String
203     */
204     public String getLocalName() {
205     return getName().getLocalPart();
206 alfonx 420 }
207 alfonx 464
208     /**
209     * The fully qualified Name of the attribute, e.g. org.bla.plo:blub
210     */
211     public Name getName() {
212     return name;
213     }
214    
215     /**
216     * The fully qualified Name of the attribute, e.g. org.bla.plo:blub
217     */
218     public void setName(org.opengis.feature.type.Name name) {
219     this.name = name;
220     }
221    
222     /**
223     * The fully qualified Name of the attribute, e.g. org.bla.plo:blub
224     */
225     public void setLocalName(String localName) {
226     this.name = new NameImpl(localName);
227     }
228 alfonx 244 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26