double graphicRotation = 0; // rotation in radians if (graphicStroke instanceof MarkStyle2D) { imageSize = ((MarkStyle2D) graphicStroke).getSize(); graphicRotation = ((MarkStyle2D) graphicStroke).getRotation(); } else if (graphicStroke instanceof IconStyle2D) {
final MarkStyle2D ms2d = (MarkStyle2D) graphicFill; final Shape markShape = ms2d.getShape(); double size = ms2d.getSize(); Rectangle2D boundsFill = markShape.getBounds2D(); double aspect =
@Override protected Expression rescaleGraphicSize(Graphic gr) { Expression size = gr.getSize(); if (size == null || size == Expression.NIL) { PointSymbolizer symbolizer = sf.createPointSymbolizer(gr, null); Style2D style = ssf.createStyle(null, symbolizer, INFINITE_RANGE); if (style instanceof IconStyle2D) { IconStyle2D is = (IconStyle2D) style; size = ff.literal(is.getIcon().getIconHeight()); } else if (style instanceof GraphicStyle2D) { GraphicStyle2D gs = (GraphicStyle2D) style; size = ff.literal(gs.getImage().getHeight()); } else if (style instanceof MarkStyle2D) { MarkStyle2D ms = (MarkStyle2D) style; size = ff.literal(ms.getSize()); } } return rescale(size); } }
public static double getStyle2DSize(Style2D style) { if (style instanceof GraphicStyle2D) { final BufferedImage image = ((GraphicStyle2D) style).getImage(); return maxSize(image.getWidth(), image.getHeight()); } else if (style instanceof IconStyle2D) { final Icon icon = ((IconStyle2D) style).getIcon(); return maxSize(icon.getIconWidth(), icon.getIconHeight()); } else if (style instanceof LineStyle2D) { LineStyle2D ls = ((LineStyle2D) style); double gsSize = getStyle2DSize(ls.getGraphicStroke()); double strokeSize = 0; if (ls.getStroke() instanceof BasicStroke) { strokeSize = ((BasicStroke) ls.getStroke()).getLineWidth(); } double offset = ls.getPerpendicularOffset(); double lineSize = maxSize(maxSize(gsSize, strokeSize), offset); // a MarkStyle2D is also a LineStyle2D, but we have to account for the symbol size if (style instanceof MarkStyle2D) { MarkStyle2D mark = (MarkStyle2D) style; return mark.getSize() + lineSize; } else { return lineSize; } } else { return 0; } }
public void testDefaultSizeMark() throws Exception { PointSymbolizer symb = sf.createPointSymbolizer(); Mark myMark = sf.createMark(); myMark.setWellKnownName(ff.literal("square")); symb.getGraphic().addMark(myMark); MarkStyle2D ms = (MarkStyle2D) sld.createPointStyle(feature, symb, range); assertEquals(16.0, ms.getSize()); }
double size = ((MarkStyle2D)graphicFill).getSize(); double aspect = (boundsFill.getHeight() > 0 && boundsFill.getWidth() > 0) ? boundsFill.getWidth()/boundsFill.getHeight() : 1.0; stippleSize = new Rectangle2D.Double(0, 0, size*aspect, size);
imageSize = ((MarkStyle2D) graphicStroke).getSize(); } else if(graphicStroke instanceof IconStyle2D) { imageSize = ((IconStyle2D) graphicStroke).getIcon().getIconWidth();
imageSize = ((MarkStyle2D) graphicStroke).getSize(); } else if(graphicStroke instanceof IconStyle2D) { imageSize = ((IconStyle2D) graphicStroke).getIcon().getIconWidth();
double size = ((MarkStyle2D)graphicFill).getSize(); double aspect = (boundsFill.getHeight() > 0 && boundsFill.getWidth() > 0) ? boundsFill.getWidth()/boundsFill.getHeight() : 1.0; stippleSize = new Rectangle2D.Double(0, 0, size*aspect, size);
} else if (graphicFill instanceof MarkStyle2D) { MarkStyle2D mark = (MarkStyle2D) graphicFill; int size = (int) Math.round(mark.getSize()); pattern = content.createPattern(size, size); Graphics2D patternGraphic = pattern.createGraphics(size, size);