×

Discussion Board

Results 1 to 4 of 4

Thread: canvas

  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    166

    canvas

    do anyone knows canvas concepts

    actually i am displaying an image on canvas and want to display a cursor or an arrow which will capture key events user will select two such points on the image this points will be the clipping region i.e create new image considering this new point and clip the original image


    thnks

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: canvas

    Hi Mahesh,
    Follow step by step..
    Canvas - As per java docs says..

    The Canvas class is a base class for writing applications that need to handle low-level events and to issue graphics calls for drawing to the display. Game applications will likely make heavy use of the Canvas class. From an application development perspective, the Canvas class is interchangeable with standard Screen classes, so an application may mix and match Canvas with high-level screens as needed. For example, a List screen may be used to select the track for a racing game, and a Canvas subclass would implement the actual game.

    The Canvas provides the developer with methods to handle game actions, key events, and pointer events (if supported by the device). Methods are also provided to identify the device's capabilities and mapping of keys to game actions. The key events are reported with respect to key codes, which are directly bound to concrete keys on the device, use of which may hinder portability. Portable applications should use game actions instead of key codes.

    Like other subclasses of Displayable, the Canvas class allows the application to register a listener for commands. Unlike other Displayables, however, the Canvas class requires applications to subclass it in order to use it. The paint() method is declared abstract, and so the application must provide an implementation in its subclass. Other event-reporting methods are not declared abstract, and their default implementations are empty (that is, they do nothing). This allows the application to override only the methods that report events in which the application has interest.

    This is in contrast to the Screen classes, which allow the application to define listeners and to register them with instances of the Screen classes. This style is not used for the Canvas class, because several new listener interfaces would need to be created, one for each kind of event that might be delivered. An alternative would be to have fewer listener interfaces, but this would require listeners to filter out events in which they had no interest.
    Read it out..
    Though you can go to java docs by your self..anyways..read it.
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: canvas

    Hi Mahesh,
    You can then draw the images over the canvas ..its really simple and can be done..like this..

    @ Graphics.drawImage(ImageToDraw ,XOffset,YOffset,anchorpoint);
    in details -
    Draws the specified image by using the anchor point. The image can be drawn in different positions relative to the anchor point by passing the appropriate position constants. See anchor points.

    If the source image contains transparent pixels, the corresponding pixels in the destination image must be left untouched. If the source image contains partially transparent pixels, a compositing operation must be performed with the destination pixels, leaving all pixels of the destination image fully opaque.

    If img is the same as the destination of this Graphics object, the result is undefined. For copying areas within an Image, copyArea should be used instead.

    Parameters:
    img - the specified image to be drawn
    x - the x coordinate of the anchor point
    y - the y coordinate of the anchor point
    anchor - the anchor point for positioning the image
    Throws:
    IllegalArgumentException - if anchor is not a legal value
    NullPointerException - if img is null
    @ For displaying the cursor you have to do the code ..there is no in built API available.Hope you can do it..

    @ For clipping the image/text/others there is a method called as setClip(xOff,yOff,WidthofClip,HeightOFClip);

    In details..
    Sets the current clip to the rectangle specified by the given coordinates. Rendering operations have no effect outside of the clipping area.

    Parameters:
    x - the x coordinate of the new clip rectangle
    y - the y coordinate of the new clip rectangle
    width - the width of the new clip rectangle
    height - the height of the new clip rectangle
    I hope that these lines can help you..
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    166

    Re: canvas

    thanks a lot for ur reply raj

Similar Threads

  1. is it possible to draw a line over videocontrol in a canvas?
    By byronlilu in forum Mobile Java General
    Replies: 13
    Last Post: 2008-11-28, 11:58
  2. How to create a partly transparent Canvas to lay on top of another Canvas?
    By mkleijer in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-05-22, 07:00
  3. Major problem with delegation to Canvas
    By bartekn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2003-10-08, 17:46
  4. 7650 and 3650 Canvas and FullCanvas memory
    By marcilgen in forum Mobile Java General
    Replies: 5
    Last Post: 2003-07-08, 12:24
  5. Larger canvas?
    By bjajo780 in forum Mobile Java General
    Replies: 1
    Last Post: 2002-06-18, 14:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×