×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    353

    getClip() equivalent in MIDP2.0

    java.awt.Graphics has a getClip() method that returns a Shape Object.
    I am not interested in the return type but only in the implementation.

    javax.microedition.lcdui.Graphics has getClipX(), getClipY(), getClipWidth() and getClipHeight() methods.

    Could I have the same functionality has getClip() in MIDP2.0?
    Last edited by KevinBoyd; 2009-09-07 at 04:49. Reason: added words

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: getClip() equivalent in MIDP2.0

    You've found the functionality you're looking for. MIDP doesn't have classes like Rectangle. However, you could create one.

    PHP Code:
    // don't put this in a "java." package!!
    package com.mycompany.mid.awtreplacement;

    public class 
    Rectange {
        private 
    int xywidthheight;

        public 
    Rectangle(int xint yint widthint height) {
            
    // ...etc.
        
    }

    Then write yourself a utility method to replace getClip()...

    PHP Code:
    public static Rectangle getClip(Graphics g) {
        return new 
    Rectangle(g.getClipX(), g.getClipY(), g.getClipWidth(), g.getClipHeight());

    Graham.

  3. #3
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    353

    Re: getClip() equivalent in MIDP2.0

    Instead of the Rectangle class could I use the default methods in MIDP instead of getClip()?

    getClipX(), getClipY(), getClipWidth() and getClipHeight()...

    For an understanding,
    what would go wrong with these four methods?
    What are the cons of this technique versus the Rectangle technique?

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: getClip() equivalent in MIDP2.0

    The only way to get the clip region is those four methods.

    The only advantage to adding the code I suggested is if the code you're porting expects a java.awt.Rectangle object, then supplying an object that looks similar might help. "getClip()" is just a wrapper for these four methods, so it works exactly the same.

    Graham.

Similar Threads

  1. ALL MIDP2.0 Mobiles have WMA1.0 or 1.1?
    By pmramprasath in forum Mobile Java General
    Replies: 20
    Last Post: 2007-01-29, 13:25
  2. How to play AMR files in MIDP2.0
    By Creator3D in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-17, 08:35
  3. JPG & MIDP2.0 & Sprite
    By Creator3D in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-02-25, 14:44
  4. Support of socket connection in MIDP2.0
    By mendjeli in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2004-02-24, 19:33
  5. midp2.0 series 60
    By casolorz in forum Mobile Java General
    Replies: 8
    Last Post: 2003-07-10, 21:49

Posting Permissions

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