APIdia Launch Partner
Top Description Fields Constructors Methods
sun.java2d

public final Class StateTrackableDelegate

extends Object
implements StateTrackable
Class Inheritance
All Implemented Interfaces
sun.java2d.StateTrackable
Imports
sun.java2d.StateTrackable.State

This class provides a basic pre-packaged implementation of the complete StateTrackable interface with implementations of the required methods in the interface and methods to manage transitions in the state of the object. Classes which wish to implement StateTrackable could create an instance of this class and delegate all of their implementations for StateTrackable methods to the corresponding methods of this class.

Field Summary

Modifier and TypeField and Description
public static final StateTrackableDelegate
IMMUTABLE_DELEGATE

The IMMUTABLE_DELEGATE provides an implementation of the StateTrackable interface that is permanently in the IMMUTABLE state.

private int
private StateTrackable.State
pack-priv StateTracker
public static final StateTrackableDelegate
UNTRACKABLE_DELEGATE

The UNTRACKABLE_DELEGATE provides an implementation of the StateTrackable interface that is permanently in the UNTRACKABLE state.

Constructor Summary

AccessConstructor and Description
private
StateTrackableDelegate(StateTrackable.State state)

Constructs a StateTrackableDelegate object with the specified initial State.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addDynamicAgent()

This method provides an easy way for delegating classes to manage temporarily setting the overall State of the delegate to DYNAMIC during well-defined time frames of dynamic pixel updating.

public static StateTrackableDelegate
createInstance(StateTrackable.State state)

Returns a StateTrackableDelegate instance with the specified initial State.

public StateTrackable.State
getState()

Implements sun.java2d.StateTrackable.getState.

Returns the general state of the complex data held by this object.

public synchronized StateTracker
getStateTracker()

Implements sun.java2d.StateTrackable.getStateTracker.

Returns an object which can track future changes to the complex data stored in this object.

public void
markDirty()

This method provides an easy way for delegating classes to indicate that the contents have changed.

protected synchronized void
removeDynamicAgent()

This method provides an easy way for delegating classes to manage restoring the overall State of the delegate back to STABLE after a well-defined time frame of dynamic pixel updating.

public synchronized void
setImmutable()

This method provides an easy way for delegating classes to change the overall State of the delegate to IMMUTABLE.

public synchronized void
setUntrackable()

This method provides an easy way for delegating classes to change the overall State of the delegate to UNTRACKABLE.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IMMUTABLE_DELEGATEback to summary
public static final StateTrackableDelegate IMMUTABLE_DELEGATE

The IMMUTABLE_DELEGATE provides an implementation of the StateTrackable interface that is permanently in the IMMUTABLE state.

numDynamicAgentsback to summary
private int numDynamicAgents
theStateback to summary
private StateTrackable.State theState
theTrackerback to summary
pack-priv StateTracker theTracker
UNTRACKABLE_DELEGATEback to summary
public static final StateTrackableDelegate UNTRACKABLE_DELEGATE

The UNTRACKABLE_DELEGATE provides an implementation of the StateTrackable interface that is permanently in the UNTRACKABLE state.

Constructor Detail

StateTrackableDelegateback to summary
private StateTrackableDelegate(StateTrackable.State state)

Constructs a StateTrackableDelegate object with the specified initial State.

Method Detail

addDynamicAgentback to summary
public synchronized void addDynamicAgent()

This method provides an easy way for delegating classes to manage temporarily setting the overall State of the delegate to DYNAMIC during well-defined time frames of dynamic pixel updating. This method should be called once before each flow of control that might dynamically update the pixels in an uncontrolled or unpredictable fashion.

The companion method removeDynamicAgent method should also be called once after each such flow of control has ended. Failing to call the remove method will result in this object permanently becoming DYNAMIC and therefore effectively untrackable.

This method will only change the State of the delegate if it is currently STABLE.

Exceptions
IllegalStateException:
if the current state is IMMUTABLE
Since
1.7
createInstanceback to summary
public static StateTrackableDelegate createInstance(StateTrackable.State state)

Returns a StateTrackableDelegate instance with the specified initial State. If the specified State is UNTRACKABLE or IMMUTABLE then the appropriate static instance UNTRACKABLE_DELEGATE or IMMUTABLE_DELEGATE is returned.

getStateback to summary
public StateTrackable.State getState()

Implements sun.java2d.StateTrackable.getState.

Doc from sun.java2d.StateTrackable.getState.

Returns the general state of the complex data held by this object. This return value can be used to determine if it makes strategic sense to try and cache information about the current contents of this object. The StateTracker returned from the getStateTracker() method will further aid in determining when the data has been changed so that the caches can be verified upon future uses.

Since
1.7
getStateTrackerback to summary
public synchronized StateTracker getStateTracker()

Implements sun.java2d.StateTrackable.getStateTracker.

Doc from sun.java2d.StateTrackable.getStateTracker.

Returns an object which can track future changes to the complex data stored in this object. If an external agent caches information about the complex data of this object, it should first get a StateTracker object from this method so that it can check if such information is current upon future uses. Note that a valid StateTracker will always be returned regardless of the return value of getState(), but in some cases the StateTracker may be a trivial implementation which always returns the same value from its isCurrent method.

  • If the current state is IMMUTABLE, this StateTracker and any future StateTracker objects returned from this method will always indicate that the state has not changed.
  • If the current state is UNTRACKABLE, this StateTracker and any future StateTracker objects returned from this method will always indicate that the state has changed.
  • If the current state is DYNAMIC, this StateTracker may always indicate that the current state has changed, but another StateTracker returned from this method in the future when the state has changed to STABLE will correctly track changes.
  • Otherwise the current state is STABLE and this StateTracker will indicate whether or not the data has changed since the time at which it was fetched from the object.
Since
1.7
markDirtyback to summary
public void markDirty()

This method provides an easy way for delegating classes to indicate that the contents have changed. This method will invalidate outstanding StateTracker objects so that any other agents which maintain cached information about the pixels will know to refresh their cached copies. This method should be called after every modification to the data, such as any calls to any of the setElem methods.

Note that, for efficiency, this method does not check the State of the object to see if it is compatible with being marked dirty (i.e. not IMMUTABLE). It is up to the callers to enforce the fact that an IMMUTABLE delegate is never modified.

Since
1.7
removeDynamicAgentback to summary
protected synchronized void removeDynamicAgent()

This method provides an easy way for delegating classes to manage restoring the overall State of the delegate back to STABLE after a well-defined time frame of dynamic pixel updating. This method should be called once after each flow of control that might dynamically update the pixels in an uncontrolled or unpredictable fashion has ended.

The companion method addDynamicAgent method should have been called at some point before each such flow of control began. If this method is called without having previously called the add method, the State of this object will become unreliable.

This method will only change the State of the delegate if the number of outstanding dynamic agents has gone to 0 and it is currently DYNAMIC.

Since
1.7
setImmutableback to summary
public synchronized void setImmutable()

This method provides an easy way for delegating classes to change the overall State of the delegate to IMMUTABLE.

Exceptions
IllegalStateException:
if the current state is UNTRACKABLE
Since
1.7
See Also
setUntrackable
setUntrackableback to summary
public synchronized void setUntrackable()

This method provides an easy way for delegating classes to change the overall State of the delegate to UNTRACKABLE. This method is typically called when references to the internal data buffers have been made public.

Exceptions
IllegalStateException:
if the current state is IMMUTABLE
Since
1.7
See Also
setImmutable