| Home | Trees | Index | Help |
|---|
| Package ocempgui :: Package widgets :: Module Diagram :: Class Diagram |
|
object--+ |INotifyable--+ |BaseObject--+ |object--+ | | |Sprite--+ |BaseWidget--+ | Diagram
Graph2D
Diagram () -> Diagram
An abstract widget class for diagram and graph implementations.
The Diagram class contains the minimum set of attributes and methods
needed to visualize diagrams or graphs from arbitrary data.
Diagrams can have different resolutions, dependant on the value
range, that should be displayed. Inheritors thus have to implement
the 'units' attribute and its related methods get_units() and
set_units(), which define, how many pixels between each full unit
have to be left. Greater values usually result in a higher
resolution, resp. pixel amount between the values.
To allow the user to know about the kind of data, that is evaluated
and displayed, the 'scale_units' attribute and its related methods
get_scale_units() and set_scale_units() must be implemented. Those
define the concrete type of data, that is displayed on each axis of
the diagram (e.g. cm, inch, kg...).
The 'axes' attribute and its related methods get_axes() and
set_axes(), which have to be implemented. denote the axes, which are
used to set the data and its results into relation. A typical
cartesian coordinate plane for example will have two axes (x and y).
The 'orientation' attribute should be respected by inheritors to
allow displaying data in a vertical or horizontal align.
diagram.orientation = ORIENTATION_HORIZONTAL
diagram.set_orientation (ORIENTATION_VERTICAL)
The Diagram contains a 'negative' attribute and set_negative()
method, which indicate, whether negative values should be shown or
not.
diagram.negative = True
diagram.set_negative = False
The 'origin' attribute and set_origin() method set the point of
origin of the diagram on its widget surface and denote a tuple of an
x and y value. Inheritors should use this to set the point of origin
of their diagram type. Most diagram implementors usually would use
this as a relative coordinate to the bottom left corner of the
widget surface.
Note, that this is different from a real relative position on the
widget surface, as those are related to the topleft corner
diagram.origin = 10, 10
diagram.set_origin (20, 20)
The 'data' attribute and set_data() method set the data to be
evaluated by the diagram inheritor using the evaluate() method. It
is up to the inheritor to perform additional sanity checks.
diagram.data = mydata
diagram.set_data (mydata)
An evaluation function, which processes the set data can be set
using the 'eval_func' attribute or set_eval_func() method. If set,
the evaluate() method will process the set data using the eval_func
and store the return values in its 'values' attribute. Otherwise, the
values will be set to the data.
def power_1 (x):
return x**2 - x
diagram.eval_func = power_1
The evaluate() method of the widget distinguishes between the type
of data and will act differently, dependant on whether it is a
sequence or not. Lists and tuples will be passed to the eval_func
using the python map() function, else the complete data will be
passed to the eval_func:
# Data is list or tuple:
self.values = map (self.eval_func, data)
# Any other type of data:
self.values = self.eval_func (data)
The result values can also be set manually without any processing
using the 'values' attribute and set_values() method. This can be
useful for inheritors like a bar chart for example.
self.values = myvalues
self.set_values (myvalues)
A concrete implementation of the Diagram class can be found as
Graph2D widget within this module.
Default action (invoked by activate()):
None
Mnemonic action (invoked by activate_mnemonic()):
None
Attributes:
scale_units - The scale unit(s) to set for the axes.
units - Pixels per unit to set.
axes - The axes to show.
negative - Indicates, that negative vaues should be taken into
account.
orientation - The orientation mapping of the axes.
origin - The position of the point of origin on the widget.
data - Data to evaluate.
values - Result values of the set data after evaluation.
eval_func - Evaluation function to calculate the values.
| Method Summary | |
|---|---|
__init__(self)
| |
D.evaluate () -> None | |
D.get_axes (...) -> None | |
D.get_scale_units (...) -> None | |
D.set_units (...) -> None | |
D.set_axes (...) -> None | |
D.set_data (...) -> None | |
D.set_eval_func (...) -> None | |
D.set_negative (...) -> None | |
D.set_orientation (...) -> None | |
D.set_origin (...) -> None | |
D.set_scale_units (...) -> None | |
D.set_units (...) -> None | |
D.set_values (...) -> None | |
| Inherited from BaseWidget | |
W.activate () -> None | |
W.activate_mnemonic (...) -> bool | |
W.check_sizes (...) -> int, int | |
W.create_style () -> WidgetStyle | |
For debugging usage only | |
W.destroy () -> None | |
W.draw () -> None | |
W.draw_bg () -> Surface | |
W.get_style () -> WidgetStyle | |
B.initclass () -> None (Class method) | |
W.lock () -> None | |
W.notify (...) -> None | |
W.rect_to_client (...) -> pygame.Rect | |
W.set_depth (...) -> None | |
W.set_dirty (...) -> None | |
W.set_entered (...) -> None | |
W.set_event_area (...) -> None | |
W.set_event_manager (...) -> None | |
W.set_focus (...) -> bool | |
W.set_index (...) -> None | |
W.set_indexable (...) -> None | |
W.set_maximum_size (...) -> None | |
W.set_minimum_size (...) -> None | |
W.set_opacity (...) -> None | |
W.set_position (...) -> None | |
W.set_sensitive (...) -> None | |
W.set_size (...) -> None | |
W.set_state (...) -> None | |
W.set_style (...) -> None | |
W.set_tooltip (...) -> None | |
W.unlock () -> None | |
W.update (...) -> None | |
W._get_rect () -> pygame.Rect | |
W._get_rect_attr (...) -> var | |
W._set_rect_attr (...) -> None | |
| Inherited from BaseObject | |
B.connect_signal (...) -> EventCallback | |
B.disconnect_signal (...) -> None | |
B.emit (...) -> bool | |
B.run_signal_handlers (...) -> None | |
| Inherited from Sprite | |
| |
add(group or list of of groups, ...) add a sprite to container | |
| |
alive() -> bool check to see if the sprite is in any groups | |
groups() -> list of groups list used sprite containers | |
kill() remove this sprite from all groups | |
remove(group or list of groups, ...) remove a sprite from container | |
| |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
| Property Summary | |
|---|---|
axes: The axes to show. | |
data: The data to evaluate. | |
eval_func: The evaluation function for calculation. | |
negative: Indicates, whether negative values are shown. | |
orientation: The orientation of the axes. | |
origin: Coordinates of the point of origin on the widget | |
scale_units: The scale units of the axes. | |
units: The pixels per unit to set. | |
values: The calculated values of the set data. | |
| Inherited from BaseWidget | |
bottom | |
bottomleft | |
bottomright | |
center | |
centerx | |
centery | |
controls: Widgets associated with the widget. | |
depth: The z-axis layer depth of the widget. | |
dirty: Indicates, whether the widget need to be redrawn. | |
entered: Indicates, whether the widget is entered. | |
eventarea: The area, which gets the events. | |
focus: The focus of the widget. | |
h | |
height | |
image: The visible surface of the widget. | |
index: The tab index position of the widget. | |
indexable: The IIndexable, the widget is attached to. | |
left | |
locked: Indicates, whether the widget is locked. | |
maxsize: The maximum size to occupy by the widget. | |
midbottom | |
midleft | |
midright | |
midtop | |
minsize: The guaranteed size of the widget. | |
opacity: The opacity of the widget. | |
position: The position of the topleft corner. | |
rect: The area occupied by the widget. | |
right | |
sensitive: The sensitivity of the widget. | |
size | |
state: The current state of the widget. | |
style: The style of the widget. | |
tooltip: The tool tip text to display for the widget. | |
top | |
topleft | |
topright | |
w | |
width | |
x | |
y | |
| Inherited from BaseObject | |
manager: The event manager to use by the object. | |
| Instance Method Details |
|---|
evaluate(self)D.evaluate () -> None Calulates the result values from the set data. Calculates the result values from the set the data using the set evaluation function. If the set data is a sequence, eval_func will be applied to each item of it (using map()) to build the return values: values = map (eval_func, data) If the set data is not a list or tuple, the data will be passed in it entirety to eval_func in order to calculate the return values: values = eval_func (data) The 'negative' attribute neither does affect the data nor the return values. |
get_axes(self)D.get_axes (...) -> None Gets the amount and names of the axes. This method has to be implemented by inherited widgets. |
get_scale_units(self)D.get_scale_units (...) -> None Gets the scale units of the axes. This method has to be implemented by inherited widgets. |
get_units(self)D.set_units (...) -> None Gets the pixels per unit for dimensioning. This method has to be implemented by inherited widgets. |
set_axes(self, axes)D.set_axes (...) -> None Sets the amount and names of the axes. This method has to be implemented by inherited widgets. |
set_data(self, data)D.set_data (...) -> None Sets the data to evaluate. This method does not perform any consistency checking or whatsoever. |
set_eval_func(self, func)D.set_eval_func (...) -> None Sets the evaluation function for the data. Raises a TypeError, if func is not callable. |
set_negative(self, negative=True)D.set_negative (...) -> None Sets the indicator, whether negative values should be shown. |
set_orientation(self, orientation='horizontal')D.set_orientation (...) -> None Sets the orientation of the axes. Raises a ValueError, if the passed argument is not a value of the ORIENTATION_TYPES tuple. |
set_origin(self, x, y)D.set_origin (...) -> None Sets the coordinates of the point of origin on the widget. Raises a TypeError, if the passed arguments are not integers. |
set_scale_units(self, units)D.set_scale_units (...) -> None Sets the scale units of the axes. This method has to be implemented by inherited widgets. |
set_units(self, units)D.set_units (...) -> None Sets the pixels per unit for dimensioning. This method has to be implemented by inherited widgets. |
set_values(self, values)D.set_values (...) -> None Sets the values without processing the data. |
| Property Details |
|---|
axesThe axes to show.
|
dataThe data to evaluate.
|
eval_funcThe evaluation function for calculation.
|
negativeIndicates, whether negative values are shown.
|
orientationThe orientation of the axes.
|
originCoordinates of the point of origin on the widget
|
scale_unitsThe scale units of the axes.
|
unitsThe pixels per unit to set.
|
valuesThe calculated values of the set data.
|
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Thu Jan 10 10:18:45 2008 | http://epydoc.sf.net |