[Schmitzm-commits] r578 - in branches/1.0-gt2-2.6/src/skrueger: . geotools i8n
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Nov 25 15:43:59 CET 2009
Author: alfonx
Date: 2009-11-25 15:43:57 +0100 (Wed, 25 Nov 2009)
New Revision: 578
Modified:
branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java
branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java
branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
branches/1.0-gt2-2.6/src/skrueger/i8n/SwitchLanguageDialog.java
Log:
SwitchLanguageDialog now it's itself to visible or diasoss itself if not needed
RasterlegendData not implements Copyable
StylingUtil createLegendPanel manages the gaps better
Modified: branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java 2009-11-25 13:22:48 UTC (rev 577)
+++ branches/1.0-gt2-2.6/src/skrueger/RasterLegendData.java 2009-11-25 14:43:57 UTC (rev 578)
@@ -28,11 +28,13 @@
* Stefan A. Krüger - additional utility classes
******************************************************************************/
package skrueger;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.apache.log4j.Logger;
import org.geotools.coverage.grid.GridCoverage2D;
@@ -45,17 +47,23 @@
import skrueger.i8n.Translation;
/**
- * Holds all the additional information needed to paint a Legend for a RasterLayer.
- * So far, only Legends for one-band raster layers are supported.
- *
+ * Holds all the additional information needed to paint a Legend for a
+ * RasterLayer. So far, only Legends for one-band raster layers are supported.
+ *
* @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Krüger</a>
- *
- * TODO implements {@link Copyable}
+ *
+ * TODO implements {@link Copyable}
*/
-public class RasterLegendData extends HashMap<Double, Translation> {
- static private final Logger LOGGER = Logger.getLogger(RasterLegendData.class);
+public class RasterLegendData extends TreeMap<Double, Translation> implements
+ Copyable<RasterLegendData> {
+ static private final Logger LOGGER = Logger
+ .getLogger(RasterLegendData.class);
+
private Boolean paintGaps = false;
+ /**
+ * Shall bigger gaps be painted between the raster images
+ */
public Boolean isPaintGaps() {
return paintGaps;
}
@@ -65,49 +73,71 @@
}
/**
- * {@link #paintGaps} defines, if gaps should be painted between the legends colors,
- * indicating nominal values in the raster (e.g. classifications)
+ * {@link #paintGaps} defines, if gaps should be painted between the legends
+ * colors, indicating nominal values in the raster (e.g. classifications)
*/
public RasterLegendData(boolean paintGaps) {
this.paintGaps = paintGaps;
}
- public boolean getPaintGaps() {
- return paintGaps ;
- }
+ /**
+ * Returns a new list containing all {@link Double} values that shall apear
+ * in the legend.
+ */
+ public List<Double> getSortedKeys() {
+ Double[] array = keySet().toArray(new Double[] {});
- public List<Double> getSortedKeys(){
- Object[] array = keySet().toArray();
-
Arrays.sort(array);
final LinkedList<Double> linkedList = new LinkedList<Double>();
- for (Object o : array){
- linkedList.add( (Double)o);
+ for (Double o : array) {
+ linkedList.add(o);
}
return linkedList;
+ }
+ /**
+ * Creates a sample {@link GridCoverage2D} (size 1x1, WGS84) for each legend
+ * value. These rasters can be used to do visualize the legend item in the
+ * corresponding color via {@link GridCoverageRenderer}.
+ */
+ public Map<Double, GridCoverage2D> createSampleRasters() {
+ Map<Double, GridCoverage2D> sampleRaster = new HashMap<Double, GridCoverage2D>();
+
+ for (Double rasterValue : keySet()) {
+ GridCoverage2D grid = GridUtil.GRID_FAC.create("Legend_"
+ + rasterValue,
+ new float[][] { { rasterValue.floatValue() } },
+ new Envelope2D(GTUtil.WGS84, 0, 0, 1, 1));
+ sampleRaster.put(rasterValue, grid);
+ }
+ return sampleRaster;
}
- /**
- * Creates a sample {@link GridCoverage2D} (size 1x1, WGS84) for each
- * legend value. These rasters can be used to do visualize the
- * legend item in the corresponding color via {@link GridCoverageRenderer}.
- */
- public Map<Double, GridCoverage2D> createSampleRasters() {
- Map<Double, GridCoverage2D> sampleRaster = new HashMap<Double, GridCoverage2D>();
-
- for (Double rasterValue : keySet()) {
- GridCoverage2D grid = GridUtil.GRID_FAC.create(
- "Legend_"+rasterValue,
- new float[][] { { rasterValue.floatValue() } },
- new Envelope2D(GTUtil.WGS84, 0,0,1,1)
- );
- sampleRaster.put(rasterValue, grid);
- }
-
-
- return sampleRaster;
- }
+ /**
+ * Creates a new {@link RasterLegendData} object with identical values
+ */
+ @Override
+ public RasterLegendData copy() {
+ RasterLegendData copy = (RasterLegendData) super.clone();
+ return copyTo(copy);
+ }
+
+ /**
+ * Deep-copies all values of this {@link RasterLegendData} to another
+ * {@link RasterLegendData}
+ */
+ @Override
+ public RasterLegendData copyTo(RasterLegendData target) {
+ target.clear();
+
+ target.setPaintGaps(isPaintGaps());
+
+ for (Double o : keySet()) {
+ target.put(new Double(o), get(o).copy());
+ }
+
+ return target;
+ }
}
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java 2009-11-25 13:22:48 UTC (rev 577)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java 2009-11-25 14:43:57 UTC (rev 578)
@@ -993,7 +993,7 @@
final Map<Double, GridCoverage2D> sampleRasters = rasterLegendData
.createSampleRasters();
- final JPanel panel = new JPanel(new MigLayout("wrap 2"));
+ final JPanel panel = new JPanel(new MigLayout("wrap 2, gapy 0"));
for (final Double rValue : legendRasterValues) {
@@ -1082,19 +1082,15 @@
}
final JLabel iconLabel = new JLabel(new ImageIcon(buffImage));
- // hbox.setAlignmentX(0f);
panel.add(iconLabel, "sgx1");
- // hbox.add(Box.createHorizontalStrut(3));
final Translation labelT = rasterLegendData.get(rValue);
final JLabel classTitleLabel = new JLabel(labelT.toString());
panel.add(classTitleLabel, "sgx2"
- + (rasterLegendData.getPaintGaps() ? ", gapy 0 3" : ""));
+ + (rasterLegendData.isPaintGaps() ? ", gapy 0:0:0 5:5:5" : ""));
classTitleLabel.setLabelFor(iconLabel);
- // box.add(hbox);
-
- if (rasterLegendData.getPaintGaps()) {
+ if (rasterLegendData.isPaintGaps()) {
iconLabel
.setBorder(BorderFactory.createLineBorder(Color.black));
}
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java 2009-11-25 13:22:48 UTC (rev 577)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java 2009-11-25 14:43:57 UTC (rev 578)
@@ -404,7 +404,7 @@
@Override
public void layerChanged(final MapLayerListEvent event) {
-// localRenderer = GTUtil.createGTRenderer();
+ // localRenderer = GTUtil.createGTRenderer();
getLocalRenderer().setContext(getMapContext());
requestStartRendering();
}
@@ -619,7 +619,7 @@
if (!isWellDefined())
return;
- LOGGER.debug("resizeTimer performed");
+// LOGGER.debug("resizeTimer performed");
final Rectangle bounds = getVisibleRect();
//
@@ -631,10 +631,11 @@
bounds.y + bounds.height);
if (setMapArea(geoMapArea)) {
- LOGGER.debug(" maparea changed");
+// LOGGER.debug(" maparea changed");
paneResized = true;
- } else
- LOGGER.debug(" maparea NOT changed");
+ }
+// else
+// LOGGER.debug(" maparea NOT changed");
}
});
resizeTimer.setRepeats(false);
@@ -649,11 +650,11 @@
// Seems to be called twice with the same size..
if (oldVisibleRect != null
&& oldVisibleRect.equals(getVisibleRect())) {
- LOGGER.debug("skipping resize.");
+// LOGGER.debug("skipping resize.");
return;
}
- LOGGER.debug("resized: " + getVisibleRect());
+// LOGGER.debug("resized: " + getVisibleRect());
resizeTimer.restart();
oldVisibleRect = getVisibleRect();
}
@@ -798,7 +799,7 @@
if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
final double divY = newArea.getMaxY()
- maxAllowedExtend.getMaxY();
- // LOGGER.debug("Moving area down by " + divY);
+// LOGGER.debug("Moving area down by " + divY);
newArea = new Envelope(new Coordinate(newArea.getMinX(),
newArea.getMinY() - divY), new Coordinate(newArea
@@ -1186,23 +1187,27 @@
public Envelope getMaxExtend() {
if (maxExtend == null) {
- // Commented-out because it takes soo much time!
- //
+
+ // The next command may take long time!
// long start = System.currentTimeMillis();
- // final ReferencedEnvelope layerBounds = GTUtil
- // .getVisibleLayoutBounds(localContext);
+ final ReferencedEnvelope layerBounds = GTUtil
+ .getVisibleLayoutBounds(localContext);
//
// LOGGER.info(
// (System.currentTimeMillis()-start)+"m to get maxExtend");
//
- // if (layerBounds == null) {
- // // TODO Last fallback could be the CRS valid area
- // return null;
- // }
- //
- // // Kartenbereich um 10% vergroessern
- // return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
- // .expandEnvelope(layerBounds, 0.1), true);
+ if (layerBounds == null) {
+ // // TODO Last fallback could be the CRS valid area
+ return null;
+ }
+
+
+// Vergrößerung um 10% nochmal rausgenommen
+// // // Kartenbereich um 10% vergroessern
+// return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
+// .expandEnvelope(layerBounds, 0.1), true);
+
+ return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true);
}
return maxExtend;
}
@@ -1420,7 +1425,7 @@
* Called by the {@link RenderingExecutor} when rendering was cancelled.
*/
public void onRenderingCancelled() {
- LOGGER.debug("Rendering cancelled");
+// LOGGER.debug("Rendering cancelled");
repaintTimer.stop();
}
@@ -1429,7 +1434,7 @@
* completed.
*/
public void onRenderingCompleted() {
- LOGGER.debug("complete");
+// LOGGER.debug("complete");
repaintTimer.stop();
@@ -1482,7 +1487,7 @@
if (!isWellDefined())
return;
-// super.paintComponent(g); // candidate for removal
+ // super.paintComponent(g); // candidate for removal
boolean paintedSomething = false;
@@ -1721,9 +1726,9 @@
requestStartRendering();
}
-
+
public void setBorder(Border b) {
- super.setBorder(b);
+ super.setBorder(b);
}
/**
@@ -1746,12 +1751,13 @@
// repaint();
// }
- /**
- * Set the new map area.
- * @param newMapArea
- * @return <code>true</code> if the mapArea has been changed and a repaint
- * has been triggered.
- */
+ /**
+ * Set the new map area.
+ *
+ * @param newMapArea
+ * @return <code>true</code> if the mapArea has been changed and a repaint
+ * has been triggered.
+ */
public boolean setMapArea(final Envelope newMapArea) {
if (newMapArea == null)
return false;
@@ -1762,7 +1768,8 @@
}
/**
- * Set the new map area.
+ * Set the new map area.
+ *
* @param newMapArea
* @return <code>true</code> if the mapArea has been changed and a repaint
* has been triggered.
Modified: branches/1.0-gt2-2.6/src/skrueger/i8n/SwitchLanguageDialog.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/i8n/SwitchLanguageDialog.java 2009-11-25 13:22:48 UTC (rev 577)
+++ branches/1.0-gt2-2.6/src/skrueger/i8n/SwitchLanguageDialog.java 2009-11-25 14:43:57 UTC (rev 578)
@@ -83,10 +83,8 @@
/**
* A dialog to select one of the available languages. If only one language
* is available, select it directly. Creating this object automatically
- * makes it visible.
- *
- * @param owner
- * @param atlasConfig
+ * makes it visible, unless there is only one language to choose from.. it
+ * that case it disposes itself autmatically.
*/
public SwitchLanguageDialog(final Component owner,
final List<String> languages) {
@@ -98,6 +96,7 @@
if (languages.size() == 1) {
LOGGER.debug("Only language '" + languages.get(0)
+ "' is available. It has been selected automatically.");
+ dispose();
return;
}
@@ -111,12 +110,14 @@
*/
private void initialize() {
this.setContentPane(getJContentPane());
- setModal(true);
- SwingUtil.centerFrameOnScreenRandom(this);
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
pack();
+
+ SwingUtil.centerFrameOnScreenRandom(this);
+ setModal(true);
+ setVisible(true);
}
/**
@@ -213,7 +214,7 @@
gridBagConstraints.gridy = 0;
jLabel = new JLabel();
jLabel.setText("Select language: "); // i8n!?! Maybe replace with an
- // icon of an index finger
+ // icon of an index finger
jPanel1 = new JPanel();
jPanel1.setLayout(new GridBagLayout());
jPanel1.add(jLabel, gridBagConstraints);
@@ -286,4 +287,4 @@
return jComboBox;
}
-}
+}
More information about the Schmitzm-commits
mailing list