|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container acm.graphics.GCanvas
public class GCanvas
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.
Field Summary |
---|
Constructor Summary | |
---|---|
GCanvas()
GCanvas that contains no objects. |
Method Summary | |
---|---|
Component |
add(Component comp)
|
void |
add(Component comp,
double x,
double y)
x , y ). |
void |
add(Component comp,
GPoint pt)
|
void |
add(GObject gobj)
|
void |
add(GObject gobj,
double x,
double y)
x , y ). |
void |
add(GObject gobj,
GPoint pt)
|
boolean |
getAutoRepaintFlag()
setAutoRepaintFlag . |
GObject |
getElement(int index)
|
GObject |
getElementAt(double x,
double y)
x , y ), or null if no such
object exists. |
GObject |
getElementAt(GPoint pt)
null if no such object exists. |
int |
getElementCount()
GCanvas . |
int |
getHeight()
|
boolean |
getNativeArcFlag()
setNativeArcFlag . |
int |
getWidth()
|
Iterator<GObject> |
iterator()
Iterator that cycles through the elements within
this container in the default direction, which is from back to front. |
Iterator<GObject> |
iterator(int direction)
Iterator that cycles through the elements
within this container in the specified direction, which must be one
of the constants GContainer.FRONT_TO_BACK
or GContainer.BACK_TO_FRONT . |
void |
remove(Component comp)
|
void |
remove(GObject gobj)
GCanvas . |
void |
removeAll()
GCanvas . |
void |
setAutoRepaintFlag(boolean state)
|
void |
setNativeArcFlag(boolean state)
GArc and GOval should use
Java arcs. |
Constructor Detail |
---|
public GCanvas()
GCanvas
that contains no objects.
Usage: | GCanvas gc = new GCanvas(); |
Method Detail |
---|
public Component add(Component comp)
Component
to match the method in
the Container
class, but the result is typically
ignored.
Usage: | gc.add(comp); | ||
Parameter: |
|
public final void add(Component comp,
double x,
double y)
x
, 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: |
|
add
in interface GContainer
public final void add(GObject gobj,
double x,
double y)
x
, y
).
Usage: | gc.add(gobj, x, y); | ||||||
Parameters: |
|
add
in interface GContainer
public final void add(GObject gobj,
GPoint pt)
Usage: | gc.add(gobj, pt); | ||||
Parameters: |
|
add
in interface GContainer
public boolean getAutoRepaintFlag()
setAutoRepaintFlag
.
Usage: | if (gc.getAutoRepaintFlag()) . . . |
Returns: | true if auto-repaint mode is enabled, and false
otherwise
|
public GObject getElement(int index)
Usage: | GObject gobj = gc.getElement(index); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified index |
getElement
in interface GContainer
public GObject getElementAt(double x,
double y)
x
, y
), or null
if no such
object exists.
Usage: | GObject gobj = gc.getElementAt(x, y); | ||||
Parameters: |
| ||||
Returns: | The graphical object at the specified location, or null
if no such object exists
|
getElementAt
in interface GContainer
public final GObject getElementAt(GPoint pt)
null
if no such object exists.
Usage: | GObject gobj = gc.getElementAt(pt); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified location, or null
if no such object exists
|
getElementAt
in interface GContainer
public int getElementCount()
GCanvas
.
Usage: | int n = gc.getElementCount(); |
Returns: | The number of graphical objects in this GCanvas
|
getElementCount
in interface GContainer
public int getHeight()
Usage: | int height = gc.getHeight(); |
Returns: | The height of this canvas in pixels |
public boolean getNativeArcFlag()
setNativeArcFlag
.
Usage: | if (gc.getNativeArcFlag()) . . . |
Returns: | true if native arcs are enabled, and false
otherwise
|
public int getWidth()
Usage: | int width = gc.getWidth(); |
Returns: | The width of this canvas |
public Iterator<GObject> iterator()
Iterator
that cycles through the elements within
this container in the default direction, which is from back to front.
You can also run the iterator in the opposite direction by using the
iterator
(
direction)
form of this method.
Usage: | Iterator |
Returns: | An Iterator ranging over the elements of the
container from back to front
|
public Iterator<GObject> iterator(int direction)
Iterator
that cycles through the elements
within this container in the specified direction, which must be one
of the constants GContainer.FRONT_TO_BACK
or GContainer.BACK_TO_FRONT
.
for (Iterator<GObject> i = gc.iterator(direction); i.hasNext(); )
Usage: | Iterator |
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)
GCanvas
.
Usage: | gc.remove(gobj); | ||
Parameter: |
|
remove
in interface GContainer
public void removeAll()
GCanvas
.
Usage: | gc.removeAll(); |
removeAll
in interface GContainer
public void setAutoRepaintFlag(boolean state)
setAutoRepaintFlag(false)
, but you must then make explicit
calls to repaint()
whenever you want to update the display.
The advantage of this model is that you can then make many different changes
and have them all appear at once with a single repaint
call.
Usage: | gc.setAutoRepaintFlag(state); | ||
Parameter: |
|
public void setNativeArcFlag(boolean state)
GArc
and GOval
should use
Java arcs. By default, arcs and ovals are rendered using polygons and polylines
to ensure that the same set of pixels is covered by the fill and frame.
If this value is set to true
, the renderers will use the native
arc code, which is more efficient but less accurate.
Usage: | gc.setNativeArcFlag(state); | ||
Parameter: |
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |