first commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#BlueJ class context
|
||||
comment0.params=title
|
||||
comment0.target=Canvas(java.lang.String)
|
||||
comment0.text=\n\ Create\ a\ Canvas\ with\ default\ height,\ width\ and\ background\ color\ \n\ (300,\ 300,\ white).\n\ @param\ title\ \ title\ to\ appear\ in\ Canvas\ Frame\ \ \ \ \ \n
|
||||
comment1.params=title\ width\ height
|
||||
comment1.target=Canvas(java.lang.String,\ int,\ int)
|
||||
comment1.text=\n\ Create\ a\ Canvas\ with\ default\ background\ color\ (white).\n\ @param\ title\ \ title\ to\ appear\ in\ Canvas\ Frame\n\ @param\ width\ \ the\ desired\ width\ for\ the\ canvas\n\ @param\ height\ \ the\ desired\ height\ for\ the\ canvas\n
|
||||
comment10.params=xPos\ yPos\ diameter
|
||||
comment10.target=void\ eraseCircle(int,\ int,\ int)
|
||||
comment10.text=\n\ Erase\ the\ internal\ dimensions\ of\ the\ given\ circle.\ This\ is\ a\ \n\ convenience\ method.\ A\ similar\ effect\ can\ be\ achieved\ with\n\ the\ "erase"\ method.\n
|
||||
comment11.params=xPos\ yPos\ width\ height
|
||||
comment11.target=void\ eraseRectangle(int,\ int,\ int,\ int)
|
||||
comment11.text=\n\ Erase\ the\ internal\ dimensions\ of\ the\ given\ rectangle.\ This\ is\ a\ \n\ convenience\ method.\ A\ similar\ effect\ can\ be\ achieved\ with\n\ the\ "erase"\ method.\n
|
||||
comment12.params=shape
|
||||
comment12.target=void\ erase(java.awt.Shape)
|
||||
comment12.text=\n\ Erase\ a\ given\ shape's\ interior\ on\ the\ screen.\n\ @param\ \ shape\ \ the\ shape\ object\ to\ be\ erased\ \n
|
||||
comment13.params=shape
|
||||
comment13.target=void\ eraseOutline(java.awt.Shape)
|
||||
comment13.text=\n\ Erases\ a\ given\ shape's\ outline\ on\ the\ screen.\n\ @param\ \ shape\ \ the\ shape\ object\ to\ be\ erased\ \n
|
||||
comment14.params=image\ x\ y
|
||||
comment14.target=boolean\ drawImage(java.awt.Image,\ int,\ int)
|
||||
comment14.text=\n\ Draws\ an\ image\ onto\ the\ canvas.\n\ @param\ \ image\ \ \ the\ Image\ object\ to\ be\ displayed\ \n\ @param\ \ x\ \ \ \ \ \ \ x\ co-ordinate\ for\ Image\ placement\ \n\ @param\ \ y\ \ \ \ \ \ \ y\ co-ordinate\ for\ Image\ placement\ \n\ @return\ \ returns\ boolean\ value\ representing\ whether\ the\ image\ was\ \n\ \ \ \ \ \ \ \ \ \ completely\ loaded\ \n
|
||||
comment15.params=text\ x\ y
|
||||
comment15.target=void\ drawString(java.lang.String,\ int,\ int)
|
||||
comment15.text=\n\ Draws\ a\ String\ on\ the\ Canvas.\n\ @param\ \ text\ \ \ the\ String\ to\ be\ displayed\ \n\ @param\ \ x\ \ \ \ \ \ x\ co-ordinate\ for\ text\ placement\ \n\ @param\ \ y\ \ \ \ \ \ y\ co-ordinate\ for\ text\ placement\n
|
||||
comment16.params=text\ x\ y
|
||||
comment16.target=void\ eraseString(java.lang.String,\ int,\ int)
|
||||
comment16.text=\n\ Erases\ a\ String\ on\ the\ Canvas.\n\ @param\ \ text\ \ \ \ \ the\ String\ to\ be\ displayed\ \n\ @param\ \ x\ \ \ \ \ \ \ \ x\ co-ordinate\ for\ text\ placement\ \n\ @param\ \ y\ \ \ \ \ \ \ \ y\ co-ordinate\ for\ text\ placement\n
|
||||
comment17.params=x1\ y1\ x2\ y2
|
||||
comment17.target=void\ drawLine(int,\ int,\ int,\ int)
|
||||
comment17.text=\n\ Draws\ a\ line\ on\ the\ Canvas.\n\ @param\ \ x1\ \ \ x\ co-ordinate\ of\ start\ of\ line\ \n\ @param\ \ y1\ \ \ y\ co-ordinate\ of\ start\ of\ line\ \n\ @param\ \ x2\ \ \ x\ co-ordinate\ of\ end\ of\ line\ \n\ @param\ \ y2\ \ \ y\ co-ordinate\ of\ end\ of\ line\ \n
|
||||
comment18.params=newColor
|
||||
comment18.target=void\ setForegroundColor(java.awt.Color)
|
||||
comment18.text=\n\ Sets\ the\ foreground\ color\ of\ the\ Canvas.\n\ @param\ \ newColor\ \ \ the\ new\ color\ for\ the\ foreground\ of\ the\ Canvas\ \n
|
||||
comment19.params=
|
||||
comment19.target=java.awt.Color\ getForegroundColor()
|
||||
comment19.text=\n\ Returns\ the\ current\ color\ of\ the\ foreground.\n\ @return\ \ \ the\ color\ of\ the\ foreground\ of\ the\ Canvas\ \n
|
||||
comment2.params=title\ width\ height\ bgColor
|
||||
comment2.target=Canvas(java.lang.String,\ int,\ int,\ java.awt.Color)
|
||||
comment2.text=\n\ Create\ a\ Canvas.\n\ @param\ title\ \ title\ to\ appear\ in\ Canvas\ Frame\n\ @param\ width\ \ the\ desired\ width\ for\ the\ canvas\n\ @param\ height\ \ the\ desired\ height\ for\ the\ canvas\n\ @param\ bgClour\ \ the\ desired\ background\ color\ of\ the\ canvas\n
|
||||
comment20.params=newColor
|
||||
comment20.target=void\ setBackgroundColor(java.awt.Color)
|
||||
comment20.text=\n\ Sets\ the\ background\ color\ of\ the\ Canvas.\n\ @param\ \ newColor\ \ \ the\ new\ color\ for\ the\ background\ of\ the\ Canvas\ \n
|
||||
comment21.params=
|
||||
comment21.target=java.awt.Color\ getBackgroundColor()
|
||||
comment21.text=\n\ Returns\ the\ current\ color\ of\ the\ background\n\ @return\ \ \ the\ color\ of\ the\ background\ of\ the\ Canvas\ \n
|
||||
comment22.params=newFont
|
||||
comment22.target=void\ setFont(java.awt.Font)
|
||||
comment22.text=\n\ changes\ the\ current\ Font\ used\ on\ the\ Canvas\n\ @param\ \ newFont\ \ \ new\ font\ to\ be\ used\ for\ String\ output\n
|
||||
comment23.params=
|
||||
comment23.target=java.awt.Font\ getFont()
|
||||
comment23.text=\n\ Returns\ the\ current\ font\ of\ the\ canvas.\n\ @return\ \ \ \ \ the\ font\ currently\ in\ use\n
|
||||
comment24.params=width\ height
|
||||
comment24.target=void\ setSize(int,\ int)
|
||||
comment24.text=\n\ Sets\ the\ size\ of\ the\ canvas.\n\ @param\ \ width\ \ \ \ new\ width\ \n\ @param\ \ height\ \ \ new\ height\ \n
|
||||
comment25.params=
|
||||
comment25.target=java.awt.Dimension\ getSize()
|
||||
comment25.text=\n\ Returns\ the\ size\ of\ the\ canvas.\n\ @return\ \ \ \ \ The\ current\ dimension\ of\ the\ canvas\n
|
||||
comment26.params=milliseconds
|
||||
comment26.target=void\ wait(int)
|
||||
comment26.text=\n\ Waits\ for\ a\ specified\ number\ of\ milliseconds\ before\ finishing.\n\ This\ provides\ an\ easy\ way\ to\ specify\ a\ small\ delay\ which\ can\ be\n\ used\ when\ producing\ animations.\n\ @param\ \ milliseconds\ \ the\ number\ \n
|
||||
comment3.params=visible
|
||||
comment3.target=void\ setVisible(boolean)
|
||||
comment3.text=\n\ Set\ the\ canvas\ visibility\ and\ brings\ canvas\ to\ the\ front\ of\ screen\n\ when\ made\ visible.\ This\ method\ can\ also\ be\ used\ to\ bring\ an\ already\n\ visible\ canvas\ to\ the\ front\ of\ other\ windows.\n\ @param\ visible\ \ boolean\ value\ representing\ the\ desired\ visibility\ of\n\ the\ canvas\ (true\ or\ false)\ \n
|
||||
comment4.params=
|
||||
comment4.target=boolean\ isVisible()
|
||||
comment4.text=\n\ Provide\ information\ on\ visibility\ of\ the\ Canvas.\n\ @return\ \ true\ if\ canvas\ is\ visible,\ false\ otherwise\n
|
||||
comment5.params=shape
|
||||
comment5.target=void\ draw(java.awt.Shape)
|
||||
comment5.text=\n\ Draw\ the\ outline\ of\ a\ given\ shape\ onto\ the\ canvas.\n\ @param\ \ shape\ \ the\ shape\ object\ to\ be\ drawn\ on\ the\ canvas\n
|
||||
comment6.params=shape
|
||||
comment6.target=void\ fill(java.awt.Shape)
|
||||
comment6.text=\n\ Fill\ the\ internal\ dimensions\ of\ a\ given\ shape\ with\ the\ current\ \n\ foreground\ color\ of\ the\ canvas.\n\ @param\ \ shape\ \ the\ shape\ object\ to\ be\ filled\ \n
|
||||
comment7.params=xPos\ yPos\ diameter
|
||||
comment7.target=void\ fillCircle(int,\ int,\ int)
|
||||
comment7.text=\n\ Fill\ the\ internal\ dimensions\ of\ the\ given\ circle\ with\ the\ current\ \n\ foreground\ color\ of\ the\ canvas.\n\ @param\ \ xPos\ \ The\ x-coordinate\ of\ the\ circle\ center\ point\n\ @param\ \ yPos\ \ The\ y-coordinate\ of\ the\ circle\ center\ point\n\ @param\ \ diameter\ \ The\ diameter\ of\ the\ circle\ to\ be\ drawn\n
|
||||
comment8.params=xPos\ yPos\ width\ height
|
||||
comment8.target=void\ fillRectangle(int,\ int,\ int,\ int)
|
||||
comment8.text=\n\ Fill\ the\ internal\ dimensions\ of\ the\ given\ rectangle\ with\ the\ current\ \n\ foreground\ color\ of\ the\ canvas.\ This\ is\ a\ convenience\ method.\ A\ similar\ \n\ effect\ can\ be\ achieved\ with\ the\ "fill"\ method.\n
|
||||
comment9.params=
|
||||
comment9.target=void\ erase()
|
||||
comment9.text=\n\ Erase\ the\ whole\ canvas.\n
|
||||
numComments=27
|
364
Semester 1/Programming 1/Java/examples/projects/chapter06/scribble/Canvas.java
Executable file
364
Semester 1/Programming 1/Java/examples/projects/chapter06/scribble/Canvas.java
Executable file
@@ -0,0 +1,364 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
/**
|
||||
* Class Canvas - a class to allow for simple graphical
|
||||
* drawing on a canvas.
|
||||
*
|
||||
* @author Michael Kölling (mik)
|
||||
* @author Bruce Quig
|
||||
*
|
||||
* @version 2016.02.29
|
||||
*/
|
||||
|
||||
public class Canvas
|
||||
{
|
||||
private JFrame frame;
|
||||
private CanvasPane canvas;
|
||||
private Graphics2D graphic;
|
||||
private Color backgroundColor;
|
||||
private Image canvasImage;
|
||||
|
||||
/**
|
||||
* Create a Canvas with default height, width and background color
|
||||
* (300, 300, white).
|
||||
* @param title title to appear in Canvas Frame
|
||||
*/
|
||||
public Canvas(String title)
|
||||
{
|
||||
this(title, 300, 300, Color.white);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Canvas with default background color (white).
|
||||
* @param title title to appear in Canvas Frame
|
||||
* @param width the desired width for the canvas
|
||||
* @param height the desired height for the canvas
|
||||
*/
|
||||
public Canvas(String title, int width, int height)
|
||||
{
|
||||
this(title, width, height, Color.white);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Canvas.
|
||||
* @param title title to appear in Canvas Frame
|
||||
* @param width the desired width for the canvas
|
||||
* @param height the desired height for the canvas
|
||||
* @param bgClour the desired background color of the canvas
|
||||
*/
|
||||
public Canvas(String title, int width, int height, Color bgColor)
|
||||
{
|
||||
frame = new JFrame();
|
||||
canvas = new CanvasPane();
|
||||
frame.setContentPane(canvas);
|
||||
frame.setTitle(title);
|
||||
canvas.setPreferredSize(new Dimension(width, height));
|
||||
backgroundColor = bgColor;
|
||||
frame.pack();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the canvas visibility and brings canvas to the front of screen
|
||||
* when made visible. This method can also be used to bring an already
|
||||
* visible canvas to the front of other windows.
|
||||
* @param visible boolean value representing the desired visibility of
|
||||
* the canvas (true or false)
|
||||
*/
|
||||
public void setVisible(boolean visible)
|
||||
{
|
||||
if(graphic == null) {
|
||||
// first time: instantiate the offscreen image and fill it with
|
||||
// the background color
|
||||
Dimension size = canvas.getSize();
|
||||
canvasImage = canvas.createImage(size.width, size.height);
|
||||
graphic = (Graphics2D)canvasImage.getGraphics();
|
||||
graphic.setColor(backgroundColor);
|
||||
graphic.fillRect(0, 0, size.width, size.height);
|
||||
graphic.setColor(Color.black);
|
||||
}
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide information on visibility of the Canvas.
|
||||
* @return true if canvas is visible, false otherwise
|
||||
*/
|
||||
public boolean isVisible()
|
||||
{
|
||||
return frame.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the outline of a given shape onto the canvas.
|
||||
* @param shape the shape object to be drawn on the canvas
|
||||
*/
|
||||
public void draw(Shape shape)
|
||||
{
|
||||
graphic.draw(shape);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the internal dimensions of a given shape with the current
|
||||
* foreground color of the canvas.
|
||||
* @param shape the shape object to be filled
|
||||
*/
|
||||
public void fill(Shape shape)
|
||||
{
|
||||
graphic.fill(shape);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the internal dimensions of the given circle with the current
|
||||
* foreground color of the canvas.
|
||||
* @param xPos The x-coordinate of the circle center point
|
||||
* @param yPos The y-coordinate of the circle center point
|
||||
* @param diameter The diameter of the circle to be drawn
|
||||
*/
|
||||
public void fillCircle(int xPos, int yPos, int diameter)
|
||||
{
|
||||
Ellipse2D.Double circle = new Ellipse2D.Double(xPos, yPos, diameter, diameter);
|
||||
fill(circle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the internal dimensions of the given rectangle with the current
|
||||
* foreground color of the canvas. This is a convenience method. A similar
|
||||
* effect can be achieved with the "fill" method.
|
||||
*/
|
||||
public void fillRectangle(int xPos, int yPos, int width, int height)
|
||||
{
|
||||
fill(new Rectangle(xPos, yPos, width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase the whole canvas.
|
||||
*/
|
||||
public void erase()
|
||||
{
|
||||
Color original = graphic.getColor();
|
||||
graphic.setColor(backgroundColor);
|
||||
Dimension size = canvas.getSize();
|
||||
graphic.fill(new Rectangle(0, 0, size.width, size.height));
|
||||
graphic.setColor(original);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase the internal dimensions of the given circle. This is a
|
||||
* convenience method. A similar effect can be achieved with
|
||||
* the "erase" method.
|
||||
*/
|
||||
public void eraseCircle(int xPos, int yPos, int diameter)
|
||||
{
|
||||
Ellipse2D.Double circle = new Ellipse2D.Double(xPos, yPos, diameter, diameter);
|
||||
erase(circle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase the internal dimensions of the given rectangle. This is a
|
||||
* convenience method. A similar effect can be achieved with
|
||||
* the "erase" method.
|
||||
*/
|
||||
public void eraseRectangle(int xPos, int yPos, int width, int height)
|
||||
{
|
||||
erase(new Rectangle(xPos, yPos, width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Erase a given shape's interior on the screen.
|
||||
* @param shape the shape object to be erased
|
||||
*/
|
||||
public void erase(Shape shape)
|
||||
{
|
||||
Color original = graphic.getColor();
|
||||
graphic.setColor(backgroundColor);
|
||||
graphic.fill(shape); // erase by filling background color
|
||||
graphic.setColor(original);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases a given shape's outline on the screen.
|
||||
* @param shape the shape object to be erased
|
||||
*/
|
||||
public void eraseOutline(Shape shape)
|
||||
{
|
||||
Color original = graphic.getColor();
|
||||
graphic.setColor(backgroundColor);
|
||||
graphic.draw(shape); // erase by drawing background color
|
||||
graphic.setColor(original);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an image onto the canvas.
|
||||
* @param image the Image object to be displayed
|
||||
* @param x x co-ordinate for Image placement
|
||||
* @param y y co-ordinate for Image placement
|
||||
* @return returns boolean value representing whether the image was
|
||||
* completely loaded
|
||||
*/
|
||||
public boolean drawImage(Image image, int x, int y)
|
||||
{
|
||||
boolean result = graphic.drawImage(image, x, y, null);
|
||||
canvas.repaint();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a String on the Canvas.
|
||||
* @param text the String to be displayed
|
||||
* @param x x co-ordinate for text placement
|
||||
* @param y y co-ordinate for text placement
|
||||
*/
|
||||
public void drawString(String text, int x, int y)
|
||||
{
|
||||
graphic.drawString(text, x, y);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases a String on the Canvas.
|
||||
* @param text the String to be displayed
|
||||
* @param x x co-ordinate for text placement
|
||||
* @param y y co-ordinate for text placement
|
||||
*/
|
||||
public void eraseString(String text, int x, int y)
|
||||
{
|
||||
Color original = graphic.getColor();
|
||||
graphic.setColor(backgroundColor);
|
||||
graphic.drawString(text, x, y);
|
||||
graphic.setColor(original);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a line on the Canvas.
|
||||
* @param x1 x co-ordinate of start of line
|
||||
* @param y1 y co-ordinate of start of line
|
||||
* @param x2 x co-ordinate of end of line
|
||||
* @param y2 y co-ordinate of end of line
|
||||
*/
|
||||
public void drawLine(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
graphic.drawLine(x1, y1, x2, y2);
|
||||
canvas.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the foreground color of the Canvas.
|
||||
* @param newColor the new color for the foreground of the Canvas
|
||||
*/
|
||||
public void setForegroundColor(Color newColor)
|
||||
{
|
||||
graphic.setColor(newColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current color of the foreground.
|
||||
* @return the color of the foreground of the Canvas
|
||||
*/
|
||||
public Color getForegroundColor()
|
||||
{
|
||||
return graphic.getColor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color of the Canvas.
|
||||
* @param newColor the new color for the background of the Canvas
|
||||
*/
|
||||
public void setBackgroundColor(Color newColor)
|
||||
{
|
||||
backgroundColor = newColor;
|
||||
graphic.setBackground(newColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current color of the background
|
||||
* @return the color of the background of the Canvas
|
||||
*/
|
||||
public Color getBackgroundColor()
|
||||
{
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* changes the current Font used on the Canvas
|
||||
* @param newFont new font to be used for String output
|
||||
*/
|
||||
public void setFont(Font newFont)
|
||||
{
|
||||
graphic.setFont(newFont);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current font of the canvas.
|
||||
* @return the font currently in use
|
||||
**/
|
||||
public Font getFont()
|
||||
{
|
||||
return graphic.getFont();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the canvas.
|
||||
* @param width new width
|
||||
* @param height new height
|
||||
*/
|
||||
public void setSize(int width, int height)
|
||||
{
|
||||
canvas.setPreferredSize(new Dimension(width, height));
|
||||
Image oldImage = canvasImage;
|
||||
canvasImage = canvas.createImage(width, height);
|
||||
graphic = (Graphics2D)canvasImage.getGraphics();
|
||||
graphic.setColor(backgroundColor);
|
||||
graphic.fillRect(0, 0, width, height);
|
||||
graphic.drawImage(oldImage, 0, 0, null);
|
||||
frame.pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the canvas.
|
||||
* @return The current dimension of the canvas
|
||||
*/
|
||||
public Dimension getSize()
|
||||
{
|
||||
return canvas.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a specified number of milliseconds before finishing.
|
||||
* This provides an easy way to specify a small delay which can be
|
||||
* used when producing animations.
|
||||
* @param milliseconds the number
|
||||
*/
|
||||
public void wait(int milliseconds)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(milliseconds);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// ignoring exception at the moment
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Inner class CanvasPane - the actual canvas component contained in the
|
||||
* Canvas frame. This is essentially a JPanel with added capability to
|
||||
* refresh the image drawn on it.
|
||||
*/
|
||||
private class CanvasPane extends JPanel
|
||||
{
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
g.drawImage(canvasImage, 0, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
#BlueJ class context
|
||||
comment0.params=
|
||||
comment0.target=DrawDemo()
|
||||
comment0.text=\n\ Prepare\ the\ drawing\ demo.\ Create\ a\ fresh\ canvas\ and\ make\ it\ visible.\n
|
||||
comment1.params=
|
||||
comment1.target=void\ drawSquare()
|
||||
comment1.text=\n\ Draw\ a\ square\ on\ the\ screen.\n
|
||||
comment2.params=
|
||||
comment2.target=void\ drawWheel()
|
||||
comment2.text=\n\ Draw\ a\ wheel\ made\ of\ many\ squares.\n
|
||||
comment3.params=pen
|
||||
comment3.target=void\ square(Pen)
|
||||
comment3.text=\n\ Draw\ a\ square\ in\ the\ pen's\ color\ at\ the\ pen's\ location.\n
|
||||
comment4.params=
|
||||
comment4.target=void\ colorScribble()
|
||||
comment4.text=\n\ Draw\ some\ random\ squiggles\ on\ the\ screen,\ in\ random\ colors.\n
|
||||
comment5.params=
|
||||
comment5.target=void\ clear()
|
||||
comment5.text=\n\ Clear\ the\ screen.\n
|
||||
numComments=6
|
@@ -0,0 +1,87 @@
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Class DrawDemo - provides some short demonstrations showing how to use the
|
||||
* Pen class to create various drawings.
|
||||
*
|
||||
* @author Michael Kölling and David J. Barnes
|
||||
* @version 2016.02.29
|
||||
*/
|
||||
|
||||
public class DrawDemo
|
||||
{
|
||||
private Canvas myCanvas;
|
||||
private Random random;
|
||||
|
||||
/**
|
||||
* Prepare the drawing demo. Create a fresh canvas and make it visible.
|
||||
*/
|
||||
public DrawDemo()
|
||||
{
|
||||
myCanvas = new Canvas("Drawing Demo", 500, 400);
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a square on the screen.
|
||||
*/
|
||||
public void drawSquare()
|
||||
{
|
||||
Pen pen = new Pen(320, 260, myCanvas);
|
||||
pen.setColor(Color.BLUE);
|
||||
|
||||
square(pen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a wheel made of many squares.
|
||||
*/
|
||||
public void drawWheel()
|
||||
{
|
||||
Pen pen = new Pen(250, 200, myCanvas);
|
||||
pen.setColor(Color.RED);
|
||||
|
||||
for (int i=0; i<36; i++) {
|
||||
square(pen);
|
||||
pen.turn(10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a square in the pen's color at the pen's location.
|
||||
*/
|
||||
private void square(Pen pen)
|
||||
{
|
||||
for (int i=0; i<4; i++) {
|
||||
pen.move(100);
|
||||
pen.turn(90);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw some random squiggles on the screen, in random colors.
|
||||
*/
|
||||
public void colorScribble()
|
||||
{
|
||||
Pen pen = new Pen(250, 200, myCanvas);
|
||||
|
||||
for (int i=0; i<10; i++) {
|
||||
// pick a random color
|
||||
int red = random.nextInt(256);
|
||||
int green = random.nextInt(256);
|
||||
int blue = random.nextInt(256);
|
||||
pen.setColor(new Color(red, green, blue));
|
||||
|
||||
pen.randomSquiggle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the screen.
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
myCanvas.erase();
|
||||
}
|
||||
}
|
32
Semester 1/Programming 1/Java/examples/projects/chapter06/scribble/Pen.ctxt
Executable file
32
Semester 1/Programming 1/Java/examples/projects/chapter06/scribble/Pen.ctxt
Executable file
@@ -0,0 +1,32 @@
|
||||
#BlueJ class context
|
||||
comment0.params=
|
||||
comment0.target=Pen()
|
||||
comment0.text=\n\ Create\ a\ new\ Pen\ with\ its\ own\ canvas.\ The\ pen\ will\ create\ a\ new\ canvas\ for\ \n\ itself\ to\ draw\ on,\ and\ start\ in\ the\ default\ state\ (centre\ of\ canvas,\ direction\n\ right,\ color\ black,\ pen\ down).\n
|
||||
comment1.params=xPos\ yPos\ drawingCanvas
|
||||
comment1.target=Pen(int,\ int,\ Canvas)
|
||||
comment1.text=\n\ Create\ a\ new\ Pen\ for\ a\ given\ canvas.\ The\ direction\ is\ initially\ 0\ (to\ the\ right),\n\ the\ color\ is\ black,\ and\ the\ pen\ is\ down.\n\n\ @param\ xPos\ \ the\ initial\ horizontal\ coordinate\ of\ the\ pen\n\ @param\ yPos\ \ the\ initial\ vertical\ coordinate\ of\ the\ pen\n\ @param\ drawingCanvas\ \ the\ canvas\ to\ draw\ on\n
|
||||
comment2.params=distance
|
||||
comment2.target=void\ move(int)
|
||||
comment2.text=\n\ Move\ the\ specified\ distance\ in\ the\ current\ direction.\ If\ the\ pen\ is\ down,\ \n\ leave\ a\ line\ on\ the\ canvas.\n\ \n\ @param\ distance\ \ The\ distance\ to\ move\ forward\ from\ the\ current\ location.\n
|
||||
comment3.params=x\ y
|
||||
comment3.target=void\ moveTo(int,\ int)
|
||||
comment3.text=\n\ Move\ to\ the\ specified\ location.\ If\ the\ pen\ is\ down,\ leave\ a\ line\ on\ the\ canvas.\n\ \n\ @param\ x\ \ \ The\ x-coordinate\ to\ move\ to.\n\ @param\ y\ \ \ The\ y-coordinate\ to\ move\ to.\n
|
||||
comment4.params=degrees
|
||||
comment4.target=void\ turn(int)
|
||||
comment4.text=\n\ Turn\ the\ specified\ amount\ (out\ of\ a\ 360\ degree\ circle)\ clockwise\ from\ the\ current\ \n\ rotation.\n\ \n\ @param\ degrees\ \ The\ amount\ of\ degrees\ to\ turn.\ (360\ is\ a\ full\ circle.)\n
|
||||
comment5.params=angle
|
||||
comment5.target=void\ turnTo(int)
|
||||
comment5.text=\n\ Turn\ to\ the\ specified\ direction.\ 0\ is\ right,\ 90\ is\ down,\ 180\ is\ left,\ 270\ is\ up.\n\ \n\ @param\ angle\ \ The\ angle\ to\ turn\ to.\n
|
||||
comment6.params=newColor
|
||||
comment6.target=void\ setColor(java.awt.Color)
|
||||
comment6.text=\n\ Set\ the\ drawing\ color.\n\ \n\ @param\ newColor\ \ The\ color\ to\ use\ for\ subsequent\ drawing\ operations.\n
|
||||
comment7.params=
|
||||
comment7.target=void\ penUp()
|
||||
comment7.text=\n\ Lift\ the\ pen\ up.\ Moving\ afterwards\ will\ not\ leave\ a\ line\ on\ the\ canvas.\n
|
||||
comment8.params=
|
||||
comment8.target=void\ penDown()
|
||||
comment8.text=\n\ Put\ the\ pen\ down.\ Moving\ afterwards\ will\ leave\ a\ line\ on\ the\ canvas.\n
|
||||
comment9.params=
|
||||
comment9.target=void\ randomSquiggle()
|
||||
comment9.text=\n\ Scribble\ on\ the\ canvas\ in\ the\ current\ color.\ The\ size\ and\ complexity\ of\ the\ \n\ squiggle\ produced\ is\ defined\ by\ the\ constants\ SQIGGLE_SIZE\ and\ SQIGGLE_COUNT.\n
|
||||
numComments=10
|
148
Semester 1/Programming 1/Java/examples/projects/chapter06/scribble/Pen.java
Executable file
148
Semester 1/Programming 1/Java/examples/projects/chapter06/scribble/Pen.java
Executable file
@@ -0,0 +1,148 @@
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* A pen can be used to draw on a canvas. The pen maintains a position, direction, color,
|
||||
* and an up/down state. The pen can be moved across the canvas. If the pen is down, it
|
||||
* leaves a line on the canvas when moved. (If it is up, it will not draw a line.)
|
||||
*
|
||||
* @author Michael Kölling & David J. Barnes
|
||||
* @version 2016.02.29
|
||||
*/
|
||||
public class Pen
|
||||
{
|
||||
// constants for randomSquiggle method
|
||||
private static final int SQIGGLE_SIZE = 40;
|
||||
private static final int SQIGGLE_COUNT = 30;
|
||||
|
||||
private int xPosition;
|
||||
private int yPosition;
|
||||
private int rotation;
|
||||
private Color color;
|
||||
private boolean penDown;
|
||||
|
||||
private Canvas canvas;
|
||||
private Random random;
|
||||
|
||||
/**
|
||||
* Create a new Pen with its own canvas. The pen will create a new canvas for
|
||||
* itself to draw on, and start in the default state (centre of canvas, direction
|
||||
* right, color black, pen down).
|
||||
*/
|
||||
public Pen()
|
||||
{
|
||||
this (280, 220, new Canvas("My Canvas", 560, 440));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Pen for a given canvas. The direction is initially 0 (to the right),
|
||||
* the color is black, and the pen is down.
|
||||
*
|
||||
* @param xPos the initial horizontal coordinate of the pen
|
||||
* @param yPos the initial vertical coordinate of the pen
|
||||
* @param drawingCanvas the canvas to draw on
|
||||
*/
|
||||
public Pen(int xPos, int yPos, Canvas drawingCanvas)
|
||||
{
|
||||
xPosition = xPos;
|
||||
yPosition = yPos;
|
||||
rotation = 0;
|
||||
penDown = true;
|
||||
color = Color.BLACK;
|
||||
canvas = drawingCanvas;
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the specified distance in the current direction. If the pen is down,
|
||||
* leave a line on the canvas.
|
||||
*
|
||||
* @param distance The distance to move forward from the current location.
|
||||
*/
|
||||
public void move(int distance)
|
||||
{
|
||||
double angle = Math.toRadians(rotation);
|
||||
int newX = (int) Math.round(xPosition + Math.cos(angle) * distance);
|
||||
int newY = (int) Math.round(yPosition + Math.sin(angle) * distance);
|
||||
|
||||
moveTo(newX, newY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move to the specified location. If the pen is down, leave a line on the canvas.
|
||||
*
|
||||
* @param x The x-coordinate to move to.
|
||||
* @param y The y-coordinate to move to.
|
||||
*/
|
||||
public void moveTo(int x, int y)
|
||||
{
|
||||
if (penDown) {
|
||||
canvas.setForegroundColor(color);
|
||||
canvas.drawLine(xPosition, yPosition, x, y);
|
||||
}
|
||||
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn the specified amount (out of a 360 degree circle) clockwise from the current
|
||||
* rotation.
|
||||
*
|
||||
* @param degrees The amount of degrees to turn. (360 is a full circle.)
|
||||
*/
|
||||
public void turn(int degrees)
|
||||
{
|
||||
rotation = rotation + degrees;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn to the specified direction. 0 is right, 90 is down, 180 is left, 270 is up.
|
||||
*
|
||||
* @param angle The angle to turn to.
|
||||
*/
|
||||
public void turnTo(int angle)
|
||||
{
|
||||
rotation = angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the drawing color.
|
||||
*
|
||||
* @param newColor The color to use for subsequent drawing operations.
|
||||
*/
|
||||
public void setColor(Color newColor)
|
||||
{
|
||||
color = newColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lift the pen up. Moving afterwards will not leave a line on the canvas.
|
||||
*/
|
||||
public void penUp()
|
||||
{
|
||||
penDown = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the pen down. Moving afterwards will leave a line on the canvas.
|
||||
*/
|
||||
public void penDown()
|
||||
{
|
||||
penDown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scribble on the canvas in the current color. The size and complexity of the
|
||||
* squiggle produced is defined by the constants SQIGGLE_SIZE and SQIGGLE_COUNT.
|
||||
*/
|
||||
public void randomSquiggle()
|
||||
{
|
||||
for (int i=0; i<SQIGGLE_COUNT; i++) {
|
||||
move(random.nextInt(SQIGGLE_SIZE));
|
||||
turn(160 + random.nextInt(40));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
Scribble - a demonstration of graphical output on a Canvas class.
|
||||
|
||||
This project is part of the material for the book
|
||||
|
||||
Objects First with Java - A Practical Introduction using BlueJ
|
||||
Sixth edition
|
||||
David J. Barnes and Michael Kölling
|
||||
Pearson Education, 2016
|
||||
|
||||
This project is discussed in chapter 6.
|
||||
|
||||
This project provides some short graphical demos in the DrawDemo class.
|
||||
|
||||
This project provides great scope for extension. The Canvas class does
|
||||
not usually need to be changed. It may be best to treat it as a library
|
||||
class (open the editor and switch to "documentation" view).
|
||||
|
||||
Other classes can be changed or added. The book contains suggestions
|
||||
for various exercises.
|
@@ -0,0 +1,748 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc (build 1.8.0_31) on Mon Oct 05 10:02:33 BST 2015 -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
Canvas
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2015-10-05">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Canvas";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
<HR>
|
||||
<!-- ======== START OF CLASS DATA ======== -->
|
||||
<H2>
|
||||
Class Canvas</H2>
|
||||
<PRE>
|
||||
java.lang.Object
|
||||
<IMG SRC="./resources/inherit.gif" ALT="extended by "><B>Canvas</B>
|
||||
</PRE>
|
||||
<HR>
|
||||
<DL>
|
||||
<DT><PRE>public class <B>Canvas</B><DT>extends java.lang.Object</DL>
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Class Canvas - a class to allow for simple graphical
|
||||
drawing on a canvas.
|
||||
<P>
|
||||
|
||||
<P>
|
||||
<DL>
|
||||
<DT><B>Version:</B></DT>
|
||||
<DD>2016.02.29</DD>
|
||||
<DT><B>Author:</B></DT>
|
||||
<DD>Michael Kölling (mik), Bruce Quig</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<P>
|
||||
|
||||
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
||||
|
||||
<A NAME="constructor_summary"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Constructor Summary</B></FONT></TH>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD><CODE><B><A HREF="Canvas.html#Canvas(java.lang.String)">Canvas</A></B>(java.lang.String title)</CODE>
|
||||
|
||||
<BR>
|
||||
Create a Canvas with default height, width and background color
|
||||
(300, 300, white).</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD><CODE><B><A HREF="Canvas.html#Canvas(java.lang.String, int, int)">Canvas</A></B>(java.lang.String title,
|
||||
int width,
|
||||
int height)</CODE>
|
||||
|
||||
<BR>
|
||||
Create a Canvas with default background color (white).</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD><CODE><B><A HREF="Canvas.html#Canvas(java.lang.String, int, int, java.awt.Color)">Canvas</A></B>(java.lang.String title,
|
||||
int width,
|
||||
int height,
|
||||
java.awt.Color bgColor)</CODE>
|
||||
|
||||
<BR>
|
||||
Create a Canvas.</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<!-- ========== METHOD SUMMARY =========== -->
|
||||
|
||||
<A NAME="method_summary"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Method Summary</B></FONT></TH>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#draw(java.awt.Shape)">draw</A></B>(java.awt.Shape shape)</CODE>
|
||||
|
||||
<BR>
|
||||
Draw the outline of a given shape onto the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> boolean</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#drawImage(java.awt.Image, int, int)">drawImage</A></B>(java.awt.Image image,
|
||||
int x,
|
||||
int y)</CODE>
|
||||
|
||||
<BR>
|
||||
Draws an image onto the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#drawLine(int, int, int, int)">drawLine</A></B>(int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2)</CODE>
|
||||
|
||||
<BR>
|
||||
Draws a line on the Canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#drawString(java.lang.String, int, int)">drawString</A></B>(java.lang.String text,
|
||||
int x,
|
||||
int y)</CODE>
|
||||
|
||||
<BR>
|
||||
Draws a String on the Canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#erase()">erase</A></B>()</CODE>
|
||||
|
||||
<BR>
|
||||
Erase the whole canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#erase(java.awt.Shape)">erase</A></B>(java.awt.Shape shape)</CODE>
|
||||
|
||||
<BR>
|
||||
Erase a given shape's interior on the screen.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#eraseCircle(int, int, int)">eraseCircle</A></B>(int xPos,
|
||||
int yPos,
|
||||
int diameter)</CODE>
|
||||
|
||||
<BR>
|
||||
Erase the internal dimensions of the given circle.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#eraseOutline(java.awt.Shape)">eraseOutline</A></B>(java.awt.Shape shape)</CODE>
|
||||
|
||||
<BR>
|
||||
Erases a given shape's outline on the screen.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#eraseRectangle(int, int, int, int)">eraseRectangle</A></B>(int xPos,
|
||||
int yPos,
|
||||
int width,
|
||||
int height)</CODE>
|
||||
|
||||
<BR>
|
||||
Erase the internal dimensions of the given rectangle.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#eraseString(java.lang.String, int, int)">eraseString</A></B>(java.lang.String text,
|
||||
int x,
|
||||
int y)</CODE>
|
||||
|
||||
<BR>
|
||||
Erases a String on the Canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#fill(java.awt.Shape)">fill</A></B>(java.awt.Shape shape)</CODE>
|
||||
|
||||
<BR>
|
||||
Fill the internal dimensions of a given shape with the current
|
||||
foreground color of the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#fillCircle(int, int, int)">fillCircle</A></B>(int xPos,
|
||||
int yPos,
|
||||
int diameter)</CODE>
|
||||
|
||||
<BR>
|
||||
Fill the internal dimensions of the given circle with the current
|
||||
foreground color of the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#fillRectangle(int, int, int, int)">fillRectangle</A></B>(int xPos,
|
||||
int yPos,
|
||||
int width,
|
||||
int height)</CODE>
|
||||
|
||||
<BR>
|
||||
Fill the internal dimensions of the given rectangle with the current
|
||||
foreground color of the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> java.awt.Color</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#getBackgroundColor()">getBackgroundColor</A></B>()</CODE>
|
||||
|
||||
<BR>
|
||||
Returns the current color of the background</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> java.awt.Font</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#getFont()">getFont</A></B>()</CODE>
|
||||
|
||||
<BR>
|
||||
Returns the current font of the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> java.awt.Color</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#getForegroundColor()">getForegroundColor</A></B>()</CODE>
|
||||
|
||||
<BR>
|
||||
Returns the current color of the foreground.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> java.awt.Dimension</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#getSize()">getSize</A></B>()</CODE>
|
||||
|
||||
<BR>
|
||||
Returns the size of the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> boolean</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#isVisible()">isVisible</A></B>()</CODE>
|
||||
|
||||
<BR>
|
||||
Provide information on visibility of the Canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#setBackgroundColor(java.awt.Color)">setBackgroundColor</A></B>(java.awt.Color newColor)</CODE>
|
||||
|
||||
<BR>
|
||||
Sets the background color of the Canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#setFont(java.awt.Font)">setFont</A></B>(java.awt.Font newFont)</CODE>
|
||||
|
||||
<BR>
|
||||
changes the current Font used on the Canvas</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#setForegroundColor(java.awt.Color)">setForegroundColor</A></B>(java.awt.Color newColor)</CODE>
|
||||
|
||||
<BR>
|
||||
Sets the foreground color of the Canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#setSize(int, int)">setSize</A></B>(int width,
|
||||
int height)</CODE>
|
||||
|
||||
<BR>
|
||||
Sets the size of the canvas.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#setVisible(boolean)">setVisible</A></B>(boolean visible)</CODE>
|
||||
|
||||
<BR>
|
||||
Set the canvas visibility and brings canvas to the front of screen
|
||||
when made visible.</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
||||
<CODE> void</CODE></FONT></TD>
|
||||
<TD><CODE><B><A HREF="Canvas.html#wait(int)">wait</A></B>(int milliseconds)</CODE>
|
||||
|
||||
<BR>
|
||||
Waits for a specified number of milliseconds before finishing.</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
|
||||
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
|
||||
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
||||
|
||||
<A NAME="constructor_detail"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
||||
<B>Constructor Detail</B></FONT></TH>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<A NAME="Canvas(java.lang.String)"><!-- --></A><H3>
|
||||
Canvas</H3>
|
||||
<PRE>
|
||||
public <B>Canvas</B>(java.lang.String title)</PRE>
|
||||
<DL>
|
||||
<DD>Create a Canvas with default height, width and background color
|
||||
(300, 300, white).
|
||||
<P>
|
||||
<DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>title</CODE> - title to appear in Canvas Frame</DL>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="Canvas(java.lang.String, int, int)"><!-- --></A><H3>
|
||||
Canvas</H3>
|
||||
<PRE>
|
||||
public <B>Canvas</B>(java.lang.String title,
|
||||
int width,
|
||||
int height)</PRE>
|
||||
<DL>
|
||||
<DD>Create a Canvas with default background color (white).
|
||||
<P>
|
||||
<DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>title</CODE> - title to appear in Canvas Frame<DD><CODE>width</CODE> - the desired width for the canvas<DD><CODE>height</CODE> - the desired height for the canvas</DL>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="Canvas(java.lang.String, int, int, java.awt.Color)"><!-- --></A><H3>
|
||||
Canvas</H3>
|
||||
<PRE>
|
||||
public <B>Canvas</B>(java.lang.String title,
|
||||
int width,
|
||||
int height,
|
||||
java.awt.Color bgColor)</PRE>
|
||||
<DL>
|
||||
<DD>Create a Canvas.
|
||||
<P>
|
||||
<DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>title</CODE> - title to appear in Canvas Frame<DD><CODE>width</CODE> - the desired width for the canvas<DD><CODE>height</CODE> - the desired height for the canvas<DD><CODE>bgClour</CODE> - the desired background color of the canvas</DL>
|
||||
</DL>
|
||||
|
||||
<!-- ============ METHOD DETAIL ========== -->
|
||||
|
||||
<A NAME="method_detail"><!-- --></A>
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
||||
<B>Method Detail</B></FONT></TH>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<A NAME="draw(java.awt.Shape)"><!-- --></A><H3>
|
||||
draw</H3>
|
||||
<PRE>
|
||||
public void <B>draw</B>(java.awt.Shape shape)</PRE>
|
||||
<DL>
|
||||
<DD>Draw the outline of a given shape onto the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>shape</CODE> - the shape object to be drawn on the canvas</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="drawImage(java.awt.Image, int, int)"><!-- --></A><H3>
|
||||
drawImage</H3>
|
||||
<PRE>
|
||||
public boolean <B>drawImage</B>(java.awt.Image image,
|
||||
int x,
|
||||
int y)</PRE>
|
||||
<DL>
|
||||
<DD>Draws an image onto the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>image</CODE> - the Image object to be displayed<DD><CODE>x</CODE> - x co-ordinate for Image placement<DD><CODE>y</CODE> - y co-ordinate for Image placement
|
||||
<DT><B>Returns:</B><DD>returns boolean value representing whether the image was
|
||||
completely loaded</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="drawLine(int, int, int, int)"><!-- --></A><H3>
|
||||
drawLine</H3>
|
||||
<PRE>
|
||||
public void <B>drawLine</B>(int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2)</PRE>
|
||||
<DL>
|
||||
<DD>Draws a line on the Canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>x1</CODE> - x co-ordinate of start of line<DD><CODE>y1</CODE> - y co-ordinate of start of line<DD><CODE>x2</CODE> - x co-ordinate of end of line<DD><CODE>y2</CODE> - y co-ordinate of end of line</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="drawString(java.lang.String, int, int)"><!-- --></A><H3>
|
||||
drawString</H3>
|
||||
<PRE>
|
||||
public void <B>drawString</B>(java.lang.String text,
|
||||
int x,
|
||||
int y)</PRE>
|
||||
<DL>
|
||||
<DD>Draws a String on the Canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the String to be displayed<DD><CODE>x</CODE> - x co-ordinate for text placement<DD><CODE>y</CODE> - y co-ordinate for text placement</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="erase()"><!-- --></A><H3>
|
||||
erase</H3>
|
||||
<PRE>
|
||||
public void <B>erase</B>()</PRE>
|
||||
<DL>
|
||||
<DD>Erase the whole canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="erase(java.awt.Shape)"><!-- --></A><H3>
|
||||
erase</H3>
|
||||
<PRE>
|
||||
public void <B>erase</B>(java.awt.Shape shape)</PRE>
|
||||
<DL>
|
||||
<DD>Erase a given shape's interior on the screen.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>shape</CODE> - the shape object to be erased</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="eraseCircle(int, int, int)"><!-- --></A><H3>
|
||||
eraseCircle</H3>
|
||||
<PRE>
|
||||
public void <B>eraseCircle</B>(int xPos,
|
||||
int yPos,
|
||||
int diameter)</PRE>
|
||||
<DL>
|
||||
<DD>Erase the internal dimensions of the given circle. This is a
|
||||
convenience method. A similar effect can be achieved with
|
||||
the "erase" method.
|
||||
<P>
|
||||
<DD><DL>
|
||||
</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="eraseOutline(java.awt.Shape)"><!-- --></A><H3>
|
||||
eraseOutline</H3>
|
||||
<PRE>
|
||||
public void <B>eraseOutline</B>(java.awt.Shape shape)</PRE>
|
||||
<DL>
|
||||
<DD>Erases a given shape's outline on the screen.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>shape</CODE> - the shape object to be erased</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="eraseRectangle(int, int, int, int)"><!-- --></A><H3>
|
||||
eraseRectangle</H3>
|
||||
<PRE>
|
||||
public void <B>eraseRectangle</B>(int xPos,
|
||||
int yPos,
|
||||
int width,
|
||||
int height)</PRE>
|
||||
<DL>
|
||||
<DD>Erase the internal dimensions of the given rectangle. This is a
|
||||
convenience method. A similar effect can be achieved with
|
||||
the "erase" method.
|
||||
<P>
|
||||
<DD><DL>
|
||||
</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="eraseString(java.lang.String, int, int)"><!-- --></A><H3>
|
||||
eraseString</H3>
|
||||
<PRE>
|
||||
public void <B>eraseString</B>(java.lang.String text,
|
||||
int x,
|
||||
int y)</PRE>
|
||||
<DL>
|
||||
<DD>Erases a String on the Canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the String to be displayed<DD><CODE>x</CODE> - x co-ordinate for text placement<DD><CODE>y</CODE> - y co-ordinate for text placement</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="fill(java.awt.Shape)"><!-- --></A><H3>
|
||||
fill</H3>
|
||||
<PRE>
|
||||
public void <B>fill</B>(java.awt.Shape shape)</PRE>
|
||||
<DL>
|
||||
<DD>Fill the internal dimensions of a given shape with the current
|
||||
foreground color of the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>shape</CODE> - the shape object to be filled</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="fillCircle(int, int, int)"><!-- --></A><H3>
|
||||
fillCircle</H3>
|
||||
<PRE>
|
||||
public void <B>fillCircle</B>(int xPos,
|
||||
int yPos,
|
||||
int diameter)</PRE>
|
||||
<DL>
|
||||
<DD>Fill the internal dimensions of the given circle with the current
|
||||
foreground color of the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>xPos</CODE> - The x-coordinate of the circle center point<DD><CODE>yPos</CODE> - The y-coordinate of the circle center point<DD><CODE>diameter</CODE> - The diameter of the circle to be drawn</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="fillRectangle(int, int, int, int)"><!-- --></A><H3>
|
||||
fillRectangle</H3>
|
||||
<PRE>
|
||||
public void <B>fillRectangle</B>(int xPos,
|
||||
int yPos,
|
||||
int width,
|
||||
int height)</PRE>
|
||||
<DL>
|
||||
<DD>Fill the internal dimensions of the given rectangle with the current
|
||||
foreground color of the canvas. This is a convenience method. A similar
|
||||
effect can be achieved with the "fill" method.
|
||||
<P>
|
||||
<DD><DL>
|
||||
</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="getBackgroundColor()"><!-- --></A><H3>
|
||||
getBackgroundColor</H3>
|
||||
<PRE>
|
||||
public java.awt.Color <B>getBackgroundColor</B>()</PRE>
|
||||
<DL>
|
||||
<DD>Returns the current color of the background
|
||||
<P>
|
||||
<DD><DL>
|
||||
|
||||
<DT><B>Returns:</B><DD>the color of the background of the Canvas</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="getFont()"><!-- --></A><H3>
|
||||
getFont</H3>
|
||||
<PRE>
|
||||
public java.awt.Font <B>getFont</B>()</PRE>
|
||||
<DL>
|
||||
<DD>Returns the current font of the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
|
||||
<DT><B>Returns:</B><DD>the font currently in use</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="getForegroundColor()"><!-- --></A><H3>
|
||||
getForegroundColor</H3>
|
||||
<PRE>
|
||||
public java.awt.Color <B>getForegroundColor</B>()</PRE>
|
||||
<DL>
|
||||
<DD>Returns the current color of the foreground.
|
||||
<P>
|
||||
<DD><DL>
|
||||
|
||||
<DT><B>Returns:</B><DD>the color of the foreground of the Canvas</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="getSize()"><!-- --></A><H3>
|
||||
getSize</H3>
|
||||
<PRE>
|
||||
public java.awt.Dimension <B>getSize</B>()</PRE>
|
||||
<DL>
|
||||
<DD>Returns the size of the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
|
||||
<DT><B>Returns:</B><DD>The current dimension of the canvas</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="isVisible()"><!-- --></A><H3>
|
||||
isVisible</H3>
|
||||
<PRE>
|
||||
public boolean <B>isVisible</B>()</PRE>
|
||||
<DL>
|
||||
<DD>Provide information on visibility of the Canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
|
||||
<DT><B>Returns:</B><DD>true if canvas is visible, false otherwise</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="setBackgroundColor(java.awt.Color)"><!-- --></A><H3>
|
||||
setBackgroundColor</H3>
|
||||
<PRE>
|
||||
public void <B>setBackgroundColor</B>(java.awt.Color newColor)</PRE>
|
||||
<DL>
|
||||
<DD>Sets the background color of the Canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>newColor</CODE> - the new color for the background of the Canvas</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="setFont(java.awt.Font)"><!-- --></A><H3>
|
||||
setFont</H3>
|
||||
<PRE>
|
||||
public void <B>setFont</B>(java.awt.Font newFont)</PRE>
|
||||
<DL>
|
||||
<DD>changes the current Font used on the Canvas
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>newFont</CODE> - new font to be used for String output</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="setForegroundColor(java.awt.Color)"><!-- --></A><H3>
|
||||
setForegroundColor</H3>
|
||||
<PRE>
|
||||
public void <B>setForegroundColor</B>(java.awt.Color newColor)</PRE>
|
||||
<DL>
|
||||
<DD>Sets the foreground color of the Canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>newColor</CODE> - the new color for the foreground of the Canvas</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="setSize(int, int)"><!-- --></A><H3>
|
||||
setSize</H3>
|
||||
<PRE>
|
||||
public void <B>setSize</B>(int width,
|
||||
int height)</PRE>
|
||||
<DL>
|
||||
<DD>Sets the size of the canvas.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>width</CODE> - new width<DD><CODE>height</CODE> - new height</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="setVisible(boolean)"><!-- --></A><H3>
|
||||
setVisible</H3>
|
||||
<PRE>
|
||||
public void <B>setVisible</B>(boolean visible)</PRE>
|
||||
<DL>
|
||||
<DD>Set the canvas visibility and brings canvas to the front of screen
|
||||
when made visible. This method can also be used to bring an already
|
||||
visible canvas to the front of other windows.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>visible</CODE> - boolean value representing the desired visibility of
|
||||
the canvas (true or false)</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<A NAME="wait(int)"><!-- --></A><H3>
|
||||
wait</H3>
|
||||
<PRE>
|
||||
public void <B>wait</B>(int milliseconds)</PRE>
|
||||
<DL>
|
||||
<DD>Waits for a specified number of milliseconds before finishing.
|
||||
This provides an easy way to specify a small delay which can be
|
||||
used when producing animations.
|
||||
<P>
|
||||
<DD><DL>
|
||||
<DT><B>Parameters:</B><DD><CODE>milliseconds</CODE> - the number</DL>
|
||||
</DD>
|
||||
</DL>
|
||||
<!-- ========= END OF CLASS DATA ========= -->
|
||||
<HR>
|
||||
|
||||
<HR>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc (build 1.8.0_31) on Mon Oct 05 10:02:33 BST 2015 -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
All Classes
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2015-10-05">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
<FONT size="+1" CLASS="FrameHeadingFont">
|
||||
<B>All Classes</B></FONT>
|
||||
<BR>
|
||||
|
||||
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="Canvas.html" title="class in <Unnamed>" target="classFrame">Canvas</A>
|
||||
<BR>
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc (build 1.8.0_31) on Mon Oct 05 10:02:33 BST 2015 -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
All Classes
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2015-10-05">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
<FONT size="+1" CLASS="FrameHeadingFont">
|
||||
<B>All Classes</B></FONT>
|
||||
<BR>
|
||||
|
||||
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="Canvas.html" title="class in <Unnamed>">Canvas</A>
|
||||
<BR>
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc (build 1.8.0_31) on Mon Oct 05 10:02:33 BST 2015 -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
Constant Field Values
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2015-10-05">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
<SCRIPT type="text/javascript">
|
||||
function windowTitle()
|
||||
{
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Constant Field Values";
|
||||
}
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white" onload="windowTitle();">
|
||||
<HR>
|
||||
|
||||
<HR>
|
||||
<CENTER>
|
||||
<H1>
|
||||
Constant Field Values</H1>
|
||||
</CENTER>
|
||||
<HR SIZE="4" NOSHADE>
|
||||
<B>Contents</B><UL>
|
||||
</UL>
|
||||
|
||||
<HR>
|
||||
|
||||
<HR>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc on Mon Oct 05 10:02:33 BST 2015-->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
Generated Documentation (Untitled)
|
||||
</TITLE>
|
||||
<SCRIPT type="text/javascript">
|
||||
targetPage = "" + window.location.search;
|
||||
if (targetPage != "" && targetPage != "undefined")
|
||||
targetPage = targetPage.substring(1);
|
||||
if (targetPage.indexOf(":") != -1)
|
||||
targetPage = "undefined";
|
||||
function loadFrames() {
|
||||
if (targetPage != "" && targetPage != "undefined")
|
||||
top.classFrame.location = top.targetPage;
|
||||
}
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>
|
||||
</NOSCRIPT>
|
||||
</HEAD>
|
||||
<FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
|
||||
<FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
|
||||
<FRAME src="Canvas.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
|
||||
<NOFRAMES>
|
||||
<H2>
|
||||
Frame Alert</H2>
|
||||
|
||||
<P>
|
||||
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
|
||||
<BR>
|
||||
Link to<A HREF="Canvas.html">Non-frame version.</A>
|
||||
</NOFRAMES>
|
||||
</FRAMESET>
|
||||
</HTML>
|
@@ -0,0 +1,43 @@
|
||||
Class documentation
|
||||
<---- javadoc command: ---->
|
||||
/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Frameworks/jdk.framework/Versions/A/Contents/Home/bin/javadoc
|
||||
-author
|
||||
-version
|
||||
-nodeprecated
|
||||
-package
|
||||
-noindex
|
||||
-notree
|
||||
-nohelp
|
||||
-nonavbar
|
||||
-source
|
||||
1.8
|
||||
-classpath
|
||||
/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/bluejcore.jar:/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/junit-4.8.2.jar:/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/userlib/pi4j-core.jar:/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/userlib/pi4j-device.jar:/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/userlib/pi4j-gpio-extension.jar:/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/userlib/pi4j-service.jar:/Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble
|
||||
-d
|
||||
/Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc
|
||||
-encoding
|
||||
UTF-8
|
||||
-charset
|
||||
UTF-8
|
||||
-docletpath
|
||||
/Applications/BlueJ/BlueJ 3.1.5/BlueJ.app/Contents/Resources/Java/bjdoclet.jar
|
||||
-doclet
|
||||
bluej.doclet.doclets.formats.html.HtmlDoclet
|
||||
/Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/Canvas.java
|
||||
<---- end of javadoc command ---->
|
||||
Loading source file /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/Canvas.java...
|
||||
Constructing Javadoc information...
|
||||
Standard Doclet version 1.8.0_31
|
||||
Building tree for all the packages and classes...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/Canvas.html...
|
||||
/Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/Canvas.java:51: warning - @param argument "bgClour" is not a parameter name.
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/package-frame.html...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/package-summary.html...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/constant-values.html...
|
||||
Building index for all the packages and classes...
|
||||
Building index for all classes...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/allclasses-frame.html...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/allclasses-noframe.html...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/index.html...
|
||||
Generating /Users/mik/Documents/Dropbox/ofwj/projects/chapter06/scribble/doc/stylesheet.css...
|
||||
1 warning
|
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc (build 1.8.0_31) on Mon Oct 05 10:02:33 BST 2015 -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
<Unnamed>
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2015-10-05">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
<FONT size="+1" CLASS="FrameTitleFont">
|
||||
<A HREF="package-summary.html" target="classFrame"><Unnamed></A></FONT>
|
||||
<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">
|
||||
Classes</FONT>
|
||||
<FONT CLASS="FrameItemFont">
|
||||
<BR>
|
||||
<A HREF="Canvas.html" title="class in <Unnamed>" target="classFrame">Canvas</A></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@@ -0,0 +1 @@
|
||||
|
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<!--NewPage-->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Generated by javadoc (build 1.8.0_31) on Mon Oct 05 10:02:33 BST 2015 -->
|
||||
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>
|
||||
|
||||
</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2015-10-05">
|
||||
|
||||
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
|
||||
|
||||
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
<HR>
|
||||
|
||||
<HR>
|
||||
<H2>
|
||||
Package <Unnamed>
|
||||
</H2>
|
||||
|
||||
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
||||
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
||||
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
||||
<B>Class Summary</B></FONT></TH>
|
||||
</TR>
|
||||
<TR BGCOLOR="white" CLASS="TableRowColor">
|
||||
<TD WIDTH="15%"><B><A HREF="Canvas.html" title="class in <Unnamed>">Canvas</A></B></TD>
|
||||
<TD>Class Canvas - a class to allow for simple graphical
|
||||
drawing on a canvas.</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
|
||||
<P>
|
||||
<DL>
|
||||
</DL>
|
||||
<HR>
|
||||
|
||||
<HR>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
Binary file not shown.
After Width: | Height: | Size: 57 B |
@@ -0,0 +1,29 @@
|
||||
/* Javadoc style sheet */
|
||||
|
||||
/* Define colors, fonts and other style attributes here to override the defaults */
|
||||
|
||||
/* Page background color */
|
||||
body { background-color: #FFFFFF; color:#000000 }
|
||||
|
||||
/* Headings */
|
||||
h1 { font-size: 145% }
|
||||
|
||||
/* Table colors */
|
||||
.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
|
||||
.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
|
||||
.TableRowColor { background: #FFFFFF; color:#000000 } /* White */
|
||||
|
||||
/* Font used in left-hand frame lists */
|
||||
.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
|
||||
.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
|
||||
.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
|
||||
|
||||
/* Navigation bar fonts and colors */
|
||||
.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
|
||||
.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
|
||||
.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
|
||||
.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
|
||||
|
||||
.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
|
||||
.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
|
||||
|
@@ -0,0 +1,64 @@
|
||||
#BlueJ package file
|
||||
dependency1.from=DrawDemo
|
||||
dependency1.to=Canvas
|
||||
dependency1.type=UsesDependency
|
||||
dependency2.from=Pen
|
||||
dependency2.to=Canvas
|
||||
dependency2.type=UsesDependency
|
||||
dependency3.from=DrawDemo
|
||||
dependency3.to=Pen
|
||||
dependency3.type=UsesDependency
|
||||
objectbench.height=76
|
||||
objectbench.width=756
|
||||
package.editor.height=394
|
||||
package.editor.width=648
|
||||
package.editor.x=70
|
||||
package.editor.y=80
|
||||
package.numDependencies=3
|
||||
package.numTargets=3
|
||||
package.showExtends=true
|
||||
package.showUses=true
|
||||
project.charset=UTF-8
|
||||
readme.editor.height=707
|
||||
readme.editor.width=917
|
||||
readme.editor.x=53
|
||||
readme.editor.y=50
|
||||
target1.editor.height=756
|
||||
target1.editor.width=948
|
||||
target1.editor.x=427
|
||||
target1.editor.y=141
|
||||
target1.height=60
|
||||
target1.name=Canvas
|
||||
target1.naviview.expanded=true
|
||||
target1.showInterface=true
|
||||
target1.type=ClassTarget
|
||||
target1.typeParameters=
|
||||
target1.width=100
|
||||
target1.x=390
|
||||
target1.y=230
|
||||
target2.editor.height=700
|
||||
target2.editor.width=900
|
||||
target2.editor.x=92
|
||||
target2.editor.y=56
|
||||
target2.height=60
|
||||
target2.name=Pen
|
||||
target2.naviview.expanded=true
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.typeParameters=
|
||||
target2.width=100
|
||||
target2.x=260
|
||||
target2.y=140
|
||||
target3.editor.height=713
|
||||
target3.editor.width=1016
|
||||
target3.editor.x=311
|
||||
target3.editor.y=34
|
||||
target3.height=60
|
||||
target3.name=DrawDemo
|
||||
target3.naviview.expanded=true
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.typeParameters=
|
||||
target3.width=110
|
||||
target3.x=110
|
||||
target3.y=50
|
Reference in New Issue
Block a user