CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.rubik
Class DefaultCubeAttributes

java.lang.Object
  extended by ch.randelshofer.rubik.DefaultCubeAttributes
All Implemented Interfaces:
CubeAttributes, java.lang.Cloneable

public class DefaultCubeAttributes
extends java.lang.Object
implements CubeAttributes

A default implementation of the CubeAttributes interface.

Version:
2.2 2007-08-29 Added property partExplosion.
2.1 2006-01-05 Background color and background image property added.
2.0 2004-10-08 Renamed fro CubeColorModel3D to DefaultCubeAttributes.
1.2 2002-05-05 Methods setAlpha and setBeta added.
1.1 Now uses the original Rubik's Cube Color scheme.
1.0 2001-08-19 Created.
Author:
Werner Randelshofer

Field Summary
protected  float alpha
           
protected  float beta
           
protected  java.beans.PropertyChangeSupport changeSupport
           
protected  java.awt.Color frontBgColor
           
protected  java.awt.Image frontBgImage
           
protected  boolean frontBgImageVisible
           
protected  float[] partExplosion
           
protected  java.awt.Color[] partsFillColor
          Holds the fill color of the parts.
protected  java.awt.Color[] partsOutlineColor
          Holds the outline color of the parts.
protected  boolean[] partsVisible
          Is true, when the part is visible.
protected  java.awt.Color rearBgColor
           
protected  java.awt.Image rearBgImage
           
protected  boolean rearBgImageVisible
           
protected  float scaleFactor
           
protected  int[] stickerCountPerFace
           
protected  float[] stickerExplosion
           
protected  java.awt.Color[] stickersFillColor
          Holds the fill color of the stickers.
protected  java.awt.Image stickersImage
           
protected  boolean stickersImageVisible
           
protected  java.awt.Color[] stickersOutlineColor
          Holds the outline color of the stickers.
protected  boolean[] stickersVisible
          Is true, when the sticker is visible.
protected  boolean valueIsAdjusting
           
 
Fields inherited from interface ch.randelshofer.rubik.CubeAttributes
ALPHA_PROPERTY, BETA_PROPERTY, EXPLOSION_FACTOR_PROPERTY, FRONT_BG_COLOR_PROPERTY, FRONT_BG_IMAGE_PROPERTY, FRONT_BG_IMAGE_VISIBLE_PROPERTY, PART_EXPLOSION_PROPERTY, PART_FILL_COLOR_PROPERTY, PART_OUTLINE_COLOR_PROPERTY, PART_VISIBLE_PROPERTY, REAR_BG_COLOR_PROPERTY, REAR_BG_IMAGE_PROPERTY, REAR_BG_IMAGE_VISIBLE_PROPERTY, SCALE_FACTOR_PROPERTY, STICKER_EXPLOSION_PROPERTY, STICKER_FILL_COLOR_PROPERTY, STICKER_OUTLINE_COLOR_PROPERTY, STICKER_VISIBLE_PROPERTY, STICKERS_IMAGE_PROPERTY, STICKERS_IMAGE_VISIBLE_PROPERTY, TWIST_DURATION_PROPERTY, VALUE_IS_ADJUSTING_PROPERTY
 
Constructor Summary
DefaultCubeAttributes(int partCount, int stickerCount, int[] stickerCountPerFace)
          Creates a new instance.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property change listener.
 java.lang.Object clone()
          Clones the attributes.
 void dispose()
          Gets rid of allocated resources.
 float getAlpha()
          Gets the alpha orientation of the cube.
 float getBeta()
          Gets the beta orientation of the cube.
 float getExplosionFactor()
          Gets the global explosion factor of the cube.
 int getFaceCount()
           
 java.awt.Color getFrontBgColor()
           
 java.awt.Image getFrontBgImage()
           
 int getPartCount()
           
 float getPartExplosion(int index)
          Gets the explosion factor of a single part of the cube.
 java.awt.Color getPartFillColor(int index)
           
 java.awt.Color getPartOutlineColor(int index)
           
 java.awt.Color getRearBgColor()
           
 java.awt.Image getRearBgImage()
           
 float getScaleFactor()
           
 int getStickerCount()
           
 int getStickerCount(int face)
           
 float getStickerExplosion(int index)
          Gets the explosion factor of a single sticker of the cube.
 java.awt.Color getStickerFillColor(int index)
           
 int getStickerOffset(int face)
           
 java.awt.Color getStickerOutlineColor(int index)
           
 java.awt.Image getStickersImage()
           
 int getTwistDuration()
           
 boolean getValueIsAdjusting()
          Returns true if the current changes to the value property are part of a series of changes.
 boolean isFrontBgImageVisible()
           
 boolean isPartVisible(int index)
           
 boolean isRearBgImageVisible()
           
 boolean isStickersImageVisible()
           
 boolean isStickerVisible(int index)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a property change listener.
 void reset()
           
 void setAlpha(float newValue)
           
 void setBeta(float newValue)
           
 void setExplosionFactor(float newValue)
           
 void setFrontBgColor(java.awt.Color newValue)
           
 void setFrontBgImage(java.awt.Image newValue)
           
 void setFrontBgImageVisible(boolean newValue)
           
 void setPartExplosion(int index, float newValue)
           
 void setPartFillColor(java.awt.Color[] newValue)
           
 void setPartFillColor(int index, java.awt.Color newValue)
           
 void setPartOutlineColor(java.awt.Color[] newValue)
           
 void setPartOutlineColor(int index, java.awt.Color newValue)
           
 void setPartVisible(int index, boolean newValue)
           
 void setRearBgColor(java.awt.Color newValue)
           
 void setRearBgImage(java.awt.Image newValue)
           
 void setRearBgImageVisible(boolean newValue)
           
 void setScaleFactor(float newValue)
           
 void setStickerExplosion(int index, float newValue)
           
 void setStickerFillColor(java.awt.Color[] newValue)
           
 void setStickerFillColor(int index, java.awt.Color newValue)
           
 void setStickerOutlineColor(java.awt.Color[] newValue)
           
 void setStickerOutlineColor(int index, java.awt.Color newValue)
           
 void setStickersImage(java.awt.Image newValue)
           
 void setStickersImageVisible(boolean newValue)
           
 void setStickerVisible(int index, boolean newValue)
           
 void setTo(CubeAttributes that)
          Sets the attributes of this cube to the specified attributes.
 void setTwistDuration(int newValue)
           
 void setValueIsAdjusting(boolean newValue)
          This attribute indicates that any upcoming changes to the value of the model should be considered a single event.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeSupport

protected java.beans.PropertyChangeSupport changeSupport

partsVisible

protected boolean[] partsVisible
Is true, when the part is visible.


partsFillColor

protected java.awt.Color[] partsFillColor
Holds the fill color of the parts.


partsOutlineColor

protected java.awt.Color[] partsOutlineColor
Holds the outline color of the parts.


stickersVisible

protected boolean[] stickersVisible
Is true, when the sticker is visible.


stickersFillColor

protected java.awt.Color[] stickersFillColor
Holds the fill color of the stickers. This is used only, when stickersImage is null.


stickersOutlineColor

protected java.awt.Color[] stickersOutlineColor
Holds the outline color of the stickers.


scaleFactor

protected float scaleFactor

alpha

protected float alpha

beta

protected float beta

stickersImage

protected java.awt.Image stickersImage

stickerCountPerFace

protected int[] stickerCountPerFace

frontBgColor

protected java.awt.Color frontBgColor

frontBgImage

protected java.awt.Image frontBgImage

rearBgColor

protected java.awt.Color rearBgColor

rearBgImage

protected java.awt.Image rearBgImage

rearBgImageVisible

protected boolean rearBgImageVisible

frontBgImageVisible

protected boolean frontBgImageVisible

stickersImageVisible

protected boolean stickersImageVisible

valueIsAdjusting

protected boolean valueIsAdjusting

partExplosion

protected float[] partExplosion

stickerExplosion

protected float[] stickerExplosion
Constructor Detail

DefaultCubeAttributes

public DefaultCubeAttributes(int partCount,
                             int stickerCount,
                             int[] stickerCountPerFace)
Creates a new instance.

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener.

Specified by:
addPropertyChangeListener in interface CubeAttributes

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener.

Specified by:
removePropertyChangeListener in interface CubeAttributes

getAlpha

public float getAlpha()
Description copied from interface: CubeAttributes
Gets the alpha orientation of the cube.

Specified by:
getAlpha in interface CubeAttributes

getBeta

public float getBeta()
Description copied from interface: CubeAttributes
Gets the beta orientation of the cube.

Specified by:
getBeta in interface CubeAttributes

getExplosionFactor

public float getExplosionFactor()
Description copied from interface: CubeAttributes
Gets the global explosion factor of the cube.

Specified by:
getExplosionFactor in interface CubeAttributes

getPartExplosion

public float getPartExplosion(int index)
Description copied from interface: CubeAttributes
Gets the explosion factor of a single part of the cube.

Specified by:
getPartExplosion in interface CubeAttributes

setPartExplosion

public void setPartExplosion(int index,
                             float newValue)

getScaleFactor

public float getScaleFactor()
Specified by:
getScaleFactor in interface CubeAttributes

setStickersImage

public void setStickersImage(java.awt.Image newValue)

getStickersImage

public java.awt.Image getStickersImage()
Specified by:
getStickersImage in interface CubeAttributes

setAlpha

public void setAlpha(float newValue)

setBeta

public void setBeta(float newValue)

setScaleFactor

public void setScaleFactor(float newValue)

setExplosionFactor

public void setExplosionFactor(float newValue)

setPartVisible

public void setPartVisible(int index,
                           boolean newValue)

isPartVisible

public boolean isPartVisible(int index)
Specified by:
isPartVisible in interface CubeAttributes

setStickerVisible

public void setStickerVisible(int index,
                              boolean newValue)

isStickerVisible

public boolean isStickerVisible(int index)
Specified by:
isStickerVisible in interface CubeAttributes

getPartFillColor

public java.awt.Color getPartFillColor(int index)
Specified by:
getPartFillColor in interface CubeAttributes

getStickerFillColor

public java.awt.Color getStickerFillColor(int index)
Specified by:
getStickerFillColor in interface CubeAttributes

setPartFillColor

public void setPartFillColor(int index,
                             java.awt.Color newValue)

setStickerFillColor

public void setStickerFillColor(int index,
                                java.awt.Color newValue)

getPartOutlineColor

public java.awt.Color getPartOutlineColor(int index)
Specified by:
getPartOutlineColor in interface CubeAttributes

getStickerOutlineColor

public java.awt.Color getStickerOutlineColor(int index)
Specified by:
getStickerOutlineColor in interface CubeAttributes

setPartOutlineColor

public void setPartOutlineColor(int index,
                                java.awt.Color newValue)

setStickerOutlineColor

public void setStickerOutlineColor(int index,
                                   java.awt.Color newValue)

setPartOutlineColor

public void setPartOutlineColor(java.awt.Color[] newValue)

setPartFillColor

public void setPartFillColor(java.awt.Color[] newValue)

setStickerFillColor

public void setStickerFillColor(java.awt.Color[] newValue)

setStickerOutlineColor

public void setStickerOutlineColor(java.awt.Color[] newValue)

getPartCount

public int getPartCount()
Specified by:
getPartCount in interface CubeAttributes

getStickerCount

public int getStickerCount()
Specified by:
getStickerCount in interface CubeAttributes

getFaceCount

public int getFaceCount()
Specified by:
getFaceCount in interface CubeAttributes

getStickerCount

public int getStickerCount(int face)
Specified by:
getStickerCount in interface CubeAttributes

getStickerOffset

public int getStickerOffset(int face)
Specified by:
getStickerOffset in interface CubeAttributes

reset

public void reset()
Specified by:
reset in interface CubeAttributes

setFrontBgColor

public void setFrontBgColor(java.awt.Color newValue)

setFrontBgImage

public void setFrontBgImage(java.awt.Image newValue)

getFrontBgColor

public java.awt.Color getFrontBgColor()
Specified by:
getFrontBgColor in interface CubeAttributes

getFrontBgImage

public java.awt.Image getFrontBgImage()
Specified by:
getFrontBgImage in interface CubeAttributes

setRearBgColor

public void setRearBgColor(java.awt.Color newValue)

setRearBgImage

public void setRearBgImage(java.awt.Image newValue)

getRearBgColor

public java.awt.Color getRearBgColor()
Specified by:
getRearBgColor in interface CubeAttributes

getRearBgImage

public java.awt.Image getRearBgImage()
Specified by:
getRearBgImage in interface CubeAttributes

isFrontBgImageVisible

public boolean isFrontBgImageVisible()
Specified by:
isFrontBgImageVisible in interface CubeAttributes

isRearBgImageVisible

public boolean isRearBgImageVisible()
Specified by:
isRearBgImageVisible in interface CubeAttributes

isStickersImageVisible

public boolean isStickersImageVisible()
Specified by:
isStickersImageVisible in interface CubeAttributes

setFrontBgImageVisible

public void setFrontBgImageVisible(boolean newValue)

setRearBgImageVisible

public void setRearBgImageVisible(boolean newValue)

setStickersImageVisible

public void setStickersImageVisible(boolean newValue)

setValueIsAdjusting

public void setValueIsAdjusting(boolean newValue)
Description copied from interface: CubeAttributes
This attribute indicates that any upcoming changes to the value of the model should be considered a single event. This attribute will be set to true at the start of a series of changes to the value, and will be set to false when the value has finished changing. Normally this allows a listener to only take action when the final value change in committed, instead of having to do updates for all intermediate values.

Sliders and scrollbars use this property when a drag is underway.

Specified by:
setValueIsAdjusting in interface CubeAttributes
Parameters:
newValue - true if the upcoming changes to the value property are part of a series

getValueIsAdjusting

public boolean getValueIsAdjusting()
Description copied from interface: CubeAttributes
Returns true if the current changes to the value property are part of a series of changes.

Specified by:
getValueIsAdjusting in interface CubeAttributes
Returns:
the valueIsAdjustingProperty.
See Also:
CubeAttributes.setValueIsAdjusting(boolean)

getStickerExplosion

public float getStickerExplosion(int index)
Description copied from interface: CubeAttributes
Gets the explosion factor of a single sticker of the cube.

Specified by:
getStickerExplosion in interface CubeAttributes

setStickerExplosion

public void setStickerExplosion(int index,
                                float newValue)

dispose

public void dispose()
Description copied from interface: CubeAttributes
Gets rid of allocated resources.

Specified by:
dispose in interface CubeAttributes

getTwistDuration

public int getTwistDuration()
Specified by:
getTwistDuration in interface CubeAttributes

setTwistDuration

public void setTwistDuration(int newValue)

setTo

public void setTo(CubeAttributes that)
Description copied from interface: CubeAttributes
Sets the attributes of this cube to the specified attributes.

Specified by:
setTo in interface CubeAttributes

clone

public java.lang.Object clone()
Description copied from interface: CubeAttributes
Clones the attributes.

Specified by:
clone in interface CubeAttributes
Overrides:
clone in class java.lang.Object
Returns:
a clone of the attributes.

(c) Werner Randelshofer.
All rights reserved.