jdk/src/java.desktop/share/classes/sun/java2d/StateTrackableDelegate.java
author lbourges
Mon, 23 Nov 2015 15:02:19 -0800
changeset 34419 14108cfd0823
parent 32865 f9cb6e427f9e
permissions -rw-r--r--
8143849: Integrate Marlin renderer per JEP 265 Reviewed-by: flar, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.java2d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.java2d.StateTrackable.State;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import static sun.java2d.StateTrackable.State.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This class provides a basic pre-packaged implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * complete {@link StateTrackable} interface with implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * of the required methods in the interface and methods to manage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * transitions in the state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Classes which wish to implement StateTrackable could create an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * instance of this class and delegate all of their implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * for {@code StateTrackable} methods to the corresponding methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public final class StateTrackableDelegate implements StateTrackable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * The {@code UNTRACKABLE_DELEGATE} provides an implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * of the StateTrackable interface that is permanently in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * {@link State#UNTRACKABLE UNTRACKABLE} state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26037
diff changeset
    47
    public static final StateTrackableDelegate UNTRACKABLE_DELEGATE =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        new StateTrackableDelegate(UNTRACKABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * The {@code IMMUTABLE_DELEGATE} provides an implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * of the StateTrackable interface that is permanently in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * {@link State#IMMUTABLE IMMUTABLE} state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 26037
diff changeset
    55
    public static final StateTrackableDelegate IMMUTABLE_DELEGATE =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        new StateTrackableDelegate(IMMUTABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * Returns a {@code StateTrackableDelegate} instance with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * specified initial {@link State State}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * If the specified {@code State} is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * {@link State#UNTRACKABLE UNTRACKABLE} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * {@link State#IMMUTABLE IMMUTABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * then the approprirate static instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * {@link #UNTRACKABLE_DELEGATE} or {@link #IMMUTABLE_DELEGATE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public static StateTrackableDelegate createInstance(State state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        switch (state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        case UNTRACKABLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            return UNTRACKABLE_DELEGATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        case STABLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            return new StateTrackableDelegate(STABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        case DYNAMIC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            return new StateTrackableDelegate(DYNAMIC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        case IMMUTABLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            return IMMUTABLE_DELEGATE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            throw new InternalError("unknown state");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private State theState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    StateTracker theTracker;   // package private for easy access from tracker
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private int numDynamicAgents;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Constructs a StateTrackableDelegate object with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * initial State.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private StateTrackableDelegate(State state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        this.theState = state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @inheritDoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public State getState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        return theState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @inheritDoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public synchronized StateTracker getStateTracker() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        StateTracker st = theTracker;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (st == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            switch (theState) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            case IMMUTABLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                st = StateTracker.ALWAYS_CURRENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            case STABLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                st = new StateTracker() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                    public boolean isCurrent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                        return (theTracker == this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            case DYNAMIC:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                // We return the NEVER_CURRENT tracker, but that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                // just temporary while we are in the DYNAMIC state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                // NO BREAK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            case UNTRACKABLE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                st = StateTracker.NEVER_CURRENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            theTracker = st;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return st;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * This method provides an easy way for delegating classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * change the overall {@link State State} of the delegate to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * {@link State#IMMUTABLE IMMUTABLE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @throws IllegalStateException if the current state is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *         {@link State#UNTRACKABLE UNTRACKABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @see #setUntrackable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public synchronized void setImmutable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (theState == UNTRACKABLE || theState == DYNAMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            throw new IllegalStateException("UNTRACKABLE or DYNAMIC "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                            "objects cannot become IMMUTABLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        theState = IMMUTABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        theTracker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * This method provides an easy way for delegating classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * change the overall {@link State State} of the delegate to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * {@link State#UNTRACKABLE UNTRACKABLE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * This method is typically called when references to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * internal data buffers have been made public.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @throws IllegalStateException if the current state is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *         {@link State#IMMUTABLE IMMUTABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see #setImmutable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public synchronized void setUntrackable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (theState == IMMUTABLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            throw new IllegalStateException("IMMUTABLE objects cannot "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                            "become UNTRACKABLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        theState = UNTRACKABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        theTracker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * This method provides an easy way for delegating classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * manage temporarily setting the overall {@link State State}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * of the delegate to {@link State#DYNAMIC DYNAMIC}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * during well-defined time frames of dynamic pixel updating.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * This method should be called once before each flow of control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * that might dynamically update the pixels in an uncontrolled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * or unpredictable fashion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * The companion method {@link #removeDynamicAgent} method should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * also be called once after each such flow of control has ended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Failing to call the remove method will result in this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * permanently becoming {@link State#DYNAMIC DYNAMIC}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * and therefore effectively untrackable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * This method will only change the {@link State State} of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * delegate if it is currently {@link State#STABLE STABLE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @throws IllegalStateException if the current state is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *         {@link State#IMMUTABLE IMMUTABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public synchronized void addDynamicAgent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        if (theState == IMMUTABLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            throw new IllegalStateException("Cannot change state from "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                            "IMMUTABLE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        ++numDynamicAgents;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        if (theState == STABLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            theState = DYNAMIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            theTracker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * This method provides an easy way for delegating classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * manage restoring the overall {@link State State} of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * delegate back to {@link State#STABLE STABLE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * after a well-defined time frame of dynamic pixel updating.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * This method should be called once after each flow of control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * that might dynamically update the pixels in an uncontrolled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * or unpredictable fashion has ended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * The companion method {@link #addDynamicAgent} method should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * have been called at some point before each such flow of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * control began.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * If this method is called without having previously called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * the add method, the {@link State State} of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * will become unreliable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * This method will only change the {@link State State} of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * delegate if the number of outstanding dynamic agents has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * gone to 0 and it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * {@link State#DYNAMIC DYNAMIC}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    protected synchronized void removeDynamicAgent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (--numDynamicAgents == 0 && theState == DYNAMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            theState = STABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            theTracker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * This method provides an easy way for delegating classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * indicate that the contents have changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * This method will invalidate outstanding StateTracker objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * so that any other agents which maintain cached information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * about the pixels will know to refresh their cached copies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * This method should be called after every modification to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * the data, such as any calls to any of the setElem methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Note that, for efficiency, this method does not check the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * {@link State State} of the object to see if it is compatible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * with being marked dirty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * (i.e. not {@link State#IMMUTABLE IMMUTABLE}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * It is up to the callers to enforce the fact that an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * {@code IMMUTABLE} delegate is never modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
26004
7507a1b93f67 6521783: Unnecessary final modifier for a method in a final class
serb
parents: 5506
diff changeset
   253
    public void markDirty() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        theTracker = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
}