class documentation

class ChartView(object): (source)

Constructor: ChartView(chart, root, **kw)

View In Hierarchy

A component for viewing charts. This is used by ChartParserApp to allow students to interactively experiment with various chart parsing techniques. It is also used by Chart.draw().

Method __init__ Construct a new Chart display.
Method add_callback Undocumented
Method cycle_tree Undocumented
Method draw Draw everything (from scratch).
Method draw_tree Undocumented
Method erase_tree Undocumented
Method get_font_size Undocumented
Method mark_edge Mark an edge
Method markonly_edge Undocumented
Method page_down Undocumented
Method page_up Undocumented
Method remove_callback Undocumented
Method scroll_down Undocumented
Method scroll_up Undocumented
Method set_font_size Undocumented
Method unmark_edge Unmark an edge (or all edges)
Method update Draw any edges that have not been drawn. This is typically called when a after modifies the canvas that a CanvasView is displaying. update will cause any edges that have been added to the chart to be drawn.
Method view_edge Undocumented
Method _add_edge Add a single edge to the ChartView:
Method _analyze Analyze the sentence string, to figure out how big a unit needs to be, How big the tree should be, etc.
Method _analyze_edge Given a new edge, recalculate:
Method _color_edge Color in an edge with the given colors. If no colors are specified, use intelligent defaults (dependent on selection, etc.)
Method _configure The configure callback. This is called whenever the window is resized. It is also called when the window is first mapped. It figures out the unit size, and redraws the contents of each canvas.
Method _draw_edge Draw a single edge on the ChartView.
Method _draw_loclines Draw location lines. These are vertical gridlines used to show where each location unit is.
Method _draw_sentence Draw the sentence string.
Method _draw_treecycle Undocumented
Method _draw_treetok No summary
Method _edge_conflict Return True if the given edge overlaps with any edge on the given level. This is used by _add_edge to figure out what level a new edge should be added to.
Method _fire_callbacks Undocumented
Method _grow Grow the window, if necessary
Method _init_fonts Undocumented
Method _resize Update the scroll-regions for each canvas. This ensures that everything is within a scroll-region, so the user can use the scrollbars to view the entire display. This does not resize the window.
Method _sb_canvas Helper for __init__: construct a canvas with a scrollbar.
Constant _CHART_LEVEL_SIZE Undocumented
Constant _LEAF_SPACING Undocumented
Constant _MARGIN Undocumented
Constant _TREE_LEVEL_SIZE Undocumented
Instance Variable _boldfont Undocumented
Instance Variable _callbacks Undocumented
Instance Variable _chart The chart that we are giving a view of. This chart may be modified; after it is modified, you should call update.
Instance Variable _chart_canvas The canvas we're using to display the chart itself.
Instance Variable _chart_height The height of the chart canvas.
Instance Variable _chart_level_size Undocumented
Instance Variable _chart_sb Undocumented
Instance Variable _compact Undocumented
Instance Variable _edgelevels A list of edges at each level of the chart (the top level is the 0th element). This list is used to remember where edges should be drawn; and to make sure that no edges are overlapping on the chart view.
Instance Variable _edgetags A dictionary mapping from edges to the tags of the canvas elements (lines, etc) used to display that edge. The values of this dictionary have the form (linetag, rhstag1, dottag, rhstag2, lhstag).
Instance Variable _font Undocumented
Instance Variable _fontsize The current font size
Instance Variable _loclines Undocumented
Instance Variable _marks A dictionary from edges to marks. Marks are strings, specifying colors (e.g. 'green').
Instance Variable _root The root window.
Instance Variable _sentence The list of tokens that the chart spans.
Instance Variable _sentence_canvas The canvas we're using to display the sentence text. May be None, if we're not displaying the sentence text.
Instance Variable _sentence_height The height of the sentence canvas.
Instance Variable _sysfont Undocumented
Instance Variable _text_height The height of a text string (in the normal font).
Instance Variable _tree_canvas The canvas we're using to display the tree that each edge spans. May be None, if we're not displaying trees.
Instance Variable _tree_height The height of the tree
Instance Variable _tree_sb Undocumented
Instance Variable _tree_tags Undocumented
Instance Variable _treetags A list of all the tags that make up the tree; used to erase the tree (without erasing the loclines).
Instance Variable _treetoks Undocumented
Instance Variable _treetoks_edge Undocumented
Instance Variable _treetoks_index Undocumented
Instance Variable _unitsize Pixel size of one unit (from the location). This is determined by the span of the chart's location, and the width of the chart display canvas.
def __init__(self, chart, root=None, **kw): (source)

Construct a new Chart display.

def add_callback(self, event, func): (source)

Undocumented

def cycle_tree(self): (source)

Undocumented

def draw(self): (source)

Draw everything (from scratch).

def draw_tree(self, edge=None): (source)

Undocumented

def erase_tree(self): (source)

Undocumented

def get_font_size(self): (source)

Undocumented

def mark_edge(self, edge, mark='#0df'): (source)

Mark an edge

def markonly_edge(self, edge, mark='#0df'): (source)

Undocumented

def page_down(self, *e): (source)

Undocumented

def page_up(self, *e): (source)

Undocumented

def remove_callback(self, event, func=None): (source)

Undocumented

def scroll_down(self, *e): (source)

Undocumented

def scroll_up(self, *e): (source)

Undocumented

def set_font_size(self, size): (source)

Undocumented

def unmark_edge(self, edge=None): (source)

Unmark an edge (or all edges)

def update(self, chart=None): (source)

Draw any edges that have not been drawn. This is typically called when a after modifies the canvas that a CanvasView is displaying. update will cause any edges that have been added to the chart to be drawn.

If update is given a chart argument, then it will replace the current chart with the given chart.

def view_edge(self, edge): (source)

Undocumented

def _add_edge(self, edge, minlvl=0): (source)

Add a single edge to the ChartView:

  • Call analyze_edge to recalculate display parameters
  • Find an available level
  • Call _draw_edge
def _analyze(self): (source)

Analyze the sentence string, to figure out how big a unit needs to be, How big the tree should be, etc.

def _analyze_edge(self, edge): (source)

Given a new edge, recalculate:

  • _text_height
  • _unitsize (if the edge text is too big for the current _unitsize, then increase _unitsize)
def _color_edge(self, edge, linecolor=None, textcolor=None): (source)

Color in an edge with the given colors. If no colors are specified, use intelligent defaults (dependent on selection, etc.)

def _configure(self, e): (source)

The configure callback. This is called whenever the window is resized. It is also called when the window is first mapped. It figures out the unit size, and redraws the contents of each canvas.

def _draw_edge(self, edge, lvl): (source)

Draw a single edge on the ChartView.

def _draw_loclines(self): (source)

Draw location lines. These are vertical gridlines used to show where each location unit is.

def _draw_sentence(self): (source)

Draw the sentence string.

def _draw_treecycle(self): (source)

Undocumented

def _draw_treetok(self, treetok, index, depth=0): (source)
Parameters
treetokUndocumented
indexThe index of the first leaf in the tree.
depthUndocumented
Returns
The index of the first leaf after the tree.
def _edge_conflict(self, edge, lvl): (source)

Return True if the given edge overlaps with any edge on the given level. This is used by _add_edge to figure out what level a new edge should be added to.

def _fire_callbacks(self, event, *args): (source)

Undocumented

def _grow(self): (source)

Grow the window, if necessary

def _init_fonts(self, root): (source)

Undocumented

def _resize(self): (source)

Update the scroll-regions for each canvas. This ensures that everything is within a scroll-region, so the user can use the scrollbars to view the entire display. This does not resize the window.

def _sb_canvas(self, root, expand='y', fill='both', side='bottom'): (source)

Helper for __init__: construct a canvas with a scrollbar.

_CHART_LEVEL_SIZE: int = (source)

Undocumented

Value
40
_LEAF_SPACING: int = (source)

Undocumented

Value
10
_MARGIN: int = (source)

Undocumented

Value
10
_TREE_LEVEL_SIZE: int = (source)

Undocumented

Value
12
_boldfont = (source)

Undocumented

_callbacks: dict = (source)

Undocumented

The chart that we are giving a view of. This chart may be modified; after it is modified, you should call update.

_chart_canvas = (source)

The canvas we're using to display the chart itself.

_chart_height = (source)

The height of the chart canvas.

_chart_level_size = (source)

Undocumented

_chart_sb = (source)

Undocumented

_compact: int = (source)

Undocumented

_edgelevels: list = (source)

A list of edges at each level of the chart (the top level is the 0th element). This list is used to remember where edges should be drawn; and to make sure that no edges are overlapping on the chart view.

_edgetags: dict = (source)

A dictionary mapping from edges to the tags of the canvas elements (lines, etc) used to display that edge. The values of this dictionary have the form (linetag, rhstag1, dottag, rhstag2, lhstag).

Undocumented

_fontsize = (source)

The current font size

_loclines: list = (source)

Undocumented

_marks: dict = (source)

A dictionary from edges to marks. Marks are strings, specifying colors (e.g. 'green').

The root window.

_sentence = (source)

The list of tokens that the chart spans.

_sentence_canvas = (source)

The canvas we're using to display the sentence text. May be None, if we're not displaying the sentence text.

_sentence_height = (source)

The height of the sentence canvas.

_sysfont = (source)

Undocumented

_text_height = (source)

The height of a text string (in the normal font).

_tree_canvas = (source)

The canvas we're using to display the tree that each edge spans. May be None, if we're not displaying trees.

_tree_height = (source)

The height of the tree

_tree_sb = (source)

Undocumented

_tree_tags: list = (source)

Undocumented

_treetags = (source)

A list of all the tags that make up the tree; used to erase the tree (without erasing the loclines).

_treetoks = (source)

Undocumented

_treetoks_edge = (source)

Undocumented

_treetoks_index = (source)

Undocumented

_unitsize = (source)

Pixel size of one unit (from the location). This is determined by the span of the chart's location, and the width of the chart display canvas.