1 10 package org.mmbase.util.images; 11 12 import org.mmbase.bridge.Node; 13 import java.util.*; 14 15 23 24 25 public class LazyDimension extends Dimension { 26 27 protected Node node; 28 protected String template; 29 private boolean loaded = false; 30 public LazyDimension(Node n, String t) { 31 node = n; 32 template = t; 33 } 34 35 private void getDimension() { 36 if (loaded) return; 37 List args = new ArrayList(); 38 if (template != null) { 39 args.add(template); 40 } 41 Dimension dim = (Dimension) node.getFunctionValue("dimension", args).get(); 42 x = dim.getWidth(); 43 y = dim.getHeight(); 44 loaded = true; 45 } 46 47 public int getWidth() { 48 getDimension(); 49 return super.getWidth(); 50 } 51 public int getHeight() { 52 getDimension(); 53 return super.getHeight(); 54 } 55 56 public int getArea() { 57 getDimension(); 58 return super.getArea(); 59 } 60 61 } 62 | Popular Tags |