MarkStyle2D mark = (MarkStyle2D) graphic; Shape original = mark.getShape(); Rectangle2D bounds = original.getBounds2D(); MarkStyle2D resized = (MarkStyle2D) mark.clone();
if (graphicFill instanceof MarkStyle2D) { final MarkStyle2D ms2d = (MarkStyle2D) graphicFill; final Shape markShape = ms2d.getShape(); double size = ms2d.getSize(); Rectangle2D boundsFill = markShape.getBounds2D();
public void testCreateDynamicMark() throws Exception { PointSymbolizer symb = sf.createPointSymbolizer(); Mark myMark = sf.createMark(); final String ttfUrl = "ttf://Serif#${symb}"; myMark.setWellKnownName(ff.literal(ttfUrl)); symb.getGraphic().addMark(myMark); MarkStyle2D ms = (MarkStyle2D) sld.createStyle(feature, symb, range); assertNotNull(ms.getShape()); // make sure the style has been recognized as dynamic SymbolizerKey key = new SymbolizerKey(symb, range); assertTrue(sld.dynamicSymbolizers.containsKey(key)); Shape expected = new TTFMarkFactory().getShape(null, ff.literal("ttf://Serif#0xF054"), feature); // no general path equality implemented, we have to check manually PathIterator piExpected = expected.getPathIterator(new AffineTransform()); PathIterator pi = ms.getShape().getPathIterator(new AffineTransform()); double[] coordsExpected = new double[6]; double[] coords = new double[6]; assertEquals(piExpected.getWindingRule(), pi.getWindingRule()); while (!piExpected.isDone()) { assertFalse(pi.isDone()); piExpected.currentSegment(coordsExpected); pi.currentSegment(coords); assertEquals(coordsExpected[0], coords[0], 0.00001); assertEquals(coordsExpected[1], coords[1], 0.00001); piExpected.next(); pi.next(); } assertTrue(pi.isDone()); }
public Rectangle getGraphicDimensions() { if (graphic instanceof MarkStyle2D) return ((MarkStyle2D)graphic).getShape().getBounds(); else if (graphic instanceof GraphicStyle2D) { BufferedImage i = ((GraphicStyle2D)graphic).getImage(); return new Rectangle(i.getWidth(),i.getHeight()); } else { throw new RuntimeException("Can't render graphic which is not a MarkStyle2D or a GraphicStyle2D"); } }
private boolean isMarkNonHatchFill(Style2D graphicFill) { if (!(graphicFill instanceof MarkStyle2D)) { return false; } if (OPTIMIZE_VECTOR_HATCH_FILLS) { MarkStyle2D ms = (MarkStyle2D) graphicFill; ParallelLinesFiller filler = ParallelLinesFiller.fromStipple(ms.getShape()); if (filler != null) { return false; } } return true; }
if (graphicFill instanceof MarkStyle2D) Rectangle2D boundsFill = ((MarkStyle2D)graphicFill).getShape().getBounds2D(); double size = ((MarkStyle2D)graphicFill).getSize(); double aspect = (boundsFill.getHeight() > 0 && boundsFill.getWidth() > 0) ? boundsFill.getWidth()/boundsFill.getHeight() : 1.0;
if (graphicFill instanceof MarkStyle2D) Rectangle2D boundsFill = ((MarkStyle2D)graphicFill).getShape().getBounds2D(); double size = ((MarkStyle2D)graphicFill).getSize(); double aspect = (boundsFill.getHeight() > 0 && boundsFill.getWidth() > 0) ? boundsFill.getWidth()/boundsFill.getHeight() : 1.0;
MarkStyle2D mark = (MarkStyle2D) graphic; Shape original = mark.getShape(); Rectangle2D bounds = original.getBounds2D(); MarkStyle2D resized = (MarkStyle2D) mark.clone();