java.lang.ObjectPpl
public class Ppl
| Constructor Summary | |
|---|---|
Ppl()
|
|
| Method Summary | |
|---|---|
static char[] |
charFromFile(java.lang.String fileName)
reads the whole content of a file and returns it as a char array |
static char[] |
charFromFile(java.lang.String fileName,
java.lang.String charsetName)
reads the whole content of a file and returns it as a char array |
static void |
clear()
Removes all shapes from the window. |
static int |
drawCircle(double cx,
double cy,
double r)
|
static int |
drawLine(double x1,
double y1,
double x2,
double y2)
|
static int |
drawLine(double x1,
double y1,
double x2,
double y2,
java.awt.Color color)
|
static boolean |
endOfInput()
Test for availability of more input. |
static int |
erase(java.awt.Shape shape)
Adds a white shape to the window. |
static int |
eraseCircle(double cx,
double cy,
double r)
|
static void |
failWith(java.lang.String message)
Throws an new exception with the given message |
static boolean |
hasNextDouble()
Tells whether a double is available on input |
static boolean |
hasNextInt()
Tells whether an int is available on input |
static void |
initDrawing(java.lang.String s,
int x,
int y,
int w,
int h)
Opens a drawing window. |
static int |
paint(java.awt.Shape shape,
java.awt.Color fg,
java.awt.Color bg)
Adds a shape to the window. |
static int |
paintCircle(double cx,
double cy,
double r)
|
static int |
paintCircle(double cx,
double cy,
double r,
java.awt.Color fg,
java.awt.Color bg)
|
static char |
readChar()
Reads a single character from the input. |
static double |
readDouble()
Reads a double from the input. |
static int |
readInt()
Reads an int from the input. |
static java.lang.String |
readWord()
Reads a word (delimitted by spaces) from the input as a Java String. |
static char[] |
readWordAsCharArray()
Reads a word (delimitted by spaces) from the input as an array of char. |
static void |
remove(int index)
Removes a shape from the window. |
static void |
save(java.lang.String fileName)
Saves the drawing of the window in a file. |
static void |
sleep(int milliseconds)
Wait from an amount of time. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Ppl()
| Method Detail |
|---|
public static void initDrawing(java.lang.String s,
int x,
int y,
int w,
int h)
s - the title of the window.x - the abscissa of the upper left corner of the window.y - the ordinate of the upper left corner of the window.w - the width of the drawing area of the window.h - the height of the drawing area of the window.
public static int paint(java.awt.Shape shape,
java.awt.Color fg,
java.awt.Color bg)
shape - the shape to be added.fg - the stroke color.bg - the fill color.
public static void remove(int index)
paint
or erase and must not have already been removed.
index - the index of the shape.
java.util.NoSuchElementException - if no shape of such index is present.public static void clear()
public static int erase(java.awt.Shape shape)
remove.
shape - the white shape to draw.
public static int drawLine(double x1,
double y1,
double x2,
double y2)
public static int drawLine(double x1,
double y1,
double x2,
double y2,
java.awt.Color color)
public static int drawCircle(double cx,
double cy,
double r)
public static int paintCircle(double cx,
double cy,
double r)
public static int paintCircle(double cx,
double cy,
double r,
java.awt.Color fg,
java.awt.Color bg)
public static int eraseCircle(double cx,
double cy,
double r)
public static int readInt()
public static boolean hasNextInt()
public static char[] readWordAsCharArray()
char.
public static java.lang.String readWord()
String.
public static double readDouble()
public static boolean hasNextDouble()
public static char readChar()
public static boolean endOfInput()
true is no more input is available.public static void save(java.lang.String fileName)
fileName - the file name.public static void sleep(int milliseconds)
milliseconds - the time in milliseconds.public static char[] charFromFile(java.lang.String fileName)
fileName - the file name
java.lang.IllegalArgumentException - when file does not exist or is not readable
public static char[] charFromFile(java.lang.String fileName,
java.lang.String charsetName)
fileName - the file namecharsetName - the name of the charset (UTF-8, US-ASCII, latin1, latin9, ...)
java.lang.IllegalArgumentException - when file does not exist or is not readable
java.nio.charset.UnsupportedCharsetException - if no support for the named charset is availablepublic static void failWith(java.lang.String message)
message - the exception message