@Test public void testMoveLayer6Down() { layerDownAction.moveDown(layer6); Assert.assertEquals(4, layer0.getChildren().size()); Assert.assertEquals(0, layer0.getChildIndex("layer1")); Assert.assertEquals(1, layer0.getChildIndex("layer2")); Assert.assertEquals(2, layer0.getChildIndex("layer3")); Assert.assertEquals(3, layer0.getChildIndex("layer6")); }
void moveDown(Layer layer) { if (canMove(layer)) { final Layer parentLayer = layer.getParent(); final int layerIndex = parentLayer.getChildIndex(layer.getId()); parentLayer.getChildren().remove(layer); parentLayer.getChildren().add(layerIndex + 1, layer); } }
MoveLayerDownAction extends AbstractAction { void moveDown(Layer layer) { if (canMove(layer)) { final Layer parentLayer = layer.getParent(); final int layerIndex = parentLayer.getChildIndex(layer.getId()); parentLayer.getChildren().remove(layer); parentLayer.getChildren().add(layerIndex + 1, layer); } } }
MoveLayerDownAction extends AbstractAction { void moveDown(Layer layer) { if (canMove(layer)) { final Layer parentLayer = layer.getParent(); final int layerIndex = parentLayer.getChildIndex(layer.getId()); parentLayer.getChildren().remove(layer); parentLayer.getChildren().add(layerIndex + 1, layer); } } MoveLayerDownAction(); }
MoveLayerDownAction extends AbstractAction { void moveDown(Layer layer) { if (canMove(layer)) { final Layer parentLayer = layer.getParent(); final int layerIndex = parentLayer.getChildIndex(layer.getId()); parentLayer.getChildren().remove(layer); parentLayer.getChildren().add(layerIndex + 1, layer); } } MoveLayerDownAction(); @Override void actionPerformed(ActionEvent e); boolean canMove(Layer layer); }
MoveLayerDownAction extends AbstractAction { void moveDown(Layer layer) { if (canMove(layer)) { final Layer parentLayer = layer.getParent(); final int layerIndex = parentLayer.getChildIndex(layer.getId()); parentLayer.getChildren().remove(layer); parentLayer.getChildren().add(layerIndex + 1, layer); } } MoveLayerDownAction(); @Override void actionPerformed(ActionEvent e); boolean canMove(Layer layer);  }