1 17 18 19 20 package org.apache.fop.area; 21 22 import java.util.List ; 23 import java.util.Iterator ; 24 25 31 public class MainReference extends Area { 32 33 private BodyRegion parent; 34 private List spanAreas = new java.util.ArrayList (); 35 private boolean isEmpty = true; 36 37 42 public MainReference(BodyRegion parent) { 43 this.parent = parent; 44 addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); 45 } 46 47 53 public Span createSpan(boolean spanAll) { 54 if (spanAreas.size() > 0 && getCurrentSpan().isEmpty()) { 55 spanAreas.remove(spanAreas.size() - 1); 57 } 58 RegionViewport rv = parent.getRegionViewport(); 59 int ipdWidth = (int) parent.getIPD() 60 - rv.getBorderAndPaddingWidthStart() - rv.getBorderAndPaddingWidthEnd(); 61 62 Span newSpan = new Span(((spanAll) ? 1 : getColumnCount()), 63 getColumnGap(), ipdWidth); 64 spanAreas.add(newSpan); 65 return getCurrentSpan(); 66 } 67 68 73 public List getSpans() { 74 return spanAreas; 75 } 76 77 81 public Span getCurrentSpan() { 82 return (Span) spanAreas.get(spanAreas.size() - 1); 83 } 84 85 91 public boolean isEmpty() { 92 if (isEmpty) { 93 boolean nonEmptyFound = false; 94 if (spanAreas != null) { 95 for (Iterator spaniter = spanAreas.iterator(); spaniter.hasNext();) { 96 Span spanArea = (Span) spaniter.next(); 97 nonEmptyFound |= !spanArea.isEmpty(); 98 } 99 } 100 101 isEmpty = !nonEmptyFound; 102 } 103 return isEmpty; 104 } 105 106 107 public int getColumnCount() { 108 return parent.getColumnCount(); 109 } 110 111 112 public int getColumnGap() { 113 return parent.getColumnGap(); 114 } 115 116 } 117 118 | Popular Tags |