All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pdfjet.Form Maven / Gradle / Ivy
/* */ package com.pdfjet;
/* */
/* */ import java.util.ArrayList;
/* */ import java.util.Iterator;
/* */ import java.util.List;
/* */
/* */ public class Form
/* */ implements Drawable
/* */ {
/* */ private List fields;
/* */ private float x;
/* */ private float y;
/* */ private Font f1;
/* 43 */ private float labelFontSize = 8.0F;
/* */ private Font f2;
/* 45 */ private float valueFontSize = 10.0F;
/* */ private int numberOfRows;
/* 47 */ private float rowLength = 500.0F;
/* 48 */ private float rowHeight = 12.0F;
/* 49 */ private int labelColor = 0;
/* 50 */ private int valueColor = 255;
/* */ private List endOfLinePoints;
/* */
/* */ public Form(List paramList)
/* */ {
/* 55 */ this.fields = paramList;
/* 56 */ this.endOfLinePoints = new ArrayList();
/* */ }
/* */
/* */ public Form setLocation(float paramFloat1, float paramFloat2)
/* */ {
/* 61 */ this.x = paramFloat1;
/* 62 */ this.y = paramFloat2;
/* 63 */ return this;
/* */ }
/* */
/* */ public Form setRowLength(float paramFloat)
/* */ {
/* 68 */ this.rowLength = paramFloat;
/* 69 */ return this;
/* */ }
/* */
/* */ public Form setRowHeight(float paramFloat)
/* */ {
/* 74 */ this.rowHeight = paramFloat;
/* 75 */ return this;
/* */ }
/* */
/* */ public Form setLabelFont(Font paramFont)
/* */ {
/* 80 */ this.f1 = paramFont;
/* 81 */ return this;
/* */ }
/* */
/* */ public Form setLabelFontSize(float paramFloat)
/* */ {
/* 86 */ this.labelFontSize = paramFloat;
/* 87 */ return this;
/* */ }
/* */
/* */ public Form setValueFont(Font paramFont)
/* */ {
/* 92 */ this.f2 = paramFont;
/* 93 */ return this;
/* */ }
/* */
/* */ public Form setValueFontSize(float paramFloat)
/* */ {
/* 98 */ this.valueFontSize = paramFloat;
/* 99 */ return this;
/* */ }
/* */
/* */ public Form setLabelColor(int paramInt)
/* */ {
/* 104 */ this.labelColor = paramInt;
/* 105 */ return this;
/* */ }
/* */
/* */ public Form setValueColor(int paramInt)
/* */ {
/* 110 */ this.valueColor = paramInt;
/* 111 */ return this;
/* */ }
/* */
/* */ public List getEndOfLinePoints()
/* */ {
/* 116 */ return this.endOfLinePoints;
/* */ }
/* */
/* */ public float[] drawOn(Page paramPage)
/* */ throws Exception
/* */ {
/* 128 */ for (Iterator localIterator1 = this.fields.iterator(); localIterator1.hasNext(); ) { localObject = (Field)localIterator1.next();
/* 129 */ if (((Field)localObject).format) {
/* 130 */ ((Field)localObject).values = format(localObject.values[0], localObject.values[1], this.f2, this.rowLength);
/* 131 */ ((Field)localObject).altDescription = new String[((Field)localObject).values.length];
/* 132 */ ((Field)localObject).actualText = new String[((Field)localObject).values.length];
/* 133 */ for (int i = 0; i < ((Field)localObject).values.length; i++) {
/* 134 */ ((Field)localObject).altDescription[i] = localObject.values[i];
/* 135 */ ((Field)localObject).actualText[i] = localObject.values[i];
/* */ }
/* */ }
/* 138 */ if (((Field)localObject).x == 0.0F) {
/* 139 */ this.numberOfRows += ((Field)localObject).values.length;
/* */ }
/* */ }
/* */
/* 143 */ if (this.numberOfRows == 0) {
/* 144 */ return new float[] { this.x, this.y };
/* */ }
/* */
/* 147 */ float f3 = this.rowHeight * this.numberOfRows;
/* 148 */ Object localObject = new Box();
/* 149 */ ((Box)localObject).setLocation(this.x, this.y);
/* 150 */ ((Box)localObject).setSize(this.rowLength, f3);
/* 151 */ ((Box)localObject).drawOn(paramPage);
/* */
/* 153 */ float f4 = 0.0F;
/* 154 */ int j = 1;
/* 155 */ float f5 = 0.0F;
/* 156 */ for (Field localField : this.fields) {
/* 157 */ if (localField.x == 0.0F) {
/* 158 */ f5 += j * this.rowHeight;
/* 159 */ j = localField.values.length;
/* */ }
/* 161 */ f4 = f5;
/* 162 */ for (int k = 0; k < localField.values.length; k++) {
/* 163 */ Font localFont = k == 0 ? this.f1 : this.f2;
/* 164 */ float f6 = k == 0 ? this.labelFontSize : this.valueFontSize;
/* 165 */ int m = k == 0 ? this.labelColor : this.valueColor;
/* 166 */ new TextLine(localFont, localField.values[k]).setFontSize(f6).setColor(m).placeIn((Box)localObject, localField.x + this.f1.getDescent(), f4 - localFont.getDescent()).setAltDescription(localField.altDescription[k] + ",").setActualText(localField.actualText[k] + ",").drawOn(paramPage);
/* */
/* 173 */ this.endOfLinePoints.add(new float[] { localField.x + this.f1.getDescent() + localFont.stringWidth(localField.values[k]), f4 - localFont.getDescent() });
/* */
/* 177 */ if (k == localField.values.length - 1) {
/* 178 */ new Line(0.0F, 0.0F, this.rowLength, 0.0F).placeIn((Box)localObject, 0.0F, f4).drawOn(paramPage);
/* */
/* 181 */ if (localField.x != 0.0F) {
/* 182 */ new Line(0.0F, -(localField.values.length - 1) * this.rowHeight, 0.0F, 0.0F).placeIn((Box)localObject, localField.x, f4).drawOn(paramPage);
/* */ }
/* */
/* */ }
/* */
/* 187 */ f4 += this.rowHeight;
/* */ }
/* */ }
/* */
/* 191 */ return new float[] { this.x + this.rowLength, this.y + f3 };
/* */ }
/* */
/* */ public static String[] format(String paramString1, String paramString2, Font paramFont, float paramFloat)
/* */ {
/* 197 */ String[] arrayOfString = paramString2.split("\\r?\\n");
/* 198 */ ArrayList localArrayList = new ArrayList();
/* 199 */ StringBuilder localStringBuilder = new StringBuilder();
/* 200 */ for (int i = 0; i < arrayOfString.length; i++) {
/* 201 */ localObject = arrayOfString[i];
/* 202 */ if (paramFont.stringWidth((String)localObject) < paramFloat) {
/* 203 */ localArrayList.add(localObject);
/* */ }
/* */ else
/* */ {
/* 207 */ localStringBuilder.setLength(0);
/* 208 */ for (j = 0; j < ((String)localObject).length(); j++) {
/* 209 */ localStringBuilder.append(((String)localObject).charAt(j));
/* 210 */ if (paramFont.stringWidth(localStringBuilder.toString()) > paramFloat - paramFont.stringWidth(" ")) {
/* 211 */ while ((j > 0) && (((String)localObject).charAt(j) != ' ')) {
/* 212 */ j--;
/* */ }
/* 214 */ String str = ((String)localObject).substring(0, j).replaceAll("\\s+$", "");
/* 215 */ localArrayList.add(str);
/* 216 */ localStringBuilder.setLength(0);
/* 217 */ while ((j < ((String)localObject).length()) && (((String)localObject).charAt(j) == ' ')) {
/* 218 */ j++;
/* */ }
/* 220 */ localObject = ((String)localObject).substring(j);
/* 221 */ j = 0;
/* */ }
/* */ }
/* */
/* 225 */ if (!((String)localObject).equals("")) {
/* 226 */ localArrayList.add(localObject);
/* */ }
/* */ }
/* */ }
/* 230 */ i = localArrayList.size();
/* 231 */ Object localObject = new String[1 + i];
/* 232 */ localObject[0] = paramString1;
/* 233 */ for (int j = 0; j < i; j++) {
/* 234 */ localObject[(j + 1)] = ((String)localArrayList.get(j));
/* */ }
/* */
/* 237 */ return localObject;
/* */ }
/* */ }
/* Location: E:\EGGWIFI\Customer\trunk\src\Workspace\Customer\Customer Maven Webapp\src\main\webapp\WEB-INF\lib\PDFjet.jar
* Qualified Name: com.pdfjet.Form
* JD-Core Version: 0.6.2
*/