public void setPaint(Paint paint) { if (paint == null) return; if (paint.equals(getPaint())) return; if (paint instanceof Color) { setColor((Color) paint); } else { super.setPaint(paint); hostGraphics.setPaint(paint); } }
@Test public void testGet() { RandomColors c = new RandomColors(); int STEPS = 10; Paint[] actual = new Paint[STEPS]; // Test two runs in order to hit cache for (int run = 0; run < 2; run++) { Paint prv = null; for (int i = 0; i < STEPS; i++) { Paint cur = c.get(i); if (run == 0) { actual[i] = cur; } else { assertEquals(actual[i], cur); } assertNotNull(cur); assertFalse(cur.equals(prv)); prv = cur; } } }
private boolean checkNewPaint(Paint oldPaint) { if (paint == oldPaint) return false; return !((paint instanceof Color) && paint.equals(oldPaint)); }