[Schmitzm-commits] r361 - branches/1.0-gt2-2.6/src/skrueger/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Aug 31 20:21:18 CEST 2009
Author: alfonx
Date: 2009-08-31 20:21:17 +0200 (Mon, 31 Aug 2009)
New Revision: 361
Modified:
branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java
Log:
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java 2009-08-31 16:04:44 UTC (rev 360)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java 2009-08-31 18:21:17 UTC (rev 361)
@@ -243,165 +243,165 @@
return sampleShape;
}
+//
+// /**
+// * Puts a BufferedImage into this.legendGraphic
+// */
+// public void produceLegendGraphic(SimpleFeatureType featureType, Style gt2Style,
+// Rule[] applicableRules) {
+//
+// // final FeatureTypeStyle[] ftStyles = gt2Style.getFeatureTypeStyles();
+//
+// // if (request.getRule() != null) {
+// // applicableRules = new Rule[] { request.getRule() };
+// // } else {
+// // applicableRules = getApplicableRules(ftStyles, scaleDenominator);
+// // }
+//
+// final int ruleCount = applicableRules.length;
+//
+// /**
+// * A legend graphic is produced for each applicable rule. They're being
+// * holded here until the process is done and then painted on a "stack"
+// * like legend.
+// */
+// final List<BufferedImage> legendsStack = new ArrayList<BufferedImage>(
+// ruleCount);
+//
+// for (int i = 0; i < ruleCount; i++) {
+// BufferedImage image = createImageForRule(applicableRules[i],
+// featureType, SIZE);
+// legendsStack.add(image);
+// }
+//
+// // this.legendGraphic =
+// // scaleImage(mergeLegends(legendsStack,applicableRules), request);
+// this.legendGraphic = mergeLegends(legendsStack, applicableRules);
+// }
+//
+// /**
+// * Recieves a list of <code>BufferedImages</code> and produces a new one
+// * which holds all the images in <code>imageStack</code> one above the
+// * other.
+// *
+// * @param imageStack
+// * the list of BufferedImages, one for each applicable Rule
+// * @param rules
+// * The applicable rules, one for each image in the stack
+// * @param request
+// * The request.
+// *
+// * @return the stack image with all the images on the argument list.
+// *
+// * @throws IllegalArgumentException
+// * if the list is empty
+// */
+// private static BufferedImage mergeLegends(List<BufferedImage> imageStack,
+// Rule[] rules) {
+// if (imageStack.size() == 0) {
+// throw new IllegalArgumentException("No legend graphics passed");
+// }
+//
+// BufferedImage finalLegend = null;
+//
+// if (imageStack.size() == 1) {
+// finalLegend = (BufferedImage) imageStack.get(0);
+// } else {
+// final int imgCount = imageStack.size();
+// final String[] labels = new String[imgCount];
+//
+// BufferedImage img = ((BufferedImage) imageStack.get(0));
+// FontMetrics fontMetrics = img.getGraphics().getFontMetrics();
+//
+// final int rowHeight = Math.max(fontMetrics.getHeight(), img
+// .getHeight());
+//
+// // calculate the total dimensions of the image
+// int totalHeight = rowHeight * imgCount;
+// int totalWidth = 0;
+//
+// for (int i = 0; i < imgCount; i++) {
+// img = (BufferedImage) imageStack.get(i);
+//
+// Rule rule = rules[i];
+//
+// // does this rule have a label
+// labels[i] = rule.getTitle();
+//
+// if (labels[i] == null) {
+// labels[i] = rule.getName();
+// }
+//
+// int w = img.getWidth();
+//
+// if (labels[i] != null) {
+// Graphics g = img.getGraphics();
+// w += g.getFontMetrics().stringWidth(labels[i]);
+// }
+//
+// totalWidth = Math.max(w, totalWidth);
+// }
+//
+// // create the final image
+// finalLegend = new BufferedImage(totalWidth, totalHeight,
+// BufferedImage.TYPE_INT_ARGB);
+//
+// Graphics2D finalGraphics = finalLegend.createGraphics();
+//
+// finalGraphics.setColor(Color.white);
+// finalGraphics.fillRect(0, 0, totalWidth, totalHeight);
+//
+// int h = 0;
+//
+// for (int i = 0; i < imgCount; i++) {
+// img = (BufferedImage) imageStack.get(i);
+//
+// // draw the image
+// int y = h;
+//
+// if (img.getHeight() < rowHeight) {
+// // move the image to the center of the row
+// y += (int) ((rowHeight - img.getHeight()) / 2d);
+// }
+//
+// finalGraphics.drawImage(img, 0, y, imgObs);
+//
+// // draw the label
+// if (labels[i] != null) {
+// finalGraphics.setColor(Color.BLACK);
+//
+// y = (h + rowHeight) - fontMetrics.getDescent();
+//
+// if (fontMetrics.getHeight() < rowHeight) {
+// // move the baseline to the center of the row
+// y -= (int) ((rowHeight - fontMetrics.getHeight()) / 2d);
+// }
+//
+// finalGraphics.drawString(labels[i], img.getWidth(), y);
+// }
+//
+// h += rowHeight;
+// }
+// }
+//
+// return finalLegend;
+// }
+//
+// /**
+// * DOCUMENT ME!
+// *
+// * @return
+// *
+// * @throws IllegalStateException
+// * DOCUMENT ME!
+// */
+// public BufferedImage getLegendGraphic() {
+// if (this.legendGraphic == null) {
+// throw new IllegalStateException();
+// }
+// return this.legendGraphic;
+// }
- /**
- * Puts a BufferedImage into this.legendGraphic
- */
- public void produceLegendGraphic(SimpleFeatureType featureType, Style gt2Style,
- Rule[] applicableRules) {
-
- // final FeatureTypeStyle[] ftStyles = gt2Style.getFeatureTypeStyles();
-
- // if (request.getRule() != null) {
- // applicableRules = new Rule[] { request.getRule() };
- // } else {
- // applicableRules = getApplicableRules(ftStyles, scaleDenominator);
- // }
-
- final int ruleCount = applicableRules.length;
-
- /**
- * A legend graphic is produced for each applicable rule. They're being
- * holded here until the process is done and then painted on a "stack"
- * like legend.
- */
- final List<BufferedImage> legendsStack = new ArrayList<BufferedImage>(
- ruleCount);
-
- for (int i = 0; i < ruleCount; i++) {
- BufferedImage image = createImageForRule(applicableRules[i],
- featureType, SIZE);
- legendsStack.add(image);
- }
-
- // this.legendGraphic =
- // scaleImage(mergeLegends(legendsStack,applicableRules), request);
- this.legendGraphic = mergeLegends(legendsStack, applicableRules);
- }
-
- /**
- * Recieves a list of <code>BufferedImages</code> and produces a new one
- * which holds all the images in <code>imageStack</code> one above the
- * other.
- *
- * @param imageStack
- * the list of BufferedImages, one for each applicable Rule
- * @param rules
- * The applicable rules, one for each image in the stack
- * @param request
- * The request.
- *
- * @return the stack image with all the images on the argument list.
- *
- * @throws IllegalArgumentException
- * if the list is empty
- */
- private static BufferedImage mergeLegends(List<BufferedImage> imageStack,
- Rule[] rules) {
- if (imageStack.size() == 0) {
- throw new IllegalArgumentException("No legend graphics passed");
- }
-
- BufferedImage finalLegend = null;
-
- if (imageStack.size() == 1) {
- finalLegend = (BufferedImage) imageStack.get(0);
- } else {
- final int imgCount = imageStack.size();
- final String[] labels = new String[imgCount];
-
- BufferedImage img = ((BufferedImage) imageStack.get(0));
- FontMetrics fontMetrics = img.getGraphics().getFontMetrics();
-
- final int rowHeight = Math.max(fontMetrics.getHeight(), img
- .getHeight());
-
- // calculate the total dimensions of the image
- int totalHeight = rowHeight * imgCount;
- int totalWidth = 0;
-
- for (int i = 0; i < imgCount; i++) {
- img = (BufferedImage) imageStack.get(i);
-
- Rule rule = rules[i];
-
- // does this rule have a label
- labels[i] = rule.getTitle();
-
- if (labels[i] == null) {
- labels[i] = rule.getName();
- }
-
- int w = img.getWidth();
-
- if (labels[i] != null) {
- Graphics g = img.getGraphics();
- w += g.getFontMetrics().stringWidth(labels[i]);
- }
-
- totalWidth = Math.max(w, totalWidth);
- }
-
- // create the final image
- finalLegend = new BufferedImage(totalWidth, totalHeight,
- BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D finalGraphics = finalLegend.createGraphics();
-
- finalGraphics.setColor(Color.white);
- finalGraphics.fillRect(0, 0, totalWidth, totalHeight);
-
- int h = 0;
-
- for (int i = 0; i < imgCount; i++) {
- img = (BufferedImage) imageStack.get(i);
-
- // draw the image
- int y = h;
-
- if (img.getHeight() < rowHeight) {
- // move the image to the center of the row
- y += (int) ((rowHeight - img.getHeight()) / 2d);
- }
-
- finalGraphics.drawImage(img, 0, y, imgObs);
-
- // draw the label
- if (labels[i] != null) {
- finalGraphics.setColor(Color.BLACK);
-
- y = (h + rowHeight) - fontMetrics.getDescent();
-
- if (fontMetrics.getHeight() < rowHeight) {
- // move the baseline to the center of the row
- y -= (int) ((rowHeight - fontMetrics.getHeight()) / 2d);
- }
-
- finalGraphics.drawString(labels[i], img.getWidth(), y);
- }
-
- h += rowHeight;
- }
- }
-
- return finalLegend;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return
- *
- * @throws IllegalStateException
- * DOCUMENT ME!
- */
- public BufferedImage getLegendGraphic() {
- if (this.legendGraphic == null) {
- throw new IllegalStateException();
- }
- return this.legendGraphic;
- }
-
// /**
// * Paints a little rectangle in the color defined by the
// * {@link ColorMapEntry}
More information about the Schmitzm-commits
mailing list