001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.osm;
003
004import org.openstreetmap.josm.gui.mappaint.StyleCache;
005
006/**
007 * Object that can be rendered using a cacheable style.
008 * @since 13636
009 */
010public interface Stylable {
011
012    /**
013     * Returns the cached style.
014     * @return the cached style
015     */
016    StyleCache getCachedStyle();
017
018    /**
019     * Sets the cached style.
020     * @param mappaintStyle the cached style
021     */
022    void setCachedStyle(StyleCache mappaintStyle);
023
024    /**
025     * Clears the cached style.
026     * This should not be called from outside. Fixing the UI to add relevant
027     * get/set functions calling this implicitly is preferred, so we can have
028     * transparent cache handling in the future.
029     */
030    default void clearCachedStyle() {
031        setCachedStyle(null);
032    }
033
034    /**
035     * Check if the cached style for this primitive is up to date.
036     * @return true if the cached style for this primitive is up to date
037     * @since 13420
038     */
039    boolean isCachedStyleUpToDate();
040
041    /**
042     * Declare that the cached style for this primitive is up to date.
043     * @since 13420
044     */
045    void declareCachedStyleUpToDate();
046}