@Test public void testPrefWidthOverrideThenRestoreComputedSize() { Region region = new MockRegion(10, 20, 100, 200, 500, 600); region.setPrefWidth(150.0); region.setPrefWidth(Region.USE_COMPUTED_SIZE); // reset assertEquals(Region.USE_COMPUTED_SIZE, region.getPrefWidth(), 1e-100); assertEquals(100, region.prefWidth(-1), 1e-100); }
private Region generateClosedDoorPane(int n, int e, int s, int w) { Region closedDoor = new Region(); closedDoor.setPrefHeight(CELL_SIZE); closedDoor.setPrefWidth(CELL_SIZE); int north_gap = BORDER_WIDTH, east_gap = BORDER_WIDTH, south_gap = BORDER_WIDTH, west_gap = BORDER_WIDTH; if (n == 3) { north_gap = 0; } if (e == 3) { east_gap = 0; } if (s == 3) { south_gap = 0; } if (w == 3) { west_gap = 0; } Insets gap = new Insets(north_gap, east_gap, south_gap, west_gap); closedDoor.setBackground( new Background(new BackgroundFill(CLOSED_DOOR_COLOR, CornerRadii.EMPTY, gap))); return closedDoor; }
@Test public void testPrefWidthNegativeTreatedAsZero() { Region region = new Region(); region.setPrefWidth(-10); assertEquals(0, region.prefWidth(-1), 0); assertEquals(0, region.prefWidth(5), 0); }
@Test public void testPrefWidthNaNTreatedAsZero() { Region region = new Region(); region.setPrefWidth(Double.NaN); assertEquals(0, region.prefWidth(-1), 0); assertEquals(0, region.prefWidth(5), 0); }
// Test for RT-13820 @Test public void changingShapeElementsShouldResultInRender() { Region r = new Region(); r.setPrefWidth(640); r.setPrefHeight(480); LineTo lineTo; Path p = new Path( new MoveTo(0, 0), lineTo = new LineTo(100, 0), new LineTo(50, 100), new ClosePath()); r.setBackground(new Background(new BackgroundFill(Color.BLUE, null, null))); r.setCenterShape(true); r.setScaleShape(true); r.setShape(p); r.impl_syncPeer(); NGRegion peer = r.impl_getPeer(); assertFalse(peer.isClean()); peer.clearDirtyTree(); assertTrue(peer.isClean()); lineTo.setX(200); p.impl_syncPeer(); r.impl_syncPeer(); assertFalse(peer.isClean()); }
@Test public void testPrefWidthOverride() { Region region = new MockRegion(10, 20, 100, 200, 500, 600); assertEquals(100, region.prefWidth(-1), 1e-100); region.setPrefWidth(150.0); assertEquals(150, region.getPrefWidth(), 1e-100); assertEquals(150, region.prefWidth(-1), 1e-100); }
private Region generateFloorSurfacePane(int t, int n, int e, int s, int w) { Region floor = new Region(); floor.setPrefHeight(CELL_SIZE); floor.setPrefWidth(CELL_SIZE); Color floorSurface = Color.web("fff"); switch (t) { case (0): floorSurface = BARE_FLOOR_COLOR; break; case (1): floorSurface = LOW_PILE_COLOR; break; case (2): floorSurface = HIGH_PILE_COLOR; break; case (3): // TODO: replace with stair color floorSurface = Color.web("f00"); break; default: System.out.println("Unsupported floor type"); break; } int floor_n = 0, floor_e = 0, floor_s = 0, floor_w = 0; if (n > 0) { floor_n = BORDER_WIDTH; } if (e > 0) { floor_e = BORDER_WIDTH; } if (s > 0) { floor_s = BORDER_WIDTH; } if (w > 0) { floor_w = BORDER_WIDTH; } Insets floorGap = new Insets(floor_n, floor_e, floor_s, floor_w); floor.setBackground( new Background(new BackgroundFill(floorSurface, CornerRadii.EMPTY, floorGap))); return floor; }