CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.cubetwister.doc
Class SolverModel

java.lang.Object
  extended by ch.randelshofer.beans.AbstractBean
      extended by ch.randelshofer.cubetwister.doc.SolverModel
All Implemented Interfaces:
CubeAttributes, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class SolverModel
extends AbstractBean
implements CubeAttributes, java.beans.PropertyChangeListener

SolverModel.

Version:
1.1 2009-01-09 Use modifiersEx instead of modifiers!
1.0 2005-05-05 Created.
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
protected  javax.swing.event.EventListenerList listenerList
           
 
Fields inherited from class ch.randelshofer.beans.AbstractBean
propertySupport
 
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
SolverModel(Cube3D cube3D, ScriptPlayer player, CubeAttributes target)
          Creates a new instance of SolverModel
 
Method Summary
 void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Adds an UndoableEditListener.
 void clear()
           
 java.lang.Object clone()
          Clones the attributes.
 void dispose()
          Gets rid of allocated resources.
 void fill()
           
 void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
          Notify all listeners that have registered interest for notification on this event type.
 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()
           
 Cube getMappedCube(Cube cube)
           
 java.lang.String getMappedPermutationString(Cube cube, Notation notation)
           
 java.lang.String getMappedStickersString(Cube cube)
           
 int getPartCount()
           
 float getPartExplosion(int index)
          Gets the explosion factor of a single part of the cube.
 java.awt.Color getPartFillColor(int partIndex)
           
 java.awt.Color getPartOutlineColor(int partIndex)
           
 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 stickerIndex)
           
 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 isPainting()
           
 boolean isPartVisible(int partIndex)
           
 boolean isRearBgImageVisible()
           
 boolean isSolveable()
           
 boolean isSolverSupported()
           
 boolean isStickersChanged()
          Returns true, if the solver model affects the stickerFaces of the cube.
 boolean isStickersImageVisible()
           
 boolean isStickerVisible(int stickerIndex)
           
 boolean isTwisting()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
          Removes an UndoableEditListener.
 void reset()
           
 void setCubeAttributes(CubeAttributes m)
           
 void setPaintFace(int newValue)
          Sets the face we are painting.
 void setPlayer(ScriptPlayer player)
           
 void setStickerMapping(int stickerIndex, int mapValue)
          The side of the cube.
 void setTo(CubeAttributes that)
          Sets the attributes of this cube to the specified attributes.
 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 ch.randelshofer.beans.AbstractBean
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.randelshofer.rubik.CubeAttributes
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

listenerList

protected javax.swing.event.EventListenerList listenerList
Constructor Detail

SolverModel

public SolverModel(Cube3D cube3D,
                   ScriptPlayer player,
                   CubeAttributes target)
Creates a new instance of SolverModel

Method Detail

setPlayer

public void setPlayer(ScriptPlayer player)

setCubeAttributes

public void setCubeAttributes(CubeAttributes m)

setPaintFace

public void setPaintFace(int newValue)
Sets the face we are painting. If this is -1, we are twisting the cube. If this is >= 0, we are painting on the cube.


isPainting

public boolean isPainting()

isTwisting

public boolean isTwisting()

reset

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

clear

public void clear()

fill

public void fill()

setStickerMapping

public void setStickerMapping(int stickerIndex,
                              int mapValue)
The side of the cube. Values 0..5 = Front, Right, Bottom, Back, Left, Top. Or -1 if the side can not be determined.


getStickerFillColor

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

isStickerVisible

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

getPartFillColor

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

getPartOutlineColor

public java.awt.Color getPartOutlineColor(int partIndex)
Specified by:
getPartOutlineColor 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

getScaleFactor

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

isPartVisible

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

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.

isStickersChanged

public boolean isStickersChanged()
Returns true, if the solver model affects the stickerFaces of the cube.


isSolverSupported

public boolean isSolverSupported()

isSolveable

public boolean isSolveable()

getMappedStickersString

public java.lang.String getMappedStickersString(Cube cube)

getMappedPermutationString

public java.lang.String getMappedPermutationString(Cube cube,
                                                   Notation notation)

getMappedCube

public Cube getMappedCube(Cube cube)

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Adds an UndoableEditListener.


removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Removes an UndoableEditListener.


fireUndoableEditHappened

public void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


getFaceCount

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

getPartCount

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

getStickerCount

public int getStickerCount()
Specified by:
getStickerCount 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

getStickerOutlineColor

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

getStickersImage

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

getFrontBgColor

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

getFrontBgImage

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

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

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)

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

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

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

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.