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 |
Undocumented |
Method | cycle |
Undocumented |
Method | draw |
Draw everything (from scratch). |
Method | draw |
Undocumented |
Method | erase |
Undocumented |
Method | get |
Undocumented |
Method | mark |
Mark an edge |
Method | markonly |
Undocumented |
Method | page |
Undocumented |
Method | page |
Undocumented |
Method | remove |
Undocumented |
Method | scroll |
Undocumented |
Method | scroll |
Undocumented |
Method | set |
Undocumented |
Method | unmark |
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 |
Undocumented |
Method | _add |
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 |
Given a new edge, recalculate: |
Method | _color |
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 |
Draw a single edge on the ChartView. |
Method | _draw |
Draw location lines. These are vertical gridlines used to show where each location unit is. |
Method | _draw |
Draw the sentence string. |
Method | _draw |
Undocumented |
Method | _draw |
No summary |
Method | _edge |
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 |
Undocumented |
Method | _grow |
Grow the window, if necessary |
Method | _init |
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 |
Helper for __init__: construct a canvas with a scrollbar. |
Constant | _CHART |
Undocumented |
Constant | _LEAF |
Undocumented |
Constant | _MARGIN |
Undocumented |
Constant | _TREE |
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 |
The canvas we're using to display the chart itself. |
Instance Variable | _chart |
The height of the chart canvas. |
Instance Variable | _chart |
Undocumented |
Instance Variable | _chart |
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 |
The canvas we're using to display the sentence text. May be None, if we're not displaying the sentence text. |
Instance Variable | _sentence |
The height of the sentence canvas. |
Instance Variable | _sysfont |
Undocumented |
Instance Variable | _text |
The height of a text string (in the normal font). |
Instance Variable | _tree |
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 |
The height of the tree |
Instance Variable | _tree |
Undocumented |
Instance Variable | _tree |
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 |
Undocumented |
Instance Variable | _treetoks |
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. |
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.
Add a single edge to the ChartView:
- Call analyze_edge to recalculate display parameters
- Find an available level
- Call _draw_edge
Analyze the sentence string, to figure out how big a unit needs to be, How big the tree should be, etc.
Given a new edge, recalculate:
- _text_height
- _unitsize (if the edge text is too big for the current _unitsize, then increase _unitsize)
Color in an edge with the given colors. If no colors are specified, use intelligent defaults (dependent on selection, etc.)
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.
Parameters | |
treetok | Undocumented |
index | The index of the first leaf in the tree. |
depth | Undocumented |
Returns | |
The index of the first leaf after the tree. |
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.
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.
The chart that we are giving a view of. This chart may be modified; after it is modified, you should call update.
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.
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).
The canvas we're using to display the sentence text. May be None, if we're not displaying the sentence text.
The canvas we're using to display the tree that each edge spans. May be None, if we're not displaying trees.