[Schmitzm-commits] r863 - in trunk/src: schmitzm/geotools/gui skrueger/geotools skrueger/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun May 23 15:42:15 CEST 2010
Author: alfonx
Date: 2010-05-23 15:42:13 +0200 (Sun, 23 May 2010)
New Revision: 863
Modified:
trunk/src/schmitzm/geotools/gui/SelectableXMapPane.java
trunk/src/skrueger/geotools/StyledFS.java
trunk/src/skrueger/swing/AtlasDialog.java
trunk/src/skrueger/swing/CancellableDialogAdapter.java
Log:
Added some basic GUI for the AtlasStyler PostGIS support.
Modified: trunk/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/SelectableXMapPane.java 2010-05-22 01:24:46 UTC (rev 862)
+++ trunk/src/schmitzm/geotools/gui/SelectableXMapPane.java 2010-05-23 13:42:13 UTC (rev 863)
@@ -210,7 +210,7 @@
// LOGGER.debug("Scale in XMapPane = "+scale);
double scale2 = 1. / getWorldToScreenTransform().getScaleX();
- LOGGER.debug("Alternativ = " + scale2);
+// LOGGER.debug("Alternativ = " + scale2);
return scale2;
}
Modified: trunk/src/skrueger/geotools/StyledFS.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFS.java 2010-05-22 01:24:46 UTC (rev 862)
+++ trunk/src/skrueger/geotools/StyledFS.java 2010-05-23 13:42:13 UTC (rev 863)
@@ -30,6 +30,7 @@
package skrueger.geotools;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
@@ -52,6 +53,7 @@
import schmitzm.geotools.io.GeoImportUtil;
import schmitzm.geotools.styling.StylingUtil;
import skrueger.AttributeMetadataImpl;
+import skrueger.AttributeMetadataInterface;
import skrueger.i8n.Translation;
import com.vividsolutions.jts.geom.Envelope;
@@ -62,13 +64,13 @@
*
* @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Krüger</a>
*
- * TODO Rename to StyledShapefile
+ * TODO Rename to StyledShapefile
*/
public class StyledFS implements StyledFeatureSourceInterface {
private static final Logger LOGGER = Logger.getLogger(StyledFS.class);
private final FeatureSource<SimpleFeatureType, SimpleFeature> fs;
-
+
/** Caching the CRS of the layer **/
CoordinateReferenceSystem crs = null;
@@ -86,7 +88,8 @@
private File sldFile;
- private AttributeMetadataMap map;
+ /** A map of simple attribute names to their meta-data **/
+ private AttributeMetadataMap<AttributeMetadataImpl> map;
private Filter filter = Filter.INCLUDE;
@@ -154,8 +157,7 @@
public CoordinateReferenceSystem getCrs() {
if (crs == null) {
- crs = fs.getSchema()
- .getCoordinateReferenceSystem();
+ crs = fs.getSchema().getCoordinateReferenceSystem();
if (fs.getSchema().getCoordinateReferenceSystem() == null) {
LOGGER.warn("Could not determine the CRS of " + getTitle()
+ ". Using default " + GeoImportUtil.getDefaultCRS());
@@ -251,30 +253,34 @@
/**
*
*/
- public AttributeMetadataMap getAttributeMetaDataMap() {
+ public AttributeMetadataMap<AttributeMetadataImpl> getAttributeMetaDataMap() {
if (map == null) {
map = new AttributeMetadataImplMap();
-// // Leaving out the first one, it will be the_geom
-// for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {
-// AttributeDescriptor attDesc = fs.getSchema().getDescriptor(i);
-//
-// AttributeMetadataImpl attMetaData = new AttributeMetadataImpl( new NameImpl(attDesc
-// .getName().getNamespaceURI(), attDesc
-// .getName().getLocalPart()), map.getLanguages());
-// map.put(attDesc.getName(), attMetaData);
-// }
-
+ // // Leaving out the first one, it will be the_geom
+ // for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {
+ // AttributeDescriptor attDesc = fs.getSchema().getDescriptor(i);
+ //
+ // AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
+ // new NameImpl(attDesc
+ // .getName().getNamespaceURI(), attDesc
+ // .getName().getLocalPart()), map.getLanguages());
+ // map.put(attDesc.getName(), attMetaData);
+ // }
+
// Leaving out the first one, it will be the_geom
for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {
AttributeDescriptor attDesc = fs.getSchema().getDescriptor(i);
- // TODO AttributeMetadataAS would be nicer, which would not work with Translations ;-)
- AttributeMetadataImpl attMetaData = new AttributeMetadataImpl( new NameImpl(attDesc
- .getName().getNamespaceURI(), attDesc
- .getName().getLocalPart()), map.getLanguages());
- if (String.class.isAssignableFrom( attDesc.getType().getBinding() )){
+ // TODO AttributeMetadataAS would be nicer, which would not work
+ // with Translations ;-)
+ AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
+ new NameImpl(attDesc.getName().getNamespaceURI(),
+ attDesc.getName().getLocalPart()), map
+ .getLanguages());
+ if (String.class.isAssignableFrom(attDesc.getType()
+ .getBinding())) {
// For Strings we add the "" as NODATA values
attMetaData.addNodataValue("");
}
@@ -294,7 +300,7 @@
public File getSldFile() {
return sldFile;
}
-
+
public void setSldFile(File sldFile) {
this.sldFile = sldFile;
}
@@ -359,4 +365,23 @@
return getGeoObject().getSchema();
}
+ /**
+ * Tries to load a style from the file denoted in {@link #getSldFile()}. If
+ * the file doesn't exits, return <code>null</code>;
+ * @return <code>true</code> is style was loaded
+ */
+ public boolean loadStyle() {
+ if (getSldFile() == null)
+ return false;
+
+ try {
+ Style[] loadSLD = StylingUtil.loadSLD(getSldFile());
+ setStyle(loadSLD[0]);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+
+ }
+
}
Modified: trunk/src/skrueger/swing/AtlasDialog.java
===================================================================
--- trunk/src/skrueger/swing/AtlasDialog.java 2010-05-22 01:24:46 UTC (rev 862)
+++ trunk/src/skrueger/swing/AtlasDialog.java 2010-05-23 13:42:13 UTC (rev 863)
@@ -12,25 +12,33 @@
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
+import net.miginfocom.swing.MigLayout;
+
import schmitzm.swing.SwingUtil;
+/**
+ * A basic super class for atlas dialogs. It listens to the ESC key and calls
+ * the {@link #close()} method. The layout manager is initialized with
+ * {@link MigLayout}.
+ */
public class AtlasDialog extends JDialog {
public AtlasDialog(final Component owner, String title) {
super(SwingUtil.getParentWindow(owner), title);
initDialog();
}
-
+
/** A flag checking that we just get disposed once **/
protected boolean isDisposed = false;
-
public AtlasDialog(final Component parentWindowComponent) {
this(parentWindowComponent, null);
}
private void initDialog() {
+ setLayout(new MigLayout());
+
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@@ -75,7 +83,7 @@
return rootPane;
}
-
+
@Override
public void dispose() {
super.dispose();
Modified: trunk/src/skrueger/swing/CancellableDialogAdapter.java
===================================================================
--- trunk/src/skrueger/swing/CancellableDialogAdapter.java 2010-05-22 01:24:46 UTC (rev 862)
+++ trunk/src/skrueger/swing/CancellableDialogAdapter.java 2010-05-23 13:42:13 UTC (rev 863)
@@ -96,6 +96,7 @@
@Override
public void cancelClose() {
cancel();
+ cancelled = true;
dispose();
}
More information about the Schmitzm-commits
mailing list