org.gnu.gnome
Class Canvas

java.lang.Object
  extended by org.gnu.glib.Struct
      extended by org.gnu.glib.GObject
          extended by org.gnu.gtk.GtkObject
              extended by org.gnu.gtk.Widget
                  extended by org.gnu.gtk.Container
                      extended by org.gnu.gtk.Layout
                          extended by org.gnu.gnome.Canvas
Direct Known Subclasses:
IconList

public class Canvas
extends org.gnu.gtk.Layout

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


Constructor Summary
Canvas()
          Deprecated.  
Canvas(boolean useAntialiased)
          Constructs a new Canvas.
Canvas(org.gnu.glib.Handle handle)
          Constructs a new Canvas object form a native resource.
 
Method Summary
static Canvas getCanvas(org.gnu.glib.Handle handle)
          Internal static factory method to be used by Java-Gnome only.
 boolean getCenterScrollRegion()
           
 org.gnu.gdk.Color getColor(java.lang.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.
 org.gnu.gdk.RgbDither getDither()
          Returns the dither mode of an antialiased canvas.
 CanvasItem getFocusedCanvasItem()
          The currently focused item, or NULL if none.
 CanvasItem getGrabbedCanvasItem()
          The item that holds a pointer grab, or NULL if none.
 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.
 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.
 double getScrollX2()
          The x2 coordinate of the scrolling region.
 double getScrollY1()
          The y1 coordinate of the scrolling region.
 double getScrollY2()
          The y2 coordinate of the scrolling region.
static org.gnu.glib.Type getType()
          Retrieve the runtime type used by the GLib library.
 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(org.gnu.gdk.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)
           
 
Methods inherited from class org.gnu.gtk.Layout
addChild, getBinWindow, getHorizontalAdjustment, getLayout, getSize, getVerticalAdjustment, moveChild, setHorizontalAdjustment, setSize, setVerticalAdjustment
 
Methods inherited from class org.gnu.gtk.Container
add, addListener, getBooleanChildProperty, getBorderWidth, getChildProperty, getChildren, getEventListenerClass, getEventType, getIntChildProperty, getResizeMode, remove, removeListener, resizeChildren, setBooleanChildProperty, setBorderWidth, setChildProperty, setIntChildProperty, setResizeMode
 
Methods inherited from class org.gnu.gtk.Widget
activate, addAccelerator, addEvents, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, canActivateAccel, createContext, createLayout, draw, drawArea, drawArea, finish, getAccessible, getAllocation, getCanFocus, getColormap, getContext, getData, getDisplay, getDragData, getExtensionEvents, getModifierStyle, getName, getParent, getParentWindow, getPointer, getRootWindow, getScreen, getSensitive, getStyle, getToplevel, getWidget, getWindow, grabDefault, grabFocus, hasFocus, hasScreen, hide, hideAll, highlight, highlight, intersect, isAncestor, makeWidget, modifyStyle, popColormap, pushColormap, realize, removeAccelerator, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, reparent, setBackgroundColor, setBaseColor, setCanFocus, setColormap, setDoubleBuffered, setDragDestination, setDragIcon, setDragIconPixbuf, setDragIconStock, setDragSource, setEvents, setExtensionEvents, setFont, setForegroundColor, setMinimumSize, setName, setNoDragDestination, setNoDragSource, setSensitive, setTextColor, shapeCombineMask, show, showAll, unHighlight, unHighlight
 
Methods inherited from class org.gnu.gtk.GtkObject
destroy, sink
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class org.gnu.glib.Struct
equals, getHandle, getNullHandle, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Canvas

public Canvas(boolean useAntialiased)
Constructs a new Canvas.


Canvas

public Canvas()
Deprecated. 

Construct a new Canvas.


Canvas

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

Parameters:
handle - The handle to the native resource.
Method Detail

getCanvas

public static Canvas getCanvas(org.gnu.glib.Handle handle)
Internal static factory method to be used by Java-Gnome only.


getColor

public org.gnu.gdk.Color getColor(java.lang.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.


getDither

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


setDither

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


getFocusedCanvasItem

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


getGrabbedCanvasItem

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


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.


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

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.


setScrollX1

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

Parameters:
x1 -

getScrollX2

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


setScrollX2

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

Parameters:
x2 -

getScrollY1

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


setScrollY1

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

Parameters:
y1 -

getScrollY2

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


setScrollY2

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

Parameters:
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.

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.

update

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


getType

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


getCenterScrollRegion

public boolean getCenterScrollRegion()

setCenterScrollRegion

public void setCenterScrollRegion(boolean center)

requestRedraw

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

windowToWorldX

public double windowToWorldX(double winx)

windowToWorldY

public double windowToWorldY(double winy)

worldToWindowX

public double worldToWindowX(double worldx)

worldToWindowY

public double worldToWindowY(double worldy)