uk.co.keang.sudoku.event
Class SolutionEvent

java.lang.Object
  extended by java.util.EventObject
      extended by uk.co.keang.sudoku.event.SolutionEvent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
AssociatedPairsEvent, AsymmetricGroupsEvent, BruteForceEvent, FixedLineEvent, HiddenGroupsEvent, KnownValueEvent, MatchingGroupEvent, SplitGroupsEvent, ZeroChoiceEvent

public class SolutionEvent
extends java.util.EventObject
implements java.lang.Cloneable

A solution event

Author:
A.G.Docherty
See Also:
Serialized Form

Nested Class Summary
static class SolutionEvent.DisplayOrder
           
static class SolutionEvent.Grouping
           
 
Field Summary
protected static java.lang.String[] lblTextXAxis
           
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
SolutionEvent(AbstractSolver src, java.lang.String msg, Puzzle grid, java.util.List<java.awt.Point> loc, Puzzle.Cell removed, java.util.List<java.awt.Point> from, SolutionEvent.Grouping g)
          A solver event for a changed cell
 
Method Summary
 boolean canCoalesce(SolutionEvent e)
          Returns true if the source and location are the same and if they both have change sets
 SolutionEvent clone()
           
 void coalesce(SolutionEvent e)
          Coalesces the given event with this one
 SolutionEvent.DisplayOrder displayOrder()
          Gets the display order for event replay.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getDescription()
           
 SolutionEvent.Grouping getGrouping()
           
 java.util.List<java.awt.Point> getLocations()
          Gets the locations of the cells being modified or resolved
 Puzzle getPuzzle()
          The grid after any changes have been applied
 java.util.List<java.awt.Point> getReferencedLocations()
          Gets the location of the squares that were used to create the change
 Puzzle.Cell getReferencedValues()
          The values which are to be highlighted in the referenced locations.
 Puzzle.Cell getRemovedValues()
          The values which are to be removed from this cell
 int hashCode()
           
 boolean isResolved()
          True if all of the location cells are resolved
(package private)  void setDisplayOrder(SolutionEvent.DisplayOrder order)
          Sets the display order for the event replay.
 java.lang.String toString()
          The description of the event
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

lblTextXAxis

protected static java.lang.String[] lblTextXAxis
Constructor Detail

SolutionEvent

public SolutionEvent(AbstractSolver src,
                     java.lang.String msg,
                     Puzzle grid,
                     java.util.List<java.awt.Point> loc,
                     Puzzle.Cell removed,
                     java.util.List<java.awt.Point> from,
                     SolutionEvent.Grouping g)
              throws IllegalGridException
A solver event for a changed cell

Parameters:
src - the solver that generated the event
msg - a descriptive message from the solver
grid - the grid after the proposed changes are applied
loc - the locations (0 based) of the cells that has been modified
removed - the values that been removed from this cells possible values list
from - a list of locations (0 based) of the cells used to determine which values can be removed
Throws:
IllegalGridException
Method Detail

getRemovedValues

public Puzzle.Cell getRemovedValues()
The values which are to be removed from this cell

Returns:
the values

getReferencedValues

public Puzzle.Cell getReferencedValues()
The values which are to be highlighted in the referenced locations. This implementation returns the removed values. Override this method if you want different behaviour.

Returns:
the values

getReferencedLocations

public java.util.List<java.awt.Point> getReferencedLocations()
Gets the location of the squares that were used to create the change

Returns:

getLocations

public java.util.List<java.awt.Point> getLocations()
Gets the locations of the cells being modified or resolved

Returns:

getPuzzle

public Puzzle getPuzzle()
The grid after any changes have been applied

Returns:

isResolved

public boolean isResolved()
True if all of the location cells are resolved

Returns:

getDescription

public java.lang.String getDescription()

getGrouping

public SolutionEvent.Grouping getGrouping()

clone

public SolutionEvent clone()
Overrides:
clone in class java.lang.Object

canCoalesce

public boolean canCoalesce(SolutionEvent e)
Returns true if the source and location are the same and if they both have change sets

Parameters:
e -
Returns:

coalesce

public void coalesce(SolutionEvent e)
Coalesces the given event with this one

Parameters:
e -

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
The description of the event

Overrides:
toString in class java.util.EventObject
Returns:

setDisplayOrder

void setDisplayOrder(SolutionEvent.DisplayOrder order)
Sets the display order for the event replay. By default this is EDITED_FIRST.

Parameters:
order - the order

displayOrder

public SolutionEvent.DisplayOrder displayOrder()
Gets the display order for event replay. By default this is EDITED_FIRST.

Returns:
the order