1 package org.joshy.html; 2 3 import java.util.*; 4 import java.awt.Dimension ; 5 import org.joshy.u; 6 import org.joshy.html.box.*; 7 import org.w3c.dom.*; 8 9 public class CustomBlockLayout extends BoxLayout { 10 public Box createBox(Context c, Node node) { 11 BlockBox box = new BlockBox(); 12 box.node = node; 13 return box; 14 } 15 16 19 public Dimension getIntrinsicDimensions(Context c, Element elem) { 20 return new Dimension (50,50); 21 } 22 23 public Box layout(Context c, Element elem) { 24 BlockBox block = (BlockBox)createBox(c,elem); 25 27 Border border = getBorder(c, block); 28 Border padding = getPadding(c, block); 29 Border margin = getMargin(c, block); 30 31 Dimension dim = this.getIntrinsicDimensions(c,elem); 32 33 block.width = (int)dim.getWidth(); 35 block.height = (int)dim.getHeight(); 36 37 block.width = margin.left + border.left + padding.left + block.width + 39 padding.right + border.right + margin.right; 40 block.height = margin.top + border.top + padding.top + block.height + 41 padding.bottom + border.bottom + margin.bottom; 42 43 block.x = c.getExtents().x; 44 block.y = c.getExtents().y; 45 return block; 46 } 47 48 50 public void paintComponent(Context c, Box box) { 51 u.p("Custom components must override paintComponent"); 52 } 53 54 } 55 | Popular Tags |