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.Text Maven / Gradle / Ivy
/* */ package com.pdfjet;
/* */
/* */ import java.util.ArrayList;
/* */ import java.util.List;
/* */
/* */ public class Text
/* */ {
/* */ private List paragraphs;
/* */ private Font font;
/* */ private Font fallbackFont;
/* */ private float x;
/* */ private float y;
/* */ private float w;
/* */ private float x_text;
/* */ private float y_text;
/* */ private float leading;
/* */ private float paragraphLeading;
/* */ private List beginParagraphPoints;
/* */ private List endParagraphPoints;
/* */ private float spaceBetweenTextLines;
/* */
/* */ public Text(List paramList)
/* */ throws Exception
/* */ {
/* 56 */ this.paragraphs = paramList;
/* 57 */ this.font = ((TextLine)((Paragraph)paramList.get(0)).list.get(0)).getFont();
/* 58 */ this.fallbackFont = ((TextLine)((Paragraph)paramList.get(0)).list.get(0)).getFallbackFont();
/* 59 */ this.leading = this.font.getBodyHeight();
/* 60 */ this.paragraphLeading = (2.0F * this.leading);
/* 61 */ this.beginParagraphPoints = new ArrayList();
/* 62 */ this.endParagraphPoints = new ArrayList();
/* 63 */ this.spaceBetweenTextLines = this.font.stringWidth(this.fallbackFont, " ");
/* */ }
/* */
/* */ public Text setLocation(float paramFloat1, float paramFloat2)
/* */ {
/* 68 */ this.x = paramFloat1;
/* 69 */ this.y = paramFloat2;
/* 70 */ return this;
/* */ }
/* */
/* */ public Text setWidth(float paramFloat)
/* */ {
/* 75 */ this.w = paramFloat;
/* 76 */ return this;
/* */ }
/* */
/* */ public Text setLeading(float paramFloat)
/* */ {
/* 81 */ this.leading = paramFloat;
/* 82 */ return this;
/* */ }
/* */
/* */ public Text setParagraphLeading(float paramFloat)
/* */ {
/* 87 */ this.paragraphLeading = paramFloat;
/* 88 */ return this;
/* */ }
/* */
/* */ public List getBeginParagraphPoints()
/* */ {
/* 93 */ return this.beginParagraphPoints;
/* */ }
/* */
/* */ public List getEndParagraphPoints()
/* */ {
/* 98 */ return this.endParagraphPoints;
/* */ }
/* */
/* */ public Text setSpaceBetweenTextLines(float paramFloat)
/* */ {
/* 103 */ this.spaceBetweenTextLines = paramFloat;
/* 104 */ return this;
/* */ }
/* */
/* */ public float[] drawOn(Page paramPage) throws Exception
/* */ {
/* 109 */ return drawOn(paramPage, true);
/* */ }
/* */
/* */ public float[] drawOn(Page paramPage, boolean paramBoolean) throws Exception
/* */ {
/* 114 */ this.x_text = this.x;
/* 115 */ this.y_text = (this.y + this.font.getAscent());
/* 116 */ for (Paragraph localParagraph : this.paragraphs) {
/* 117 */ int i = localParagraph.list.size();
/* 118 */ StringBuilder localStringBuilder = new StringBuilder();
/* */ TextLine localTextLine;
/* 119 */ for (int j = 0; j < i; j++) {
/* 120 */ localTextLine = (TextLine)localParagraph.list.get(j);
/* 121 */ localStringBuilder.append(localTextLine.getText());
/* */ }
/* 123 */ for (j = 0; j < i; j++) {
/* 124 */ localTextLine = (TextLine)localParagraph.list.get(j);
/* 125 */ if (j == 0) {
/* 126 */ this.beginParagraphPoints.add(new float[] { this.x_text, this.y_text });
/* */ }
/* 128 */ localTextLine.setAltDescription(j == 0 ? localStringBuilder.toString() : " ");
/* 129 */ localTextLine.setActualText(j == 0 ? localStringBuilder.toString() : " ");
/* 130 */ float[] arrayOfFloat = drawTextLine(paramPage, this.x_text, this.y_text, localTextLine, paramBoolean);
/* */
/* 132 */ if (j == i - 1) {
/* 133 */ this.endParagraphPoints.add(new float[] { arrayOfFloat[0], arrayOfFloat[1] });
/* */ }
/* 135 */ this.x_text = arrayOfFloat[0];
/* 136 */ if (localTextLine.getTrailingSpace()) {
/* 137 */ this.x_text += this.spaceBetweenTextLines;
/* */ }
/* 139 */ this.y_text = arrayOfFloat[1];
/* */ }
/* 141 */ this.x_text = this.x;
/* 142 */ this.y_text += this.paragraphLeading;
/* */ }
/* 144 */ return new float[] { this.x_text, this.y_text + this.font.getDescent() };
/* */ }
/* */
/* */ public float[] drawTextLine(Page paramPage, float paramFloat1, float paramFloat2, TextLine paramTextLine, boolean paramBoolean)
/* */ throws Exception
/* */ {
/* 155 */ Font localFont1 = paramTextLine.getFont();
/* 156 */ Font localFont2 = paramTextLine.getFallbackFont();
/* 157 */ int i = paramTextLine.getColor();
/* */
/* 159 */ String[] arrayOfString = null;
/* 160 */ String str1 = paramTextLine.getText();
/* 161 */ if (stringIsCJK(str1)) {
/* 162 */ arrayOfString = tokenizeCJK(str1, this.w);
/* */ }
/* */ else {
/* 165 */ arrayOfString = str1.split("\\s+");
/* */ }
/* */
/* 168 */ StringBuilder localStringBuilder = new StringBuilder();
/* 169 */ int j = 1;
/* 170 */ for (int k = 0; k < arrayOfString.length; k++) {
/* 171 */ String str2 = " " + arrayOfString[k];
/* 172 */ if (localFont1.stringWidth(localFont2, str2) < this.w - (paramFloat1 - this.x)) {
/* 173 */ localStringBuilder.append(str2);
/* 174 */ paramFloat1 += localFont1.stringWidth(localFont2, str2);
/* */ }
/* */ else {
/* 177 */ if (paramBoolean) {
/* 178 */ 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);
/* */
/* 189 */ j = 0;
/* */ }
/* 191 */ paramFloat1 = this.x + localFont1.stringWidth(localFont2, arrayOfString[k]);
/* 192 */ paramFloat2 += this.leading;
/* 193 */ localStringBuilder.setLength(0);
/* 194 */ localStringBuilder.append(arrayOfString[k]);
/* */ }
/* */ }
/* 197 */ if (paramBoolean) {
/* 198 */ 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);
/* */
/* 209 */ j = 0;
/* */ }
/* */
/* 212 */ return new float[] { paramFloat1, paramFloat2 };
/* */ }
/* */
/* */ private boolean stringIsCJK(String paramString)
/* */ {
/* 221 */ int i = 0;
/* 222 */ for (int j = 0; j < paramString.length(); j++) {
/* 223 */ int k = paramString.charAt(j);
/* 224 */ if (((k >= 19968) && (k <= 40917)) || ((k >= 12352) && (k <= 12447)) || ((k >= 12448) && (k <= 12543)) || ((k >= 4352) && (k <= 4607)))
/* */ {
/* 228 */ i++;
/* */ }
/* */ }
/* 231 */ return i > paramString.length() / 2;
/* */ }
/* */
/* */ private String[] tokenizeCJK(String paramString, float paramFloat)
/* */ {
/* 236 */ ArrayList localArrayList = new ArrayList();
/* 237 */ StringBuilder localStringBuilder = new StringBuilder();
/* 238 */ for (int i = 0; i < paramString.length(); i++) {
/* 239 */ char c = paramString.charAt(i);
/* 240 */ if (this.font.stringWidth(this.fallbackFont, localStringBuilder.toString()) < paramFloat) {
/* 241 */ localStringBuilder.append(c);
/* */ }
/* */ else {
/* 244 */ localArrayList.add(localStringBuilder.toString());
/* 245 */ localStringBuilder.setLength(0);
/* */ }
/* */ }
/* 248 */ if (localStringBuilder.toString().length() > 0) {
/* 249 */ localArrayList.add(localStringBuilder.toString());
/* */ }
/* 251 */ return (String[])localArrayList.toArray(new String[localArrayList.size()]);
/* */ }
/* */ }
/* Location: E:\EGGWIFI\Customer\trunk\src\Workspace\Customer\Customer Maven Webapp\src\main\webapp\WEB-INF\lib\PDFjet.jar
* Qualified Name: com.pdfjet.Text
* JD-Core Version: 0.6.2
*/