|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--acm.graphics.GCanvas
public class GCanvas extends Container implements GContainer
The GCanvas class is a lightweight component that also serves as a container for graphical objects. As such, this class provides the link between graphical objects and the window system. Conceptually, the GCanvas provides a background canvas to which other graphical objects can be added.
Constructor Summary |
GCanvas() |
Method Summary | |
Component | add(Component comp) |
void | add(Component comp,
double x,
double y) |
void | add(Component comp,
GPoint pt) |
void | add(GObject gobj) |
void | add(GObject gobj,
double x,
double y) |
void | add(GObject gobj,
GPoint pt) |
boolean | getAutoRepaintFlag() |
GObject | getElement(int index) |
GObject | getElementAt(double x,
double y) |
GObject | getElementAt(GPoint pt) |
int | getElementCount() |
int | getHeight() |
boolean | getNativeArcFlag() |
int | getWidth() |
Iterator | iterator() |
Iterator | iterator(int direction) |
void | remove(Component comp) |
void | remove(GObject gobj) |
void | removeAll() |
void | setAutoRepaintFlag(boolean state) |
void | setNativeArcFlag(boolean state) |
Constructor Detail |
public GCanvas()
Usage: | GCanvas gc = new GCanvas(); |
Method Detail |
public Component add(Component comp)
Usage: | gc.add(comp); | ||
Parameter: |
|
public final void add(Component comp,
double x,
double y)
Usage: | gc.add(comp, x, y); | ||||||
Parameters: |
|
public final void add(Component comp,
GPoint pt)
Usage: | gc.add(comp, pt); | ||||
Parameters: |
|
public void add(GObject gobj)
Usage: | gc.add(gobj); | ||
Parameter: |
| ||
Specified by: | add in interface GContainer |
public final void add(GObject gobj,
double x,
double y)
Usage: | gc.add(gobj, x, y); | ||||||
Parameters: |
| ||||||
Specified by: | add in interface GContainer |
public final void add(GObject gobj,
GPoint pt)
Usage: | gc.add(gobj, pt); | ||||
Parameters: |
| ||||
Specified by: | add in interface GContainer |
public boolean getAutoRepaintFlag()
Usage: | if (gc.getAutoRepaintFlag()) . . . |
Returns: | true if auto-repaint mode is enabled, and falseotherwise |
public GObject getElement(int index)
Usage: | GObject gobj = gc.getElement(index); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified index | ||
Specified by: | getElement in interface GContainer |
public GObject getElementAt(double x,
double y)
Usage: | GObject gobj = gc.getElementAt(x, y); | ||||
Parameters: |
| ||||
Returns: | The graphical object at the specified location, or nullif no such object exists | ||||
Specified by: | getElementAt in interface GContainer |
public final GObject getElementAt(GPoint pt)
Usage: | GObject gobj = gc.getElementAt(pt); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified location, or nullif no such object exists | ||
Specified by: | getElementAt in interface GContainer |
public int getElementCount()
Usage: | int n = gc.getElementCount(); |
Returns: | The number of graphical objects in this GCanvas |
Specified by: | getElementCount in interface GContainer |
public int getHeight()
Usage: | int height = gc.getHeight(); |
Returns: | The height of this canvas in pixels |
public boolean getNativeArcFlag()
Usage: | if (gc.getNativeArcFlag()) . . . |
Returns: | true if native arcs are enabled, and falseotherwise |
public int getWidth()
Usage: | int width = gc.getWidth(); |
Returns: | The width of this canvas |
public Iterator iterator()
Applets that want to run in browsers, however, should avoid using this method, because Iterator is not supported on 1.1 browsers. For maximum portability, you should rely instead on the getElementCount and getElement methods, which provide the same functionality in a browser-compatible way.
Usage: | Iterator i = gc.iterator(); |
Returns: | An Iterator ranging over the elements of the container from back to front |
public Iterator iterator(int direction)
for (Iterator i = gc.iterator(direction); i.hasNext(); )
Applets that want to run in browsers, however, should avoid using this method, because Iterator is not supported on 1.1 browsers. For maximum portability, you should rely instead on the getElementCount and getElement methods, which provide the same functionality in a browser-compatible way.
Usage: | Iterator i = gc.iterator(direction); |
Returns: | An Iterator ranging over the elements of the container in the specified direction |
public void remove(Component comp)
Usage: | gc.remove(comp); | ||
Parameter: |
|
public void remove(GObject gobj)
Usage: | gc.remove(gobj); | ||
Parameter: |
| ||
Specified by: | remove in interface GContainer |
public void removeAll()
Usage: | gc.removeAll(); |
Specified by: | removeAll in interface GContainer |
public void setAutoRepaintFlag(boolean state)
Usage: | gc.setAutoRepaintFlag(state); | ||
Parameter: |
|
public void setNativeArcFlag(boolean state)
Usage: | gc.setNativeArcFlag(state); | ||
Parameter: |
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |