edu.mit.sketch.danclock.model
Class Clock

java.lang.Object
  extended by edu.mit.sketch.danclock.model.Clock

public class Clock
extends java.lang.Object

Represents a sketch of a clock, consisting of an outer face, hands, digits, and possibly a center piece. (Some people draw a ring in the middle to connect the hands.) Clocks additionally have unclassified strokes, which either haven't yet been grouped using Clock's classification methods, or need to be grouped manually using the GUI. Note that some recognition steps in Clock depend on other components already being recognized, whether by Clock's automatic methods or the GUI. Digits, for example, depend on everything else already being grouped, such that the only unclassified strokes are digit strokes. The dependency order is {face (depends on nothing), center, hands, digits}.

Author:
dan

Constructor Summary
Clock(java.util.Collection<Stroke> strokes)
          Constructs an unclassified clock from a set of strokes.
Clock(FaceSymbol face, CenterSymbol center, java.util.Set<DigitSymbol> digits, java.util.Set<HandSymbol> hands, java.util.Set<Stroke> unclassifiedStrokes)
          Constructs a classified clock from the given components.
 
Method Summary
 void classifyAll()
           
 boolean classifyClockCenter()
          Attepts to group any strokes drawn as a center piece connecting the clock hands.
 boolean classifyClockFace()
          Attempts to find the circular outer clock face of this clock.
 boolean classifyDigits()
          Attepts to find the digits.
 boolean classifyHands()
          Attempts to find the hour and minute hands.
 BoundingBox getBounds()
           
 CenterSymbol getCenter()
           
 java.util.Set<Stroke> getClassifiedStrokes()
           
 java.util.Set<DigitSymbol> getDigits()
           
 FaceSymbol getFace()
           
 java.util.Set<HandSymbol> getHands()
           
 java.util.SortedSet<Stroke> getStrokes()
           
 java.util.Set<Stroke> getUnclassifiedStrokes()
           
 boolean hasClockCenter()
           
 boolean hasClockFace()
           
 boolean hasDigits()
           
 boolean hasStandardDigits()
           
 boolean hasStandardHands()
           
 void setClockCenter(CenterSymbol center)
           
 void setClockFace(FaceSymbol face)
           
 void setDigits(java.util.Collection<DigitSymbol> digitSymbol)
           
 void setHands(java.util.Set<HandSymbol> hands)
           
 void unclassifyAll()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clock

public Clock(java.util.Collection<Stroke> strokes)
Constructs an unclassified clock from a set of strokes.

Parameters:
strokes - the constituent strokes

Clock

public Clock(FaceSymbol face,
             CenterSymbol center,
             java.util.Set<DigitSymbol> digits,
             java.util.Set<HandSymbol> hands,
             java.util.Set<Stroke> unclassifiedStrokes)
Constructs a classified clock from the given components. Null or empty arguements denote absenses of the respective components.

Method Detail

classifyClockFace

public boolean classifyClockFace()
Attempts to find the circular outer clock face of this clock. If successful, the recognized strokes will be pulled out of the unclassified set and become the clock face.

Returns:
true if a clock face was recognized by this classification, false otherwise. (if a clock face is already recognized, this method will fail to recognize anything further.)

classifyClockCenter

public boolean classifyClockCenter()
Attepts to group any strokes drawn as a center piece connecting the clock hands. Assumes the outer clock face has already been classified correctly.

Returns:
true if a clock center was recognized, false otherwise.

classifyHands

public boolean classifyHands()
Attempts to find the hour and minute hands. Assumes the clock face and clock center have already been classified correctly.

Returns:
true if one or more clock hands were recognized, false otherwise

classifyDigits

public boolean classifyDigits()
Attepts to find the digits. Assumes all other clock components have been classified correctly.

Returns:
true if one or more digits were recognized, false otherwise.

classifyAll

public void classifyAll()

unclassifyAll

public void unclassifyAll()

setClockFace

public void setClockFace(FaceSymbol face)

setClockCenter

public void setClockCenter(CenterSymbol center)

setHands

public void setHands(java.util.Set<HandSymbol> hands)

setDigits

public void setDigits(java.util.Collection<DigitSymbol> digitSymbol)

hasClockFace

public boolean hasClockFace()
Returns:
true iff this clock contains a classified face symbol.

hasClockCenter

public boolean hasClockCenter()
Returns:
true iff this clock contains a classified center symbol

hasDigits

public boolean hasDigits()
Returns:
true iff this clock contains one or more classified digits

hasStandardDigits

public boolean hasStandardDigits()
Returns:
true iff this clock has 12 digits labeled from 1-12, like most clocks.

hasStandardHands

public boolean hasStandardHands()
Returns:
true iff this clock contains 1 hour and 1 minute hand.

getStrokes

public java.util.SortedSet<Stroke> getStrokes()
Returns:
the strokes that make up this clock.

getClassifiedStrokes

public java.util.Set<Stroke> getClassifiedStrokes()
Returns:
The set of strokes that are recognized as belonging to a clock's face, center, hands or digits.

getUnclassifiedStrokes

public java.util.Set<Stroke> getUnclassifiedStrokes()
Returns:
The set of strokes that haven't yet been classified. getClassifiedStrokes() U getUnclassifiedStrokes() = getStrokes()

getFace

public FaceSymbol getFace()
Returns:
this clock's face, or null if one hasn't been classified

getCenter

public CenterSymbol getCenter()
Returns:
this clock's center symbol, or null if one hasn't been classified.

getDigits

public java.util.Set<DigitSymbol> getDigits()
Returns:
a set of this clock's digit symbols. the set is empty if no digits have been classified.

getHands

public java.util.Set<HandSymbol> getHands()
Returns:
a set of this clock's hour hands. an empty set is returned if no hour hands have been classified.

getBounds

public BoundingBox getBounds()
Returns:
the tightest rectangle that bounds this clock.