For your first issue you will want to look at using map units to set the
size of the symbol - you can use setUnitOfMeasure on the symbolizer to
define the units.
For the second issue it may be that by using getMaxBounds() to get the size
of the map you end up drawing a bigger area than you expected, but we'd
really need to see a screenshot and the image produced to be sure. I
usually use something like - RenderedImage bufferedImage =
frame.getMapPane().getBaseImage(); to grab the screen image to save.
Ian
On 2 March 2017 at 08:26, Anna Amat <anna.amat...@gmail.com> wrote:
>
> Hi all,
>
> I have two questions related to the size of the point symbolizers.
>
> 1. Is there a way to set the size dependending on the zoom of the map. I
> mean: my point size has a physical meaning so I need it to cover always the
> same area of the map.
>
> 2. When I capture an image of the map and its features the size of the
> symbolizers on the image is not the same as the one on the screen. Anyone
> knows how to solve this issue? The same happend with the TextSymbolizer
> that labels the feature.
>
> (Bellow I have pasted simplified examples of how I create the point
> symbolizer and the image)
>
> Thanks in advance,
> Anna
>
>
>
> a) Point Symbolizer:
>
> Stroke stroke = sf.createStroke(ff.literal(colorLine),
> ff.literal(sizeLine),
> ff.literal((float) colorLine.getAlpha() / 255), null,
> null, null, null, null, null);
>
> fill = sf.createFill(ff.literal(color), ff.literal((float)
> color.getAlpha() / 255));
>
> Mark mark = sf.getCircleMark();
> mark.setFill(fill);
> mark.setStroke(stroke);
>
> Graphic graphic = sf.createDefaultGraphic();
> graphic.graphicalSymbols().clear();
> graphic.graphicalSymbols().add(mark);
> graphic.setSize(ff.literal(size));
>
> PointSymbolizer pointSymbolizer = sb.createPointSymbolizer(graphic,
> "the_geom");
>
>
> b) Image capture:
>
> Rectangle imageBounds = null;
> ReferencedEnvelope mapBounds = null;
> try {
> mapBounds = mapContent.getMaxBounds();
> double heightToWidth = mapBounds.getSpan(1) /
> mapBounds.getSpan(0);
> imageBounds = new Rectangle(0, 0, imageWidth, (int)
> Math.round(imageWidth * heightToWidth));
>
> } catch (Exception e) {
> // failed to access map layers
> throw new RuntimeException(e);
> }
>
> BufferedImage image = new BufferedImage(imageBounds.width,
> imageBounds.height, BufferedImage.TYPE_INT_RGB);
>
> Graphics2D gr = image.createGraphics();
> gr.setPaint(Color.WHITE);
> gr.fill(imageBounds);
>
> try {
> renderer.paint(gr, imageBounds, mapBounds);
> File fileToSave = new File(file);
> ImageIO.write(image, "jpeg", fileToSave);
>
> } catch (IOException e) {
> throw new RuntimeException(e);
> }
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
--
Ian Turton
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users