/[schmitzm]/trunk/src/skrueger/geotools/LegendIconFeatureRenderer.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/LegendIconFeatureRenderer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1231 by alfonx, Thu Nov 4 00:53:20 2010 UTC revision 1270 by alfonx, Sun Nov 14 00:25:52 2010 UTC
# Line 48  import java.awt.Graphics2D; Line 48  import java.awt.Graphics2D;
48  import java.awt.RenderingHints;  import java.awt.RenderingHints;
49  import java.awt.image.BufferedImage;  import java.awt.image.BufferedImage;
50    
 import javax.swing.tree.DefaultTreeCellRenderer;  
   
51  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
52  import org.geotools.factory.GeoTools;  import org.geotools.factory.GeoTools;
53  import org.geotools.factory.Hints;  import org.geotools.factory.Hints;
 import org.geotools.feature.IllegalAttributeException;  
54  import org.geotools.geometry.jts.LiteShape2;  import org.geotools.geometry.jts.LiteShape2;
55  import org.geotools.renderer.lite.StyledShapePainter;  import org.geotools.renderer.lite.StyledShapePainter;
56  import org.geotools.renderer.style.SLDStyleFactory;  import org.geotools.renderer.style.SLDStyleFactory;
# Line 67  import org.geotools.styling.Style; Line 64  import org.geotools.styling.Style;
64  import org.geotools.styling.Symbolizer;  import org.geotools.styling.Symbolizer;
65  import org.geotools.styling.TextSymbolizer;  import org.geotools.styling.TextSymbolizer;
66  import org.geotools.util.NumberRange;  import org.geotools.util.NumberRange;
67    import org.opengis.feature.IllegalAttributeException;
68  import org.opengis.feature.simple.SimpleFeature;  import org.opengis.feature.simple.SimpleFeature;
69  import org.opengis.feature.simple.SimpleFeatureType;  import org.opengis.feature.simple.SimpleFeatureType;
70  import org.opengis.feature.type.AttributeDescriptor;  import org.opengis.feature.type.AttributeDescriptor;
# Line 83  import com.vividsolutions.jts.geom.Polyg Line 81  import com.vividsolutions.jts.geom.Polyg
81   * Based on geoserver!   * Based on geoserver!
82   * <hr>   * <hr>
83   * <b>Changes by <a href="mailto:[email protected]">Martin Schmitz</a></b>   * <b>Changes by <a href="mailto:[email protected]">Martin Schmitz</a></b>
  * <br>  
  * <ul>  
84   * <li>07.02.2008:<br>   * <li>07.02.2008:<br>
85   * Determining the default values of a {@link SimpleFeatureType} by   * Determining the default values of a {@link SimpleFeatureType} by
86   * {@link FeatureUtil#getDefaultAttributeValues(SimpleFeatureType)} instead of   * {@link FeatureUtil#getDefaultAttributeValues(SimpleFeatureType)} instead of
# Line 94  import com.vividsolutions.jts.geom.Polyg Line 90  import com.vividsolutions.jts.geom.Polyg
90   *   *
91   * @author Stefan Alfons Tzeggai   * @author Stefan Alfons Tzeggai
92   */   */
93  public class LegendIconFeatureRenderer extends DefaultTreeCellRenderer {  public class LegendIconFeatureRenderer {
94          // private static final Dimension SIZE = new Dimension(30,20);          // private static final Dimension SIZE = new Dimension(30,20);
95    
96          Logger LOGGER = Logger.getLogger(LegendIconFeatureRenderer.class);          Logger LOGGER = Logger.getLogger(LegendIconFeatureRenderer.class);
# Line 108  public class LegendIconFeatureRenderer e Line 104  public class LegendIconFeatureRenderer e
104          final static LegendIconFeatureRenderer instance = new LegendIconFeatureRenderer();          final static LegendIconFeatureRenderer instance = new LegendIconFeatureRenderer();
105    
106          public static LegendIconFeatureRenderer getInstance() {          public static LegendIconFeatureRenderer getInstance() {
107                  // In GT 2.4.5 it we have to create a new one all the time!                  return instance;
   
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 // TODO TEST, whether we still need to recreate the renderer here....  
                 return new LegendIconFeatureRenderer();  
                 // return instance;  
108          }          }
109    
110          /**          /**
# Line 155  public class LegendIconFeatureRenderer e Line 140  public class LegendIconFeatureRenderer e
140          private Hints hints;          private Hints hints;
141    
142          /**          /**
143           * Returns a <code>java.awt.Shape</code> appropiate to render a legend           * Returns a <code>java.awt.Shape</code> appropriate to render a legend
144           * graphic given the symbolizer type and the legend dimensions.           * graphic given the symbolizer type and the legend dimensions.
145           *           *
146           * @param symbolizer           * @param symbolizer
# Line 169  public class LegendIconFeatureRenderer e Line 154  public class LegendIconFeatureRenderer e
154           *         symbolizer, wether it is a LineSymbolizer, a PolygonSymbolizer,           *         symbolizer, wether it is a LineSymbolizer, a PolygonSymbolizer,
155           *         or a Point ot Text Symbolizer           *         or a Point ot Text Symbolizer
156           *           *
          * @throws IllegalArgumentException  
          *             if an unknown symbolizer impl was passed in.  
157           */           */
158          private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth,          private LiteShape2 getSampleShape(Symbolizer symbolizer, int legendWidth,
159                          int legendHeight) {                          int legendHeight) {
# Line 307  public class LegendIconFeatureRenderer e Line 290  public class LegendIconFeatureRenderer e
290                                                  size.height);                                                  size.height);
291    
292                                  if (style2d != null) {                                  if (style2d != null) {
293                                          StyledShapePainter styledShapePainter = new StyledShapePainter(null);                                          StyledShapePainter styledShapePainter = new StyledShapePainter(
294                                          styledShapePainter.paint(graphics, shape,                                                          null);
295                                                          style2d, Integer.MAX_VALUE);                                          styledShapePainter.paint(graphics, shape, style2d,
296                                                            Integer.MAX_VALUE);
297                                  }                                  }
298                          }                          }
299                  } catch (Exception e) {                  } catch (Exception e) {

Legend:
Removed from v.1231  
changed lines
  Added in v.1270

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26