1 package org.joshy.html; 2 3 import java.awt.image.BufferedImage ; 4 import org.joshy.html.swing.DOMInspector; 5 import javax.swing.*; 6 import java.awt.*; 7 import java.awt.event.*; 8 import org.joshy.x; 9 import org.joshy.u; 10 import org.w3c.dom.*; 11 import java.io.File ; 12 import org.joshy.html.box.Box; 13 import java.util.Date ; 14 import org.joshy.html.css.DefaultCSSMarker; 15 import java.io.*; 16 17 public class SpeedTest { 18 public static void main(String [] args) throws Exception { 19 20 Document doc = x.loadDocument("demos/header.xhtml"); 22 Element html = (Element)doc.getDocumentElement(); 23 Element body = x.child(html,"body"); 24 25 BufferedImage buff = new BufferedImage (500,500, BufferedImage.TYPE_4BYTE_ABGR); 27 28 Graphics g = buff.getGraphics(); 30 31 32 Context c = new Context(); 34 Point origin = new Point(0,0); 35 Point last = new Point(0,0); 36 c.css = new CSSBank(); 38 Object marker = new DefaultCSSMarker(); 39 InputStream stream = marker.getClass().getResourceAsStream("default.css"); 41 c.css.parse(new InputStreamReader(stream)); 42 c.css.parseInlineStyles(html); 43 c.graphics = g; 44 c.setExtents(new Rectangle(0,0,500,500)); 45 c.cursor = last; 47 c.setMaxWidth(0); 48 49 50 BodyLayout layout = new BodyLayout(); 52 53 54 int total = 0; 55 for(int i=0; i<10; i++) { 56 u.sleep(100); 57 long start_time = new java.util.Date ().getTime(); 58 Box body_box = layout.layout(c,body); 60 long end_time = new java.util.Date ().getTime(); 61 u.p("ending count = " + (end_time-start_time) + " msec"); 62 total += (end_time-start_time); 63 } 64 u.p("avg = " + (total/10)); 65 } 66 } 67 | Popular Tags |