Package saui_pr4 :: Module latticeui :: Class LatticeView :: Class DisplayCloud
[hide private]
[frames] | no frames]

Class DisplayCloud

source code

  object --+    
           |    
LatticeCloud --+
               |
              LatticeView.DisplayCloud

A "cloud" of words to be displayed in the lattice view.

This object controls the presentation of and user interaction with a LatticeCloud. It lays out the words from a cloud according to their posterior probability and timing, and responds to resizing and click events.

The user is able to select a set of correct words within a cloud. These words are recorded by this object internally in the correct_words list.

Instance Methods [hide private]
 
__init__(self, size, context, desc, model, word)
Initialize a DisplayCloud.
source code
boolean
contains(self, x, y)
Returns True if point (x,y) is inside this cloud's extents.
source code
 
y_expand(self, parent)
Expand the cloud to its maximum vertical size.
source code
set(DisplayWord)
get_output_words(self)
Get the set of corrected words.
source code
 
collapse(self, parent)
Collapse the cloud to its minimum size, retaining any user corrections.
source code
 
assimilate(self, parent, other)
Assimilate a neighbouring (we hope) cloud into this one.
source code
LatticeView.DisplayWord
find_word(self, x, y)
Find and return the display word in this cloud which contains point (x,y).
source code
 
double_click(self, parent, x, y)
React to a double click.
source code
 
click(self, parent, x, y)
React to a discrete mouse click.
source code
(int, int)
drag_delta(self, parent, x, y, delta_x, delta_y)
React to drag motion of (delta_x, delta_y) to point (x,y).
source code
boolean
is_minimum(self)
Returns True if this cloud is at its minimum size.
source code
 
end_drag(self, parent, x, y)
React to ending a drag at point (x,y)
source code
 
update_words(self)
Update the list of words to match extents.
source code
 
draw(self, gc)
Draw this cloud in a given graphics context.
source code

Inherited from LatticeCloud: __iter__, set_beam, set_time_extents

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Instance Variables [hide private]
pango.Context context
Pango context for drawing this cloud
set(DisplayWord) corrected_words
Set of user-selected words
pango.FontDescription desc
Basic Pango font description for drawing this cloud
int edge_resistance
"Gravity zone" around minimum extents to which we snap.
[int, int, int, int] extents
Logical extents of this cloud
set(DisplayWord) hyp_words
Set of original hypothesis word objects in this cloud
(int, int, int, int) max_extents
Maximum extents of this cloud
(int, int, int, int) min_extents
Minimum extents of this cloud
int min_font_size
Minimum font size to use, in pango.SCALE units
DisplayWord saved_word
Saved word from a previous click, for use in double-click handling
float scale
Scaling factor for drawing
  sign_x
Sign of a delta which "expands" the cloud horizontally
  sign_y
Sign of a delta which "expands" the cloud vertically
set(DisplayWord) words
Set of word objects contained in this cloud.

Inherited from LatticeCloud: beam, dag, end, max, min, nodes, start

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, size, context, desc, model, word)
(Constructor)

source code 
Initialize a DisplayCloud.
Parameters:
  • size ((int, int)) - Size of the parent object
  • context (pango.Context) - Pango context for drawing this cloud
  • desc (pango.FontDescription) - Basic Pango font description for drawing this cloud
  • model (LatticeModel) - LatticeModel to get this cloud from.
  • word (LatticeView.DisplayWord) - DisplayWord to use for the initial extents of this cloud.
Overrides: LatticeCloud.__init__

contains(self, x, y)

source code 
Returns True if point (x,y) is inside this cloud's extents.
Parameters:
  • x (int) - Horizontal position of picking point
  • y (int) - Vertical position of picking point
Returns: boolean
True if point (x,y) is inside this cloud's extents

y_expand(self, parent)

source code 
Expand the cloud to its maximum vertical size.
Parameters:
  • parent (LatticeView) - Parent widget

get_output_words(self)

source code 
Get the set of corrected words. If no corrections have been made, this will return the set of original hypothesis words encompassed by this cloud.
Returns: set(DisplayWord)
The set of corrected (or original) words. Note that this is a reference to this set. If you wish to manipulated it, you must copy it!

collapse(self, parent)

source code 
Collapse the cloud to its minimum size, retaining any user corrections.
Parameters:
  • parent (LatticeView) - Parent widget

assimilate(self, parent, other)

source code 
Assimilate a neighbouring (we hope) cloud into this one.
Parameters:
  • parent (LatticeView) - Parent widget
  • other (LatticeView.DisplayCloud) - Cloud to be assimilated

find_word(self, x, y)

source code 
Find and return the display word in this cloud which contains point (x,y).
Parameters:
  • x (int) - Horizontal pixel position (in parent coordinates)
  • y (int) - Vertical pixel position (in parent coordinates)
Returns: LatticeView.DisplayWord
Word in this cloud which contains point (x,y)

double_click(self, parent, x, y)

source code 
React to a double click.
Parameters:
  • parent (LatticeView) - Parent widget
  • x (int) - Click point X
  • y (int) - Click point Y

click(self, parent, x, y)

source code 
React to a discrete mouse click.
Parameters:
  • parent (LatticeView) - Parent widget
  • x (int) - Click point X
  • y (int) - Click point Y

drag_delta(self, parent, x, y, delta_x, delta_y)

source code 
React to drag motion of (delta_x, delta_y) to point (x,y).
Parameters:
  • parent (LatticeView) - Parent widget
  • x (int) - Destination point X
  • y (int) - Destination point Y
  • delta_x (int) - Horizontal distance travelled
  • delta_y (int) - Vertical distance travelled
Returns: (int, int)
The effective (x,y) delta after compensating for drag direction. This indicates the desired change in size for this cloud.

is_minimum(self)

source code 
Returns True if this cloud is at its minimum size.
Returns: boolean
True if this cloud is at its minimum size (duh)

end_drag(self, parent, x, y)

source code 
React to ending a drag at point (x,y)
Parameters:
  • parent (LatticeView) - Parent widget
  • x (int) - Destination point X
  • y (int) - Destination point Y

draw(self, gc)

source code 
Draw this cloud in a given graphics context.
Parameters:
  • gc (cairo.Context) - Cairo context (not to be confused with a Pango context) for drawing.