×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    17

    Double Buffering on Nokia devices.

    Hi Guys,
    I am developing a j2me application for s40 and s60 devices. The application works fine but on s60 devices the screen flickers while on s40 devices the application display handles. I just wanted to know if double buffering automatically supported in s40 devices and not on s60 devices? Or is there any other reason for the flickering to occur only on s60 devices?
    Thanks and Regards,
    Abhijeeth Hiliyana
    Last edited by AbhijeethHiliyana; 2010-12-31 at 10:16.

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

    Re: Double Buffering on Nokia devices.

    At what point does the screen flicker?

    What Displayable object are you displaying when the flickering occurs (for example, Canvas, Form, etc.)?

    Or does it flicker when you call Display.setCurrent()?

    Graham.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    17

    Re: Double Buffering on Nokia devices.

    I display a form. The form contains many customitems. I add the custom items to the form and then set the form as current. When i navigate back i delete all elements in the form and then reload the elements. Now this flow is working fine on s40 devices but on s60 devices i get a flicker where a white screen is displayed for a split second and then the items are displayed.
    Thanks and Regards,
    Abhijeeth

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

    Re: Double Buffering on Nokia devices.

    Are you deleting and re-populating the Form from the evenr thread, or from a thread you create yourself?

    You might be better to use a separate Form object, rather than trying to re-use the same one.

    Graham.

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

    Re: Double Buffering on Nokia devices.

    Quote Originally Posted by AbhijeethHiliyana View Post
    I display a form. The form contains many customitems. I add the custom items to the form and then set the form as current. When i navigate back i delete all elements in the form and then reload the elements. Now this flow is working fine on s40 devices but on s60 devices i get a flicker where a white screen is displayed for a split second and then the items are displayed.
    Thanks and Regards,
    Abhijeeth
    Could you share the code lines where you are loading and creating the items and setting all to the form?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    17

    Re: Double Buffering on Nokia devices.

    Ya sure

    This where i load from the main form
    if(cmd == this.okCommand) {
    int a = Integer.parseInt(this.a.getString());
    int b = Integer.parseInt(this.b.getString());
    int resultado = a+b;
    this.resultForm = new MyResultForm("", this.mainForm); //creates a "MyResultForm" object
    this.resultForm.setResultado(String.valueOf(resultado));
    this.d.setCurrent(this.resultForm);
    this.resultForm.setHelloWorld(this);
    }

    where myResultform is a custom form object.

    The code for my result form is

    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;

    public class MyResultForm extends Form implements CommandListener {

    private StringItem resultado;
    private Command backCommand; //command to return to the first form
    private Displayable previous;
    private Helloworld myWorld;

    //Constructor: receives the Form's title and the previous displayable. Any kind of displayable class (Alert, TextBox, List) can be
    //sent to this second input paramenter.
    public MyResultForm(String title, Displayable previousDisplayable) {
    super(title);
    this.previous = previousDisplayable;

    this.resultado = new StringItem("Result: ", "");//shows the result of the sum
    this.backCommand = new Command("Back", Command.BACK, 1); //creates the back command
    MyCustomItem item=new MyCustomItem("Temp");
    // this.append(this.resultado);
    this.append(item);
    this.addCommand(this.backCommand);
    this.setCommandListener(this);
    }

    protected void setResultado(String resultado) {
    this.resultado.setText(resultado);
    }

    protected void setHelloWorld(Helloworld world)
    {
    this.myWorld=world;
    }

    public void commandAction(Command command, Displayable arg1) {
    if(command == this.backCommand)
    {
    //this.previous
    this.deleteAll();
    myWorld.back();
    Helloworld.d.setCurrent(myWorld.getMainForm());
    }//returns to the first form
    }
    }




    THe code for the custom item object is
    import javax.microedition.lcdui.CustomItem;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Image;

    public class MyCustomItem extends CustomItem {
    private Image offScreen=null;
    public MyCustomItem(String arg0) {
    super("");

    // TODO Auto-generated constructor stub
    }

    protected int getMinContentHeight() {
    // TODO Auto-generated method stub
    return 60;
    }

    protected int getMinContentWidth() {
    // TODO Auto-generated method stub
    return 100;
    }

    protected int getPrefContentHeight(int arg0) {
    // TODO Auto-generated method stub
    return getMinContentHeight();
    }

    protected int getPrefContentWidth(int arg0) {
    // TODO Auto-generated method stub
    return getMinContentWidth();
    }

    protected void paintClipRect(Graphics g)
    {
    int clipX = g.getClipX();
    int clipY = g.getClipY();

    int clipH = g.getClipHeight();
    int clipW = g.getClipWidth();
    int color = g.getColor();
    //g.dr
    g.setColor(Display.COLOR_BACKGROUND);
    g.fillRect(clipX, clipY, clipW, clipH);
    g.setColor(Display.COLOR_BACKGROUND);
    }

    protected void paint(Graphics g, int w, int h) {
    // TODO Auto-generated method stub
    if(offScreen==null)
    {
    offScreen=Image.createImage(w, h);
    }

    Graphics originalG=null;
    originalG = g;
    /*originalG.setColor(Display.COLOR_BACKGROUND);
    originalG.drawRect(0, 0, w - 1, h - 1);*/
    g = offScreen.getGraphics();
    paintClipRect(g);

    g.setColor(Display.COLOR_BACKGROUND);
    g.drawRect(0, 0, w - 1, h - 1);
    g.setColor(0, 0, 255);
    int offset = 0;
    for (int y = 4; y < h; y += 12){
    offset = (offset + 12) % 24;
    for (int x = 7; x < w; x += 24){
    g.fillTriangle(x + offset, y, x + offset - 3, y + 6, x + offset + 3, y + 6);
    }
    }
    originalG.drawImage(offScreen, 0, 0,
    Graphics.TOP | Graphics.LEFT);
    }

    }



    Sorry for the extremely long post. Actually in the custom item i tried to implement double buffering. This a example that i tried after i observed the issue on my application.
    Last edited by AbhijeethHiliyana; 2011-01-04 at 05:48.

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    17

    Re: Double Buffering on Nokia devices.

    Hi I tried to restructure the custom item code so that the paint method just displays a simple image. But i can still see the flicker when the image loads.

    The source code is

    public class MyCustomItem extends CustomItem {
    private Image offScreen=null;
    public MyCustomItem(String arg0) {
    super("");
    try {
    offScreen=Image.createImage("/index.jpeg");
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    /*Graphics g=null;
    g=offScreen.getGraphics();
    g.setColor(0x00000000);
    g.drawRect(0, 0, offScreen.getWidth() - 1, offScreen.getHeight() - 1);
    g.fillRect(0, 0, offScreen.getWidth() - 1, offScreen.getHeight() - 1);
    g.setColor(0, 0, 255);
    int offset = 0;
    for (int y = 4; y < offScreen.getHeight(); y += 12){
    offset = (offset + 12) % 24;
    for (int x = 7; x < offScreen.getWidth(); x += 24){
    g.fillTriangle(x + offset, y, x + offset - 3, y + 6, x + offset + 3, y + 6);
    }
    }*/
    // TODO Auto-generated constructor stub
    }

    protected int getMinContentHeight() {
    // TODO Auto-generated method stub
    return 48;
    }

    protected int getMinContentWidth() {
    // TODO Auto-generated method stub
    return 48;
    }

    protected int getPrefContentHeight(int arg0) {
    // TODO Auto-generated method stub
    return getMinContentHeight();
    }

    protected int getPrefContentWidth(int arg0) {
    // TODO Auto-generated method stub
    return getMinContentWidth();
    }

    protected void paintClipRect(Graphics g)
    {
    int clipX = g.getClipX();
    int clipY = g.getClipY();

    int clipH = g.getClipHeight();
    int clipW = g.getClipWidth();
    int color = g.getColor();
    //g.dr
    g.setColor(Display.COLOR_BACKGROUND);
    g.fillRect(clipX, clipY, clipW, clipH);
    g.setColor(Display.COLOR_BACKGROUND);
    }

    protected void paint(Graphics g, int w, int h) {
    // TODO Auto-generated method stub
    /*if(offScreen==null)
    {

    }

    Graphics originalG=null;
    originalG = g;
    originalG.setColor(Display.COLOR_BACKGROUND);
    originalG.drawRect(0, 0, w - 1, h - 1);
    g = offScreen.getGraphics();
    //paintClipRect(g);

    g.setColor(Display.COLOR_BACKGROUND);
    g.drawRect(0, 0, w - 1, h - 1);
    g.setColor(0, 0, 255);
    int offset = 0;
    for (int y = 4; y < h; y += 12){
    offset = (offset + 12) % 24;
    for (int x = 7; x < w; x += 24){
    g.fillTriangle(x + offset, y, x + offset - 3, y + 6, x + offset + 3, y + 6);
    }
    }*/
    g.drawImage(offScreen, 0, 0,
    Graphics.TOP | Graphics.LEFT);
    }

    }

Similar Threads

  1. How to use double buffering?
    By gift_te in forum Symbian
    Replies: 2
    Last Post: 2006-12-25, 17:46
  2. Double Buffering
    By kukan in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-06-27, 22:30
  3. Flickering after double buffering
    By petertai in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2004-03-27, 14:05
  4. Double Buffering??
    By heatherstancliffe in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2003-09-15, 17:44
  5. double buffering. How to do it?
    By kondziop in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2003-04-18, 11:15

Posting Permissions

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