Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-07-2009, 09:24 AM
Member
 
Join Date: Feb 2009
Posts: 1
Rep Power: 0
rukawa527 is on a distinguished road
Default Need Help: Double Buffer
I'm using java program to display up a svg file. I would like to include double buffer method since the file will be periodically updated and re-displayed. Can anyone show me hw i suppose to add in the coding of double buffer?


Here's my code:
__________________________________________________ ___________
import java.awt.*;
import javax.swing.*;
import org.apache.batik.swing.JSVGCanvas;


public class displaySVG extends JFrame {

Thread thrd;
protected JFrame f; //The frame.
protected JSVGCanvas svgCanvas = new JSVGCanvas();

public displaySVG(JFrame f) {
this.f = f;
}

public void displaySVG(){
// Create a new JFrame.
displaySVG app = new displaySVG(f);

// Add components to the frame.
f.getContentPane().add(app.createComponents());
f.setSize(550, 400);
f.setVisible(true);

//update function
//re-display
}

public JComponent createComponents() {

// Create a panel and add the button, status label and the SVG canvas.
final JPanel panel = new JPanel(new BorderLayout());
JPanel p = new JPanel();
svgCanvas.setURI("file:/C:/Documents and Settings/Ricky" +
"/My Documents/NetBeansProjects/Project_test1/" +
"floorplan1.svg");
panel.add(p);
panel.add(svgCanvas);
return panel;
}



}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 02-09-2009, 01:39 AM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 972
Rep Power: 2
Steve11235 is on a distinguished road
Default
For many JComponents, isDoubleBuffered is a property of the component, and the component handles the buffering.

In the case of JSVGCanvas (actually, an Apache Batik class), it uses isDoubleBufferedRendering and setDoubleBufferedRendering. Just setDoubleBufferedRendering(true) before you display it.

Double buffering means that the component maintains two buffers, one with the currently displayed information, and a second in which new information can be built without interfering with the display. Each time the component is rendered, the buffers swap roles.

This is only useful if generating the information for the component takes a long time, from the human eye's perspective, and it doubles the memory required to hold the data.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffer QPRocky Networking 2 02-02-2009 04:54 PM
Double.valueOf() vs Double.parseDouble() greenbean New To Java 10 01-12-2009 09:39 AM
Can't DOUBLE BUFFER images hunterbdb Java 2D 7 11-14-2008 09:53 PM
Help with String Buffer mathias AWT / Swing 1 08-07-2007 07:52 AM
how to set the value of BUFFER SIZE oregon Advanced Java 1 08-06-2007 04:16 AM


All times are GMT +2. The time now is 05:02 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org