@Test public void testMoveForward() throws Exception { final Coords base = new Coords(0, 0); final Coords northMove = NORTH.moveForward(NORTH.moveForward(NORTH.moveForward(base))); assertEquals(new Coords(0, 3), northMove); final Coords southMove = SOUTH.moveForward(SOUTH.moveForward(SOUTH.moveForward(base))); assertEquals(new Coords(0, -3), southMove); final Coords eastMove = EAST.moveForward(EAST.moveForward(EAST.moveForward(base))); assertEquals(new Coords(3, 0), eastMove); final Coords westMove = WEST.moveForward(WEST.moveForward(WEST.moveForward(base))); assertEquals(new Coords(-3, 0), westMove); }
@Test public void testTurnLeft() throws Exception { assertEquals(NORTH.turnLeft(), WEST); assertEquals(WEST.turnLeft(), SOUTH); assertEquals(SOUTH.turnLeft(), EAST); assertEquals(EAST.turnLeft(), NORTH); }
/** {@inheritDoc} */ @Override public void add(IComponent pComponent, Object pConstraints, int pIndex) { if (pConstraints == null || CENTER.equals(pConstraints)) { resource.setCenter((Node) pComponent.getResource()); } else if (EAST.equals(pConstraints)) { resource.setRight((Node) pComponent.getResource()); } else if (NORTH.equals(pConstraints)) { resource.setTop((Node) pComponent.getResource()); } else if (SOUTH.equals(pConstraints)) { resource.setBottom((Node) pComponent.getResource()); } else if (WEST.equals(pConstraints)) { resource.setLeft((Node) pComponent.getResource()); } else { resource.setCenter((Node) pComponent.getResource()); } BorderPane.setAlignment((Node) pComponent.getResource(), Pos.CENTER); updateGaps(); }