1 14 package org.compiere.print.layout; 15 16 import java.awt.*; 17 import java.util.*; 18 19 import org.compiere.model.*; 20 import org.compiere.util.*; 21 22 28 public class Page 29 { 30 35 public Page (Properties ctx, int pageNo) 36 { 37 m_ctx = ctx; 38 m_pageNo = pageNo; 39 if (m_pageInfo == null || m_pageInfo.length() == 0) 40 m_pageInfo = String.valueOf(m_pageNo); 41 } 43 44 public static final String CONTEXT_PAGE = "*Page"; 45 46 public static final String CONTEXT_PAGECOUNT = "*PageCount"; 47 48 public static final String CONTEXT_MULTIPAGE = "*MultiPageInfo"; 49 50 public static final String CONTEXT_COPY = "*CopyInfo"; 51 52 53 public static final String CONTEXT_REPORTNAME = "*ReportName"; 54 55 public static final String CONTEXT_HEADER = "*Header"; 56 57 public static final String CONTEXT_DATE = "*CurrentDate"; 58 59 public static final String CONTEXT_TIME = "*CurrentDateTime"; 60 61 62 private int m_pageNo; 63 64 private int m_pageCount = 1; 65 66 private String m_pageInfo; 67 68 private Properties m_ctx; 69 70 private ArrayList m_elements = new ArrayList(); 71 72 76 public int getPageNo() 77 { 78 return m_pageNo; 79 } 81 85 public String getPageInfo() 86 { 87 return m_pageInfo; 88 } 90 95 public void setPageInfo (String pageInfo) 96 { 97 if (m_pageInfo == null || m_pageInfo.length() == 0) 98 m_pageInfo = String.valueOf(m_pageNo); 99 m_pageInfo = pageInfo; 100 } 102 106 public void setPageCount (int pageCount) 107 { 108 m_pageCount = pageCount; 109 } 111 115 public void addElement (PrintElement element) 116 { 117 if (element != null) 118 m_elements.add(element); 119 } 121 122 123 131 public void paint (Graphics2D g2D, Rectangle bounds, boolean isView, boolean isCopy) 132 { 133 m_ctx.put (CONTEXT_PAGE, m_pageInfo); 134 StringBuffer sb = new StringBuffer (); 137 if (m_pageCount != 1) sb.append(Msg.getMsg(m_ctx, "Page")).append(" ") 139 .append(m_pageNo) 140 .append(" ").append(Msg.getMsg(m_ctx, "of")).append(" ") 141 .append(m_pageCount); 142 else 143 sb.append(" "); 144 m_ctx.put(CONTEXT_MULTIPAGE, sb.toString()); 145 sb = new StringBuffer (); 148 if (isCopy) sb.append("(") 150 .append(Msg.getMsg(m_ctx, "DocumentCopy")) 151 .append(")"); 152 else 153 sb.append(" "); 154 m_ctx.put(CONTEXT_COPY, sb.toString()); 155 157 g2D.setColor(Color.white); 159 g2D.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); 160 Point pageStart = new Point(bounds.getLocation()); 162 for (int i = 0; i < m_elements.size(); i++) 163 { 164 PrintElement e = (PrintElement)m_elements.get(i); 165 e.paint(g2D, m_pageNo, pageStart, m_ctx, isView); 166 } 167 } 169 170 171 176 public MQuery getDrillDown (Point relativePoint) 177 { 178 MQuery retValue = null; 179 for (int i = 0; i < m_elements.size() && retValue == null; i++) 180 { 181 PrintElement element = (PrintElement)m_elements.get(i); 182 retValue = element.getDrillDown (relativePoint, m_pageNo); 183 } 184 return retValue; 185 } 187 192 public MQuery getDrillAcross (Point relativePoint) 193 { 194 MQuery retValue = null; 195 for (int i = 0; i < m_elements.size() && retValue == null; i++) 196 { 197 PrintElement element = (PrintElement)m_elements.get(i); 198 retValue = element.getDrillAcross (relativePoint, m_pageNo); 199 } 200 return retValue; 201 } 203 207 public String toString() 208 { 209 StringBuffer sb = new StringBuffer ("Page["); 210 sb.append(m_pageNo).append(",Elements=").append(m_elements.size()); 211 sb.append("]"); 212 return sb.toString(); 213 } 215 } | Popular Tags |