コード例 #1
0
  @Before
  public void setup() {
    shape =
        new NGShape() {
          @Override
          public Shape getShape() {
            return new Ellipse2D(10, 10, 10, 10);
          }

          @Override
          protected boolean supportsOpaqueRegions() {
            return true;
          }

          @Override
          protected RectBounds computeOpaqueRegion(RectBounds opaqueRegion) {
            // For the sake of the tests in this class we actually don't care
            // what the opaque region is, so I just make something up
            opaqueRegion.setBounds(0, 0, 20, 20);
            return opaqueRegion;
          }
        };
    shape.setDrawPaint(Color.WHITE);
    shape.setFillPaint(Color.BLACK);
  }
コード例 #2
0
 @Test
 public void hasOpaqueRegionReturnsFalseIfFillPaintIsNotOpaque() {
   shape.setFillPaint(
       new LinearGradient(
           0,
           0,
           1,
           1,
           BaseTransform.IDENTITY_TRANSFORM,
           true,
           0,
           Arrays.asList(new Stop(Color.BLACK, 0), new Stop(Color.TRANSPARENT, 1))));
   assertFalse(shape.hasOpaqueRegion());
 }
コード例 #3
0
  @Test
  public void getOpaqueRegionChangesWhenFillChanged() {
    RectBounds or = shape.getOpaqueRegion();
    assertNotNull(or);

    shape.setFillPaint(null);
    assertNull(shape.getOpaqueRegion());

    shape.setFillPaint(Color.BLACK);
    assertNotNull(shape.getOpaqueRegion());
    assertEquals(or, shape.getOpaqueRegion());
  }
コード例 #4
0
 @Test
 public void hasOpaqueRegionReturnsFalseIfFillPaintIsNull() {
   shape.setFillPaint(null);
   assertFalse(shape.hasOpaqueRegion());
 }
コード例 #5
0
 @Test
 public void hasOpaqueRegionReturnsFalseIfModeIsEmpty() {
   shape.setMode(NGShape.Mode.EMPTY);
   assertFalse(shape.hasOpaqueRegion());
 }
コード例 #6
0
 @Test
 public void hasOpaqueRegionReturnsFalseIfModeIsStroke() {
   shape.setMode(NGShape.Mode.STROKE);
   assertFalse(shape.hasOpaqueRegion());
 }
コード例 #7
0
  @Test
  public void getOpaqueRegionChangesWhenModeChanged() {
    RectBounds or = shape.getOpaqueRegion();
    assertNotNull(or);

    shape.setMode(NGShape.Mode.EMPTY);
    assertNull(shape.getOpaqueRegion());

    shape.setMode(NGShape.Mode.FILL);
    assertNotNull(shape.getOpaqueRegion());
    assertEquals(or, shape.getOpaqueRegion());

    shape.setMode(NGShape.Mode.STROKE);
    assertNull(shape.getOpaqueRegion());

    shape.setMode(NGShape.Mode.STROKE_FILL);
    assertNotNull(shape.getOpaqueRegion());
    assertEquals(or, shape.getOpaqueRegion());
  }
コード例 #8
0
 @Test
 public void hasOpaqueRegionReturnsTrueIfModeIsFILL() {
   assertTrue(shape.hasOpaqueRegion());
 }
コード例 #9
0
 @Test
 public void hasOpaqueRegionReturnsTrueIfModeIsSTROKE_FILE() {
   shape.setMode(NGShape.Mode.STROKE_FILL);
   assertTrue(shape.hasOpaqueRegion());
 }