[xgap] 6.2 Graphic Objects in Sheets

[Up] [Previous] [Next] [Index]

# 6.2 Graphic Objects in Sheets

All graphics within graphic sheets are so called graphic objects. They are GAP objects in the category `IsGraphicObject`. These objects are linked internally to the actual graphics within the window. You can modify these objects via certain operations which leads to the corresponding change of the real graphics on the screen. The types of graphic objects supported in XGAP are: boxes, circles, discs, diamonds, rectangles, lines, texts, vertices and connections. Vertices are compound objects consisting of a circle, rectangle oder diamond with a short text inside. They remember their connections to other vertices. That means that if for example the position of a vertex is changed, the line which makes the connection to some other vertex is also changed automatically. For every graphic object there is a constructor which has the same name as the graphic object (e.g. `Box` is the constructor for boxes).

- `IsGraphicObject(` gobj`) C`

  This is the category in which all graphic objects are.

  Constructors:

- `Box(` sheet`,` x`,` y`,` w`,` h`) O`
- `Box(` sheet`,` x`,` y`,` w`,` h`,` defaults`) O`

  creates a new graphic object, namely a filled black box, in the graphic sheet sheet and returns a GAP record describing this object. The four corners of the box are (x,y), (x+w,y), (x+w,y+h), and (x,y+h).

  Note that the box is w+1 pixel wide and h+1 pixels high.

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Box`, except that the color of the box will be color. See Color Models for how to select a color.

  See operations for graphic objects for a list of operations that apply to boxes.

  Note that `Reshape` for boxes takes three parameters, namely the box object, the new width, and the new height of the box.

- `Circle(` sheet`,` x`,` y`,` r`) O`
- `Circle(` sheet`,` x`,` y`,` r`,` defaults`) O`

  creates a new graphic object, namely a black circle, in the graphic sheet sheet and returns a GAP record describing this object. The center of the circle is (x,y) and the radius is r.

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Circle`, except that the color of the circle will be color. See Color Models for how to select a color. If the record contains a component `width` of value width, the line width of the circle is set accordingly.

  See operations for graphic objects for a list of operations that apply to circles.

  Note that `Reshape` for circles takes two parameters, namely the circle object, and the new radius of the circle.

- `Disc(` sheet`,` x`,` y`,` r`) O`
- `Disc(` sheet`,` x`,` y`,` r`,` defaults`) O`

  creates a new graphic object, namely a disc (a black filled circle), in the graphic sheet sheet and returns a GAP record describing this object. The center of the disc is (x,y) and the radius is r.

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Disc`, except that the color of the disc will be color. See Color Models for how to select a color.

  See operations for graphic objects for a list of operations that apply to discs.

  Note that `Reshape` for discs takes two parameters, namely the disc object, and the new radius.

- `Diamond(` sheet`,` x`,` y`,` w`,` h`) O`
- `Diamond(` sheet`,` x`,` y`,` w`,` h`,` defaults`) O`

  creates a new graphic object, namely a black diamond, in the graphic sheet sheet and returns a GAP record describing this object. The left corner of the diamond is (x,y), the others are (x+w,y-h), (x+w,y+h), and (x+2w,y).

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Diamond`, except that the color of the diamond will be color. See Color Models for how to select a color. If the record contains a component `width` with integer value width, the line width is set accordingly.

  See operations for graphic objects for a list of operations that apply to diamonds.

  Note that `Reshape` for diamonds takes three parameters, namely the diamond object, and the new width and height values.

- `Rectangle(` sheet`,` x`,` y`,` w`,` h`) O`
- `Rectangle(` sheet`,` x`,` y`,` w`,` h`,` defaults`) O`

  creates a new graphic object, namely a black rectangle, in the graphic sheet sheet and returns a GAP record describing this object. The four corners of the box are (x,y), (x+w,y), (x+w,y+h), and (x,y+h).

  Note that the rectangle is w+1 pixel wide and h+1 pixels high.

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Rectangle`, except that the color of the rectangle will be color. See Color Models for how to select a color. If the record contains a component `width` with integer value width, the line width is set accordingly.

  See operations for graphic objects for a list of operations that apply to rectangles.

  Note that `Reshape` for rectangles takes three parameters, namely the rectangle object, and the new width and height values.

- `Line(` sheet`,` x`,` y`,` w`,` h`) O`
- `Line(` sheet`,` x`,` y`,` w`,` h`,` defaults`) O`

  creates a new graphic object, namely a black line, in the graphic sheet sheet and returns a GAP record describing this object. The line has the end points (x,y) and (x+w,y+h).

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Line`, except that the color of the line will be color. See Color Models for how to select a color. If the record contains a component `width` with integer value width, the line width is set accordingly. If the record contains a component `label` with a string value label, a text object is attached as a label to the line.

  See operations for graphic objects for a list of operations that apply to lines.

  Note that `Reshape` for lines takes three parameters, namely the line object, and the new w and h value. `Change` for lines in contrast takes five parameters, namely the line object and all four coordinates like in the original call.

- `Text(` sheet`,` font`,` x`,` y`,` str`) O`
- `Text(` sheet`,` font`,` x`,` y`,` str`,` defaults`) O`

  creates a new graphic object, namely the string str as a black text, in the graphic sheet sheet and returns a GAP record describing this object. The text has the baseline of the first character at (x,y).

  If a record defaults is given and contains a component `color` of value color, the function works like the first version of `Text`, except that the color of the text will be color. See Color Models for how to select a color.

  See operations for graphic objects for a list of operations that apply to texts.

  Note that `Reshape` for texts takes two parameters, namely the text object, and the new font. Use `Relabel` to change the string of the text.

  Operations for graphic objects:

- `Connection(` vertex`,` vertex`) O`
- `Connection(` vertex`,` vertex`,` defaults`) O`

  Connects two vertices with a line. The second variation can get a defaults record for the actual line. The same entries as in the defaults record for lines are allowed.

- `Disconnect(` vertex`,` vertex`) O`

  Deletes connection between two vertices.

- `Draw(` object`) O`

  This operation (re-)draws a graphic object on the screen. You normally do not need to call this yourself. But in some rare cases of object overlaps you could find it useful.

- `Delete(` sheet`,` object`) O`
- `Delete(` object`) O`

  Deletes a graphic object. Calls `Destroy` first, so the graphic object is no more alive afterwards. The object is deleted from the list of objects in its graphic sheet. There is no way to reactivate such an object afterwards.

- `Destroy(` object`) O`

  Destroys a graphic object. It disappears from the screen and will not be alive any more after this call. Note that object is not deleted from the list of objects in its graphic sheet sheet. This makes it possible to `Revive` it again. In order to delete object from sheet, use `Delete(` sheet`,` obj`)`, which calls `Destroy` for obj.

- `Revive(` object`) O`

  Note that object must be in the list of objects in its graphic sheet! So this is only possible for `Destroyed`, not for `Deleted` graphic objects.

- `Move(` object`,` x`,` y`) O`

  Changes the position of a graphic object absolutely. It must be alive and will be moved at once on the screen.

- `MoveDelta(` object`,` dx`,` dy`) O`

  Changes the position of a graphic object relatively. It must be alive and will be moved at once on the screen.

- `PSString(` object`) O`

  Creates a postscript string which describes the graphic object. Normally you do not need to call this because it is only used internally if the user exports the whole graphic sheet to encapsulated postscript.

- `PrintInfo(` object`) O`

  This operation prints debugging info about a graphic object.

- `Recolor(` object`,` col`) O`

  Changes the color of a graphic object. See Color Models for how to select a color.

- `Reshape(` object`, ... ) O`

  Changes the shape of a graphic object. The parameters depend on the type of the object. See the descriptions of the constructors for the actual usage.

- `\in`

  This infix operation needs a vector of two integers to its left and a graphic object to its right (``vector of two integers'' means a list of two integers e.g. `[15,9]`). It determines, if the position given by the two integer coordinates is inside (e.g. for boxes) or on (e.g. for lines) the graphic objects. Returns a boolean value.

- `Change(` object`, ... ) O`

  Changes the shape of a graphic object. The parameters depend on the type of the object. See the descriptions of the constructors for the actual usage.

- `Relabel(` object`,` str`) O`

  Changes the label of a graphic object. The second argument must always be a string.

- `SetWidth(` object`,` w`) O`

  Changes the line width of the graphic object. The line width w must be a relatively small integer.

- `Highlight(` vertex`) O`
- `Highlight(` vertex`,` flag`) O`

  In the first form this operation switches the highlighting status of a vertex to ON. In the second form the flag decides about ON or OFF. Highlighting normally means a thicker line width and a change in color.

  [Up] [Previous] [Next] [Index]