The Tensegrity Graph Framework provides several interfaces and implementations for a complex
graphical component called a Composite. The framework classes involved
are used to provide the visualization backbone for drawing visual Node
and visual Edge instances.
A Composite is basically a container of Primitive shapes - atomic,
generic geometric objects that specify lines, rectangles, and ellipses.
A Composite container may be nested inside another container so that
both parent and child Composite objects may be handled as one. Moreover,
a Composite may be added to and removed from a CompositeView, a
component which provides the basic drawing, user interaction and layout
functionalities in a Graph application. Finally, A Composite is always
positioned inside a relative CoordinateSystem, which uses a Scale to
place objects in two dimensions.
Being the top-level Composite container, the CompositeView interface
is finally merged into the VisualGraphView interface
specified in the Graph package. This allows clients to speak to a
top-level VisualGraph as if it were a CompositeView as well.
This chapter will thoroughly explain the concepts behind the Composite
components. This includes information about how they can be constructed
and filled with Primitive parts. First we discuss scales and coordinate
systems, however.
A Scale provides a basic system of units for measuring and placing objects
in a view. Therefore, any visual object being displayed is done so in the
context of such a Scale, which exists for each dimension within the
2-dimensional CoordinateSystem.
Scales are constrained by two values: the minimum and the maximum numbers
which define the Scale's interval and conversion logic. This basically
configures the algorithm which converts the logical units of a graphical object
into the logical units of a top-level coordinate system or the physical units on
the screen. It is very likely that most of the scales you will deal with shall
have a linear ratio. Non-linear ratios, such as logarithmic ones, exist as well.
Within the Tensegrity Graph Framework, you will often find that a CoordinateSystem and a Scale
are nested. Any Composite must use its own CoordinateSystem to properly
scale and position contained Primitive and child Composite objects.
A Scale is an object that represents a scale from a
mathematical point of view. It consists of two values: the minimum
scale value and the maximum scale value, which together define an
interval or numerical range. A Scale can be implemented
as a linear or logarithmic Scale.
Linear Scale (min: 0, max: 10)

Linear Scale (min: -500, max: 2000)

To avoid creating identical Scale objects (same type
and interval), instances are pooled in the ScalePool
singleton. Since many clients may have a reference to the very
same instance, Scale objects are immutable. A mutable
version is defined by the MutableScale interface.
In order to be able to convert a value from one Scale into the range of
another, the Scale interface defines the following methods:
double descale(double, double, double)
Converts the value given by valueToDescale from the range
given by minimum and maximum to the range of
this Scale. The mathematical expression for this is:
valueToScale *
(maximum scale value - minimum scale value) /
(maximum - minimum)
.
double getDescaleFactor(double, double)
Returns the scale factor that converts a value from the range given
by minimum and maximum to range of this
Scale. The mathematical expression for this is:
(maximum scale value - minimum scale value) /
(maximum - minimum)
.
double getScaleFactor(double, double)
Returns the scale factor that converts a value from the range of this
Scale to the range given by minimum and
maximum. The mathematical expression for this is:
(maximum - minimum) /
(maximum scale value - minimum scale value)
.
double scale(double, double, double)
Converts the value given by valueToScale from the range of
this Scale to the range given by minimum and
maximum. The mathematical expression for this is:
valueToScale *
(maximum - minimum) /
(maximum scale value - minimum scale value)
.
The direction of a Scale can be reversed by exchanging the minimum and
maximum values. In this case, the minimum value will be greater than the
maximum value. In this way it becomes possible to set the orientation of
a CoordinateSystem in any of four possible directions.
© 2004, 2005 Tensegrity Software GmbH