@Override public void clearSelection() { selectedShape = null; for (WiresShape shape : getShapesInCanvas()) { shape.setSelected(false); if (shape instanceof HasControlPoints) { ((HasControlPoints) shape).hideControlPoints(); } if (shape instanceof HasMagnets) { ((HasMagnets) shape).hideMagnetPoints(); } } canvasLayer.batch(); }
public void clear() { //Detach Shapes in Containers; as destroying a Container automatically destroys it's contained Shapes //This sounds as though we need not worry about those, however "shapesInCanvas" this means we cannot //simply iterate over "shapesInCanvas" as it's content changes as Shapes are destroyed. for (WiresShape shape : shapesInCanvas) { if (shape instanceof WiresContainer) { final WiresContainer wc = (WiresContainer) shape; for (WiresBaseShape bc : wc.getContainedShapes()) { wc.detachShape(bc); } } } //Now it's safe to destroy all Shapes for (WiresShape shape : shapesInCanvas) { shape.destroy(); canvasLayer.remove((IPrimitive<?>) shape); } clearSelection(); shapesInCanvas.clear(); panel.getViewport().setPixelSize(DEFAULT_SIZE_WIDTH, DEFAULT_SIZE_HEIGHT); panel.getViewport().draw(); }
public void clear() { //Detach Shapes in Containers; as destroying a Container automatically destroys it's contained Shapes //This sounds as though we need not worry about those, however "shapesInCanvas" this means we cannot //simply iterate over "shapesInCanvas" as it's content changes as Shapes are destroyed. for (WiresShape shape : shapesInCanvas) { if (shape instanceof WiresContainer) { final WiresContainer wc = (WiresContainer) shape; for (WiresBaseShape bc : wc.getContainedShapes()) { wc.detachShape(bc); } } } //Now it's safe to destroy all Shapes for (WiresShape shape : shapesInCanvas) { shape.destroy(); canvasLayer.remove((IPrimitive<?>) shape); } clearSelection(); shapesInCanvas.clear(); panel.getViewport().setPixelSize(DEFAULT_SIZE_WIDTH, DEFAULT_SIZE_HEIGHT); panel.getViewport().draw(); }
@Override public void clearSelection() { selectedShape = null; for (WiresShape shape : getShapesInCanvas()) { shape.setSelected(false); if (shape instanceof HasControlPoints) { ((HasControlPoints) shape).hideControlPoints(); } if (shape instanceof HasMagnets) { ((HasMagnets) shape).hideMagnetPoints(); } } canvasLayer.batch(); }