Object-Oriented Programming with Java Lecture Notes
1 April 2008 • Graphic Programming
Outline
Display hardware.
Computer graphics.
Computer graphics in Java.
Computer Graphics
Computer Graphics
is the visual display of non-textual information.
It may include text, but not optimized for it.
Not computer graphics: terminals, printers (but they can be, depending).
Display Hardware
The original computer-graphics hardware were blinkenlights and oscilloscopes.
Oscilloscopes eventually morphed (early 60s) into
vector displays
.
Vector Display Hardware
A vector display is a CRT that knows how to draw lines and (perhaps) simple curves (conics, say).
Collectively known as
strokes
.
“Knows how” means “has the electronics”.
Data to be displayed are described in terms of the drawing strokes.
A compact and efficient data representation.
Driving Vector Displays
An image descritption (a sequence of stroke descriptions) is written to a storage block called the
display list
.
The
vector display driver
interprets the display list and drives the display electronics.
The display electronics leaves traces on the screen, showing the data.
Vector Graphics
There are two lasting ideas from vector displays: display lists and high-level graphical descriptions.
Display lists have morphed into hierarchial, tree-like scene descriptors.
High-level graphical descriptions have morphed into
vector graphics
.
Currently popular vector-graphics systems include Flash and SVG (scalable vector graphics).
Video Killed The Vector Star
Televisions were a potential competitor to vector displays.
Vector displays have a constant-intensity beam moving in varying patterns.
Television displays have a varying intensity beam moving in constant patterns.
First tv advantage: images of varying intensity.
The beam pattern is a
raster
: side-to-side scans moving down the display.
Hence “raster” in raster display and raster graphics.
Driving Raster Display
Raster displays are driven from an image buffer, but not a display list.
Raster image buffers are integer matrices (
video memory
).
Each element in the matrix describes a pixel (picture element) in the displayed image.
The description includes color and intensity.
Video memory is read in sync with the raster scan, the values read determine the beam intensity.
Bit-Mapped Displays
The main problem with raster displays is the cost of video memory.
Technology advanced enough by the early 70s to make
bit-mapped displays
possible.
The Alto developed at Xerox PARC had a bi-level display.
Graphics State
The
graphics state
defines context under which drawing and display takes place.
More generally known as the
{graphics, imaging, drawing} × {state, context, environment}
Graphics state contents include such information as
Drawing surface characteristics (height, width, depth, position).
Current drawing characteristics (color, position, transformation).
Graphics
The abstract class
Graphics
is the Java implementation of a graphics context.
It contains abstract methods to draw arcs, images, lines, ovals, polygons, rectangles, strings, and others.
It contains abstract methods to manipulate clipping, font, color, drawing modes, and other graphics state.
Concrete Graphics Classes
Graphics2D
and
DebugGraphics
are concrete implementations of the Graphics abstract class.
The Graphics2D class describes a 2D-drawing world.
It extends Graphics to provide methods for
2D transformations (scaling, rotation, shear).
Rendering hints (pixel rounding, antialiasing).
Device specific routines.
2D Graphics
The Java 2D drawing surface is an infinite Cartesian integer grid.
Each grid point is a pixel, the characteristics of which are determined by the underlying device.
Drawing-surface coordinates are in
screen orientation
, a
x
-axis mirror image of the standard coordinate-system orientation.
Standard orientation: positive
x
to the left, positive
y
up.
Screen orientation: positive
x
to the left, positive
y
down.
This page last modified on 4 March 2008.