×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    15

    Thumbs up How to Put the Signature(using Pen)Nokia 5230 mobile

    Hi to All

    I'm doing j2me application, I'm using Nokia 5230 thats s60 v5 handwriting recognition featured mobile. I need to capture pen events like drag, or tap.
    In one MIDlet i had a textBox, user wants to sign(own signature) in that textbox. how to capture the sign and save .
    How can i do this?
    Suggest me any ideas! or any other way pls tel me



    By
    Chandrasekaran

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    376

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    Rather i will suggest you one thing as far you use the textbox it is going to detect keywords in it raher create canvas paint the sigature store it as image and appned this always

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,545

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    FWIW, in the documentation library http://library.forum.nokia.com/ you can create a search scope that limits the searches only to Java, and then search for "touch".

    Then you can find information about how to capture touch events in Java. E.g., the path

    Java Developer's Library 3.8
    -> Developer's Guides
    ----> UI and Graphics
    --------> Touch UI

    Once you know how to capture touch events and their location on the screen, and then if you also know how to draw points/lines on the screen (canvas), then you should be able to allow the user to write their signature on the screen, which you can then capture and display. At least in theory; I haven't tried to create something like this in Java myself. ;-)

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    Quote Originally Posted by chandrasekaranbe View Post
    Hi to All

    I'm doing j2me application, I'm using Nokia 5230 thats s60 v5 handwriting recognition featured mobile. I need to capture pen events like drag, or tap.
    In one MIDlet i had a textBox, user wants to sign(own signature) in that textbox. how to capture the sign and save .
    How can i do this?
    Suggest me any ideas! or any other way pls tel me



    By
    Chandrasekaran
    The text box that you want to use for Signature input - should be a custom item - create an image of the same size, and then you need to capture the touch events (pointer dragged) on this custom item and paint/join all the points that you get over the blank image you have created on your custom Item - i.e. using the getGraphics from it. Pass this image on submit to save or process further.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  5. #5
    Registered User
    Join Date
    Apr 2011
    Posts
    15

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    Hi Experts

    i try to this program ,i cant get drawable(sign iamge) image but empty screen is save in mobile card

    //Sample code For Paint(put sign) to save png format

    import java.io.IOException;
    import java.io.OutputStream;

    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.midlet.MIDlet;

    public class ScratchPad extends MIDlet {
    private Display display; // Display object
    private ScratchPadCanvas canvas; // Canvas

    public ScratchPad() {
    display = Display.getDisplay(this);
    canvas = new ScratchPadCanvas(this);
    }

    protected void startApp() {
    display.setCurrent(canvas);
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean unconditional) {
    }

    public void exitMIDlet() {
    destroyApp(true);
    notifyDestroyed();
    }
    }

    /*--------------------------------------------------
    * Class ScratchPadCanvas
    *
    * Pointer event handling
    *-------------------------------------------------*/
    class ScratchPadCanvas extends Canvas implements CommandListener {
    private Command cmExit; // Exit midlet
    private Command cmClear; // Clear display
    private Command cmSave; // Save Paint Image
    private int startx = 0, // Where pointer was clicked
    starty = 0, currentx = 0, // Current location
    currenty = 0;
    private ScratchPad midlet;
    private boolean clearDisplay = true;
    private Image screenshot;
    FileConnection file = null;
    OutputStream outStream = null;

    /*--------------------------------------------------
    * Constructor
    *-------------------------------------------------*/
    public ScratchPadCanvas(ScratchPad midlet) {
    this.midlet = midlet;

    cmExit = new Command("Exit", Command.EXIT, 1);
    // cmClear = new Command("Clear", Command.SCREEN, 1);
    cmSave = new Command("Save", Command.SCREEN, 1);
    addCommand(cmExit);
    // addCommand(cmClear);
    addCommand(cmSave);
    setCommandListener(this);
    }

    public Image getScreenShot() {
    screenshot = Image.createImage(getWidth(), getHeight());
    Graphics g = screenshot.getGraphics();
    g.drawLine(100, 200, 200, 100);
    paint(g);
    SaveImage(screenshot);
    return screenshot;


    }

    private void SaveImage(Image screenshot) {
    // TODO Auto-generated method stub
    try {
    // convert image to PNG (without alpha)
    byte[] pngData = PNGEncoder.toPNG(screenshot, false);
    System.out.println("PNG" + pngData.length);
    String dirPhotos = System.getProperty("fileconn.dir.photos");
    String fileName = dirPhotos + "Image.png";
    // Open file
    file = (FileConnection) Connector.open(fileName,
    Connector.READ_WRITE);
    // If there is no file then create it
    if (file.exists() == false) {
    file.create();
    }
    // Write data received from camera while making snapshot to file
    outStream = file.openOutputStream();
    outStream.write(pngData);
    System.out.println(fileName);

    // convert back to Image
    // Image newImage = Image.createImage(pngData, 0, pngData.length);
    } catch (IOException ioExc) {
    Alert ss=new Alert(ioExc.getMessage());

    } catch (Exception exc) {
    Alert ss=new Alert(exc.getMessage());
    } finally {
    // Try to close file
    try {
    if (outStream != null) {
    outStream.close();
    }
    if (file != null) {
    file.close();
    }
    } catch (Exception exc) {
    // Do nothing
    }
    }

    }

    /*--------------------------------------------------
    * Draw line based on start and ending points
    *-------------------------------------------------*/
    protected void paint(Graphics g) {
    // Clear the background (to white)
    if (clearDisplay) {
    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());
    if (screenshot != null)
    g.drawImage(screenshot, getWidth(), getHeight(), Graphics.TOP
    | Graphics.LEFT);
    clearDisplay = false;
    startx = currentx = starty = currenty = 0;
    return;
    }

    // Draw with black pen
    g.setColor(0, 0, 0);
    g.setColor(0x000000);
    // Draw line
    g.drawLine(startx, starty, currentx, currenty);

    // New starting point is the current position
    startx = currentx;
    starty = currenty;
    }

    /*--------------------------------------------------
    * Command event handling
    *-------------------------------------------------*/
    public void commandAction(Command c, Displayable d) {
    if (c == cmExit)
    midlet.exitMIDlet();
    else if (c == cmSave) {
    // clearDisplay = true;
    // repaint();
    getScreenShot();

    }
    }

    /*--------------------------------------------------
    * Pointer pressed
    *-------------------------------------------------*/
    protected void pointerPressed(int x, int y) {
    startx = x;
    starty = y;
    }

    /*--------------------------------------------------
    * Pointer moved
    *-------------------------------------------------*/
    protected void pointerDragged(int x, int y) {

    currentx = x;
    currenty = y;
    repaint();
    }
    }

    any body solve this problem

    By

    chandrasekaran
    Last edited by chandrasekaranbe; 2011-05-30 at 14:04.

  6. #6
    Registered User
    Join Date
    Aug 2012
    Posts
    8

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    Hi chandrasekaranbe,

    when run code that appear this error

    what must i do ?
    Last edited by students60; 2012-09-20 at 07:54.

  7. #7
    Nokia Developer Expert
    Join Date
    May 2012
    Posts
    224

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    you need PNGEncoder class. read the article PNG Encoding in Java ME http://www.developer.nokia.com/Commu...ing_in_Java_ME

  8. #8
    Registered User
    Join Date
    Aug 2012
    Posts
    8

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    Thaaanks
    But how import this class to ScratchPad ??

  9. #9
    Nokia Developer Expert
    Join Date
    May 2012
    Posts
    224

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    this class is needed if you want to save the image (in PNG format).

  10. #10
    Registered User
    Join Date
    Aug 2012
    Posts
    8

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile

    I know that ,
    I need this class to implement my program online and offline character recognation
    and the idea of class scratchpad similar to part offline character recognation
    but i am beginner in j2me ,I am not sure if my steps implement true or no
    -I use netbeans 6.8
    -create new javame mobile application project named Project ,next
    device : DefoultFxTouchPhone1,cldc1.1,MIDP-2.1,next
    R.c of poject new package (named scratchpad) new class (scratchpad ) and copy code scarchpad from here page and paste in scratch.java
    R.c of package scratchpad new class named PNGEncoder and copy -paste and bild the project successfuly without error ,but when run it :the device appears bluescreen with hellow midlet message .
    please guide me to correct way for run this application

    sorry for protraction.

  11. #11
    Nokia Developer Expert
    Join Date
    May 2012
    Posts
    224

    Re: How to Put the Signature(using Pen)Nokia 5230 mobile


Similar Threads

  1. How to Put the Signature in Touch Screen Mobile Using J2me Midlet Appln
    By chandrasekaranbe in forum Mobile Design and User Experience
    Replies: 1
    Last Post: 2011-05-25, 07:09
  2. How to put the sigature in touch Screen Mobile(5230) using j2me midlet
    By chandrasekaranbe in forum Mobile Java General
    Replies: 4
    Last Post: 2011-05-23, 11:02
  3. How to connect my Nokia 5230 to internet using Bluetooth or usb?
    By philipina in forum Mobile Web Site Development
    Replies: 4
    Last Post: 2011-05-20, 05:27
  4. Replies: 2
    Last Post: 2011-05-12, 08:33
  5. How to put MIDI ring tone to the phone by using PC Conectivity SDK ?
    By shadowz in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2004-03-04, 03:57

Posting Permissions

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