The concept of a graphical type enables the specification of an external graphical presentation for ConceptBase objects. The graphical type is declared using a special pre-defined attribute category. An application program then uses this information to determine the graphical presentation of an object.
The next subsection introduces the basic concepts behind graphical types, while section C.2 presents the standard graphical type definitions for the ConceptBase Graph Editor. Section C.3 describes the definition of application-specific types.
A specific graphical type is defined as an instance of the object GraphicalType. For the new Graph Editor implemented in Java, this class has been specialized in a class JavaGraphicalType. Instances of this class specify a graphical represenation of an object by defining graphical attributes such as shape, color, line thickness, font etc. Since the actual attributes and their admissible value depend on the used visualization tool, the definition of GraphicalType looks very simple.
GraphicalType in Class end
The declaration of a graphical type for a concrete object is done by using the attribute graphtype which is defined for Proposition and therefore available for all objects:
Proposition with attribute graphtype : GraphicalType end
The attribute can be defined explicitely for an object or can be specified by using a deductive rule (see section C.2 for an example). For the Graph Editor application included in the usage enviroment, one can attach a priority value to each graphical type. If there multiple graphtype attributes defined for one object, the graphical type with the highest priority value will be used.
Many applications employ multiple notations to provide different perspectives on the same set of objects. Each perspective emphasizes on a specific aspect of the world, such as the data oriented, the process oriented and the behavior oriented viewpoint, and uses an aspect-specific notation. A graphical notation (as e.g. the Entity-Relationship diagram) typically consists of a set of different graphical symbols (as e.g. diamonds, rectangles, and lines). A graphical palette is used to combine the set of graphical types that together form a notation:
Individual GraphicalPalette in Class with attribute contains : GraphicalType default : GraphicalType end
In such a setting the same object may participate in different perspectives. ConceptBase offers the possibility to specify multiple graphical types for the same object. A tool can then provide different graphical views on the same object. To get the desired graphical type of an object under a specific palette, an application program specifies the name of the actual graphical palette as answer format when querying the ConceptBase server. Although this mechanism is available for arbitrary application programs we restrict our description to the ConceptBase Graph Editor.
The default specification serves as a catch all: an answer object, for which none of the graphical types of the current palette is specified, is presented using the default graphical type of that palette.
The Graph Editor is implemented using the Java Programming Language. It is entirely based on the Swing toolkit (package javax.swing). The graphical objects shown in the Graph Editor are all instances of the class JComponent in the javax.swing package. User-defined representations of objects can be provided by overwriting a specific class of the Graph Editor (details are given below).
Based on our experience with the old graph browser for X11, we have extended the graphical type model for the Graph Editor. First, the class GraphicalType has been specialized by a class JavaGraphicalType:
Class JavaGraphicalType isA GraphicalType with attribute implementedBy : String; property : String; priority : Integer attribute,rule rPriority : $ forall jgt/JavaGraphicalType (not (exists i/Integer A_e(jgt,priority,i))) ==> A(jgt,priority,0) $ end Individual DefaultIndividualGT in JavaGraphicalType with attribute,property bgcolor : "210,210,210"; textcolor : "0,0,0"; linecolor : "0,0,0"; shape : "i5.cb.graph.shapes.Rect" attribute,implementedBy implBy : "i5.cb.graph.cbeditor.CBIndividual" end
The object DefaultIndividualGT is an example for the instantiation
of a graphical type.
The attribute implementedBy specifies the full name of the Java class
that provides the implementation for this graphical type. This class
has to be a sub class of "i5.cb.graph.cbeditor.CBUserObject"
.
The property attribute specifies name-value pairs which will
be used by the Java implementation to set certain properties, e.g.
color, shape, font1.
The priority value is used to resolve ambiguity
if multiple graphical types apply to one object. The graphical type
with the highest priority will be used. The rule specifies a default
value of 0 for the priority.
The graphical palette has also been extended. There are now defaults for different types of objects, and graphical types for implicit links can be defined. Thus, the default attribute defined in GraphicalPalette will not be used anymore. The contains attribute has still to be used, i.e. a graphical type will only be used if it is also contained in the current graphical palette. Although the attributes are not declared as single and necessary, each graphical palette should have at least one and at most one attribute in these categories.
Class JavaGraphicalPalette isA GraphicalPalette with attribute defaultIndividual : JavaGraphicalType; defaultLink : JavaGraphicalType; implicitIsA : JavaGraphicalType; implicitInstanceOf : JavaGraphicalType; implicitAttribute : JavaGraphicalType end
For the standard objects, there are a number of predefined graphical types. There are contained in the graphical palette DefaultJavaPalette which is used by default by the Graph Editor.
type of object | graphical type | style |
Individuals | DefaultIndividualGT | gray box |
Links | DefaultLinkGT | thin black line with label |
InstanceOf | DefaultInstanceOfGT | green line without label |
IsA | DefaultIsAGT | blue line without label |
Attribute | DefaultAttributeGT | black line with label |
Class | ClassGT | turquoise box |
SimpleClass | SimpleClassGT | pink oval |
MetaClass | MetaClassGT | light blue oval |
MetametaClass | MetametaGT | bright green oval |
QueryClass | QueryClassGT | red oval |
Implicit In | ImplicitInstanceOfGT | dashed green line |
Implicit IsA | ImplicitIsAGT | dashed blue line |
Implicit Attribute | ImplicitAttributeGT | dashed black line |
The object DefaultJavaPalette has also some rules which define the default relationship between objects and graphical types, e.g. all instances of Class have the graphical type ClassGT.
To support the user in defining his own graphical types we provide some examples and documentation of the properties.
There are two ways to customize the graphical types:
Both possibilities will presented in the next two subsections.
The easiest way to modify the representation of an object in the Graph Editor is to load an existing graphical type, modify its properties and store it as a new graphical type.
The properties available and there meaning are given in the following. Note that colors have to be given as RGB color value, e.g. "0,0,0" is black, "255,0,0" is red, "255,255,255" is white, etc. Furthermore, all attributes have to be strings, even if they are just numbers, e.g. use "1" instead of 1 as attribute value.
Edges with empty label (anonymous edge) are displayed with a square dot in the middle of the edge. The color of the square dot is by default the edgecolor and its size is set to 6 pixels. If the graphical type of an anonymous edge has bgcolor defined, then the square dot is adjusted to the edgewidth and displayed in bgcolor.
Do not forget to include the new graphical type into the graphical palette. It is not necessary to define a new graphical palette, you can extend the default palette. Furthermore, you have to define the graphtype attribute of some object in such a way that it refers to the new graphical type. Make sure, that the new graphical type has a higher priority than other graphical type which might apply (10 is the highest priority of the default graphical types).
An example of user-defined graphical types can be found in D.2.
The implementedBy attribute of a graphical type specifies the class name of a Java class implementing this graphical type. This class has to be a subclass of “i5.cb.graph.cbeditor.CBUserObject”. If you are going to implement your own class, it is most useful to extend CBIndividual or CBLink in the package i5.cb.graph.cbeditor.
The class CBUserObject provides several methods which can be overwritten to implement your own graphical types:
Furthermore, the CBUserObject class provides several methods which might be useful for implementing new graphical types:
Example: The following example defines a graphical type that uses a JButton to visualize the object. Only the method getSmallComponent is overwritten. The background color of the button will be changed if the property bgcolor has been defined. The example shows that the implementation of graphical types is quite simple.
import i5.cb.graph.cbeditor.*; import javax.swing.*; import java.awt.Component; /** * An example for a user defined CBUserObject */ public class MyOwnGraphType extends CBUserObject { public Component getSmallComponent() { JButton jButton=new JButton(this.getTelosObject().toString()); if(hasProperty("bgcolor")) jButton.setBackground(CBUtil.stringToColor(getProperty("bgcolor"))); return jButton; } }
The package i5.cb.graph.shape contains several shapes which might be useful for the ConceptBase Graph Editor. To use these shapes, you have to specify the full class name (including the package name) as value of the property shape of a graphical type.
class name | style |
Arrow | Head of an arrow pointing to the right |
Arrow2 | Complete arrow pointing up |
Cross | a cross (like the red cross) |
Diamond | a diamond/rhombus |
DoubleArrow | a horizontal arrow pointing in both directions |
Ellipse | Ellipse |
Hexagon, Octagon, Pentagon | as the name says |
Rect | a rectangle |
RoundRectangle | a rectangle with round corners |
Star | a star |
Triangle | a triangle |
XCross | a cross in the form of an X |
The class GraphShapePolygon is the base class for most of the shapes defined here and might be used to define your own shapes. Its constructor is identical with the constructor of java.awt.Polygon:
public GraphShapePolygon(int[] xs, int[] ys, int num)
xs and ys describe the coordinates of the corners of the polygon and num is the length of the array xs or ys. Start and end point should be identical. For example, to define a triangle, you need the following code:
import i5.cb.graph.shape.GraphShapePolygon; public class Triangle extends GraphShapePolygon { private static int xpoints[]={0,2,4,0}; private static int ypoints[]={2,0,2,2}; public Triangle() { super(xpoints,ypoints,4); } }