com.birosoft.liquid.skin
Class SkinSimpleButtonIndexModel

java.lang.Object
  extended by com.birosoft.liquid.skin.SkinSimpleButtonIndexModel

public class SkinSimpleButtonIndexModel
extends java.lang.Object

A Simple Index Model for a button. Use it to calculate which of the subimages of a skin should be used. The order of evaluation of the states is: 1. Test if button is disabled 2. Test if button is pressed 3. Test if button is in rollover state 4. Button must be in normal state then. The first test that evaluates to true determines the index for the skin to be used. If the component is not a subclass of AbstractButton one can explicitly pass the relevant states to getIndexForState but use the same logic.


Constructor Summary
SkinSimpleButtonIndexModel()
          Creates a SkinIndexModel for the button with the indices normal=0, rollover=1, pushed=2 and disabled=3
SkinSimpleButtonIndexModel(int normal, int rollover, int pressed, int disabled)
          Creates a SkinIndexModel for the button with the given states.
 
Method Summary
 javax.swing.AbstractButton getButton()
          Returns the button.
 int getIndexForState()
          Returns the index of the image of the skin to be used for rendering.
 int getIndexForState(boolean isEnabled, boolean isRollover, boolean isPressed)
          This methode can be used for other Components than AbstractButtons.
 void setButton(javax.swing.AbstractButton button)
          Sets the button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkinSimpleButtonIndexModel

public SkinSimpleButtonIndexModel()
Creates a SkinIndexModel for the button with the indices normal=0, rollover=1, pushed=2 and disabled=3

Parameters:
button -

SkinSimpleButtonIndexModel

public SkinSimpleButtonIndexModel(int normal,
                                  int rollover,
                                  int pressed,
                                  int disabled)
Creates a SkinIndexModel for the button with the given states.

Parameters:
normal - the index of the normal image
rollover - the index of the rollover image
pressed - the index of the pressed image
disabled - the index of the disabled image
Method Detail

getIndexForState

public int getIndexForState()
Returns the index of the image of the skin to be used for rendering. The button must be set before calling getIndexForState.

Returns:
int the index of the image that should be used for rendering due to the state of the button
See Also:
setButton

getIndexForState

public int getIndexForState(boolean isEnabled,
                            boolean isRollover,
                            boolean isPressed)
This methode can be used for other Components than AbstractButtons. The states are passed directly, but the logic to decide which index to use is the same as in getIndexForState so that consistency is preserved.

Parameters:
isEnabled -
isPressed -
isRollover -
Returns:
int

getButton

public javax.swing.AbstractButton getButton()
Returns the button.

Returns:
AbstractButton

setButton

public void setButton(javax.swing.AbstractButton button)
Sets the button.

Parameters:
button - The button to set