SetsApplet
Class SetDisplayCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--SetsApplet.SetDisplayCanvas

class SetDisplayCanvas
extends Canvas
implements ActionListener

A Canvas that draws two intersecting rectangles and a number of randomly placed points, drawn black. Modify the Canvas so that:

You will need to implement the colorSets method

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
Component.AWTTreeLock
 
Field Summary
(package private) static char DRAW_CHAR
           
(package private)  boolean initialized
           
(package private) static int NUM_POINTS
           
private  ColoredPointSet points
           
private  Random rand
           
private  Rectangle rectA
           
private  Rectangle rectB
           
 
Fields inherited from class java.awt.Canvas
base, graphicsConfig, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
(package private) SetDisplayCanvas()
           
 
Method Summary
 void actionPerformed(ActionEvent e)
          Handles a button press.
(package private)  void assignPoints()
          Builds a random set of points inside the canvas.
(package private)  void buildRects()
          Builds the Rectangles.
(package private)  void calculatePoints()
          Builds a random set of points, and calculate the intersections with rectA, rectB.
(package private)  void colorSets()
          Write this method to set the color of all points.
(package private)  void drawPoint(Graphics g, ColoredPoint p)
          Draws a point.
 void paint(Graphics g)
          Paints the canvas.
(package private)  void paintBoundaries(Graphics g)
          Draws the boundaries of the regions.
(package private)  void paintSet(Graphics g)
          Draws a set of points.
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

NUM_POINTS

static final int NUM_POINTS

DRAW_CHAR

static final char DRAW_CHAR

rand

private Random rand

initialized

boolean initialized

points

private ColoredPointSet points

rectA

private Rectangle rectA

rectB

private Rectangle rectB
Constructor Detail

SetDisplayCanvas

SetDisplayCanvas()
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
Handles a button press.
Specified by:
actionPerformed in interface ActionListener

calculatePoints

void calculatePoints()
Builds a random set of points, and calculate the intersections with rectA, rectB.

buildRects

void buildRects()
Builds the Rectangles.

assignPoints

void assignPoints()
Builds a random set of points inside the canvas.

colorSets

void colorSets()
Write this method to set the color of all points. By default a ColoredPoint has Color.black as it's color. You need to: You may want to use the bulk methods and the ColoredPointSet.containedIn() method.

You need to modify this method.


paint

public void paint(Graphics g)
Paints the canvas.
Overrides:
paint in class Canvas

paintSet

void paintSet(Graphics g)
Draws a set of points.

drawPoint

void drawPoint(Graphics g,
               ColoredPoint p)
Draws a point.

paintBoundaries

void paintBoundaries(Graphics g)
Draws the boundaries of the regions.