(Canvas canvas, int width, int height, float dpi, int xpos, int ypos)
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int ypos) { |
| 32 | canvas.translate(30, 30); |
| 33 | |
| 34 | try (var ts = new TextStyle().setColor(0xFFcc3333)) { |
| 35 | assert 0xFFcc3333 == ts.getColor(); |
| 36 | drawLine(canvas, "Shall I compare thee to a summer’s day?", ts); |
| 37 | } |
| 38 | |
| 39 | try (Shader sh = Shader.makeLinearGradient(0, 0, 0, 13, new int[] { 0xFF3A1C71, 0xFFD76D77, 0xFFFFAF7B }); |
| 40 | Paint p = new Paint().setShader(sh); |
| 41 | var ts = new TextStyle().setForeground(p)) { |
| 42 | assert p.equals(ts.getForeground()); |
| 43 | drawLine(canvas, "Thou art more lovely and more temperate:", ts); |
| 44 | ts.setForeground(null); |
| 45 | assert null == ts.getForeground(); |
| 46 | } |
| 47 | |
| 48 | try (Shader sh = Shader.makeLinearGradient(0, 0, 0, 13, new int[] { 0xFF3A1C71, 0xFFD76D77, 0xFFFFAF7B }); |
| 49 | Paint p = new Paint().setShader(sh); |
| 50 | var ts = new TextStyle().setBackground(p)) { |
| 51 | assert p.equals(ts.getBackground()); |
| 52 | drawLine(canvas, "Rough winds do shake the darling buds of May,", ts); |
| 53 | } |
| 54 | |
| 55 | var d = DecorationStyle.NONE.withUnderline(true).withColor(0xFF3A1C71); |
| 56 | try (var ts = new TextStyle().setColor(0xFF000000).setDecorationStyle(d)) { |
| 57 | assert d.equals(ts.getDecorationStyle()) : "Expected " + d + ", got " + ts.getDecorationStyle(); |
| 58 | assert d.hasUnderline() && !d.hasOverline() && !d.hasLineThrough(); |
| 59 | drawLine(canvas, "And summer’s lease hath all too short a date;", ts); |
| 60 | } |
| 61 | |
| 62 | d = DecorationStyle.NONE.withUnderline(true).withColor(0xFFFFAF7B).withGaps(false); |
| 63 | try (var ts = new TextStyle().setColor(0xFF000000).setDecorationStyle(d)) { |
| 64 | assert d.equals(ts.getDecorationStyle()); |
| 65 | drawLine(canvas, "Sometime too hot the eye of heaven shines,", ts); |
| 66 | } |
| 67 | |
| 68 | for (var lineStyle: DecorationLineStyle.values()) { |
| 69 | d = DecorationStyle.NONE.withUnderline(true).withColor(0xFF3A1C71).withLineStyle(lineStyle); |
| 70 | try (var ts = new TextStyle().setColor(0xFF000000).setDecorationStyle(d)) { |
| 71 | assert d.equals(ts.getDecorationStyle()); |
| 72 | drawLine(canvas, "And often is his gold complexion dimm'd; (opaque gyroscope)", ts); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | d = DecorationStyle.NONE.withOverline(true).withLineThrough(true).withColor(0xFFD76D77).withThicknessMultiplier(3); |
| 77 | try (var ts = new TextStyle().setColor(0xFF000000).setDecorationStyle(d)) { |
| 78 | assert d.equals(ts.getDecorationStyle()); |
| 79 | assert !d.hasUnderline() && d.hasOverline() && d.hasLineThrough(); |
| 80 | drawLine(canvas, "And every fair from fair sometime declines,", ts); |
| 81 | } |
| 82 | |
| 83 | try (var ts = new TextStyle().setColor(0xFF000000).setFontStyle(FontStyle.BOLD_ITALIC)) { |
| 84 | assert FontStyle.BOLD_ITALIC.equals(ts.getFontStyle()); |
| 85 | drawLine(canvas, "By chance or nature’s changing course untrimm'd;", ts); |
| 86 | } |
| 87 |
nothing calls this directly
no test coverage detected