org.gnu.gnome

Class Canvas

Known Direct Subclasses:
IconList

public class Canvas
extends Layout

You can use the GnomeCanvas widget to draw figures, display graphics, position widgets, and more.

Constructor Summary

Canvas()
Deprecated.
Canvas(Handle handle)
Constructs a new Canvas object form a native resource.
Canvas(boolean useAntialiased)
Constructs a new Canvas.

Method Summary

boolean
getCenterScrollRegion()
Color
getColor(String spec)
Takes a string specification for a color and allocates it into the specified GdkColor.
long
getColorPixel(int rgba)
Allocates a color from the RGB value passed into this function.
CanvasItem
getCurrentCanvasItem()
The item containing the mouse pointer, or NULL if none.
protected static Handle
getCurrentItem(Handle cptr)
RgbDither
getDither()
Returns the dither mode of an antialiased canvas.
CanvasItem
getFocusedCanvasItem()
The currently focused item, or NULL if none.
protected static Handle
getFocusedItem(Handle cptr)
CanvasItem
getGrabbedCanvasItem()
The item that holds a pointer grab, or NULL if none.
protected static Handle
getGrabbedItem(Handle cptr)
CanvasItem
getItemAt(double x, double y)
Returns the item that is at the specified position in world coordinates, or NULL if no item is there.
double
getPixelsPerUnit()
Scaling factor to be used for display.
protected static double
getPixelsPerUnit(Handle cptr)
CanvasGroup
getRoot()
Returns the root canvas item group of the canvas
double
getScrollOffsetX()
Returns the horizontal scroll offset of the canvas in canvas pixel coordinates.
double
getScrollOffsetY()
Returns the vertical scroll offset of the canvas in canvas pixel coordinates.
double
getScrollX1()
The x1 coordinate of the scrolling region.
protected static double
getScrollX1(Handle cptr)
double
getScrollX2()
The x2 coordinate of the scrolling region.
protected static double
getScrollX2(Handle cptr)
double
getScrollY1()
The y1 coordinate of the scrolling region.
protected static double
getScrollY1(Handle cptr)
double
getScrollY2()
The y2 coordinate of the scrolling region.
protected static double
getScrollY2(Handle cptr)
static Type
getType()
Retrieve the runtime type used by the GLib library.
protected static boolean
gnome_canvas_get_center_scroll_region(Handle canvas)
protected static boolean
gnome_canvas_get_color(Handle canvas, String spec, Handle[] color)
protected static long
gnome_canvas_get_color_pixel(Handle canvas, int rgba)
protected static int
gnome_canvas_get_dither(Handle canvas)
protected static Handle
gnome_canvas_get_item_at(Handle canvas, double x, double y)
protected static void
gnome_canvas_get_scroll_offsets(Handle canvas, int[] cx, int[] cy)
protected static void
gnome_canvas_get_scroll_region(Handle canvas, double[] x1, double[] y1, double[] x2, double[] y2)
protected static int
gnome_canvas_get_type()
protected static Handle
gnome_canvas_new()
protected static Handle
gnome_canvas_new_aa()
protected static void
gnome_canvas_request_redraw(Handle canvas, int x1, int y1, int x2, int y2)
protected static Handle
gnome_canvas_root(Handle canvas)
protected static void
gnome_canvas_scroll_to(Handle canvas, int cx, int cy)
protected static void
gnome_canvas_set_center_scroll_region(Handle canvas, boolean center)
protected static void
gnome_canvas_set_dither(Handle canvas, int dither)
protected static void
gnome_canvas_set_pixels_per_unit(Handle canvas, double n)
protected static void
gnome_canvas_set_scroll_region(Handle canvas, double x1, double y1, double x2, double y2)
protected static void
gnome_canvas_set_stipple_origin(Handle canvas, Handle gc)
protected static void
gnome_canvas_update_now(Handle canvas)
protected static void
gnome_canvas_window_to_world(Handle canvas, double winx, double winy, double[] worldx, double[] worldy)
protected static void
gnome_canvas_world_to_window(Handle canvas, double worldx, double worldy, double[] winx, double[] winy)
void
requestRedraw(int x1, int y1, int x2, int y2)
void
scrollTo(int cx, int cy)
Scrolls the canvas to the specified offsets, given in canvas pixel coordinates.
void
setCenterScrollRegion(boolean center)
void
setDither(RgbDither dither)
Controls the dithering used when the canvas renders.
void
setPixelsPerUnit(double n)
Sets the number of pixels that correspond to one unit in world coordinates.
void
setScrollRegion(double x1, double y1, double x2, double y2)
Convenience method to set all 4 coordinates of the scroll region at once.
void
setScrollX1(double x1)
Set the scroll region's X1 coordinate.
void
setScrollX2(double x2)
Set the scroll region's X2 coordinate.
void
setScrollY1(double y1)
Set the scroll region's Y1 coordinate.
void
setScrollY2(double y2)
Set the scroll region's Y2 coordinate.
void
update()
Requests that the canvas be repainted immediately instead of during the idle loop.
double
windowToWorldX(double winx)
double
windowToWorldY(double winy)
double
worldToWindowX(double worldx)
double
worldToWindowY(double worldy)

Constructor Details

Canvas

public Canvas()

Deprecated.

Construct a new Canvas.


Canvas

public Canvas(Handle handle)
Constructs a new Canvas object form a native resource.

Parameters:
handle - The handle to the native resource.


Canvas

public Canvas(boolean useAntialiased)
Constructs a new Canvas.

Method Details

getCenterScrollRegion

public boolean getCenterScrollRegion()


getColor

public Color getColor(String spec)
Takes a string specification for a color and allocates it into the specified GdkColor.

Parameters:
spec - The color to allocate.


getColorPixel

public long getColorPixel(int rgba)
Allocates a color from the RGB value passed into this function.

Parameters:
rgba - The RGB value.


getCurrentCanvasItem

public CanvasItem getCurrentCanvasItem()
The item containing the mouse pointer, or NULL if none.


getCurrentItem

protected static final Handle getCurrentItem(Handle cptr)


getDither

public RgbDither getDither()
Returns the dither mode of an antialiased canvas. Only applicable to antialiased canvases - ignored by non-antialiased convases.


getFocusedCanvasItem

public CanvasItem getFocusedCanvasItem()
The currently focused item, or NULL if none.


getFocusedItem

protected static final Handle getFocusedItem(Handle cptr)


getGrabbedCanvasItem

public CanvasItem getGrabbedCanvasItem()
The item that holds a pointer grab, or NULL if none.


getGrabbedItem

protected static final Handle getGrabbedItem(Handle cptr)


getItemAt

public CanvasItem getItemAt(double x,
                            double y)
Returns the item that is at the specified position in world coordinates, or NULL if no item is there.

Parameters:
x - The horizontal coordinate.
y - The vertical coordinate.


getPixelsPerUnit

public double getPixelsPerUnit()
Scaling factor to be used for display.


getPixelsPerUnit

protected static final double getPixelsPerUnit(Handle cptr)


getRoot

public CanvasGroup getRoot()
Returns the root canvas item group of the canvas


getScrollOffsetX

public double getScrollOffsetX()
Returns the horizontal scroll offset of the canvas in canvas pixel coordinates.

Returns:
The scroll offset x coordinate.


getScrollOffsetY

public double getScrollOffsetY()
Returns the vertical scroll offset of the canvas in canvas pixel coordinates.

Returns:
The scroll offset y coordinate.


getScrollX1

public double getScrollX1()
The x1 coordinate of the scrolling region.


getScrollX1

protected static final double getScrollX1(Handle cptr)


getScrollX2

public double getScrollX2()
The x2 coordinate of the scrolling region.


getScrollX2

protected static final double getScrollX2(Handle cptr)


getScrollY1

public double getScrollY1()
The y1 coordinate of the scrolling region.


getScrollY1

protected static final double getScrollY1(Handle cptr)


getScrollY2

public double getScrollY2()
The y2 coordinate of the scrolling region.


getScrollY2

protected static final double getScrollY2(Handle cptr)


getType

public static Type getType()
Retrieve the runtime type used by the GLib library.


gnome_canvas_get_center_scroll_region

protected static final boolean gnome_canvas_get_center_scroll_region(Handle canvas)


gnome_canvas_get_color

protected static final boolean gnome_canvas_get_color(Handle canvas,
                                                      String spec,
                                                      Handle[] color)


gnome_canvas_get_color_pixel

protected static final long gnome_canvas_get_color_pixel(Handle canvas,
                                                         int rgba)


gnome_canvas_get_dither

protected static final int gnome_canvas_get_dither(Handle canvas)


gnome_canvas_get_item_at

protected static final Handle gnome_canvas_get_item_at(Handle canvas,
                                                       double x,
                                                       double y)


gnome_canvas_get_scroll_offsets

protected static final void gnome_canvas_get_scroll_offsets(Handle canvas,
                                                            int[] cx,
                                                            int[] cy)


gnome_canvas_get_scroll_region

protected static final void gnome_canvas_get_scroll_region(Handle canvas,
                                                           double[] x1,
                                                           double[] y1,
                                                           double[] x2,
                                                           double[] y2)


gnome_canvas_get_type

protected static final int gnome_canvas_get_type()


gnome_canvas_new

protected static final Handle gnome_canvas_new()


gnome_canvas_new_aa

protected static final Handle gnome_canvas_new_aa()


gnome_canvas_request_redraw

protected static final void gnome_canvas_request_redraw(Handle canvas,
                                                        int x1,
                                                        int y1,
                                                        int x2,
                                                        int y2)


gnome_canvas_root

protected static final Handle gnome_canvas_root(Handle canvas)


gnome_canvas_scroll_to

protected static final void gnome_canvas_scroll_to(Handle canvas,
                                                   int cx,
                                                   int cy)


gnome_canvas_set_center_scroll_region

protected static final void gnome_canvas_set_center_scroll_region(Handle canvas,
                                                                  boolean center)


gnome_canvas_set_dither

protected static final void gnome_canvas_set_dither(Handle canvas,
                                                    int dither)


gnome_canvas_set_pixels_per_unit

protected static final void gnome_canvas_set_pixels_per_unit(Handle canvas,
                                                             double n)


gnome_canvas_set_scroll_region

protected static final void gnome_canvas_set_scroll_region(Handle canvas,
                                                           double x1,
                                                           double y1,
                                                           double x2,
                                                           double y2)


gnome_canvas_set_stipple_origin

protected static final void gnome_canvas_set_stipple_origin(Handle canvas,
                                                            Handle gc)


gnome_canvas_update_now

protected static final void gnome_canvas_update_now(Handle canvas)


gnome_canvas_window_to_world

protected static final void gnome_canvas_window_to_world(Handle canvas,
                                                         double winx,
                                                         double winy,
                                                         double[] worldx,
                                                         double[] worldy)


gnome_canvas_world_to_window

protected static final void gnome_canvas_world_to_window(Handle canvas,
                                                         double worldx,
                                                         double worldy,
                                                         double[] winx,
                                                         double[] winy)


requestRedraw

public void requestRedraw(int x1,
                          int y1,
                          int x2,
                          int y2)


scrollTo

public void scrollTo(int cx,
                     int cy)
Scrolls the canvas to the specified offsets, given in canvas pixel coordinates.

Parameters:
cx - Horizontal coordinate.
cy - Vertical coordinate.


setCenterScrollRegion

public void setCenterScrollRegion(boolean center)


setDither

public void setDither(RgbDither dither)
Controls the dithering used when the canvas renders. Only applicable to antialiased canvases - ignored by non-antialiased canvases.


setPixelsPerUnit

public void setPixelsPerUnit(double n)
Sets the number of pixels that correspond to one unit in world coordinates.

Parameters:
n - The number of pixels


setScrollRegion

public void setScrollRegion(double x1,
                            double y1,
                            double x2,
                            double y2)
Convenience method to set all 4 coordinates of the scroll region at once.

Parameters:
x1 - First horizontal coordinate.
y1 - First vertical coordinate.
x2 - Second horizontal coordinate.
y2 - Second vertical coordinate.


setScrollX1

public void setScrollX1(double x1)
Set the scroll region's X1 coordinate.

Parameters:
x1 -


setScrollX2

public void setScrollX2(double x2)
Set the scroll region's X2 coordinate.

Parameters:
x2 -


setScrollY1

public void setScrollY1(double y1)
Set the scroll region's Y1 coordinate.

Parameters:
y1 -


setScrollY2

public void setScrollY2(double y2)
Set the scroll region's Y2 coordinate.

Parameters:
y2 -


update

public void update()
Requests that the canvas be repainted immediately instead of during the idle loop.


windowToWorldX

public double windowToWorldX(double winx)


windowToWorldY

public double windowToWorldY(double winy)


worldToWindowX

public double worldToWindowX(double worldx)


worldToWindowY

public double worldToWindowY(double worldy)