|
|||||||
| 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 GContainerThe 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.
| Field Summary | |
| static int | BACK_TO_FRONT
|
| static int | FRONT_TO_BACK
|
| Constructor Summary |
| GCanvas()
|
| Method Summary | |
| Component | add(Component comp)
|
| void | add(Component comp,
double x,
double y)
|
| void | add(Component comp,
java.awt.Point pt)
|
| void | add(GObject gobj)
|
| void | add(GObject gobj,
double x,
double y)
|
| void | add(GObject gobj,
java.awt.Point pt)
|
| GObject | getElement(int index)
|
| GObject | getElementAt(double x,
double y)
|
| GObject | getElementAt(Point pt)
|
| int | getElementCount()
|
| int | getHeight()
|
| int | getWidth()
|
| boolean | isAutoRepaintEnabled()
|
| boolean | isOpaque()
|
| Iterator | iterator()
|
| Iterator | iterator(int direction)
|
| void | onMouseClicked(double x,
double y)
|
| void | onMouseDragged(double x,
double y)
|
| void | onMouseMoved(double x,
double y)
|
| void | onMousePressed(double x,
double y)
|
| void | onMouseReleased(double x,
double y)
|
| void | paint(Graphics g)
|
| void | remove(GObject gobj)
|
| void | removeAll()
|
| void | setAutoRepaintEnabled(boolean state)
|
| void | setOpaque(boolean flag)
|
| Field Detail |
public static final int BACK_TO_FRONT
public static final int FRONT_TO_BACK| 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(java.awt.Component comp,
double x,
double y)| Usage: | gc.add(comp, x, y); | ||||||
| Parameters: |
|
public final void add(java.awt.Component comp,
Point pt)| Usage: | gc.add(comp, pt); | ||||
| Parameters: |
|
public void add(GObject gobj)| Usage: | gc.add(gobj); | ||
| Parameter: |
| ||
| Specified by: | add in interface GContainer |
public 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,
Point pt)| Usage: | gc.add(gobj, pt); | ||||
| Parameters: |
| ||||
| Specified by: | add in interface GContainer |
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 null if no such object exists | ||||
| Specified by: | getElementAt in interface GContainer |
public final GObject getElementAt(Point pt)| Usage: | GObject gobj = gc.getElementAt(pt); | ||
| Parameter: |
| ||
| Returns: | The graphical object at the specified location, or null if 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 int getWidth()| Usage: | int width = gc.getWidth(); |
| Returns: | The width of this canvas |
public boolean isAutoRepaintEnabled()| Usage: | if (gc.isAutoRepaintEnabled()) . . . |
| Returns: | true if auto-repaint mode is enabled, and false otherwise |
public boolean isOpaque()
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 onMouseClicked(double x,
double y)| Usage: | gc.onMouseClicked(x, y); | ||||
| Parameters: |
|
public void onMouseDragged(double x,
double y)| Usage: | gc.onMouseDragged(x, y); | ||||
| Parameters: |
|
public void onMouseMoved(double x,
double y)| Usage: | gc.onMouseMoved(x, y); | ||||
| Parameters: |
|
public void onMousePressed(double x,
double y)| Usage: | gc.onMousePressed(x, y); | ||||
| Parameters: |
|
public void onMouseReleased(double x,
double y)| Usage: | gc.onMouseReleased(x, y); | ||||
| Parameters: |
|
public void paint(Graphics g)
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 setAutoRepaintEnabled(boolean state)| Usage: | gc.setAutoRepaintEnabled(state); | ||
| Parameter: |
|
public void setOpaque(boolean flag)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||