de.matthiasmann.twl.model
Class StringAttributes

java.lang.Object
  extended by de.matthiasmann.twl.model.StringAttributes
All Implemented Interfaces:
AnimationState, AttributedString, java.lang.CharSequence

public class StringAttributes
extends java.lang.Object
implements AttributedString


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.renderer.AnimationState
AnimationState.StateKey
 
Constructor Summary
StringAttributes(ObservableCharSequence cs)
           
StringAttributes(ObservableCharSequence cs, AnimationState baseAnimState)
           
StringAttributes(java.lang.String text)
           
StringAttributes(java.lang.String text, AnimationState baseAnimState)
           
 
Method Summary
 int advance()
          Moves the current position forward to the next segment.
 char charAt(int index)
           
 void clearAnimationStates()
           
 boolean getAnimationState(AnimationState.StateKey state)
          Checks if the given state is active.
 int getAnimationTime(AnimationState.StateKey state)
          Returns the time since the specified state has changed in ms.
 int getPosition()
          Returns the current position of the attribute iterator
 boolean getShouldAnimateState(AnimationState.StateKey state)
          Checks if this state was changed based on user interaction or not.
 int length()
           
 void optimize()
          Optimizes the internal representation.
 void removeAnimationState(AnimationState.StateKey key)
           
 void removeAnimationState(AnimationState.StateKey key, int from, int end)
           
 void setAnimationState(AnimationState.StateKey key, int from, int end, boolean active)
           
 void setPosition(int pos)
          Changes the current position.
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringAttributes

public StringAttributes(java.lang.String text,
                        AnimationState baseAnimState)

StringAttributes

public StringAttributes(java.lang.String text)

StringAttributes

public StringAttributes(ObservableCharSequence cs,
                        AnimationState baseAnimState)

StringAttributes

public StringAttributes(ObservableCharSequence cs)
Method Detail

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

length

public int length()
Specified by:
length in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

getPosition

public int getPosition()
Description copied from interface: AttributedString
Returns the current position of the attribute iterator

Specified by:
getPosition in interface AttributedString
Returns:
the current position

setPosition

public void setPosition(int pos)
Description copied from interface: AttributedString
Changes the current position.

Specified by:
setPosition in interface AttributedString
Parameters:
pos - the new position

advance

public int advance()
Description copied from interface: AttributedString
Moves the current position forward to the next segment.

Specified by:
advance in interface AttributedString
Returns:
the new position

getAnimationState

public boolean getAnimationState(AnimationState.StateKey state)
Description copied from interface: AnimationState
Checks if the given state is active.

Specified by:
getAnimationState in interface AnimationState
Parameters:
state - the state key.
Returns:
true if the state is set

getAnimationTime

public int getAnimationTime(AnimationState.StateKey state)
Description copied from interface: AnimationState
Returns the time since the specified state has changed in ms. If the specified state was never changed then a free running time is returned.

Specified by:
getAnimationTime in interface AnimationState
Parameters:
state - the state key.
Returns:
time since last state change is ms.

getShouldAnimateState

public boolean getShouldAnimateState(AnimationState.StateKey state)
Description copied from interface: AnimationState
Checks if this state was changed based on user interaction or not. If this method returns false then the animation time should not be used for single shot animations.

Specified by:
getShouldAnimateState in interface AnimationState
Parameters:
state - the state key.
Returns:
true if single shot animations should run or not.

setAnimationState

public void setAnimationState(AnimationState.StateKey key,
                              int from,
                              int end,
                              boolean active)

removeAnimationState

public void removeAnimationState(AnimationState.StateKey key,
                                 int from,
                                 int end)

removeAnimationState

public void removeAnimationState(AnimationState.StateKey key)

clearAnimationStates

public void clearAnimationStates()

optimize

public void optimize()
Optimizes the internal representation. This need O(n) time.