Art Show | Course Home | Homework | Labs | Programming | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science P125
Introduction to Computer Science

Michael Goldwasser

Spring 2005

Dept. of Math & Computer Science

Supplemental Documentation: The EzWindows library

Reading: Ch. 3.9 and App. E as a reference

To continue developing our use of interesting objects, we will experiment a bit with a graphics library provided by the authors of our textbook. This library is known as EzWindows and has been installed on our department machines. Please note that this is not part of the standard C++ libraries but instead has been designed by the authors for instructional purposes. Programming Note: If you are trying to do any of your programming without use of your department account, you will not be able to use EzWindows (unless you install it yourself).

The EzWindows library is initially discussed, in part, in Chapter 3.9 of the text, and discussed in a variety of places later in the text as well. Appendix E of the text (starting at page 891) gives more complete and organized documentation of the entire package. Be warned that that documentation is more complete than we need; we will only be discussing a subset of the library functionality. But still it gives a nice overview if scanned.


Preliminaries

The graphical system is based on the use of a coordinate system for which the origin is at the top-left corner. The positive x-axis is to the right, and the positive y-axis is downward (note the difference in orientation between this common computer science convention and the common mathematics conventions).

The unit of measure is centimeters (or fractions thereof). Of course, this may be only approximate depending on the system.

A color type has been defined to include a palette of common colors, identified with the names: Black, White, Red, Green, Blue, Yellow, Cyan, Magenta


Relevant Classes


class Position

This class is really defined as a convenience for the rest of the package. The graphics package deals with a two-dimenensional coordinate system. This means when describing the position of graphical objects, we might wish to specify two distinct numeric objects, one of which for the "x-coordinate" and another for the "y-coordinate".

Alternatively, it may be more convenient to have a single object which reprsents such a two-dimensional positional data. This is how the Position class is defined.

attributes (i.e. data members)

constructor(s)

actions (i.e. member functions, methods)


class SimpleWindow

A SimpleWindow object represents a window which can be placed on the screen. All of the other graphical primitives must be associated with such a window in order to be created or displayed.

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


class WindowObject

Though we will generally not try to create objects from this class directly, it is worth discussing this because all of the other graphical primitives we will see are variants of this base class.

attributes (i.e. data members)

What all such objects have in common is that they have a "center" position and an associated window

actions (i.e. member functions, methods)

All such objects will support the following actions:


class Label

A Label is one particular kind of WindowObject. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject. In addition, a Label object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)

Note: This class definition does not offer a way to change the background color after a label has been constructed.

class RaySegment

A RaySegment object represents a "ray" which is either a line stroke from a start point to an end point and which optionally may include an arrow-head at the end point. Note carefully that the "center" position which is inherited from the WindowObject class is actually treated as the start point of a RaySegment.

A RaySegment is one particular kind of WindowObject. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject. In addition, a RaySegment object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


class Shape

The remaining window object types share some additional commonalities, in that each represents an object with "area." The class Shape is a general class which identifies those commonalities. So in addition to all of the attributes and actions associated with te more general class WindowObject, all Shape objects offer the following additional support:

attributes (i.e. data members)

actions (i.e. member functions, methods)


class RectangleShape

A RectangleShape is one particular kind of Shape. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject and class Shape. In addition, a RectangleShape object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


class CircleShape

A CircleShape is one particular kind of Shape. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject and class Shape. In addition, a CircleShape object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


class TriangleShape

As defined by this library, a triangle represents only equilateral triangles with a horizontal bottom edge. A TriangleShape is one particular kind of Shape. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject and class Shape. In addition, a TriangleShape object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


class SquareShape

A SquareShape is one particular kind of Shape. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject and class Shape. In addition, a SquareShape object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


class EllipseShape

A EllipseShape is one particular kind of Shape, representing an axis-aligned ellipse. For this reason, it includes all of the attributes and actions supported by the more general class WindowObject and class Shape. In addition, a EllipseShape object supports the following:

attributes (i.e. data members)

constructors

actions (i.e. member functions, methods)


Michael Goldwasser
CS-P125, Spring 2005
Last modified: Tuesday, 29 March 2005
Art Show | Course Home | Homework | Labs | Programming | Schedule & Lecture Notes | Submit