[Schmitzm-commits] r463 - branches/1.0-gt2-2.6/src/skrueger

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 13 13:29:54 CEST 2009


Author: alfonx
Date: 2009-10-13 13:29:54 +0200 (Tue, 13 Oct 2009)
New Revision: 463

Added:
   branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java
Log:
* Renamed AttributeMetaData.java to AttributeMetadata.java

Copied: branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java (from rev 458, branches/1.0-gt2-2.6/src/skrueger/AttributeMetaData.java)
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/AttributeMetaData.java	2009-10-11 21:58:08 UTC (rev 458)
+++ branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java	2009-10-13 11:29:54 UTC (rev 463)
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Krüger - additional utility classes
+ ******************************************************************************/
+package skrueger;
+
+import org.apache.log4j.Logger;
+
+import skrueger.geotools.Copyable;
+import skrueger.geotools.StyledLayerInterface;
+import skrueger.i8n.Translation;
+
+/**
+ * This class holds meta information about an attribute/column. This
+ * information is used by {@link StyledLayerInterface}.
+ *
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Kr&uuml;ger</a>
+ */
+public class AttributeMetadata implements Copyable<AttributeMetadata>{
+	static private final Logger LOGGER = Logger
+			.getLogger(AttributeMetadata.class);
+	protected Translation title = new Translation();
+	protected Translation desc = new Translation();
+	protected boolean visible = false;
+	protected String unit = "";
+	protected int colIdx;
+	
+	/**
+	 * Creates an {@link AttributeMetadata} object with the following information
+	 * @param colIdx The column index of this attribute in the underlying table/dbf/etc...
+	 * @param visible Shall this attribute be displayed or hidden from the user?
+	 * @param title {@link Translation} for Name
+	 * @param desc {@link Translation} for an attribute description
+	 * @param unit {@link String} of the unit that the information is in
+	 */
+	public AttributeMetadata(final int colIdx, final Boolean visible,
+			final Translation title, final Translation desc, final String unit) {
+	
+		this.colIdx = colIdx;
+		this.title = title;
+		this.desc = desc;
+		if (colIdx == 0){
+			// The first attribute is THE_GEOM and shall never be visible!
+			this.visible = false;
+		}else
+			this.visible = visible;
+		this.unit = unit;
+	}
+
+	/**
+	 * Creates a new visible {@link AttributeMetadata} with default (no) values.  
+	 */
+	public AttributeMetadata(final Integer col, final String defaultName) {
+		this(col, true, new Translation(defaultName), new Translation(), "");
+	}
+
+	/** Only used for {@link Copyable<AttributeMetaData>#copy()}**/
+	private AttributeMetadata() {
+	}
+
+	public boolean isVisible() {
+		return visible;
+	}
+
+	public void setVisible(final Boolean visible) {
+		this.visible = visible;
+	}
+
+	/** @return the index of this attribute in the underlying table/dbf **/
+	public int getColIdx() {
+		return colIdx;
+	}
+
+	public Translation getTitle() {
+		return title;
+	}
+
+	public void setTitle(final Translation title) {
+		this.title = title;
+	}
+
+	public Translation getDesc() {
+		return desc;
+	}
+
+	public void setDesc(final Translation desc) {
+		this.desc = desc;
+	}
+
+	public String getUnit() {
+		return unit;
+	}
+
+	public void setUnit(final String unit) {
+		this.unit = unit;
+	}
+
+	@Override
+	public AttributeMetadata copyTo(AttributeMetadata amd) {
+		getTitle().copyTo(amd.getTitle());
+		getDesc().copyTo(amd.getDesc());
+		amd.setUnit(getUnit());
+		amd.setVisible(isVisible());
+		amd.setColIdx(getColIdx());
+		
+		return amd;
+	}
+
+	@Override
+	public AttributeMetadata copy() {
+		AttributeMetadata amd = new AttributeMetadata();
+		getTitle().copyTo(amd.getTitle());
+		getDesc().copyTo(amd.getDesc());
+		amd.setUnit(getUnit());
+		amd.setVisible(isVisible());
+		amd.setColIdx(getColIdx());
+		
+		return amd;
+	}
+
+	private void setColIdx(int colIdx_) {
+		colIdx = colIdx_;
+	}
+}



More information about the Schmitzm-commits mailing list