All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jhotdraw8.draw.figure.LockableFigure Maven / Gradle / Ivy

The newest version!
/*
 * @(#)LockableFigure.java
 * Copyright © 2023 The authors and contributors of JHotDraw. MIT License.
 */
package org.jhotdraw8.draw.figure;

import org.jhotdraw8.draw.key.NonNullBooleanStyleableKey;

/**
 * LockableFigure.
 *
 * @author Werner Randelshofer
 */
public interface LockableFigure extends Figure {

    /**
     * Whether the figure is locked. Default value: {@code false}.
     * 

* A locked figure can not be selected or changed by the user, unless the * user explicity unlocks the figure. *

* Locking a figure also locks all its child figures. *

* This key can be used by the user to prevent accidental selection or * editing of a figure. */ NonNullBooleanStyleableKey LOCKED = new NonNullBooleanStyleableKey("locked", false); /** * Whether this figure is not locked and all its parents are editable. * * @return true if this figure is not locked and all parents are editable */ @Override default boolean isEditable() { if (get(LOCKED)) { return false; } Figure node = getParent(); while (node != null) { if (!node.isEditable()) { return false; } node = node.getParent(); } return true; } /** * Whether the figure is not locked and all its parents are editable. * * @return true if this figure is not locked and all parents are deletable. */ @Override default boolean isDeletable() { return isEditable(); /* if (get(LOCKED)) { return false; } Figure node = getParent(); while (node != null) { if (!node.isDeletable()) { return false; } node = node.getParent(); } return true;*/ } /** * Whether the figure is not locked and all its parents are editable. * * @return true if this figure is not locked and all parents are selectable. */ @Override default boolean isSelectable() { return isEditable(); /* if (get(LOCKED)) { return false; } Figure node = getParent(); while (node != null) { if (!node.isSelectable()) { return false; } node = node.getParent(); } return true;*/ } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy