@Test public void testSimpleSquare() throws Exception { SVGMarkFactory mf = new SVGMarkFactory(); URL url = StreamingRenderer.class.getResource("test-data/square16.svg"); assertNotNull(url); Shape shape = mf.getShape(null, ff.literal(url), null); assertNotNull(shape); final TransformedShape expected = new TransformedShape( new Rectangle2D.Float(0, 0, 1, 1), new AffineTransform(1, 0, 0, -1, -0.5, 0.5)); assertEquals(expected, shape); shape = mf.getShape(null, ff.literal(url), null); assertNotNull(shape); assertEquals(expected, shape); }
@Override public Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature) throws Exception { RenderableSVG svg = cache.getRenderableSVG(feature, symbolUrl, "image/svg"); if (svg == null) { return null; } Shape shape = getShape(svg.node); final Rectangle2D bounds = shape.getBounds2D(); double maxSize = Math.max(bounds.getWidth(), bounds.getHeight()); double scaleToOne = 1 / maxSize; final AffineTransform at = new AffineTransform(scaleToOne, 0, 0, -scaleToOne, -0.5, 0.5); TransformedShape ts = new TransformedShape(shape, at); return ts; }
SVGMarkFactory implements MarkFactory { @Override public Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature) throws Exception { RenderableSVG svg = cache.getRenderableSVG(feature, symbolUrl, "image/svg"); if (svg == null) { return null; } Shape shape = getShape(svg.node); final Rectangle2D bounds = shape.getBounds2D(); double maxSize = Math.max(bounds.getWidth(), bounds.getHeight()); double scaleToOne = 1 / maxSize; final AffineTransform at = new AffineTransform(scaleToOne, 0, 0, -scaleToOne, -0.5, 0.5); TransformedShape ts = new TransformedShape(shape, at); return ts; } }
SVGMarkFactory implements MarkFactory { @Override public Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature) throws Exception { RenderableSVG svg = cache.getRenderableSVG(feature, symbolUrl, "image/svg"); if (svg == null) { return null; } Shape shape = getShape(svg.node); final Rectangle2D bounds = shape.getBounds2D(); double maxSize = Math.max(bounds.getWidth(), bounds.getHeight()); double scaleToOne = 1 / maxSize; final AffineTransform at = new AffineTransform(scaleToOne, 0, 0, -scaleToOne, -0.5, 0.5); TransformedShape ts = new TransformedShape(shape, at); return ts; } SVGMarkFactory();  SVGMarkFactory(Map<Key, Object> hints); }
SVGMarkFactory implements MarkFactory { @Override public Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature) throws Exception { RenderableSVG svg = cache.getRenderableSVG(feature, symbolUrl, "image/svg"); if (svg == null) { return null; } Shape shape = getShape(svg.node); final Rectangle2D bounds = shape.getBounds2D(); double maxSize = Math.max(bounds.getWidth(), bounds.getHeight()); double scaleToOne = 1 / maxSize; final AffineTransform at = new AffineTransform(scaleToOne, 0, 0, -scaleToOne, -0.5, 0.5); TransformedShape ts = new TransformedShape(shape, at); return ts; } SVGMarkFactory();  SVGMarkFactory(Map<Key, Object> hints); @Override Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature); }
SVGMarkFactory implements MarkFactory { @Override public Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature) throws Exception { RenderableSVG svg = cache.getRenderableSVG(feature, symbolUrl, "image/svg"); if (svg == null) { return null; } Shape shape = getShape(svg.node); final Rectangle2D bounds = shape.getBounds2D(); double maxSize = Math.max(bounds.getWidth(), bounds.getHeight()); double scaleToOne = 1 / maxSize; final AffineTransform at = new AffineTransform(scaleToOne, 0, 0, -scaleToOne, -0.5, 0.5); TransformedShape ts = new TransformedShape(shape, at); return ts; } SVGMarkFactory();  SVGMarkFactory(Map<Key, Object> hints); @Override Shape getShape(Graphics2D graphics, Expression symbolUrl, Feature feature);  }