(Canvas canvas, int width, int height, float dpi, int xpos, int ypos)
| 20 | } |
| 21 | |
| 22 | @Override |
| 23 | public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int ypos) { |
| 24 | if (_dom != null) { |
| 25 | try (SVGSVG root = _dom.getRoot(); |
| 26 | var paint = new Paint().setColor(0xFFEEEEEE);) |
| 27 | { |
| 28 | var bounds = new Point(width - 50, height - 50); |
| 29 | SVGLengthContext lc = new SVGLengthContext(bounds); |
| 30 | var svgWidth = lc.resolve(root.getWidth(), SVGLengthType.HORIZONTAL); |
| 31 | var svgHeight = lc.resolve(root.getHeight(), SVGLengthType.VERTICAL); |
| 32 | _dom.setContainerSize(bounds); |
| 33 | var scale = Math.min(bounds.getX() / svgWidth, bounds.getY() / svgHeight); |
| 34 | canvas.translate((width - svgWidth * scale) / 2f, (height - svgHeight * scale) / 2f); |
| 35 | canvas.drawRect(Rect.makeWH(svgWidth * scale, svgHeight * scale), paint); |
| 36 | canvas.scale(scale, scale); |
| 37 | _dom.render(canvas); |
| 38 | } |
| 39 | } else if (_error != null) { |
| 40 | Scene.drawStringCentered(canvas, _error.getMessage(), width / 2, height / 2, Scene.inter13, Scene.blackFill); |
| 41 | } else if (_thread != null) { |
| 42 | Scene.drawStringCentered(canvas, "Loading " + _variants[_variantIdx] + "...", width / 2, height / 2, Scene.inter13, Scene.blackFill); |
| 43 | } else { |
| 44 | _thread = new Fetch(_variants[_variantIdx]); |
| 45 | _thread.start(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | class Fetch extends Thread { |
| 50 | public String _url; |
nothing calls this directly
no test coverage detected