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);
    }
  }
예제 #2
0
  @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;
      }
    }
  }
예제 #3
0
 private boolean checkNewPaint(Paint oldPaint) {
   if (paint == oldPaint) return false;
   return !((paint instanceof Color) && paint.equals(oldPaint));
 }