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.TextFrame Maven / Gradle / Ivy
/* */ package com.pdfjet;
/* */
/* */ import java.util.ArrayList;
/* */ import java.util.List;
/* */
/* */ public class TextFrame
/* */ {
/* */ private List paragraphs;
/* */ private Font font;
/* */ private Font fallbackFont;
/* */ private float x;
/* */ private float y;
/* */ private float w;
/* */ private float h;
/* */ private float x_text;
/* */ private float y_text;
/* */ private float leading;
/* */ private float paragraphLeading;
/* */ private List beginParagraphPoints;
/* */ private List endParagraphPoints;
/* */ private float spaceBetweenTextLines;
/* */
/* */ public TextFrame(List paramList)
/* */ throws Exception
/* */ {
/* 58 */ if (paramList != null) {
/* 59 */ this.paragraphs = paramList;
/* 60 */ this.font = ((TextLine)((Paragraph)paramList.get(0)).list.get(0)).getFont();
/* 61 */ this.fallbackFont = ((TextLine)((Paragraph)paramList.get(0)).list.get(0)).getFallbackFont();
/* 62 */ this.leading = this.font.getBodyHeight();
/* 63 */ this.paragraphLeading = (2.0F * this.leading);
/* 64 */ this.beginParagraphPoints = new ArrayList();
/* 65 */ this.endParagraphPoints = new ArrayList();
/* 66 */ this.spaceBetweenTextLines = this.font.stringWidth(this.fallbackFont, " ");
/* */ }
/* */ }
/* */
/* */ public TextFrame setLocation(float paramFloat1, float paramFloat2)
/* */ {
/* 72 */ this.x = paramFloat1;
/* 73 */ this.y = paramFloat2;
/* 74 */ return this;
/* */ }
/* */
/* */ public TextFrame setWidth(float paramFloat)
/* */ {
/* 79 */ this.w = paramFloat;
/* 80 */ return this;
/* */ }
/* */
/* */ public TextFrame setHeight(float paramFloat)
/* */ {
/* 85 */ this.h = paramFloat;
/* 86 */ return this;
/* */ }
/* */
/* */ public TextFrame setLeading(float paramFloat)
/* */ {
/* 91 */ this.leading = paramFloat;
/* 92 */ return this;
/* */ }
/* */
/* */ public TextFrame setParagraphLeading(float paramFloat)
/* */ {
/* 97 */ this.paragraphLeading = paramFloat;
/* 98 */ return this;
/* */ }
/* */
/* */ public List getBeginParagraphPoints()
/* */ {
/* 103 */ return this.beginParagraphPoints;
/* */ }
/* */
/* */ public List getEndParagraphPoints()
/* */ {
/* 108 */ return this.endParagraphPoints;
/* */ }
/* */
/* */ public TextFrame setSpaceBetweenTextLines(float paramFloat)
/* */ {
/* 113 */ this.spaceBetweenTextLines = paramFloat;
/* 114 */ return this;
/* */ }
/* */
/* */ public List getParagraphs()
/* */ {
/* 119 */ return this.paragraphs;
/* */ }
/* */
/* */ public TextFrame drawOn(Page paramPage) throws Exception
/* */ {
/* 124 */ return drawOn(paramPage, true);
/* */ }
/* */
/* */ public TextFrame drawOn(Page paramPage, boolean paramBoolean) throws Exception
/* */ {
/* 129 */ this.x_text = this.x;
/* 130 */ this.y_text = (this.y + this.font.getAscent());
/* */
/* 132 */ Paragraph localParagraph1 = null;
/* 133 */ for (int i = 0; i < this.paragraphs.size(); i++) {
/* 134 */ localParagraph1 = (Paragraph)this.paragraphs.get(i);
/* */
/* 136 */ StringBuilder localStringBuilder = new StringBuilder();
/* 137 */ for (TextLine localTextLine1 : localParagraph1.list) {
/* 138 */ localStringBuilder.append(localTextLine1.getText());
/* */ }
/* */
/* 141 */ int j = localParagraph1.list.size();
/* 142 */ for (int k = 0; k < j; k++) {
/* 143 */ TextLine localTextLine2 = (TextLine)localParagraph1.list.get(k);
/* 144 */ if (k == 0) {
/* 145 */ this.beginParagraphPoints.add(new float[] { this.x_text, this.y_text });
/* */ }
/* 147 */ localTextLine2.setAltDescription(k == 0 ? localStringBuilder.toString() : " ");
/* 148 */ localTextLine2.setActualText(k == 0 ? localStringBuilder.toString() : " ");
/* */
/* 150 */ TextLine localTextLine3 = drawTextLine(paramPage, this.x_text, this.y_text, localTextLine2, paramBoolean);
/* */
/* 153 */ if (localTextLine3.getText() != null) {
/* 154 */ ArrayList localArrayList = new ArrayList();
/* 155 */ Paragraph localParagraph2 = new Paragraph(localTextLine3);
/* 156 */ k++;
/* 157 */ for (; k < j; k++) {
/* 158 */ localParagraph2.add((TextLine)localParagraph1.list.get(k));
/* */ }
/* 160 */ localArrayList.add(localParagraph2);
/* 161 */ i++;
/* 162 */ for (; i < this.paragraphs.size(); i++) {
/* 163 */ localArrayList.add(this.paragraphs.get(i));
/* */ }
/* 165 */ return new TextFrame(localArrayList);
/* */ }
/* */
/* 168 */ if (k == j - 1) {
/* 169 */ this.endParagraphPoints.add(new float[] { localTextLine3.x, localTextLine3.y });
/* */ }
/* 171 */ this.x_text = localTextLine3.x;
/* 172 */ if (localTextLine2.getTrailingSpace()) {
/* 173 */ this.x_text += this.spaceBetweenTextLines;
/* */ }
/* 175 */ this.y_text = localTextLine3.y;
/* */ }
/* 177 */ this.x_text = this.x;
/* 178 */ this.y_text += this.paragraphLeading;
/* */ }
/* */
/* 181 */ TextFrame localTextFrame = new TextFrame(null);
/* 182 */ localTextFrame.setLocation(this.x_text, this.y_text + this.font.getDescent());
/* */
/* 184 */ return localTextFrame;
/* */ }
/* */
/* */ public TextLine drawTextLine(Page paramPage, float paramFloat1, float paramFloat2, TextLine paramTextLine, boolean paramBoolean)
/* */ throws Exception
/* */ {
/* 195 */ TextLine localTextLine = null;
/* */
/* 197 */ Font localFont1 = paramTextLine.getFont();
/* 198 */ Font localFont2 = paramTextLine.getFallbackFont();
/* 199 */ int i = paramTextLine.getColor();
/* */
/* 201 */ StringBuilder localStringBuilder = new StringBuilder();
/* 202 */ String[] arrayOfString = paramTextLine.getText().split("\\s+");
/* 203 */ int j = 1;
/* 204 */ for (int k = 0; k < arrayOfString.length; k++) {
/* 205 */ String str = " " + arrayOfString[k];
/* 206 */ if (localFont1.stringWidth(localFont2, str) < this.w - (paramFloat1 - this.x)) {
/* 207 */ localStringBuilder.append(str);
/* 208 */ paramFloat1 += localFont1.stringWidth(localFont2, str);
/* */ }
/* */ else {
/* 211 */ if (paramBoolean) {
/* 212 */ new TextLine(localFont1, localStringBuilder.toString()).setFallbackFont(localFont2).setLocation(paramFloat1 - localFont1.stringWidth(localFont2, localStringBuilder.toString()), paramFloat2 + paramTextLine.getVerticalOffset()).setColor(i).setUnderline(paramTextLine.getUnderline()).setStrikeout(paramTextLine.getStrikeout()).setLanguage(paramTextLine.getLanguage()).setAltDescription(j != 0 ? paramTextLine.getAltDescription() : " ").setActualText(j != 0 ? paramTextLine.getActualText() : " ").drawOn(paramPage);
/* */
/* 223 */ j = 0;
/* */ }
/* 225 */ paramFloat1 = this.x + localFont1.stringWidth(localFont2, arrayOfString[k]);
/* 226 */ paramFloat2 += this.leading;
/* 227 */ localStringBuilder.setLength(0);
/* 228 */ localStringBuilder.append(arrayOfString[k]);
/* */
/* 230 */ if (paramFloat2 + localFont1.getDescent() > this.y + this.h) {
/* 231 */ k++;
/* 232 */ for (; k < arrayOfString.length; k++) {
/* 233 */ localStringBuilder.append(" ");
/* 234 */ localStringBuilder.append(arrayOfString[k]);
/* */ }
/* 236 */ localTextLine = new TextLine(localFont1, localStringBuilder.toString());
/* 237 */ localTextLine.setLocation(this.x, paramFloat2);
/* 238 */ return localTextLine;
/* */ }
/* */ }
/* */ }
/* 242 */ if (paramBoolean) {
/* 243 */ new TextLine(localFont1, localStringBuilder.toString()).setFallbackFont(localFont2).setLocation(paramFloat1 - localFont1.stringWidth(localFont2, localStringBuilder.toString()), paramFloat2 + paramTextLine.getVerticalOffset()).setColor(i).setUnderline(paramTextLine.getUnderline()).setStrikeout(paramTextLine.getStrikeout()).setLanguage(paramTextLine.getLanguage()).setAltDescription(j != 0 ? paramTextLine.getAltDescription() : " ").setActualText(j != 0 ? paramTextLine.getActualText() : " ").drawOn(paramPage);
/* */
/* 254 */ j = 0;
/* */ }
/* */
/* 257 */ localTextLine = new TextLine(localFont1, null);
/* 258 */ localTextLine.setLocation(paramFloat1, paramFloat2);
/* 259 */ return localTextLine;
/* */ }
/* */ }
/* Location: E:\EGGWIFI\Customer\trunk\src\Workspace\Customer\Customer Maven Webapp\src\main\webapp\WEB-INF\lib\PDFjet.jar
* Qualified Name: com.pdfjet.TextFrame
* JD-Core Version: 0.6.2
*/