objectdraw
library originally created by Kim Bruce, Andrea Danyluk, and Thomas Murtagh.
See:
Description
Interface Summary | |
---|---|
ClientListener | The ClientListener interface specifies which methods an object needs
to have in order to be able to function as a client listener. |
Drawable1DInterface | Drawable1DInterface is the interface shared by all one dimensional
graphical objects - that is, Line s and AngLine s. |
Drawable2DInterface | Drawable2DInterface is the interface shared by all two dimensional
graphical objects - rectangles, ovals, arcs, and text. |
DrawableInterface | DrawableInterface is the interface shared by all objects that can
be drawn on a canvas. |
DrawableStrokeInterface | DrawableStrokeInterface is the interface shared by all objects that consist of
lines, instead of filled in areas. |
DrawingCanvas | DrawingCanvas is the interface listing the methods of the canvas on which
objects are placed. |
LocatableInterface | LocatableInterface is an interface shared by all objects except for
lines, containing the methods for retrieving the object's reference point. |
Resizable2DInterface | Resizable2DInterface is the interface shared by all two dimensional object that
can be resized. |
ServerListener | The ServerListener interface specifies what methods an object needs in
order to be able to function as a server listener, the object managing a server. |
Class Summary | |
---|---|
ActiveObject | The ActiveObject class allows you to create a separate "thread" of a program
that runs its own code at its own pace, independently of other code that is running. |
AngLine | The AngLine class provides a different way to make lines: instead of specifying
start and end points, you make an AngLine by providing a start point, the length
of the line, and the direction (as an angle in radians) that the line should extend from the
start point. |
Animation | Animation is similar to VisibleImage , but rather
than simply displaying an unchanging image, it displays an animation. |
Client | A Client makes a connection to another computer (the server) and can
send messages to the server and receive messages back. |
Controller | Controller is the class you should extend if you want to create an applet or
window that contains your own custom GUI instead of a DrawingCanvas . |
DrawableIterator | A DrawableIterator is a list of DrawableInterface objects that
you can read through one by one in order. |
EventTimer | EventTimer will repeatedly send a message to an object by calling
one of its methods with a preset list of parameters. |
FilledArc | A FilledArc is a piece of an oval, shaped like a slice of pie. |
FilledOval | A FilledOval is an oval filled in with some color. |
FilledRect | A FilledRect is a rectangle filled in with some color. |
FilledRoundedRect | A FilledRoundedRect is a rectangle with rounded corners, filled in with some
color. |
FrameController | FrameController is a Controller that automatically pops up in its
own frame (window) when it is constructed. |
FramedArc | A FramedArc is a curved line that forms some portion of an oval. |
FramedOval | A FramedOval is an oval framed with some color. |
FramedRect | A FramedRect is a rectangle framed with some color. |
FramedRoundedRect | A FramedRoundedRect is a rectangle with rounded corners, framed with some
color. |
FrameWindowController | FrameWindowController is a WindowController that automatically
pops up in its own frame (window) when it is constructed. |
KeyInterpreter | KeyInterpreter is the class that processes key events and calls the appropriate
methods in WindowController . |
Line | A Line represents a line segment connecting two points on the screen. |
Location | A Location object represents an (x, y) point on the screen. |
MouseInterpreter | MouseInterpreter is the class that processes mouse events and calls the
appropriate methods in WindowController . |
Network | The Network class will allow you to set up networked communication
between copies of your program running on different computers on a local area
network (LAN). |
RandomDoubleGenerator | A RandomDoubleGenerator will produce a string of random double s that
are in the range it was created to produce. |
RandomIntGenerator | A RandomIntGenerator will produce a string of random int s that
are in the range it was created to produce. |
Server | A Server runs on one computer and allows other computers (clients)
to connect to it. |
SizeablePanel | SizeablePanel is a JPanel that allows you to set its size. |
Text | A Text object displays some text on the screen. |
Turtle | A Turtle object allows you to draw lines and filled-in polygons by giving
instructions to a computer creature called a "turtle" that moves around on the screen and
draws a line as it goes. |
VisibleImage | A VisibleImage is an image that can be placed on a canvas. |
WindowController | WindowController in the class that defines how you interact with the drawing
canvas of your program. |
This is a modified version of the objectdraw
library originally created by Kim Bruce, Andrea Danyluk, and Thomas Murtagh. That library was used in programming classes at Williams college, and in the textbook Java: an Eventful Approach. The purpose of the library is to simplify the use of graphical objects and events so that they will be accessible to introductory students. The original library and more information are available at:
http://eventfuljava.cs.williams.edu/
This version of the library was created by Russell Zahniser, a teacher in the Boston Public Schools, for use in introductory Java classes there. It contains several improvements over the original library:
new FilledOval(new Location(0, 0), new Location(100, 100), new Color(150, 0, 255), canvas);
toString()
methods of the various objects have been altered to print out Java code describing how that object could be constructed.int
type early on but waiting until later to introduce double
, the return types of most methods that previously returned double
have been changed to int
. Where precision is required, there is usually another version of the same method that returns a double
; so, for example, Location
has both getX()
and getDoubleX()
.WindowController
can simply provide a method like this:
public void onSpacePress()
Text
class has been extensively modified to make it more natural to use in labeling parts of a sketch:Text
object are limited to four decimal places. This avoids the common problem of a double value appearing with a long string of 9's or 0's due to the limits of double precision.
Line
object, or wrap to fit within a Oval
object. Any other shape can be used as the basis.
Text
objects, each with a different font and color, can be chained together to produce a single string of text whose style varies.
Turtle
class has been introduced for drawing turtle graphics. This is a good way to introduce ideas of looping and recursion.object.getLocation().translate(10, 20);
Location
returned from getLocation()
be capable of moving the object. It would have been better, in my view, if Location
were immutable and translate()
simply created a new Location
, but with the translate()
method there, it ought to work as a person would expect. There is an offset()
method in Location
that simply returns a new Location
offset from the position of the original.ActiveObject
is complicated because of the need to create a separate class for every type of animation. Also, it suffers from graphical artifacts due to the problems of manipulating UI elements from a thread other than the event dispatch thread. The new class EventTimer
can simply call any public method of an object, with a fixed set of arguments, on a schedule, on the event dispatch thread.Animation
class has no real pedagogical value, but adds some flair to student projects. It can display a variety of particle-based animated effects around any object on the screen.Network
class that allows students to have their program send and receive messages over a LAN simply by implementing two interfaces, one for the client and one for the server.