first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
|
|
@ -0,0 +1,61 @@
|
|||
package com.itextpdf.awt;
|
||||
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import java.awt.Font;
|
||||
|
||||
public class AsianFontMapper extends DefaultFontMapper {
|
||||
public static final String ChineseSimplifiedFont = "STSong-Light";
|
||||
|
||||
public static final String ChineseSimplifiedEncoding_H = "UniGB-UCS2-H";
|
||||
|
||||
public static final String ChineseSimplifiedEncoding_V = "UniGB-UCS2-V";
|
||||
|
||||
public static final String ChineseTraditionalFont_MHei = "MHei-Medium";
|
||||
|
||||
public static final String ChineseTraditionalFont_MSung = "MSung-Light";
|
||||
|
||||
public static final String ChineseTraditionalEncoding_H = "UniCNS-UCS2-H";
|
||||
|
||||
public static final String ChineseTraditionalEncoding_V = "UniCNS-UCS2-V";
|
||||
|
||||
public static final String JapaneseFont_Go = "HeiseiKakuGo-W5";
|
||||
|
||||
public static final String JapaneseFont_Min = "HeiseiMin-W3";
|
||||
|
||||
public static final String JapaneseEncoding_H = "UniJIS-UCS2-H";
|
||||
|
||||
public static final String JapaneseEncoding_V = "UniJIS-UCS2-V";
|
||||
|
||||
public static final String JapaneseEncoding_HW_H = "UniJIS-UCS2-HW-H";
|
||||
|
||||
public static final String JapaneseEncoding_HW_V = "UniJIS-UCS2-HW-V";
|
||||
|
||||
public static final String KoreanFont_GoThic = "HYGoThic-Medium";
|
||||
|
||||
public static final String KoreanFont_SMyeongJo = "HYSMyeongJo-Medium";
|
||||
|
||||
public static final String KoreanEncoding_H = "UniKS-UCS2-H";
|
||||
|
||||
public static final String KoreanEncoding_V = "UniKS-UCS2-V";
|
||||
|
||||
private final String defaultFont;
|
||||
|
||||
private final String encoding;
|
||||
|
||||
public AsianFontMapper(String font, String encoding) {
|
||||
this.defaultFont = font;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public BaseFont awtToPdf(Font font) {
|
||||
try {
|
||||
DefaultFontMapper.BaseFontParameters p = getBaseFontParameters(font.getFontName());
|
||||
if (p != null)
|
||||
return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb);
|
||||
return BaseFont.createFont(this.defaultFont, this.encoding, true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
package com.itextpdf.awt;
|
||||
|
||||
import com.itextpdf.text.ExceptionConverter;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DefaultFontMapper implements FontMapper {
|
||||
public static class BaseFontParameters {
|
||||
public String fontName;
|
||||
|
||||
public String encoding;
|
||||
|
||||
public boolean embedded;
|
||||
|
||||
public boolean cached;
|
||||
|
||||
public byte[] ttfAfm;
|
||||
|
||||
public byte[] pfb;
|
||||
|
||||
public BaseFontParameters(String fontName) {
|
||||
this.fontName = fontName;
|
||||
this.encoding = "Cp1252";
|
||||
this.embedded = true;
|
||||
this.cached = true;
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, String> aliases = new HashMap<String, String>();
|
||||
|
||||
private HashMap<String, BaseFontParameters> mapper = new HashMap<String, BaseFontParameters>();
|
||||
|
||||
public BaseFont awtToPdf(Font font) {
|
||||
try {
|
||||
BaseFontParameters p = getBaseFontParameters(font.getFontName());
|
||||
if (p != null)
|
||||
return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb);
|
||||
String fontKey = null;
|
||||
String logicalName = font.getName();
|
||||
if (logicalName.equalsIgnoreCase("DialogInput") || logicalName.equalsIgnoreCase("Monospaced") || logicalName.equalsIgnoreCase("Courier")) {
|
||||
if (font.isItalic()) {
|
||||
if (font.isBold()) {
|
||||
fontKey = "Courier-BoldOblique";
|
||||
} else {
|
||||
fontKey = "Courier-Oblique";
|
||||
}
|
||||
} else if (font.isBold()) {
|
||||
fontKey = "Courier-Bold";
|
||||
} else {
|
||||
fontKey = "Courier";
|
||||
}
|
||||
} else if (logicalName.equalsIgnoreCase("Serif") || logicalName.equalsIgnoreCase("TimesRoman")) {
|
||||
if (font.isItalic()) {
|
||||
if (font.isBold()) {
|
||||
fontKey = "Times-BoldItalic";
|
||||
} else {
|
||||
fontKey = "Times-Italic";
|
||||
}
|
||||
} else if (font.isBold()) {
|
||||
fontKey = "Times-Bold";
|
||||
} else {
|
||||
fontKey = "Times-Roman";
|
||||
}
|
||||
} else if (font.isItalic()) {
|
||||
if (font.isBold()) {
|
||||
fontKey = "Helvetica-BoldOblique";
|
||||
} else {
|
||||
fontKey = "Helvetica-Oblique";
|
||||
}
|
||||
} else if (font.isBold()) {
|
||||
fontKey = "Helvetica-Bold";
|
||||
} else {
|
||||
fontKey = "Helvetica";
|
||||
}
|
||||
return BaseFont.createFont(fontKey, "Cp1252", false);
|
||||
} catch (Exception e) {
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Font pdfToAwt(BaseFont font, int size) {
|
||||
String[][] names = font.getFullFontName();
|
||||
if (names.length == 1)
|
||||
return new Font(names[0][3], 0, size);
|
||||
String name10 = null;
|
||||
String name3x = null;
|
||||
for (int k = 0; k < names.length; k++) {
|
||||
String[] name = names[k];
|
||||
if (name[0].equals("1") && name[1].equals("0")) {
|
||||
name10 = name[3];
|
||||
} else if (name[2].equals("1033")) {
|
||||
name3x = name[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
String finalName = name3x;
|
||||
if (finalName == null)
|
||||
finalName = name10;
|
||||
if (finalName == null)
|
||||
finalName = names[0][3];
|
||||
return new Font(finalName, 0, size);
|
||||
}
|
||||
|
||||
public void putName(String awtName, BaseFontParameters parameters) {
|
||||
this.mapper.put(awtName, parameters);
|
||||
}
|
||||
|
||||
public void putAlias(String alias, String awtName) {
|
||||
this.aliases.put(alias, awtName);
|
||||
}
|
||||
|
||||
public BaseFontParameters getBaseFontParameters(String name) {
|
||||
String alias = this.aliases.get(name);
|
||||
if (alias == null)
|
||||
return this.mapper.get(name);
|
||||
BaseFontParameters p = this.mapper.get(alias);
|
||||
if (p == null)
|
||||
return this.mapper.get(name);
|
||||
return p;
|
||||
}
|
||||
|
||||
public void insertNames(Object[] allNames, String path) {
|
||||
String[][] names = (String[][])allNames[2];
|
||||
String main = null;
|
||||
for (int k = 0; k < names.length; k++) {
|
||||
String[] name = names[k];
|
||||
if (name[2].equals("1033")) {
|
||||
main = name[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (main == null)
|
||||
main = names[0][3];
|
||||
BaseFontParameters p = new BaseFontParameters(path);
|
||||
this.mapper.put(main, p);
|
||||
for (int i = 0; i < names.length; i++)
|
||||
this.aliases.put(names[i][3], main);
|
||||
this.aliases.put((String)allNames[0], main);
|
||||
}
|
||||
|
||||
public int insertFile(File file) {
|
||||
String name = file.getPath().toLowerCase();
|
||||
try {
|
||||
if (name.endsWith(".ttf") || name.endsWith(".otf") || name.endsWith(".afm")) {
|
||||
Object[] allNames = BaseFont.getAllFontNames(file.getPath(), "Cp1252", null);
|
||||
insertNames(allNames, file.getPath());
|
||||
return 1;
|
||||
}
|
||||
if (name.endsWith(".ttc")) {
|
||||
String[] ttcs = BaseFont.enumerateTTCNames(file.getPath());
|
||||
for (int j = 0; j < ttcs.length; j++) {
|
||||
String nt = file.getPath() + "," + j;
|
||||
Object[] allNames = BaseFont.getAllFontNames(nt, "Cp1252", null);
|
||||
insertNames(allNames, nt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int insertDirectory(String dir) {
|
||||
File file = new File(dir);
|
||||
if (!file.exists() || !file.isDirectory())
|
||||
return 0;
|
||||
File[] files = file.listFiles();
|
||||
if (files == null)
|
||||
return 0;
|
||||
int count = 0;
|
||||
for (int k = 0; k < files.length; k++)
|
||||
count += insertFile(files[k]);
|
||||
return count;
|
||||
}
|
||||
|
||||
public HashMap<String, BaseFontParameters> getMapper() {
|
||||
return this.mapper;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.itextpdf.awt;
|
||||
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import java.awt.Font;
|
||||
|
||||
public interface FontMapper {
|
||||
BaseFont awtToPdf(Font paramFont);
|
||||
|
||||
Font pdfToAwt(BaseFont paramBaseFont, int paramInt);
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,33 @@
|
|||
package com.itextpdf.awt;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfContentByte;
|
||||
import java.awt.print.PrinterGraphics;
|
||||
import java.awt.print.PrinterJob;
|
||||
|
||||
public class PdfPrinterGraphics2D extends PdfGraphics2D implements PrinterGraphics {
|
||||
private PrinterJob printerJob;
|
||||
|
||||
public PdfPrinterGraphics2D(PdfContentByte cb, float width, float height, PrinterJob printerJob) {
|
||||
super(cb, width, height);
|
||||
this.printerJob = printerJob;
|
||||
}
|
||||
|
||||
public PdfPrinterGraphics2D(PdfContentByte cb, float width, float height, boolean onlyShapes, PrinterJob printerJob) {
|
||||
super(cb, width, height, onlyShapes);
|
||||
this.printerJob = printerJob;
|
||||
}
|
||||
|
||||
public PdfPrinterGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper, PrinterJob printerJob) {
|
||||
super(cb, width, height, fontMapper, false, false, 0.0F);
|
||||
this.printerJob = printerJob;
|
||||
}
|
||||
|
||||
public PdfPrinterGraphics2D(PdfContentByte cb, float width, float height, FontMapper fontMapper, boolean onlyShapes, boolean convertImagesToJPEG, float quality, PrinterJob printerJob) {
|
||||
super(cb, width, height, fontMapper, onlyShapes, convertImagesToJPEG, quality);
|
||||
this.printerJob = printerJob;
|
||||
}
|
||||
|
||||
public PrinterJob getPrinterJob() {
|
||||
return this.printerJob;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,530 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.misc.HashCode;
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AffineTransform implements Cloneable, Serializable {
|
||||
private static final long serialVersionUID = 1330973210523860834L;
|
||||
|
||||
public static final int TYPE_IDENTITY = 0;
|
||||
|
||||
public static final int TYPE_TRANSLATION = 1;
|
||||
|
||||
public static final int TYPE_UNIFORM_SCALE = 2;
|
||||
|
||||
public static final int TYPE_GENERAL_SCALE = 4;
|
||||
|
||||
public static final int TYPE_QUADRANT_ROTATION = 8;
|
||||
|
||||
public static final int TYPE_GENERAL_ROTATION = 16;
|
||||
|
||||
public static final int TYPE_GENERAL_TRANSFORM = 32;
|
||||
|
||||
public static final int TYPE_FLIP = 64;
|
||||
|
||||
public static final int TYPE_MASK_SCALE = 6;
|
||||
|
||||
public static final int TYPE_MASK_ROTATION = 24;
|
||||
|
||||
static final int TYPE_UNKNOWN = -1;
|
||||
|
||||
static final double ZERO = 1.0E-10D;
|
||||
|
||||
double m00;
|
||||
|
||||
double m10;
|
||||
|
||||
double m01;
|
||||
|
||||
double m11;
|
||||
|
||||
double m02;
|
||||
|
||||
double m12;
|
||||
|
||||
transient int type;
|
||||
|
||||
public AffineTransform() {
|
||||
this.type = 0;
|
||||
this.m00 = this.m11 = 1.0D;
|
||||
this.m10 = this.m01 = this.m02 = this.m12 = 0.0D;
|
||||
}
|
||||
|
||||
public AffineTransform(AffineTransform t) {
|
||||
this.type = t.type;
|
||||
this.m00 = t.m00;
|
||||
this.m10 = t.m10;
|
||||
this.m01 = t.m01;
|
||||
this.m11 = t.m11;
|
||||
this.m02 = t.m02;
|
||||
this.m12 = t.m12;
|
||||
}
|
||||
|
||||
public AffineTransform(float m00, float m10, float m01, float m11, float m02, float m12) {
|
||||
this.type = -1;
|
||||
this.m00 = (double)m00;
|
||||
this.m10 = (double)m10;
|
||||
this.m01 = (double)m01;
|
||||
this.m11 = (double)m11;
|
||||
this.m02 = (double)m02;
|
||||
this.m12 = (double)m12;
|
||||
}
|
||||
|
||||
public AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12) {
|
||||
this.type = -1;
|
||||
this.m00 = m00;
|
||||
this.m10 = m10;
|
||||
this.m01 = m01;
|
||||
this.m11 = m11;
|
||||
this.m02 = m02;
|
||||
this.m12 = m12;
|
||||
}
|
||||
|
||||
public AffineTransform(float[] matrix) {
|
||||
this.type = -1;
|
||||
this.m00 = (double)matrix[0];
|
||||
this.m10 = (double)matrix[1];
|
||||
this.m01 = (double)matrix[2];
|
||||
this.m11 = (double)matrix[3];
|
||||
if (matrix.length > 4) {
|
||||
this.m02 = (double)matrix[4];
|
||||
this.m12 = (double)matrix[5];
|
||||
}
|
||||
}
|
||||
|
||||
public AffineTransform(double[] matrix) {
|
||||
this.type = -1;
|
||||
this.m00 = matrix[0];
|
||||
this.m10 = matrix[1];
|
||||
this.m01 = matrix[2];
|
||||
this.m11 = matrix[3];
|
||||
if (matrix.length > 4) {
|
||||
this.m02 = matrix[4];
|
||||
this.m12 = matrix[5];
|
||||
}
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
if (this.type != -1)
|
||||
return this.type;
|
||||
int type = 0;
|
||||
if (this.m00 * this.m01 + this.m10 * this.m11 != 0.0D) {
|
||||
type |= 0x20;
|
||||
return type;
|
||||
}
|
||||
if (this.m02 != 0.0D || this.m12 != 0.0D) {
|
||||
type |= 0x1;
|
||||
} else if (this.m00 == 1.0D && this.m11 == 1.0D && this.m01 == 0.0D && this.m10 == 0.0D) {
|
||||
type = 0;
|
||||
return type;
|
||||
}
|
||||
if (this.m00 * this.m11 - this.m01 * this.m10 < 0.0D)
|
||||
type |= 0x40;
|
||||
double dx = this.m00 * this.m00 + this.m10 * this.m10;
|
||||
double dy = this.m01 * this.m01 + this.m11 * this.m11;
|
||||
if (dx != dy) {
|
||||
type |= 0x4;
|
||||
} else if (dx != 1.0D) {
|
||||
type |= 0x2;
|
||||
}
|
||||
if ((this.m00 == 0.0D && this.m11 == 0.0D) || (this.m10 == 0.0D && this.m01 == 0.0D && (this.m00 < 0.0D || this.m11 < 0.0D))) {
|
||||
type |= 0x8;
|
||||
} else if (this.m01 != 0.0D || this.m10 != 0.0D) {
|
||||
type |= 0x10;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public double getScaleX() {
|
||||
return this.m00;
|
||||
}
|
||||
|
||||
public double getScaleY() {
|
||||
return this.m11;
|
||||
}
|
||||
|
||||
public double getShearX() {
|
||||
return this.m01;
|
||||
}
|
||||
|
||||
public double getShearY() {
|
||||
return this.m10;
|
||||
}
|
||||
|
||||
public double getTranslateX() {
|
||||
return this.m02;
|
||||
}
|
||||
|
||||
public double getTranslateY() {
|
||||
return this.m12;
|
||||
}
|
||||
|
||||
public boolean isIdentity() {
|
||||
return (getType() == 0);
|
||||
}
|
||||
|
||||
public void getMatrix(double[] matrix) {
|
||||
matrix[0] = this.m00;
|
||||
matrix[1] = this.m10;
|
||||
matrix[2] = this.m01;
|
||||
matrix[3] = this.m11;
|
||||
if (matrix.length > 4) {
|
||||
matrix[4] = this.m02;
|
||||
matrix[5] = this.m12;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDeterminant() {
|
||||
return this.m00 * this.m11 - this.m01 * this.m10;
|
||||
}
|
||||
|
||||
public void setTransform(double m00, double m10, double m01, double m11, double m02, double m12) {
|
||||
this.type = -1;
|
||||
this.m00 = m00;
|
||||
this.m10 = m10;
|
||||
this.m01 = m01;
|
||||
this.m11 = m11;
|
||||
this.m02 = m02;
|
||||
this.m12 = m12;
|
||||
}
|
||||
|
||||
public void setTransform(AffineTransform t) {
|
||||
this.type = t.type;
|
||||
setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12);
|
||||
}
|
||||
|
||||
public void setToIdentity() {
|
||||
this.type = 0;
|
||||
this.m00 = this.m11 = 1.0D;
|
||||
this.m10 = this.m01 = this.m02 = this.m12 = 0.0D;
|
||||
}
|
||||
|
||||
public void setToTranslation(double mx, double my) {
|
||||
this.m00 = this.m11 = 1.0D;
|
||||
this.m01 = this.m10 = 0.0D;
|
||||
this.m02 = mx;
|
||||
this.m12 = my;
|
||||
if (mx == 0.0D && my == 0.0D) {
|
||||
this.type = 0;
|
||||
} else {
|
||||
this.type = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setToScale(double scx, double scy) {
|
||||
this.m00 = scx;
|
||||
this.m11 = scy;
|
||||
this.m10 = this.m01 = this.m02 = this.m12 = 0.0D;
|
||||
if (scx != 1.0D || scy != 1.0D) {
|
||||
this.type = -1;
|
||||
} else {
|
||||
this.type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setToShear(double shx, double shy) {
|
||||
this.m00 = this.m11 = 1.0D;
|
||||
this.m02 = this.m12 = 0.0D;
|
||||
this.m01 = shx;
|
||||
this.m10 = shy;
|
||||
if (shx != 0.0D || shy != 0.0D) {
|
||||
this.type = -1;
|
||||
} else {
|
||||
this.type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setToRotation(double angle) {
|
||||
double sin = Math.sin(angle);
|
||||
double cos = Math.cos(angle);
|
||||
if (Math.abs(cos) < 1.0E-10D) {
|
||||
cos = 0.0D;
|
||||
sin = (sin > 0.0D) ? 1.0D : -1.0D;
|
||||
} else if (Math.abs(sin) < 1.0E-10D) {
|
||||
sin = 0.0D;
|
||||
cos = (cos > 0.0D) ? 1.0D : -1.0D;
|
||||
}
|
||||
this.m00 = this.m11 = cos;
|
||||
this.m01 = -sin;
|
||||
this.m10 = sin;
|
||||
this.m02 = this.m12 = 0.0D;
|
||||
this.type = -1;
|
||||
}
|
||||
|
||||
public void setToRotation(double angle, double px, double py) {
|
||||
setToRotation(angle);
|
||||
this.m02 = px * (1.0D - this.m00) + py * this.m10;
|
||||
this.m12 = py * (1.0D - this.m00) - px * this.m10;
|
||||
this.type = -1;
|
||||
}
|
||||
|
||||
public static AffineTransform getTranslateInstance(double mx, double my) {
|
||||
AffineTransform t = new AffineTransform();
|
||||
t.setToTranslation(mx, my);
|
||||
return t;
|
||||
}
|
||||
|
||||
public static AffineTransform getScaleInstance(double scx, double scY) {
|
||||
AffineTransform t = new AffineTransform();
|
||||
t.setToScale(scx, scY);
|
||||
return t;
|
||||
}
|
||||
|
||||
public static AffineTransform getShearInstance(double shx, double shy) {
|
||||
AffineTransform m = new AffineTransform();
|
||||
m.setToShear(shx, shy);
|
||||
return m;
|
||||
}
|
||||
|
||||
public static AffineTransform getRotateInstance(double angle) {
|
||||
AffineTransform t = new AffineTransform();
|
||||
t.setToRotation(angle);
|
||||
return t;
|
||||
}
|
||||
|
||||
public static AffineTransform getRotateInstance(double angle, double x, double y) {
|
||||
AffineTransform t = new AffineTransform();
|
||||
t.setToRotation(angle, x, y);
|
||||
return t;
|
||||
}
|
||||
|
||||
public void translate(double mx, double my) {
|
||||
concatenate(getTranslateInstance(mx, my));
|
||||
}
|
||||
|
||||
public void scale(double scx, double scy) {
|
||||
concatenate(getScaleInstance(scx, scy));
|
||||
}
|
||||
|
||||
public void shear(double shx, double shy) {
|
||||
concatenate(getShearInstance(shx, shy));
|
||||
}
|
||||
|
||||
public void rotate(double angle) {
|
||||
concatenate(getRotateInstance(angle));
|
||||
}
|
||||
|
||||
public void rotate(double angle, double px, double py) {
|
||||
concatenate(getRotateInstance(angle, px, py));
|
||||
}
|
||||
|
||||
AffineTransform multiply(AffineTransform t1, AffineTransform t2) {
|
||||
return new AffineTransform(t1.m00 * t2.m00 + t1.m10 * t2.m01, t1.m00 * t2.m10 + t1.m10 * t2.m11, t1.m01 * t2.m00 + t1.m11 * t2.m01, t1.m01 * t2.m10 + t1.m11 * t2.m11, t1.m02 * t2.m00 + t1.m12 * t2.m01 + t2.m02, t1.m02 * t2.m10 + t1.m12 * t2.m11 + t2.m12);
|
||||
}
|
||||
|
||||
public void concatenate(AffineTransform t) {
|
||||
setTransform(multiply(t, this));
|
||||
}
|
||||
|
||||
public void preConcatenate(AffineTransform t) {
|
||||
setTransform(multiply(this, t));
|
||||
}
|
||||
|
||||
public AffineTransform createInverse() throws NoninvertibleTransformException {
|
||||
double det = getDeterminant();
|
||||
if (Math.abs(det) < 1.0E-10D)
|
||||
throw new NoninvertibleTransformException(Messages.getString("awt.204"));
|
||||
return new AffineTransform(this.m11 / det, -this.m10 / det, -this.m01 / det, this.m00 / det, (this.m01 * this.m12 - this.m11 * this.m02) / det, (this.m10 * this.m02 - this.m00 * this.m12) / det);
|
||||
}
|
||||
|
||||
public Point2D transform(Point2D src, Point2D dst) {
|
||||
if (dst == null)
|
||||
if (src instanceof Point2D.Double) {
|
||||
dst = new Point2D.Double();
|
||||
} else {
|
||||
dst = new Point2D.Float();
|
||||
}
|
||||
double x = src.getX();
|
||||
double y = src.getY();
|
||||
dst.setLocation(x * this.m00 + y * this.m01 + this.m02, x * this.m10 + y * this.m11 + this.m12);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public void transform(Point2D[] src, int srcOff, Point2D[] dst, int dstOff, int length) {
|
||||
while (--length >= 0) {
|
||||
Point2D srcPoint = src[srcOff++];
|
||||
double x = srcPoint.getX();
|
||||
double y = srcPoint.getY();
|
||||
Point2D dstPoint = dst[dstOff];
|
||||
if (dstPoint == null)
|
||||
if (srcPoint instanceof Point2D.Double) {
|
||||
dstPoint = new Point2D.Double();
|
||||
} else {
|
||||
dstPoint = new Point2D.Float();
|
||||
}
|
||||
dstPoint.setLocation(x * this.m00 + y * this.m01 + this.m02, x * this.m10 + y * this.m11 + this.m12);
|
||||
dst[dstOff++] = dstPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public void transform(double[] src, int srcOff, double[] dst, int dstOff, int length) {
|
||||
int step = 2;
|
||||
if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) {
|
||||
srcOff = srcOff + length * 2 - 2;
|
||||
dstOff = dstOff + length * 2 - 2;
|
||||
step = -2;
|
||||
}
|
||||
while (--length >= 0) {
|
||||
double x = src[srcOff + 0];
|
||||
double y = src[srcOff + 1];
|
||||
dst[dstOff + 0] = x * this.m00 + y * this.m01 + this.m02;
|
||||
dst[dstOff + 1] = x * this.m10 + y * this.m11 + this.m12;
|
||||
srcOff += step;
|
||||
dstOff += step;
|
||||
}
|
||||
}
|
||||
|
||||
public void transform(float[] src, int srcOff, float[] dst, int dstOff, int length) {
|
||||
int step = 2;
|
||||
if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) {
|
||||
srcOff = srcOff + length * 2 - 2;
|
||||
dstOff = dstOff + length * 2 - 2;
|
||||
step = -2;
|
||||
}
|
||||
while (--length >= 0) {
|
||||
float x = src[srcOff + 0];
|
||||
float y = src[srcOff + 1];
|
||||
dst[dstOff + 0] = (float)((double)x * this.m00 + (double)y * this.m01 + this.m02);
|
||||
dst[dstOff + 1] = (float)((double)x * this.m10 + (double)y * this.m11 + this.m12);
|
||||
srcOff += step;
|
||||
dstOff += step;
|
||||
}
|
||||
}
|
||||
|
||||
public void transform(float[] src, int srcOff, double[] dst, int dstOff, int length) {
|
||||
while (--length >= 0) {
|
||||
float x = src[srcOff++];
|
||||
float y = src[srcOff++];
|
||||
dst[dstOff++] = (double)x * this.m00 + (double)y * this.m01 + this.m02;
|
||||
dst[dstOff++] = (double)x * this.m10 + (double)y * this.m11 + this.m12;
|
||||
}
|
||||
}
|
||||
|
||||
public void transform(double[] src, int srcOff, float[] dst, int dstOff, int length) {
|
||||
while (--length >= 0) {
|
||||
double x = src[srcOff++];
|
||||
double y = src[srcOff++];
|
||||
dst[dstOff++] = (float)(x * this.m00 + y * this.m01 + this.m02);
|
||||
dst[dstOff++] = (float)(x * this.m10 + y * this.m11 + this.m12);
|
||||
}
|
||||
}
|
||||
|
||||
public Point2D deltaTransform(Point2D src, Point2D dst) {
|
||||
if (dst == null)
|
||||
if (src instanceof Point2D.Double) {
|
||||
dst = new Point2D.Double();
|
||||
} else {
|
||||
dst = new Point2D.Float();
|
||||
}
|
||||
double x = src.getX();
|
||||
double y = src.getY();
|
||||
dst.setLocation(x * this.m00 + y * this.m01, x * this.m10 + y * this.m11);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public void deltaTransform(double[] src, int srcOff, double[] dst, int dstOff, int length) {
|
||||
while (--length >= 0) {
|
||||
double x = src[srcOff++];
|
||||
double y = src[srcOff++];
|
||||
dst[dstOff++] = x * this.m00 + y * this.m01;
|
||||
dst[dstOff++] = x * this.m10 + y * this.m11;
|
||||
}
|
||||
}
|
||||
|
||||
public Point2D inverseTransform(Point2D src, Point2D dst) throws NoninvertibleTransformException {
|
||||
double det = getDeterminant();
|
||||
if (Math.abs(det) < 1.0E-10D)
|
||||
throw new NoninvertibleTransformException(Messages.getString("awt.204"));
|
||||
if (dst == null)
|
||||
if (src instanceof Point2D.Double) {
|
||||
dst = new Point2D.Double();
|
||||
} else {
|
||||
dst = new Point2D.Float();
|
||||
}
|
||||
double x = src.getX() - this.m02;
|
||||
double y = src.getY() - this.m12;
|
||||
dst.setLocation((x * this.m11 - y * this.m01) / det, (y * this.m00 - x * this.m10) / det);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public void inverseTransform(double[] src, int srcOff, double[] dst, int dstOff, int length) throws NoninvertibleTransformException {
|
||||
double det = getDeterminant();
|
||||
if (Math.abs(det) < 1.0E-10D)
|
||||
throw new NoninvertibleTransformException(Messages.getString("awt.204"));
|
||||
while (--length >= 0) {
|
||||
double x = src[srcOff++] - this.m02;
|
||||
double y = src[srcOff++] - this.m12;
|
||||
dst[dstOff++] = (x * this.m11 - y * this.m01) / det;
|
||||
dst[dstOff++] = (y * this.m00 - x * this.m10) / det;
|
||||
}
|
||||
}
|
||||
|
||||
public void inverseTransform(float[] src, int srcOff, float[] dst, int dstOff, int length) throws NoninvertibleTransformException {
|
||||
float det = (float)getDeterminant();
|
||||
if ((double)Math.abs(det) < 1.0E-10D)
|
||||
throw new NoninvertibleTransformException(Messages.getString("awt.204"));
|
||||
while (--length >= 0) {
|
||||
float x = src[srcOff++] - (float)this.m02;
|
||||
float y = src[srcOff++] - (float)this.m12;
|
||||
dst[dstOff++] = (x * (float)this.m11 - y * (float)this.m01) / det;
|
||||
dst[dstOff++] = (y * (float)this.m00 - x * (float)this.m10) / det;
|
||||
}
|
||||
}
|
||||
|
||||
public Shape createTransformedShape(Shape src) {
|
||||
if (src == null)
|
||||
return null;
|
||||
if (src instanceof GeneralPath)
|
||||
return ((GeneralPath)src).createTransformedShape(this);
|
||||
PathIterator path = src.getPathIterator(this);
|
||||
GeneralPath dst = new GeneralPath(path.getWindingRule());
|
||||
dst.append(path, false);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[[" + this.m00 + ", " + this.m01 + ", " + this.m02 + "], [" + this.m10 + ", " + this.m11 + ", " + this.m12 + "]]";
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCode hash = new HashCode();
|
||||
hash.append(this.m00);
|
||||
hash.append(this.m01);
|
||||
hash.append(this.m02);
|
||||
hash.append(this.m10);
|
||||
hash.append(this.m11);
|
||||
hash.append(this.m12);
|
||||
return hash.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof AffineTransform) {
|
||||
AffineTransform t = (AffineTransform)obj;
|
||||
return (this.m00 == t.m00 && this.m01 == t.m01 && this.m02 == t.m02 && this.m10 == t.m10 && this.m11 == t.m11 && this.m12 == t.m12);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream stream) throws IOException {
|
||||
stream.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
this.type = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,489 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.gl.Crossing;
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public abstract class CubicCurve2D implements Shape, Cloneable {
|
||||
public abstract double getX1();
|
||||
|
||||
public abstract double getY1();
|
||||
|
||||
public abstract Point2D getP1();
|
||||
|
||||
public abstract double getCtrlX1();
|
||||
|
||||
public abstract double getCtrlY1();
|
||||
|
||||
public abstract Point2D getCtrlP1();
|
||||
|
||||
public abstract double getCtrlX2();
|
||||
|
||||
public abstract double getCtrlY2();
|
||||
|
||||
public abstract Point2D getCtrlP2();
|
||||
|
||||
public abstract double getX2();
|
||||
|
||||
public abstract double getY2();
|
||||
|
||||
public abstract Point2D getP2();
|
||||
|
||||
public abstract void setCurve(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, double paramDouble5, double paramDouble6, double paramDouble7, double paramDouble8);
|
||||
|
||||
public static class Float extends CubicCurve2D {
|
||||
public float x1;
|
||||
|
||||
public float y1;
|
||||
|
||||
public float ctrlx1;
|
||||
|
||||
public float ctrly1;
|
||||
|
||||
public float ctrlx2;
|
||||
|
||||
public float ctrly2;
|
||||
|
||||
public float x2;
|
||||
|
||||
public float y2;
|
||||
|
||||
public Float() {}
|
||||
|
||||
public Float(float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2) {
|
||||
setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2);
|
||||
}
|
||||
|
||||
public double getX1() {
|
||||
return (double)this.x1;
|
||||
}
|
||||
|
||||
public double getY1() {
|
||||
return (double)this.y1;
|
||||
}
|
||||
|
||||
public double getCtrlX1() {
|
||||
return (double)this.ctrlx1;
|
||||
}
|
||||
|
||||
public double getCtrlY1() {
|
||||
return (double)this.ctrly1;
|
||||
}
|
||||
|
||||
public double getCtrlX2() {
|
||||
return (double)this.ctrlx2;
|
||||
}
|
||||
|
||||
public double getCtrlY2() {
|
||||
return (double)this.ctrly2;
|
||||
}
|
||||
|
||||
public double getX2() {
|
||||
return (double)this.x2;
|
||||
}
|
||||
|
||||
public double getY2() {
|
||||
return (double)this.y2;
|
||||
}
|
||||
|
||||
public Point2D getP1() {
|
||||
return new Point2D.Float(this.x1, this.y1);
|
||||
}
|
||||
|
||||
public Point2D getCtrlP1() {
|
||||
return new Point2D.Float(this.ctrlx1, this.ctrly1);
|
||||
}
|
||||
|
||||
public Point2D getCtrlP2() {
|
||||
return new Point2D.Float(this.ctrlx2, this.ctrly2);
|
||||
}
|
||||
|
||||
public Point2D getP2() {
|
||||
return new Point2D.Float(this.x2, this.y2);
|
||||
}
|
||||
|
||||
public void setCurve(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
|
||||
this.x1 = (float)x1;
|
||||
this.y1 = (float)y1;
|
||||
this.ctrlx1 = (float)ctrlx1;
|
||||
this.ctrly1 = (float)ctrly1;
|
||||
this.ctrlx2 = (float)ctrlx2;
|
||||
this.ctrly2 = (float)ctrly2;
|
||||
this.x2 = (float)x2;
|
||||
this.y2 = (float)y2;
|
||||
}
|
||||
|
||||
public void setCurve(float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.ctrlx1 = ctrlx1;
|
||||
this.ctrly1 = ctrly1;
|
||||
this.ctrlx2 = ctrlx2;
|
||||
this.ctrly2 = ctrly2;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
float rx1 = Math.min(Math.min(this.x1, this.x2), Math.min(this.ctrlx1, this.ctrlx2));
|
||||
float ry1 = Math.min(Math.min(this.y1, this.y2), Math.min(this.ctrly1, this.ctrly2));
|
||||
float rx2 = Math.max(Math.max(this.x1, this.x2), Math.max(this.ctrlx1, this.ctrlx2));
|
||||
float ry2 = Math.max(Math.max(this.y1, this.y2), Math.max(this.ctrly1, this.ctrly2));
|
||||
return new Rectangle2D.Float(rx1, ry1, rx2 - rx1, ry2 - ry1);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Double extends CubicCurve2D {
|
||||
public double x1;
|
||||
|
||||
public double y1;
|
||||
|
||||
public double ctrlx1;
|
||||
|
||||
public double ctrly1;
|
||||
|
||||
public double ctrlx2;
|
||||
|
||||
public double ctrly2;
|
||||
|
||||
public double x2;
|
||||
|
||||
public double y2;
|
||||
|
||||
public Double() {}
|
||||
|
||||
public Double(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
|
||||
setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2);
|
||||
}
|
||||
|
||||
public double getX1() {
|
||||
return this.x1;
|
||||
}
|
||||
|
||||
public double getY1() {
|
||||
return this.y1;
|
||||
}
|
||||
|
||||
public double getCtrlX1() {
|
||||
return this.ctrlx1;
|
||||
}
|
||||
|
||||
public double getCtrlY1() {
|
||||
return this.ctrly1;
|
||||
}
|
||||
|
||||
public double getCtrlX2() {
|
||||
return this.ctrlx2;
|
||||
}
|
||||
|
||||
public double getCtrlY2() {
|
||||
return this.ctrly2;
|
||||
}
|
||||
|
||||
public double getX2() {
|
||||
return this.x2;
|
||||
}
|
||||
|
||||
public double getY2() {
|
||||
return this.y2;
|
||||
}
|
||||
|
||||
public Point2D getP1() {
|
||||
return new Point2D.Double(this.x1, this.y1);
|
||||
}
|
||||
|
||||
public Point2D getCtrlP1() {
|
||||
return new Point2D.Double(this.ctrlx1, this.ctrly1);
|
||||
}
|
||||
|
||||
public Point2D getCtrlP2() {
|
||||
return new Point2D.Double(this.ctrlx2, this.ctrly2);
|
||||
}
|
||||
|
||||
public Point2D getP2() {
|
||||
return new Point2D.Double(this.x2, this.y2);
|
||||
}
|
||||
|
||||
public void setCurve(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.ctrlx1 = ctrlx1;
|
||||
this.ctrly1 = ctrly1;
|
||||
this.ctrlx2 = ctrlx2;
|
||||
this.ctrly2 = ctrly2;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
double rx1 = Math.min(Math.min(this.x1, this.x2), Math.min(this.ctrlx1, this.ctrlx2));
|
||||
double ry1 = Math.min(Math.min(this.y1, this.y2), Math.min(this.ctrly1, this.ctrly2));
|
||||
double rx2 = Math.max(Math.max(this.x1, this.x2), Math.max(this.ctrlx1, this.ctrlx2));
|
||||
double ry2 = Math.max(Math.max(this.y1, this.y2), Math.max(this.ctrly1, this.ctrly2));
|
||||
return new Rectangle2D.Double(rx1, ry1, rx2 - rx1, ry2 - ry1);
|
||||
}
|
||||
}
|
||||
|
||||
class Iterator implements PathIterator {
|
||||
CubicCurve2D c;
|
||||
|
||||
AffineTransform t;
|
||||
|
||||
int index;
|
||||
|
||||
Iterator(CubicCurve2D c, AffineTransform t) {
|
||||
this.c = c;
|
||||
this.t = t;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.index > 1);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
int type, count;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = this.c.getX1();
|
||||
coords[1] = this.c.getY1();
|
||||
count = 1;
|
||||
} else {
|
||||
type = 3;
|
||||
coords[0] = this.c.getCtrlX1();
|
||||
coords[1] = this.c.getCtrlY1();
|
||||
coords[2] = this.c.getCtrlX2();
|
||||
coords[3] = this.c.getCtrlY2();
|
||||
coords[4] = this.c.getX2();
|
||||
coords[5] = this.c.getY2();
|
||||
count = 3;
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, count);
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
int type, count;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = (float)this.c.getX1();
|
||||
coords[1] = (float)this.c.getY1();
|
||||
count = 1;
|
||||
} else {
|
||||
type = 3;
|
||||
coords[0] = (float)this.c.getCtrlX1();
|
||||
coords[1] = (float)this.c.getCtrlY1();
|
||||
coords[2] = (float)this.c.getCtrlX2();
|
||||
coords[3] = (float)this.c.getCtrlY2();
|
||||
coords[4] = (float)this.c.getX2();
|
||||
coords[5] = (float)this.c.getY2();
|
||||
count = 3;
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, count);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurve(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2) {
|
||||
setCurve(
|
||||
p1.getX(), p1.getY(),
|
||||
cp1.getX(), cp1.getY(),
|
||||
cp2.getX(), cp2.getY(),
|
||||
p2.getX(), p2.getY());
|
||||
}
|
||||
|
||||
public void setCurve(double[] coords, int offset) {
|
||||
setCurve(coords[offset + 0], coords[offset + 1], coords[offset + 2], coords[offset + 3], coords[offset + 4], coords[offset + 5], coords[offset + 6], coords[offset + 7]);
|
||||
}
|
||||
|
||||
public void setCurve(Point2D[] points, int offset) {
|
||||
setCurve(points[offset + 0]
|
||||
.getX(), points[offset + 0].getY(), points[offset + 1]
|
||||
.getX(), points[offset + 1].getY(), points[offset + 2]
|
||||
.getX(), points[offset + 2].getY(), points[offset + 3]
|
||||
.getX(), points[offset + 3].getY());
|
||||
}
|
||||
|
||||
public void setCurve(CubicCurve2D curve) {
|
||||
setCurve(
|
||||
curve.getX1(), curve.getY1(),
|
||||
curve.getCtrlX1(), curve.getCtrlY1(),
|
||||
curve.getCtrlX2(), curve.getCtrlY2(),
|
||||
curve.getX2(), curve.getY2());
|
||||
}
|
||||
|
||||
public double getFlatnessSq() {
|
||||
return getFlatnessSq(
|
||||
getX1(), getY1(),
|
||||
getCtrlX1(), getCtrlY1(),
|
||||
getCtrlX2(), getCtrlY2(),
|
||||
getX2(), getY2());
|
||||
}
|
||||
|
||||
public static double getFlatnessSq(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
|
||||
return Math.max(
|
||||
Line2D.ptSegDistSq(x1, y1, x2, y2, ctrlx1, ctrly1),
|
||||
Line2D.ptSegDistSq(x1, y1, x2, y2, ctrlx2, ctrly2));
|
||||
}
|
||||
|
||||
public static double getFlatnessSq(double[] coords, int offset) {
|
||||
return getFlatnessSq(coords[offset + 0], coords[offset + 1], coords[offset + 2], coords[offset + 3], coords[offset + 4], coords[offset + 5], coords[offset + 6], coords[offset + 7]);
|
||||
}
|
||||
|
||||
public double getFlatness() {
|
||||
return getFlatness(
|
||||
getX1(), getY1(),
|
||||
getCtrlX1(), getCtrlY1(),
|
||||
getCtrlX2(), getCtrlY2(),
|
||||
getX2(), getY2());
|
||||
}
|
||||
|
||||
public static double getFlatness(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
|
||||
return Math.sqrt(getFlatnessSq(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2));
|
||||
}
|
||||
|
||||
public static double getFlatness(double[] coords, int offset) {
|
||||
return getFlatness(coords[offset + 0], coords[offset + 1], coords[offset + 2], coords[offset + 3], coords[offset + 4], coords[offset + 5], coords[offset + 6], coords[offset + 7]);
|
||||
}
|
||||
|
||||
public void subdivide(CubicCurve2D left, CubicCurve2D right) {
|
||||
subdivide(this, left, right);
|
||||
}
|
||||
|
||||
public static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right) {
|
||||
double x1 = src.getX1();
|
||||
double y1 = src.getY1();
|
||||
double cx1 = src.getCtrlX1();
|
||||
double cy1 = src.getCtrlY1();
|
||||
double cx2 = src.getCtrlX2();
|
||||
double cy2 = src.getCtrlY2();
|
||||
double x2 = src.getX2();
|
||||
double y2 = src.getY2();
|
||||
double cx = (cx1 + cx2) / 2.0D;
|
||||
double cy = (cy1 + cy2) / 2.0D;
|
||||
cx1 = (x1 + cx1) / 2.0D;
|
||||
cy1 = (y1 + cy1) / 2.0D;
|
||||
cx2 = (x2 + cx2) / 2.0D;
|
||||
cy2 = (y2 + cy2) / 2.0D;
|
||||
double ax = (cx1 + cx) / 2.0D;
|
||||
double ay = (cy1 + cy) / 2.0D;
|
||||
double bx = (cx2 + cx) / 2.0D;
|
||||
double by = (cy2 + cy) / 2.0D;
|
||||
cx = (ax + bx) / 2.0D;
|
||||
cy = (ay + by) / 2.0D;
|
||||
if (left != null)
|
||||
left.setCurve(x1, y1, cx1, cy1, ax, ay, cx, cy);
|
||||
if (right != null)
|
||||
right.setCurve(cx, cy, bx, by, cx2, cy2, x2, y2);
|
||||
}
|
||||
|
||||
public static void subdivide(double[] src, int srcOff, double[] left, int leftOff, double[] right, int rightOff) {
|
||||
double x1 = src[srcOff + 0];
|
||||
double y1 = src[srcOff + 1];
|
||||
double cx1 = src[srcOff + 2];
|
||||
double cy1 = src[srcOff + 3];
|
||||
double cx2 = src[srcOff + 4];
|
||||
double cy2 = src[srcOff + 5];
|
||||
double x2 = src[srcOff + 6];
|
||||
double y2 = src[srcOff + 7];
|
||||
double cx = (cx1 + cx2) / 2.0D;
|
||||
double cy = (cy1 + cy2) / 2.0D;
|
||||
cx1 = (x1 + cx1) / 2.0D;
|
||||
cy1 = (y1 + cy1) / 2.0D;
|
||||
cx2 = (x2 + cx2) / 2.0D;
|
||||
cy2 = (y2 + cy2) / 2.0D;
|
||||
double ax = (cx1 + cx) / 2.0D;
|
||||
double ay = (cy1 + cy) / 2.0D;
|
||||
double bx = (cx2 + cx) / 2.0D;
|
||||
double by = (cy2 + cy) / 2.0D;
|
||||
cx = (ax + bx) / 2.0D;
|
||||
cy = (ay + by) / 2.0D;
|
||||
if (left != null) {
|
||||
left[leftOff + 0] = x1;
|
||||
left[leftOff + 1] = y1;
|
||||
left[leftOff + 2] = cx1;
|
||||
left[leftOff + 3] = cy1;
|
||||
left[leftOff + 4] = ax;
|
||||
left[leftOff + 5] = ay;
|
||||
left[leftOff + 6] = cx;
|
||||
left[leftOff + 7] = cy;
|
||||
}
|
||||
if (right != null) {
|
||||
right[rightOff + 0] = cx;
|
||||
right[rightOff + 1] = cy;
|
||||
right[rightOff + 2] = bx;
|
||||
right[rightOff + 3] = by;
|
||||
right[rightOff + 4] = cx2;
|
||||
right[rightOff + 5] = cy2;
|
||||
right[rightOff + 6] = x2;
|
||||
right[rightOff + 7] = y2;
|
||||
}
|
||||
}
|
||||
|
||||
public static int solveCubic(double[] eqn) {
|
||||
return solveCubic(eqn, eqn);
|
||||
}
|
||||
|
||||
public static int solveCubic(double[] eqn, double[] res) {
|
||||
return Crossing.solveCubic(eqn, res);
|
||||
}
|
||||
|
||||
public boolean contains(double px, double py) {
|
||||
return Crossing.isInsideEvenOdd(Crossing.crossShape(this, px, py));
|
||||
}
|
||||
|
||||
public boolean contains(double rx, double ry, double rw, double rh) {
|
||||
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
|
||||
return (cross != 255 && Crossing.isInsideEvenOdd(cross));
|
||||
}
|
||||
|
||||
public boolean intersects(double rx, double ry, double rw, double rh) {
|
||||
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
|
||||
return (cross == 255 || Crossing.isInsideEvenOdd(cross));
|
||||
}
|
||||
|
||||
public boolean contains(Point2D p) {
|
||||
return contains(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean intersects(Rectangle2D r) {
|
||||
return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public boolean contains(Rectangle2D r) {
|
||||
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return getBounds2D().getBounds();
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t) {
|
||||
return new Iterator(this, t);
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform at, double flatness) {
|
||||
return new FlatteningPathIterator(getPathIterator(at), flatness);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.misc.HashCode;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Dimension extends Dimension2D implements Serializable {
|
||||
private static final long serialVersionUID = 4723952579491349524L;
|
||||
|
||||
public double width;
|
||||
|
||||
public double height;
|
||||
|
||||
public Dimension(Dimension d) {
|
||||
this(d.width, d.height);
|
||||
}
|
||||
|
||||
public Dimension() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public Dimension(double width, double height) {
|
||||
setSize(width, height);
|
||||
}
|
||||
|
||||
public Dimension(int width, int height) {
|
||||
setSize(width, height);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCode hash = new HashCode();
|
||||
hash.append(this.width);
|
||||
hash.append(this.height);
|
||||
return hash.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof Dimension) {
|
||||
Dimension d = (Dimension)obj;
|
||||
return (d.width == this.width && d.height == this.height);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[width=" + this.width + ",height=" + this.height + "]";
|
||||
}
|
||||
|
||||
public void setSize(int width, int height) {
|
||||
this.width = (double)width;
|
||||
this.height = (double)height;
|
||||
}
|
||||
|
||||
public void setSize(Dimension d) {
|
||||
setSize(d.width, d.height);
|
||||
}
|
||||
|
||||
public void setSize(double width, double height) {
|
||||
setSize((int)Math.ceil(width), (int)Math.ceil(height));
|
||||
}
|
||||
|
||||
public Dimension getSize() {
|
||||
return new Dimension(this.width, this.height);
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public abstract class Dimension2D implements Cloneable {
|
||||
public abstract double getWidth();
|
||||
|
||||
public abstract double getHeight();
|
||||
|
||||
public abstract void setSize(double paramDouble1, double paramDouble2);
|
||||
|
||||
public void setSize(Dimension2D d) {
|
||||
setSize(d.getWidth(), d.getHeight());
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class FlatteningPathIterator implements PathIterator {
|
||||
private static final int BUFFER_SIZE = 16;
|
||||
|
||||
private static final int BUFFER_LIMIT = 16;
|
||||
|
||||
private static final int BUFFER_CAPACITY = 16;
|
||||
|
||||
int bufType;
|
||||
|
||||
int bufLimit;
|
||||
|
||||
int bufSize;
|
||||
|
||||
int bufIndex;
|
||||
|
||||
int bufSubdiv;
|
||||
|
||||
double[] buf;
|
||||
|
||||
boolean bufEmpty = true;
|
||||
|
||||
PathIterator p;
|
||||
|
||||
double flatness;
|
||||
|
||||
double flatness2;
|
||||
|
||||
double px;
|
||||
|
||||
double py;
|
||||
|
||||
double[] coords = new double[6];
|
||||
|
||||
public FlatteningPathIterator(PathIterator path, double flatness) {
|
||||
this(path, flatness, 16);
|
||||
}
|
||||
|
||||
public FlatteningPathIterator(PathIterator path, double flatness, int limit) {
|
||||
if (flatness < 0.0D)
|
||||
throw new IllegalArgumentException(Messages.getString("awt.206"));
|
||||
if (limit < 0)
|
||||
throw new IllegalArgumentException(Messages.getString("awt.207"));
|
||||
if (path == null)
|
||||
throw new NullPointerException(Messages.getString("awt.208"));
|
||||
this.p = path;
|
||||
this.flatness = flatness;
|
||||
this.flatness2 = flatness * flatness;
|
||||
this.bufLimit = limit;
|
||||
this.bufSize = Math.min(this.bufLimit, 16);
|
||||
this.buf = new double[this.bufSize];
|
||||
this.bufIndex = this.bufSize;
|
||||
}
|
||||
|
||||
public double getFlatness() {
|
||||
return this.flatness;
|
||||
}
|
||||
|
||||
public int getRecursionLimit() {
|
||||
return this.bufLimit;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return this.p.getWindingRule();
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.bufEmpty && this.p.isDone());
|
||||
}
|
||||
|
||||
void evaluate() {
|
||||
if (this.bufEmpty)
|
||||
this.bufType = this.p.currentSegment(this.coords);
|
||||
switch (this.bufType) {
|
||||
case 0:
|
||||
case 1:
|
||||
this.px = this.coords[0];
|
||||
this.py = this.coords[1];
|
||||
break;
|
||||
case 2:
|
||||
if (this.bufEmpty) {
|
||||
this.bufIndex -= 6;
|
||||
this.buf[this.bufIndex + 0] = this.px;
|
||||
this.buf[this.bufIndex + 1] = this.py;
|
||||
System.arraycopy(this.coords, 0, this.buf, this.bufIndex + 2, 4);
|
||||
this.bufSubdiv = 0;
|
||||
}
|
||||
while (this.bufSubdiv < this.bufLimit &&
|
||||
QuadCurve2D.getFlatnessSq(this.buf, this.bufIndex) >= this.flatness2) {
|
||||
if (this.bufIndex <= 4) {
|
||||
double[] tmp = new double[this.bufSize + 16];
|
||||
System.arraycopy(this.buf, this.bufIndex, tmp, this.bufIndex + 16, this.bufSize - this.bufIndex);
|
||||
this.buf = tmp;
|
||||
this.bufSize += 16;
|
||||
this.bufIndex += 16;
|
||||
}
|
||||
QuadCurve2D.subdivide(this.buf, this.bufIndex, this.buf, this.bufIndex - 4, this.buf, this.bufIndex);
|
||||
this.bufIndex -= 4;
|
||||
this.bufSubdiv++;
|
||||
}
|
||||
this.bufIndex += 4;
|
||||
this.px = this.buf[this.bufIndex];
|
||||
this.py = this.buf[this.bufIndex + 1];
|
||||
this.bufEmpty = (this.bufIndex == this.bufSize - 2);
|
||||
if (this.bufEmpty) {
|
||||
this.bufIndex = this.bufSize;
|
||||
this.bufType = 1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (this.bufEmpty) {
|
||||
this.bufIndex -= 8;
|
||||
this.buf[this.bufIndex + 0] = this.px;
|
||||
this.buf[this.bufIndex + 1] = this.py;
|
||||
System.arraycopy(this.coords, 0, this.buf, this.bufIndex + 2, 6);
|
||||
this.bufSubdiv = 0;
|
||||
}
|
||||
while (this.bufSubdiv < this.bufLimit &&
|
||||
CubicCurve2D.getFlatnessSq(this.buf, this.bufIndex) >= this.flatness2) {
|
||||
if (this.bufIndex <= 6) {
|
||||
double[] tmp = new double[this.bufSize + 16];
|
||||
System.arraycopy(this.buf, this.bufIndex, tmp, this.bufIndex + 16, this.bufSize - this.bufIndex);
|
||||
this.buf = tmp;
|
||||
this.bufSize += 16;
|
||||
this.bufIndex += 16;
|
||||
}
|
||||
CubicCurve2D.subdivide(this.buf, this.bufIndex, this.buf, this.bufIndex - 6, this.buf, this.bufIndex);
|
||||
this.bufIndex -= 6;
|
||||
this.bufSubdiv++;
|
||||
}
|
||||
this.bufIndex += 6;
|
||||
this.px = this.buf[this.bufIndex];
|
||||
this.py = this.buf[this.bufIndex + 1];
|
||||
this.bufEmpty = (this.bufIndex == this.bufSize - 2);
|
||||
if (this.bufEmpty) {
|
||||
this.bufIndex = this.bufSize;
|
||||
this.bufType = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void next() {
|
||||
if (this.bufEmpty)
|
||||
this.p.next();
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4Bx"));
|
||||
evaluate();
|
||||
int type = this.bufType;
|
||||
if (type != 4) {
|
||||
coords[0] = (float)this.px;
|
||||
coords[1] = (float)this.py;
|
||||
if (type != 0)
|
||||
type = 1;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
evaluate();
|
||||
int type = this.bufType;
|
||||
if (type != 4) {
|
||||
coords[0] = this.px;
|
||||
coords[1] = this.py;
|
||||
if (type != 0)
|
||||
type = 1;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.gl.Crossing;
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public final class GeneralPath implements Shape, Cloneable {
|
||||
public static final int WIND_EVEN_ODD = 0;
|
||||
|
||||
public static final int WIND_NON_ZERO = 1;
|
||||
|
||||
private static final int BUFFER_SIZE = 10;
|
||||
|
||||
private static final int BUFFER_CAPACITY = 10;
|
||||
|
||||
byte[] types;
|
||||
|
||||
float[] points;
|
||||
|
||||
int typeSize;
|
||||
|
||||
int pointSize;
|
||||
|
||||
int rule;
|
||||
|
||||
static int[] pointShift = new int[] { 2, 2, 4, 6, 0 };
|
||||
|
||||
class Iterator implements PathIterator {
|
||||
int typeIndex;
|
||||
|
||||
int pointIndex;
|
||||
|
||||
GeneralPath p;
|
||||
|
||||
AffineTransform t;
|
||||
|
||||
Iterator(GeneralPath path) {
|
||||
this(path, null);
|
||||
}
|
||||
|
||||
Iterator(GeneralPath path, AffineTransform at) {
|
||||
this.p = path;
|
||||
this.t = at;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return this.p.getWindingRule();
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.typeIndex >= this.p.typeSize);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
this.typeIndex++;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
int type = this.p.types[this.typeIndex];
|
||||
int count = GeneralPath.pointShift[type];
|
||||
for (int i = 0; i < count; i++)
|
||||
coords[i] = (double)this.p.points[this.pointIndex + i];
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, count / 2);
|
||||
this.pointIndex += count;
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
int type = this.p.types[this.typeIndex];
|
||||
int count = GeneralPath.pointShift[type];
|
||||
System.arraycopy(this.p.points, this.pointIndex, coords, 0, count);
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, count / 2);
|
||||
this.pointIndex += count;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public GeneralPath() {
|
||||
this(1, 10);
|
||||
}
|
||||
|
||||
public GeneralPath(int rule) {
|
||||
this(rule, 10);
|
||||
}
|
||||
|
||||
public GeneralPath(int rule, int initialCapacity) {
|
||||
setWindingRule(rule);
|
||||
this.types = new byte[initialCapacity];
|
||||
this.points = new float[initialCapacity * 2];
|
||||
}
|
||||
|
||||
public GeneralPath(Shape shape) {
|
||||
this(1, 10);
|
||||
PathIterator p = shape.getPathIterator(null);
|
||||
setWindingRule(p.getWindingRule());
|
||||
append(p, false);
|
||||
}
|
||||
|
||||
public void setWindingRule(int rule) {
|
||||
if (rule != 0 && rule != 1)
|
||||
throw new IllegalArgumentException(Messages.getString("awt.209"));
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return this.rule;
|
||||
}
|
||||
|
||||
void checkBuf(int pointCount, boolean checkMove) {
|
||||
if (checkMove && this.typeSize == 0)
|
||||
throw new IllegalPathStateException(Messages.getString("awt.20A"));
|
||||
if (this.typeSize == this.types.length) {
|
||||
byte[] tmp = new byte[this.typeSize + 10];
|
||||
System.arraycopy(this.types, 0, tmp, 0, this.typeSize);
|
||||
this.types = tmp;
|
||||
}
|
||||
if (this.pointSize + pointCount > this.points.length) {
|
||||
float[] tmp = new float[this.pointSize + Math.max(20, pointCount)];
|
||||
System.arraycopy(this.points, 0, tmp, 0, this.pointSize);
|
||||
this.points = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
public void moveTo(float x, float y) {
|
||||
if (this.typeSize > 0 && this.types[this.typeSize - 1] == 0) {
|
||||
this.points[this.pointSize - 2] = x;
|
||||
this.points[this.pointSize - 1] = y;
|
||||
} else {
|
||||
checkBuf(2, false);
|
||||
this.types[this.typeSize++] = 0;
|
||||
this.points[this.pointSize++] = x;
|
||||
this.points[this.pointSize++] = y;
|
||||
}
|
||||
}
|
||||
|
||||
public void lineTo(float x, float y) {
|
||||
checkBuf(2, true);
|
||||
this.types[this.typeSize++] = 1;
|
||||
this.points[this.pointSize++] = x;
|
||||
this.points[this.pointSize++] = y;
|
||||
}
|
||||
|
||||
public void quadTo(float x1, float y1, float x2, float y2) {
|
||||
checkBuf(4, true);
|
||||
this.types[this.typeSize++] = 2;
|
||||
this.points[this.pointSize++] = x1;
|
||||
this.points[this.pointSize++] = y1;
|
||||
this.points[this.pointSize++] = x2;
|
||||
this.points[this.pointSize++] = y2;
|
||||
}
|
||||
|
||||
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) {
|
||||
checkBuf(6, true);
|
||||
this.types[this.typeSize++] = 3;
|
||||
this.points[this.pointSize++] = x1;
|
||||
this.points[this.pointSize++] = y1;
|
||||
this.points[this.pointSize++] = x2;
|
||||
this.points[this.pointSize++] = y2;
|
||||
this.points[this.pointSize++] = x3;
|
||||
this.points[this.pointSize++] = y3;
|
||||
}
|
||||
|
||||
public void closePath() {
|
||||
if (this.typeSize == 0 || this.types[this.typeSize - 1] != 4) {
|
||||
checkBuf(0, true);
|
||||
this.types[this.typeSize++] = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public void append(Shape shape, boolean connect) {
|
||||
PathIterator p = shape.getPathIterator(null);
|
||||
append(p, connect);
|
||||
}
|
||||
|
||||
public void append(PathIterator path, boolean connect) {
|
||||
while (!path.isDone()) {
|
||||
float[] coords = new float[6];
|
||||
switch (path.currentSegment(coords)) {
|
||||
case 0:
|
||||
if (!connect || this.typeSize == 0) {
|
||||
moveTo(coords[0], coords[1]);
|
||||
break;
|
||||
}
|
||||
if (this.types[this.typeSize - 1] != 4 && this.points[this.pointSize - 2] == coords[0] && this.points[this.pointSize - 1] == coords[1])
|
||||
break;
|
||||
case 1:
|
||||
lineTo(coords[0], coords[1]);
|
||||
break;
|
||||
case 2:
|
||||
quadTo(coords[0], coords[1], coords[2], coords[3]);
|
||||
break;
|
||||
case 3:
|
||||
curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
|
||||
break;
|
||||
case 4:
|
||||
closePath();
|
||||
break;
|
||||
}
|
||||
path.next();
|
||||
connect = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Point2D getCurrentPoint() {
|
||||
if (this.typeSize == 0)
|
||||
return null;
|
||||
int j = this.pointSize - 2;
|
||||
if (this.types[this.typeSize - 1] == 4)
|
||||
for (int i = this.typeSize - 2; i > 0; i--) {
|
||||
int type = this.types[i];
|
||||
if (type == 0)
|
||||
break;
|
||||
j -= pointShift[type];
|
||||
}
|
||||
return new Point2D.Float(this.points[j], this.points[j + 1]);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.typeSize = 0;
|
||||
this.pointSize = 0;
|
||||
}
|
||||
|
||||
public void transform(AffineTransform t) {
|
||||
t.transform(this.points, 0, this.points, 0, this.pointSize / 2);
|
||||
}
|
||||
|
||||
public Shape createTransformedShape(AffineTransform t) {
|
||||
GeneralPath p = (GeneralPath)clone();
|
||||
if (t != null)
|
||||
p.transform(t);
|
||||
return p;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
float rx1, ry1, rx2, ry2;
|
||||
if (this.pointSize == 0) {
|
||||
rx1 = ry1 = rx2 = ry2 = 0.0F;
|
||||
} else {
|
||||
int i = this.pointSize - 1;
|
||||
ry1 = ry2 = this.points[i--];
|
||||
rx1 = rx2 = this.points[i--];
|
||||
while (i > 0) {
|
||||
float y = this.points[i--];
|
||||
float x = this.points[i--];
|
||||
if (x < rx1) {
|
||||
rx1 = x;
|
||||
} else if (x > rx2) {
|
||||
rx2 = x;
|
||||
}
|
||||
if (y < ry1) {
|
||||
ry1 = y;
|
||||
continue;
|
||||
}
|
||||
if (y > ry2)
|
||||
ry2 = y;
|
||||
}
|
||||
}
|
||||
return new Rectangle2D.Float(rx1, ry1, rx2 - rx1, ry2 - ry1);
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return getBounds2D().getBounds();
|
||||
}
|
||||
|
||||
boolean isInside(int cross) {
|
||||
if (this.rule == 1)
|
||||
return Crossing.isInsideNonZero(cross);
|
||||
return Crossing.isInsideEvenOdd(cross);
|
||||
}
|
||||
|
||||
public boolean contains(double px, double py) {
|
||||
return isInside(Crossing.crossShape(this, px, py));
|
||||
}
|
||||
|
||||
public boolean contains(double rx, double ry, double rw, double rh) {
|
||||
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
|
||||
return (cross != 255 && isInside(cross));
|
||||
}
|
||||
|
||||
public boolean intersects(double rx, double ry, double rw, double rh) {
|
||||
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
|
||||
return (cross == 255 || isInside(cross));
|
||||
}
|
||||
|
||||
public boolean contains(Point2D p) {
|
||||
return contains(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean contains(Rectangle2D r) {
|
||||
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public boolean intersects(Rectangle2D r) {
|
||||
return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t) {
|
||||
return new Iterator(this, t);
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t, double flatness) {
|
||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
GeneralPath p = (GeneralPath)super.clone();
|
||||
p.types = (byte[])this.types.clone();
|
||||
p.points = (float[])this.points.clone();
|
||||
return p;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public class IllegalPathStateException extends RuntimeException {
|
||||
private static final long serialVersionUID = -5158084205220481094L;
|
||||
|
||||
public IllegalPathStateException() {}
|
||||
|
||||
public IllegalPathStateException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,416 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public abstract class Line2D implements Shape, Cloneable {
|
||||
public abstract double getX1();
|
||||
|
||||
public abstract double getY1();
|
||||
|
||||
public abstract double getX2();
|
||||
|
||||
public abstract double getY2();
|
||||
|
||||
public abstract Point2D getP1();
|
||||
|
||||
public abstract Point2D getP2();
|
||||
|
||||
public abstract void setLine(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4);
|
||||
|
||||
public static class Float extends Line2D {
|
||||
public float x1;
|
||||
|
||||
public float y1;
|
||||
|
||||
public float x2;
|
||||
|
||||
public float y2;
|
||||
|
||||
public Float() {}
|
||||
|
||||
public Float(float x1, float y1, float x2, float y2) {
|
||||
setLine(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
public Float(Point2D p1, Point2D p2) {
|
||||
setLine(p1, p2);
|
||||
}
|
||||
|
||||
public double getX1() {
|
||||
return (double)this.x1;
|
||||
}
|
||||
|
||||
public double getY1() {
|
||||
return (double)this.y1;
|
||||
}
|
||||
|
||||
public double getX2() {
|
||||
return (double)this.x2;
|
||||
}
|
||||
|
||||
public double getY2() {
|
||||
return (double)this.y2;
|
||||
}
|
||||
|
||||
public Point2D getP1() {
|
||||
return new Point2D.Float(this.x1, this.y1);
|
||||
}
|
||||
|
||||
public Point2D getP2() {
|
||||
return new Point2D.Float(this.x2, this.y2);
|
||||
}
|
||||
|
||||
public void setLine(double x1, double y1, double x2, double y2) {
|
||||
this.x1 = (float)x1;
|
||||
this.y1 = (float)y1;
|
||||
this.x2 = (float)x2;
|
||||
this.y2 = (float)y2;
|
||||
}
|
||||
|
||||
public void setLine(float x1, float y1, float x2, float y2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
float rx, ry, rw, rh;
|
||||
if (this.x1 < this.x2) {
|
||||
rx = this.x1;
|
||||
rw = this.x2 - this.x1;
|
||||
} else {
|
||||
rx = this.x2;
|
||||
rw = this.x1 - this.x2;
|
||||
}
|
||||
if (this.y1 < this.y2) {
|
||||
ry = this.y1;
|
||||
rh = this.y2 - this.y1;
|
||||
} else {
|
||||
ry = this.y2;
|
||||
rh = this.y1 - this.y2;
|
||||
}
|
||||
return new Rectangle2D.Float(rx, ry, rw, rh);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Double extends Line2D {
|
||||
public double x1;
|
||||
|
||||
public double y1;
|
||||
|
||||
public double x2;
|
||||
|
||||
public double y2;
|
||||
|
||||
public Double() {}
|
||||
|
||||
public Double(double x1, double y1, double x2, double y2) {
|
||||
setLine(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
public Double(Point2D p1, Point2D p2) {
|
||||
setLine(p1, p2);
|
||||
}
|
||||
|
||||
public double getX1() {
|
||||
return this.x1;
|
||||
}
|
||||
|
||||
public double getY1() {
|
||||
return this.y1;
|
||||
}
|
||||
|
||||
public double getX2() {
|
||||
return this.x2;
|
||||
}
|
||||
|
||||
public double getY2() {
|
||||
return this.y2;
|
||||
}
|
||||
|
||||
public Point2D getP1() {
|
||||
return new Point2D.Double(this.x1, this.y1);
|
||||
}
|
||||
|
||||
public Point2D getP2() {
|
||||
return new Point2D.Double(this.x2, this.y2);
|
||||
}
|
||||
|
||||
public void setLine(double x1, double y1, double x2, double y2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
double rx, ry, rw, rh;
|
||||
if (this.x1 < this.x2) {
|
||||
rx = this.x1;
|
||||
rw = this.x2 - this.x1;
|
||||
} else {
|
||||
rx = this.x2;
|
||||
rw = this.x1 - this.x2;
|
||||
}
|
||||
if (this.y1 < this.y2) {
|
||||
ry = this.y1;
|
||||
rh = this.y2 - this.y1;
|
||||
} else {
|
||||
ry = this.y2;
|
||||
rh = this.y1 - this.y2;
|
||||
}
|
||||
return new Rectangle2D.Double(rx, ry, rw, rh);
|
||||
}
|
||||
}
|
||||
|
||||
class Iterator implements PathIterator {
|
||||
double x1;
|
||||
|
||||
double y1;
|
||||
|
||||
double x2;
|
||||
|
||||
double y2;
|
||||
|
||||
AffineTransform t;
|
||||
|
||||
int index;
|
||||
|
||||
Iterator(Line2D l, AffineTransform at) {
|
||||
this.x1 = l.getX1();
|
||||
this.y1 = l.getY1();
|
||||
this.x2 = l.getX2();
|
||||
this.y2 = l.getY2();
|
||||
this.t = at;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.index > 1);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
int type;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = this.x1;
|
||||
coords[1] = this.y1;
|
||||
} else {
|
||||
type = 1;
|
||||
coords[0] = this.x2;
|
||||
coords[1] = this.y2;
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, 1);
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
int type;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = (float)this.x1;
|
||||
coords[1] = (float)this.y1;
|
||||
} else {
|
||||
type = 1;
|
||||
coords[0] = (float)this.x2;
|
||||
coords[1] = (float)this.y2;
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, 1);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLine(Point2D p1, Point2D p2) {
|
||||
setLine(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
||||
}
|
||||
|
||||
public void setLine(Line2D line) {
|
||||
setLine(line.getX1(), line.getY1(), line.getX2(), line.getY2());
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return getBounds2D().getBounds();
|
||||
}
|
||||
|
||||
public static int relativeCCW(double x1, double y1, double x2, double y2, double px, double py) {
|
||||
x2 -= x1;
|
||||
y2 -= y1;
|
||||
px -= x1;
|
||||
py -= y1;
|
||||
double t = px * y2 - py * x2;
|
||||
if (t == 0.0D) {
|
||||
t = px * x2 + py * y2;
|
||||
if (t > 0.0D) {
|
||||
px -= x2;
|
||||
py -= y2;
|
||||
t = px * x2 + py * y2;
|
||||
if (t < 0.0D)
|
||||
t = 0.0D;
|
||||
}
|
||||
}
|
||||
return (t < 0.0D) ? -1 : ((t > 0.0D) ? 1 : 0);
|
||||
}
|
||||
|
||||
public int relativeCCW(double px, double py) {
|
||||
return relativeCCW(getX1(), getY1(), getX2(), getY2(), px, py);
|
||||
}
|
||||
|
||||
public int relativeCCW(Point2D p) {
|
||||
return relativeCCW(getX1(), getY1(), getX2(), getY2(), p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
|
||||
x2 -= x1;
|
||||
y2 -= y1;
|
||||
x3 -= x1;
|
||||
y3 -= y1;
|
||||
x4 -= x1;
|
||||
y4 -= y1;
|
||||
double AvB = x2 * y3 - x3 * y2;
|
||||
double AvC = x2 * y4 - x4 * y2;
|
||||
if (AvB == 0.0D && AvC == 0.0D) {
|
||||
if (x2 != 0.0D)
|
||||
return (x4 * x3 <= 0.0D || (x3 * x2 >= 0.0D && ((x2 > 0.0D) ? (x3 <= x2 || x4 <= x2) : (x3 >= x2 || x4 >= x2))));
|
||||
if (y2 != 0.0D)
|
||||
return (y4 * y3 <= 0.0D || (y3 * y2 >= 0.0D && ((y2 > 0.0D) ? (y3 <= y2 || y4 <= y2) : (y3 >= y2 || y4 >= y2))));
|
||||
return false;
|
||||
}
|
||||
double BvC = x3 * y4 - x4 * y3;
|
||||
return (AvB * AvC <= 0.0D && BvC * (AvB + BvC - AvC) <= 0.0D);
|
||||
}
|
||||
|
||||
public boolean intersectsLine(double x1, double y1, double x2, double y2) {
|
||||
return linesIntersect(x1, y1, x2, y2, getX1(), getY1(), getX2(), getY2());
|
||||
}
|
||||
|
||||
public boolean intersectsLine(Line2D l) {
|
||||
return linesIntersect(l.getX1(), l.getY1(), l.getX2(), l.getY2(), getX1(), getY1(), getX2(), getY2());
|
||||
}
|
||||
|
||||
public static double ptSegDistSq(double x1, double y1, double x2, double y2, double px, double py) {
|
||||
double dist;
|
||||
x2 -= x1;
|
||||
y2 -= y1;
|
||||
px -= x1;
|
||||
py -= y1;
|
||||
if (px * x2 + py * y2 <= 0.0D) {
|
||||
dist = px * px + py * py;
|
||||
} else {
|
||||
px = x2 - px;
|
||||
py = y2 - py;
|
||||
if (px * x2 + py * y2 <= 0.0D) {
|
||||
dist = px * px + py * py;
|
||||
} else {
|
||||
dist = px * y2 - py * x2;
|
||||
dist = dist * dist / (x2 * x2 + y2 * y2);
|
||||
}
|
||||
}
|
||||
if (dist < 0.0D)
|
||||
dist = 0.0D;
|
||||
return dist;
|
||||
}
|
||||
|
||||
public static double ptSegDist(double x1, double y1, double x2, double y2, double px, double py) {
|
||||
return Math.sqrt(ptSegDistSq(x1, y1, x2, y2, px, py));
|
||||
}
|
||||
|
||||
public double ptSegDistSq(double px, double py) {
|
||||
return ptSegDistSq(getX1(), getY1(), getX2(), getY2(), px, py);
|
||||
}
|
||||
|
||||
public double ptSegDistSq(Point2D p) {
|
||||
return ptSegDistSq(getX1(), getY1(), getX2(), getY2(), p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public double ptSegDist(double px, double py) {
|
||||
return ptSegDist(getX1(), getY1(), getX2(), getY2(), px, py);
|
||||
}
|
||||
|
||||
public double ptSegDist(Point2D p) {
|
||||
return ptSegDist(getX1(), getY1(), getX2(), getY2(), p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public static double ptLineDistSq(double x1, double y1, double x2, double y2, double px, double py) {
|
||||
x2 -= x1;
|
||||
y2 -= y1;
|
||||
px -= x1;
|
||||
py -= y1;
|
||||
double s = px * y2 - py * x2;
|
||||
return s * s / (x2 * x2 + y2 * y2);
|
||||
}
|
||||
|
||||
public static double ptLineDist(double x1, double y1, double x2, double y2, double px, double py) {
|
||||
return Math.sqrt(ptLineDistSq(x1, y1, x2, y2, px, py));
|
||||
}
|
||||
|
||||
public double ptLineDistSq(double px, double py) {
|
||||
return ptLineDistSq(getX1(), getY1(), getX2(), getY2(), px, py);
|
||||
}
|
||||
|
||||
public double ptLineDistSq(Point2D p) {
|
||||
return ptLineDistSq(getX1(), getY1(), getX2(), getY2(), p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public double ptLineDist(double px, double py) {
|
||||
return ptLineDist(getX1(), getY1(), getX2(), getY2(), px, py);
|
||||
}
|
||||
|
||||
public double ptLineDist(Point2D p) {
|
||||
return ptLineDist(getX1(), getY1(), getX2(), getY2(), p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean contains(double px, double py) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Point2D p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Rectangle2D r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(double rx, double ry, double rw, double rh) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean intersects(double rx, double ry, double rw, double rh) {
|
||||
return intersects(new Rectangle2D.Double(rx, ry, rw, rh));
|
||||
}
|
||||
|
||||
public boolean intersects(Rectangle2D r) {
|
||||
return r.intersectsLine(getX1(), getY1(), getX2(), getY2());
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform at) {
|
||||
return new Iterator(this, at);
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform at, double flatness) {
|
||||
return new Iterator(this, at);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public class NoninvertibleTransformException extends Exception {
|
||||
private static final long serialVersionUID = 6137225240503990466L;
|
||||
|
||||
public NoninvertibleTransformException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public interface PathIterator {
|
||||
public static final int WIND_EVEN_ODD = 0;
|
||||
|
||||
public static final int WIND_NON_ZERO = 1;
|
||||
|
||||
public static final int SEG_MOVETO = 0;
|
||||
|
||||
public static final int SEG_LINETO = 1;
|
||||
|
||||
public static final int SEG_QUADTO = 2;
|
||||
|
||||
public static final int SEG_CUBICTO = 3;
|
||||
|
||||
public static final int SEG_CLOSE = 4;
|
||||
|
||||
int getWindingRule();
|
||||
|
||||
boolean isDone();
|
||||
|
||||
void next();
|
||||
|
||||
int currentSegment(float[] paramArrayOffloat);
|
||||
|
||||
int currentSegment(double[] paramArrayOfdouble);
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Point extends Point2D implements Serializable {
|
||||
private static final long serialVersionUID = -5276940640259749850L;
|
||||
|
||||
public double x;
|
||||
|
||||
public double y;
|
||||
|
||||
public Point() {
|
||||
setLocation(0, 0);
|
||||
}
|
||||
|
||||
public Point(int x, int y) {
|
||||
setLocation(x, y);
|
||||
}
|
||||
|
||||
public Point(double x, double y) {
|
||||
setLocation(x, y);
|
||||
}
|
||||
|
||||
public Point(Point p) {
|
||||
setLocation(p.x, p.y);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof Point) {
|
||||
Point p = (Point)obj;
|
||||
return (this.x == p.x && this.y == p.y);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[x=" + this.x + ",y=" + this.y + "]";
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public Point getLocation() {
|
||||
return new Point(this.x, this.y);
|
||||
}
|
||||
|
||||
public void setLocation(Point p) {
|
||||
setLocation(p.x, p.y);
|
||||
}
|
||||
|
||||
public void setLocation(int x, int y) {
|
||||
setLocation((double)x, (double)y);
|
||||
}
|
||||
|
||||
public void setLocation(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void move(int x, int y) {
|
||||
move((double)x, (double)y);
|
||||
}
|
||||
|
||||
public void move(double x, double y) {
|
||||
setLocation(x, y);
|
||||
}
|
||||
|
||||
public void translate(int dx, int dy) {
|
||||
translate((double)dx, (double)dy);
|
||||
}
|
||||
|
||||
public void translate(double dx, double dy) {
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.misc.HashCode;
|
||||
|
||||
public abstract class Point2D implements Cloneable {
|
||||
public abstract double getX();
|
||||
|
||||
public abstract double getY();
|
||||
|
||||
public abstract void setLocation(double paramDouble1, double paramDouble2);
|
||||
|
||||
public static class Float extends Point2D {
|
||||
public float x;
|
||||
|
||||
public float y;
|
||||
|
||||
public Float() {}
|
||||
|
||||
public Float(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return (double)this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return (double)this.y;
|
||||
}
|
||||
|
||||
public void setLocation(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setLocation(double x, double y) {
|
||||
this.x = (float)x;
|
||||
this.y = (float)y;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[x=" + this.x + ",y=" + this.y + "]";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Double extends Point2D {
|
||||
public double x;
|
||||
|
||||
public double y;
|
||||
|
||||
public Double() {}
|
||||
|
||||
public Double(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setLocation(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[x=" + this.x + ",y=" + this.y + "]";
|
||||
}
|
||||
}
|
||||
|
||||
public void setLocation(Point2D p) {
|
||||
setLocation(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public static double distanceSq(double x1, double y1, double x2, double y2) {
|
||||
x2 -= x1;
|
||||
y2 -= y1;
|
||||
return x2 * x2 + y2 * y2;
|
||||
}
|
||||
|
||||
public double distanceSq(double px, double py) {
|
||||
return distanceSq(getX(), getY(), px, py);
|
||||
}
|
||||
|
||||
public double distanceSq(Point2D p) {
|
||||
return distanceSq(getX(), getY(), p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public static double distance(double x1, double y1, double x2, double y2) {
|
||||
return Math.sqrt(distanceSq(x1, y1, x2, y2));
|
||||
}
|
||||
|
||||
public double distance(double px, double py) {
|
||||
return Math.sqrt(distanceSq(px, py));
|
||||
}
|
||||
|
||||
public double distance(Point2D p) {
|
||||
return Math.sqrt(distanceSq(p));
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCode hash = new HashCode();
|
||||
hash.append(getX());
|
||||
hash.append(getY());
|
||||
return hash.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof Point2D) {
|
||||
Point2D p = (Point2D)obj;
|
||||
return (getX() == p.getX() && getY() == p.getY());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public class PolylineShape implements java.awt.Shape {
|
||||
protected int[] x;
|
||||
|
||||
protected int[] y;
|
||||
|
||||
protected int np;
|
||||
|
||||
public PolylineShape(int[] x, int[] y, int nPoints) {
|
||||
this.np = nPoints;
|
||||
this.x = new int[this.np];
|
||||
this.y = new int[this.np];
|
||||
System.arraycopy(x, 0, this.x, 0, this.np);
|
||||
System.arraycopy(y, 0, this.y, 0, this.np);
|
||||
}
|
||||
|
||||
public java.awt.geom.Rectangle2D getBounds2D() {
|
||||
int[] r = rect();
|
||||
return (r == null) ? null : new java.awt.geom.Rectangle2D.Double((double)r[0], (double)r[1], (double)r[2], (double)r[3]);
|
||||
}
|
||||
|
||||
public java.awt.Rectangle getBounds() {
|
||||
return getBounds2D().getBounds();
|
||||
}
|
||||
|
||||
private int[] rect() {
|
||||
if (this.np == 0)
|
||||
return null;
|
||||
int xMin = this.x[0], yMin = this.y[0], xMax = this.x[0], yMax = this.y[0];
|
||||
for (int i = 1; i < this.np; i++) {
|
||||
if (this.x[i] < xMin) {
|
||||
xMin = this.x[i];
|
||||
} else if (this.x[i] > xMax) {
|
||||
xMax = this.x[i];
|
||||
}
|
||||
if (this.y[i] < yMin) {
|
||||
yMin = this.y[i];
|
||||
} else if (this.y[i] > yMax) {
|
||||
yMax = this.y[i];
|
||||
}
|
||||
}
|
||||
return new int[] { xMin, yMin, xMax - xMin, yMax - yMin };
|
||||
}
|
||||
|
||||
public boolean contains(double x, double y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(java.awt.geom.Point2D p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(double x, double y, double w, double h) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(java.awt.geom.Rectangle2D r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean intersects(double x, double y, double w, double h) {
|
||||
return intersects(new java.awt.geom.Rectangle2D.Double(x, y, w, h));
|
||||
}
|
||||
|
||||
public boolean intersects(java.awt.geom.Rectangle2D r) {
|
||||
if (this.np == 0)
|
||||
return false;
|
||||
java.awt.geom.Line2D line = new java.awt.geom.Line2D.Double((double)this.x[0], (double)this.y[0], (double)this.x[0], (double)this.y[0]);
|
||||
for (int i = 1; i < this.np; i++) {
|
||||
line.setLine((double)this.x[i - 1], (double)this.y[i - 1], (double)this.x[i], (double)this.y[i]);
|
||||
if (line.intersects(r))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at) {
|
||||
return new PolylineShapeIterator(this, at);
|
||||
}
|
||||
|
||||
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness) {
|
||||
return new PolylineShapeIterator(this, at);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class PolylineShapeIterator implements java.awt.geom.PathIterator {
|
||||
protected PolylineShape poly;
|
||||
|
||||
protected java.awt.geom.AffineTransform affine;
|
||||
|
||||
protected int index;
|
||||
|
||||
PolylineShapeIterator(PolylineShape l, java.awt.geom.AffineTransform at) {
|
||||
this.poly = l;
|
||||
this.affine = at;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(MessageLocalization.getComposedMessage("line.iterator.out.of.bounds"));
|
||||
int type = (this.index == 0) ? 0 : 1;
|
||||
coords[0] = (double)this.poly.x[this.index];
|
||||
coords[1] = (double)this.poly.y[this.index];
|
||||
if (this.affine != null)
|
||||
this.affine.transform(coords, 0, coords, 0, 1);
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(MessageLocalization.getComposedMessage("line.iterator.out.of.bounds"));
|
||||
int type = (this.index == 0) ? 0 : 1;
|
||||
coords[0] = (float)this.poly.x[this.index];
|
||||
coords[1] = (float)this.poly.y[this.index];
|
||||
if (this.affine != null)
|
||||
this.affine.transform(coords, 0, coords, 0, 1);
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.index >= this.poly.np);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
this.index++;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,408 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.gl.Crossing;
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public abstract class QuadCurve2D implements Shape, Cloneable {
|
||||
public abstract double getX1();
|
||||
|
||||
public abstract double getY1();
|
||||
|
||||
public abstract Point2D getP1();
|
||||
|
||||
public abstract double getCtrlX();
|
||||
|
||||
public abstract double getCtrlY();
|
||||
|
||||
public abstract Point2D getCtrlPt();
|
||||
|
||||
public abstract double getX2();
|
||||
|
||||
public abstract double getY2();
|
||||
|
||||
public abstract Point2D getP2();
|
||||
|
||||
public abstract void setCurve(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, double paramDouble5, double paramDouble6);
|
||||
|
||||
public static class Float extends QuadCurve2D {
|
||||
public float x1;
|
||||
|
||||
public float y1;
|
||||
|
||||
public float ctrlx;
|
||||
|
||||
public float ctrly;
|
||||
|
||||
public float x2;
|
||||
|
||||
public float y2;
|
||||
|
||||
public Float() {}
|
||||
|
||||
public Float(float x1, float y1, float ctrlx, float ctrly, float x2, float y2) {
|
||||
setCurve(x1, y1, ctrlx, ctrly, x2, y2);
|
||||
}
|
||||
|
||||
public double getX1() {
|
||||
return (double)this.x1;
|
||||
}
|
||||
|
||||
public double getY1() {
|
||||
return (double)this.y1;
|
||||
}
|
||||
|
||||
public double getCtrlX() {
|
||||
return (double)this.ctrlx;
|
||||
}
|
||||
|
||||
public double getCtrlY() {
|
||||
return (double)this.ctrly;
|
||||
}
|
||||
|
||||
public double getX2() {
|
||||
return (double)this.x2;
|
||||
}
|
||||
|
||||
public double getY2() {
|
||||
return (double)this.y2;
|
||||
}
|
||||
|
||||
public Point2D getP1() {
|
||||
return new Point2D.Float(this.x1, this.y1);
|
||||
}
|
||||
|
||||
public Point2D getCtrlPt() {
|
||||
return new Point2D.Float(this.ctrlx, this.ctrly);
|
||||
}
|
||||
|
||||
public Point2D getP2() {
|
||||
return new Point2D.Float(this.x2, this.y2);
|
||||
}
|
||||
|
||||
public void setCurve(double x1, double y1, double ctrlx, double ctrly, double x2, double y2) {
|
||||
this.x1 = (float)x1;
|
||||
this.y1 = (float)y1;
|
||||
this.ctrlx = (float)ctrlx;
|
||||
this.ctrly = (float)ctrly;
|
||||
this.x2 = (float)x2;
|
||||
this.y2 = (float)y2;
|
||||
}
|
||||
|
||||
public void setCurve(float x1, float y1, float ctrlx, float ctrly, float x2, float y2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.ctrlx = ctrlx;
|
||||
this.ctrly = ctrly;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
float rx0 = Math.min(Math.min(this.x1, this.x2), this.ctrlx);
|
||||
float ry0 = Math.min(Math.min(this.y1, this.y2), this.ctrly);
|
||||
float rx1 = Math.max(Math.max(this.x1, this.x2), this.ctrlx);
|
||||
float ry1 = Math.max(Math.max(this.y1, this.y2), this.ctrly);
|
||||
return new Rectangle2D.Float(rx0, ry0, rx1 - rx0, ry1 - ry0);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Double extends QuadCurve2D {
|
||||
public double x1;
|
||||
|
||||
public double y1;
|
||||
|
||||
public double ctrlx;
|
||||
|
||||
public double ctrly;
|
||||
|
||||
public double x2;
|
||||
|
||||
public double y2;
|
||||
|
||||
public Double() {}
|
||||
|
||||
public Double(double x1, double y1, double ctrlx, double ctrly, double x2, double y2) {
|
||||
setCurve(x1, y1, ctrlx, ctrly, x2, y2);
|
||||
}
|
||||
|
||||
public double getX1() {
|
||||
return this.x1;
|
||||
}
|
||||
|
||||
public double getY1() {
|
||||
return this.y1;
|
||||
}
|
||||
|
||||
public double getCtrlX() {
|
||||
return this.ctrlx;
|
||||
}
|
||||
|
||||
public double getCtrlY() {
|
||||
return this.ctrly;
|
||||
}
|
||||
|
||||
public double getX2() {
|
||||
return this.x2;
|
||||
}
|
||||
|
||||
public double getY2() {
|
||||
return this.y2;
|
||||
}
|
||||
|
||||
public Point2D getP1() {
|
||||
return new Point2D.Double(this.x1, this.y1);
|
||||
}
|
||||
|
||||
public Point2D getCtrlPt() {
|
||||
return new Point2D.Double(this.ctrlx, this.ctrly);
|
||||
}
|
||||
|
||||
public Point2D getP2() {
|
||||
return new Point2D.Double(this.x2, this.y2);
|
||||
}
|
||||
|
||||
public void setCurve(double x1, double y1, double ctrlx, double ctrly, double x2, double y2) {
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.ctrlx = ctrlx;
|
||||
this.ctrly = ctrly;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
double rx0 = Math.min(Math.min(this.x1, this.x2), this.ctrlx);
|
||||
double ry0 = Math.min(Math.min(this.y1, this.y2), this.ctrly);
|
||||
double rx1 = Math.max(Math.max(this.x1, this.x2), this.ctrlx);
|
||||
double ry1 = Math.max(Math.max(this.y1, this.y2), this.ctrly);
|
||||
return new Rectangle2D.Double(rx0, ry0, rx1 - rx0, ry1 - ry0);
|
||||
}
|
||||
}
|
||||
|
||||
class Iterator implements PathIterator {
|
||||
QuadCurve2D c;
|
||||
|
||||
AffineTransform t;
|
||||
|
||||
int index;
|
||||
|
||||
Iterator(QuadCurve2D q, AffineTransform t) {
|
||||
this.c = q;
|
||||
this.t = t;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.index > 1);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
int type, count;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = this.c.getX1();
|
||||
coords[1] = this.c.getY1();
|
||||
count = 1;
|
||||
} else {
|
||||
type = 2;
|
||||
coords[0] = this.c.getCtrlX();
|
||||
coords[1] = this.c.getCtrlY();
|
||||
coords[2] = this.c.getX2();
|
||||
coords[3] = this.c.getY2();
|
||||
count = 2;
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, count);
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
int type, count;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = (float)this.c.getX1();
|
||||
coords[1] = (float)this.c.getY1();
|
||||
count = 1;
|
||||
} else {
|
||||
type = 2;
|
||||
coords[0] = (float)this.c.getCtrlX();
|
||||
coords[1] = (float)this.c.getCtrlY();
|
||||
coords[2] = (float)this.c.getX2();
|
||||
coords[3] = (float)this.c.getY2();
|
||||
count = 2;
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, count);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurve(Point2D p1, Point2D cp, Point2D p2) {
|
||||
setCurve(p1.getX(), p1.getY(), cp.getX(), cp.getY(), p2.getX(), p2.getY());
|
||||
}
|
||||
|
||||
public void setCurve(double[] coords, int offset) {
|
||||
setCurve(coords[offset + 0], coords[offset + 1], coords[offset + 2], coords[offset + 3], coords[offset + 4], coords[offset + 5]);
|
||||
}
|
||||
|
||||
public void setCurve(Point2D[] points, int offset) {
|
||||
setCurve(points[offset + 0]
|
||||
.getX(), points[offset + 0].getY(), points[offset + 1]
|
||||
.getX(), points[offset + 1].getY(), points[offset + 2]
|
||||
.getX(), points[offset + 2].getY());
|
||||
}
|
||||
|
||||
public void setCurve(QuadCurve2D curve) {
|
||||
setCurve(
|
||||
curve.getX1(), curve.getY1(),
|
||||
curve.getCtrlX(), curve.getCtrlY(),
|
||||
curve.getX2(), curve.getY2());
|
||||
}
|
||||
|
||||
public double getFlatnessSq() {
|
||||
return Line2D.ptSegDistSq(
|
||||
getX1(), getY1(),
|
||||
getX2(), getY2(),
|
||||
getCtrlX(), getCtrlY());
|
||||
}
|
||||
|
||||
public static double getFlatnessSq(double x1, double y1, double ctrlx, double ctrly, double x2, double y2) {
|
||||
return Line2D.ptSegDistSq(x1, y1, x2, y2, ctrlx, ctrly);
|
||||
}
|
||||
|
||||
public static double getFlatnessSq(double[] coords, int offset) {
|
||||
return Line2D.ptSegDistSq(coords[offset + 0], coords[offset + 1], coords[offset + 4], coords[offset + 5], coords[offset + 2], coords[offset + 3]);
|
||||
}
|
||||
|
||||
public double getFlatness() {
|
||||
return Line2D.ptSegDist(getX1(), getY1(), getX2(), getY2(), getCtrlX(), getCtrlY());
|
||||
}
|
||||
|
||||
public static double getFlatness(double x1, double y1, double ctrlx, double ctrly, double x2, double y2) {
|
||||
return Line2D.ptSegDist(x1, y1, x2, y2, ctrlx, ctrly);
|
||||
}
|
||||
|
||||
public static double getFlatness(double[] coords, int offset) {
|
||||
return Line2D.ptSegDist(coords[offset + 0], coords[offset + 1], coords[offset + 4], coords[offset + 5], coords[offset + 2], coords[offset + 3]);
|
||||
}
|
||||
|
||||
public void subdivide(QuadCurve2D left, QuadCurve2D right) {
|
||||
subdivide(this, left, right);
|
||||
}
|
||||
|
||||
public static void subdivide(QuadCurve2D src, QuadCurve2D left, QuadCurve2D right) {
|
||||
double x1 = src.getX1();
|
||||
double y1 = src.getY1();
|
||||
double cx = src.getCtrlX();
|
||||
double cy = src.getCtrlY();
|
||||
double x2 = src.getX2();
|
||||
double y2 = src.getY2();
|
||||
double cx1 = (x1 + cx) / 2.0D;
|
||||
double cy1 = (y1 + cy) / 2.0D;
|
||||
double cx2 = (x2 + cx) / 2.0D;
|
||||
double cy2 = (y2 + cy) / 2.0D;
|
||||
cx = (cx1 + cx2) / 2.0D;
|
||||
cy = (cy1 + cy2) / 2.0D;
|
||||
if (left != null)
|
||||
left.setCurve(x1, y1, cx1, cy1, cx, cy);
|
||||
if (right != null)
|
||||
right.setCurve(cx, cy, cx2, cy2, x2, y2);
|
||||
}
|
||||
|
||||
public static void subdivide(double[] src, int srcoff, double[] left, int leftOff, double[] right, int rightOff) {
|
||||
double x1 = src[srcoff + 0];
|
||||
double y1 = src[srcoff + 1];
|
||||
double cx = src[srcoff + 2];
|
||||
double cy = src[srcoff + 3];
|
||||
double x2 = src[srcoff + 4];
|
||||
double y2 = src[srcoff + 5];
|
||||
double cx1 = (x1 + cx) / 2.0D;
|
||||
double cy1 = (y1 + cy) / 2.0D;
|
||||
double cx2 = (x2 + cx) / 2.0D;
|
||||
double cy2 = (y2 + cy) / 2.0D;
|
||||
cx = (cx1 + cx2) / 2.0D;
|
||||
cy = (cy1 + cy2) / 2.0D;
|
||||
if (left != null) {
|
||||
left[leftOff + 0] = x1;
|
||||
left[leftOff + 1] = y1;
|
||||
left[leftOff + 2] = cx1;
|
||||
left[leftOff + 3] = cy1;
|
||||
left[leftOff + 4] = cx;
|
||||
left[leftOff + 5] = cy;
|
||||
}
|
||||
if (right != null) {
|
||||
right[rightOff + 0] = cx;
|
||||
right[rightOff + 1] = cy;
|
||||
right[rightOff + 2] = cx2;
|
||||
right[rightOff + 3] = cy2;
|
||||
right[rightOff + 4] = x2;
|
||||
right[rightOff + 5] = y2;
|
||||
}
|
||||
}
|
||||
|
||||
public static int solveQuadratic(double[] eqn) {
|
||||
return solveQuadratic(eqn, eqn);
|
||||
}
|
||||
|
||||
public static int solveQuadratic(double[] eqn, double[] res) {
|
||||
return Crossing.solveQuad(eqn, res);
|
||||
}
|
||||
|
||||
public boolean contains(double px, double py) {
|
||||
return Crossing.isInsideEvenOdd(Crossing.crossShape(this, px, py));
|
||||
}
|
||||
|
||||
public boolean contains(double rx, double ry, double rw, double rh) {
|
||||
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
|
||||
return (cross != 255 && Crossing.isInsideEvenOdd(cross));
|
||||
}
|
||||
|
||||
public boolean intersects(double rx, double ry, double rw, double rh) {
|
||||
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
|
||||
return (cross == 255 || Crossing.isInsideEvenOdd(cross));
|
||||
}
|
||||
|
||||
public boolean contains(Point2D p) {
|
||||
return contains(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean intersects(Rectangle2D r) {
|
||||
return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public boolean contains(Rectangle2D r) {
|
||||
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return getBounds2D().getBounds();
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t) {
|
||||
return new Iterator(this, t);
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t, double flatness) {
|
||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,274 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Rectangle extends Rectangle2D implements Shape, Serializable {
|
||||
private static final long serialVersionUID = -4345857070255674764L;
|
||||
|
||||
public double x;
|
||||
|
||||
public double y;
|
||||
|
||||
public double width;
|
||||
|
||||
public double height;
|
||||
|
||||
public Rectangle() {
|
||||
setBounds(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Rectangle(Point p) {
|
||||
setBounds(p.x, p.y, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
public Rectangle(Point p, Dimension d) {
|
||||
setBounds(p.x, p.y, d.width, d.height);
|
||||
}
|
||||
|
||||
public Rectangle(double x, double y, double width, double height) {
|
||||
setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
public Rectangle(int width, int height) {
|
||||
setBounds(0, 0, width, height);
|
||||
}
|
||||
|
||||
public Rectangle(Rectangle r) {
|
||||
setBounds(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
|
||||
public Rectangle(com.itextpdf.text.Rectangle r) {
|
||||
r.normalize();
|
||||
setBounds((double)r.getLeft(), (double)r.getBottom(), (double)r.getWidth(), (double)r.getHeight());
|
||||
}
|
||||
|
||||
public Rectangle(Dimension d) {
|
||||
setBounds(0.0D, 0.0D, d.width, d.height);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (this.width <= 0.0D || this.height <= 0.0D);
|
||||
}
|
||||
|
||||
public Dimension getSize() {
|
||||
return new Dimension(this.width, this.height);
|
||||
}
|
||||
|
||||
public void setSize(int mx, int my) {
|
||||
setSize((double)mx, (double)my);
|
||||
}
|
||||
|
||||
public void setSize(double width, double height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setSize(Dimension d) {
|
||||
setSize(d.width, d.height);
|
||||
}
|
||||
|
||||
public Point getLocation() {
|
||||
return new Point(this.x, this.y);
|
||||
}
|
||||
|
||||
public void setLocation(int mx, int my) {
|
||||
setLocation((double)mx, (double)my);
|
||||
}
|
||||
|
||||
public void setLocation(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setLocation(Point p) {
|
||||
setLocation(p.x, p.y);
|
||||
}
|
||||
|
||||
public void setRect(double x, double y, double width, double height) {
|
||||
int x1 = (int)Math.floor(x);
|
||||
int y1 = (int)Math.floor(y);
|
||||
int x2 = (int)Math.ceil(x + width);
|
||||
int y2 = (int)Math.ceil(y + height);
|
||||
setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
return new Rectangle(this.x, this.y, this.width, this.height);
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
return getBounds();
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y, int width, int height) {
|
||||
setBounds((double)x, (double)y, (double)width, (double)height);
|
||||
}
|
||||
|
||||
public void setBounds(double x, double y, double width, double height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public void setBounds(Rectangle r) {
|
||||
setBounds(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
|
||||
public void grow(int mx, int my) {
|
||||
translate((double)mx, (double)my);
|
||||
}
|
||||
|
||||
public void grow(double dx, double dy) {
|
||||
this.x -= dx;
|
||||
this.y -= dy;
|
||||
this.width += dx + dx;
|
||||
this.height += dy + dy;
|
||||
}
|
||||
|
||||
public void translate(int mx, int my) {
|
||||
translate((double)mx, (double)my);
|
||||
}
|
||||
|
||||
public void translate(double mx, double my) {
|
||||
this.x += mx;
|
||||
this.y += my;
|
||||
}
|
||||
|
||||
public void add(int px, int py) {
|
||||
add((double)px, (double)py);
|
||||
}
|
||||
|
||||
public void add(double px, double py) {
|
||||
double x1 = Math.min(this.x, px);
|
||||
double x2 = Math.max(this.x + this.width, px);
|
||||
double y1 = Math.min(this.y, py);
|
||||
double y2 = Math.max(this.y + this.height, py);
|
||||
setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public void add(Point p) {
|
||||
add(p.x, p.y);
|
||||
}
|
||||
|
||||
public void add(Rectangle r) {
|
||||
double x1 = Math.min(this.x, r.x);
|
||||
double x2 = Math.max(this.x + this.width, r.x + r.width);
|
||||
double y1 = Math.min(this.y, r.y);
|
||||
double y2 = Math.max(this.y + this.height, r.y + r.height);
|
||||
setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public boolean contains(int px, int py) {
|
||||
return contains((double)px, (double)py);
|
||||
}
|
||||
|
||||
public boolean contains(double px, double py) {
|
||||
if (isEmpty())
|
||||
return false;
|
||||
if (px < this.x || py < this.y)
|
||||
return false;
|
||||
px -= this.x;
|
||||
py -= this.y;
|
||||
return (px < this.width && py < this.height);
|
||||
}
|
||||
|
||||
public boolean contains(Point p) {
|
||||
return contains(p.x, p.y);
|
||||
}
|
||||
|
||||
public boolean contains(int rx, int ry, int rw, int rh) {
|
||||
return (contains(rx, ry) && contains(rx + rw - 1, ry + rh - 1));
|
||||
}
|
||||
|
||||
public boolean contains(double rx, double ry, double rw, double rh) {
|
||||
return (contains(rx, ry) && contains(rx + rw - 0.01D, ry + rh - 0.01D));
|
||||
}
|
||||
|
||||
public boolean contains(Rectangle r) {
|
||||
return contains(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
|
||||
public Rectangle2D createIntersection(Rectangle2D r) {
|
||||
if (r instanceof Rectangle)
|
||||
return intersection((Rectangle)r);
|
||||
Rectangle2D dst = new Rectangle2D.Double();
|
||||
Rectangle2D.intersect(this, r, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public Rectangle intersection(Rectangle r) {
|
||||
double x1 = Math.max(this.x, r.x);
|
||||
double y1 = Math.max(this.y, r.y);
|
||||
double x2 = Math.min(this.x + this.width, r.x + r.width);
|
||||
double y2 = Math.min(this.y + this.height, r.y + r.height);
|
||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public boolean intersects(Rectangle r) {
|
||||
return !intersection(r).isEmpty();
|
||||
}
|
||||
|
||||
public int outcode(double px, double py) {
|
||||
int code = 0;
|
||||
if (this.width <= 0.0D) {
|
||||
code |= 0x5;
|
||||
} else if (px < this.x) {
|
||||
code |= 0x1;
|
||||
} else if (px > this.x + this.width) {
|
||||
code |= 0x4;
|
||||
}
|
||||
if (this.height <= 0.0D) {
|
||||
code |= 0xA;
|
||||
} else if (py < this.y) {
|
||||
code |= 0x2;
|
||||
} else if (py > this.y + this.height) {
|
||||
code |= 0x8;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public Rectangle2D createUnion(Rectangle2D r) {
|
||||
if (r instanceof Rectangle)
|
||||
return union((Rectangle)r);
|
||||
Rectangle2D dst = new Rectangle2D.Double();
|
||||
Rectangle2D.union(this, r, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public Rectangle union(Rectangle r) {
|
||||
Rectangle dst = new Rectangle(this);
|
||||
dst.add(r);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof Rectangle) {
|
||||
Rectangle r = (Rectangle)obj;
|
||||
return (r.x == this.x && r.y == this.y && r.width == this.width && r.height == this.height);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[x=" + this.x + ",y=" + this.y + ",width=" + this.width + ",height=" + this.height + "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,451 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
import com.itextpdf.awt.geom.misc.HashCode;
|
||||
import com.itextpdf.awt.geom.misc.Messages;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public abstract class Rectangle2D extends RectangularShape {
|
||||
public static final int OUT_LEFT = 1;
|
||||
|
||||
public static final int OUT_TOP = 2;
|
||||
|
||||
public static final int OUT_RIGHT = 4;
|
||||
|
||||
public static final int OUT_BOTTOM = 8;
|
||||
|
||||
public abstract void setRect(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4);
|
||||
|
||||
public abstract int outcode(double paramDouble1, double paramDouble2);
|
||||
|
||||
public abstract Rectangle2D createIntersection(Rectangle2D paramRectangle2D);
|
||||
|
||||
public abstract Rectangle2D createUnion(Rectangle2D paramRectangle2D);
|
||||
|
||||
public static class Float extends Rectangle2D {
|
||||
public float x;
|
||||
|
||||
public float y;
|
||||
|
||||
public float width;
|
||||
|
||||
public float height;
|
||||
|
||||
public Float() {}
|
||||
|
||||
public Float(float x, float y, float width, float height) {
|
||||
setRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return (double)this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return (double)this.y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return (double)this.width;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return (double)this.height;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (this.width <= 0.0F || this.height <= 0.0F);
|
||||
}
|
||||
|
||||
public void setRect(float x, float y, float width, float height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setRect(double x, double y, double width, double height) {
|
||||
this.x = (float)x;
|
||||
this.y = (float)y;
|
||||
this.width = (float)width;
|
||||
this.height = (float)height;
|
||||
}
|
||||
|
||||
public void setRect(Rectangle2D r) {
|
||||
this.x = (float)r.getX();
|
||||
this.y = (float)r.getY();
|
||||
this.width = (float)r.getWidth();
|
||||
this.height = (float)r.getHeight();
|
||||
}
|
||||
|
||||
public int outcode(double px, double py) {
|
||||
int code = 0;
|
||||
if (this.width <= 0.0F) {
|
||||
code |= 0x5;
|
||||
} else if (px < (double)this.x) {
|
||||
code |= 0x1;
|
||||
} else if (px > (double)(this.x + this.width)) {
|
||||
code |= 0x4;
|
||||
}
|
||||
if (this.height <= 0.0F) {
|
||||
code |= 0xA;
|
||||
} else if (py < (double)this.y) {
|
||||
code |= 0x2;
|
||||
} else if (py > (double)(this.y + this.height)) {
|
||||
code |= 0x8;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
return new Float(this.x, this.y, this.width, this.height);
|
||||
}
|
||||
|
||||
public Rectangle2D createIntersection(Rectangle2D r) {
|
||||
Rectangle2D dst;
|
||||
if (r instanceof Rectangle2D.Double) {
|
||||
dst = new Rectangle2D.Double();
|
||||
} else {
|
||||
dst = new Float();
|
||||
}
|
||||
Rectangle2D.intersect(this, r, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public Rectangle2D createUnion(Rectangle2D r) {
|
||||
Rectangle2D dst;
|
||||
if (r instanceof Rectangle2D.Double) {
|
||||
dst = new Rectangle2D.Double();
|
||||
} else {
|
||||
dst = new Float();
|
||||
}
|
||||
Rectangle2D.union(this, r, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[x=" + this.x + ",y=" + this.y + ",width=" + this.width + ",height=" + this.height + "]";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Double extends Rectangle2D {
|
||||
public double x;
|
||||
|
||||
public double y;
|
||||
|
||||
public double width;
|
||||
|
||||
public double height;
|
||||
|
||||
public Double() {}
|
||||
|
||||
public Double(double x, double y, double width, double height) {
|
||||
setRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (this.width <= 0.0D || this.height <= 0.0D);
|
||||
}
|
||||
|
||||
public void setRect(double x, double y, double width, double height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setRect(Rectangle2D r) {
|
||||
this.x = r.getX();
|
||||
this.y = r.getY();
|
||||
this.width = r.getWidth();
|
||||
this.height = r.getHeight();
|
||||
}
|
||||
|
||||
public int outcode(double px, double py) {
|
||||
int code = 0;
|
||||
if (this.width <= 0.0D) {
|
||||
code |= 0x5;
|
||||
} else if (px < this.x) {
|
||||
code |= 0x1;
|
||||
} else if (px > this.x + this.width) {
|
||||
code |= 0x4;
|
||||
}
|
||||
if (this.height <= 0.0D) {
|
||||
code |= 0xA;
|
||||
} else if (py < this.y) {
|
||||
code |= 0x2;
|
||||
} else if (py > this.y + this.height) {
|
||||
code |= 0x8;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
return new Double(this.x, this.y, this.width, this.height);
|
||||
}
|
||||
|
||||
public Rectangle2D createIntersection(Rectangle2D r) {
|
||||
Rectangle2D dst = new Double();
|
||||
Rectangle2D.intersect(this, r, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public Rectangle2D createUnion(Rectangle2D r) {
|
||||
Rectangle2D dest = new Double();
|
||||
Rectangle2D.union(this, r, dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + "[x=" + this.x + ",y=" + this.y + ",width=" + this.width + ",height=" + this.height + "]";
|
||||
}
|
||||
}
|
||||
|
||||
class Iterator implements PathIterator {
|
||||
double x;
|
||||
|
||||
double y;
|
||||
|
||||
double width;
|
||||
|
||||
double height;
|
||||
|
||||
AffineTransform t;
|
||||
|
||||
int index;
|
||||
|
||||
Iterator(Rectangle2D r, AffineTransform at) {
|
||||
this.x = r.getX();
|
||||
this.y = r.getY();
|
||||
this.width = r.getWidth();
|
||||
this.height = r.getHeight();
|
||||
this.t = at;
|
||||
if (this.width < 0.0D || this.height < 0.0D)
|
||||
this.index = 6;
|
||||
}
|
||||
|
||||
public int getWindingRule() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return (this.index > 5);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public int currentSegment(double[] coords) {
|
||||
int type;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 5)
|
||||
return 4;
|
||||
if (this.index == 0) {
|
||||
type = 0;
|
||||
coords[0] = this.x;
|
||||
coords[1] = this.y;
|
||||
} else {
|
||||
type = 1;
|
||||
switch (this.index) {
|
||||
case 1:
|
||||
coords[0] = this.x + this.width;
|
||||
coords[1] = this.y;
|
||||
break;
|
||||
case 2:
|
||||
coords[0] = this.x + this.width;
|
||||
coords[1] = this.y + this.height;
|
||||
break;
|
||||
case 3:
|
||||
coords[0] = this.x;
|
||||
coords[1] = this.y + this.height;
|
||||
break;
|
||||
case 4:
|
||||
coords[0] = this.x;
|
||||
coords[1] = this.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, 1);
|
||||
return type;
|
||||
}
|
||||
|
||||
public int currentSegment(float[] coords) {
|
||||
int type;
|
||||
if (isDone())
|
||||
throw new NoSuchElementException(Messages.getString("awt.4B"));
|
||||
if (this.index == 5)
|
||||
return 4;
|
||||
if (this.index == 0) {
|
||||
coords[0] = (float)this.x;
|
||||
coords[1] = (float)this.y;
|
||||
type = 0;
|
||||
} else {
|
||||
type = 1;
|
||||
switch (this.index) {
|
||||
case 1:
|
||||
coords[0] = (float)(this.x + this.width);
|
||||
coords[1] = (float)this.y;
|
||||
break;
|
||||
case 2:
|
||||
coords[0] = (float)(this.x + this.width);
|
||||
coords[1] = (float)(this.y + this.height);
|
||||
break;
|
||||
case 3:
|
||||
coords[0] = (float)this.x;
|
||||
coords[1] = (float)(this.y + this.height);
|
||||
break;
|
||||
case 4:
|
||||
coords[0] = (float)this.x;
|
||||
coords[1] = (float)this.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.t != null)
|
||||
this.t.transform(coords, 0, coords, 0, 1);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRect(Rectangle2D r) {
|
||||
setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public void setFrame(double x, double y, double width, double height) {
|
||||
setRect(x, y, width, height);
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds2D() {
|
||||
return (Rectangle2D)clone();
|
||||
}
|
||||
|
||||
public boolean intersectsLine(double x1, double y1, double x2, double y2) {
|
||||
double rx1 = getX();
|
||||
double ry1 = getY();
|
||||
double rx2 = rx1 + getWidth();
|
||||
double ry2 = ry1 + getHeight();
|
||||
return ((rx1 <= x1 && x1 <= rx2 && ry1 <= y1 && y1 <= ry2) || (rx1 <= x2 && x2 <= rx2 && ry1 <= y2 && y2 <= ry2) ||
|
||||
|
||||
|
||||
Line2D.linesIntersect(rx1, ry1, rx2, ry2, x1, y1, x2, y2) ||
|
||||
Line2D.linesIntersect(rx2, ry1, rx1, ry2, x1, y1, x2, y2));
|
||||
}
|
||||
|
||||
public boolean intersectsLine(Line2D l) {
|
||||
return intersectsLine(l.getX1(), l.getY1(), l.getX2(), l.getY2());
|
||||
}
|
||||
|
||||
public int outcode(Point2D p) {
|
||||
return outcode(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean contains(double x, double y) {
|
||||
if (isEmpty())
|
||||
return false;
|
||||
double x1 = getX();
|
||||
double y1 = getY();
|
||||
double x2 = x1 + getWidth();
|
||||
double y2 = y1 + getHeight();
|
||||
return (x1 <= x && x < x2 && y1 <= y && y < y2);
|
||||
}
|
||||
|
||||
public boolean intersects(double x, double y, double width, double height) {
|
||||
if (isEmpty() || width <= 0.0D || height <= 0.0D)
|
||||
return false;
|
||||
double x1 = getX();
|
||||
double y1 = getY();
|
||||
double x2 = x1 + getWidth();
|
||||
double y2 = y1 + getHeight();
|
||||
return (x + width > x1 && x < x2 && y + height > y1 && y < y2);
|
||||
}
|
||||
|
||||
public boolean contains(double x, double y, double width, double height) {
|
||||
if (isEmpty() || width <= 0.0D || height <= 0.0D)
|
||||
return false;
|
||||
double x1 = getX();
|
||||
double y1 = getY();
|
||||
double x2 = x1 + getWidth();
|
||||
double y2 = y1 + getHeight();
|
||||
return (x1 <= x && x + width <= x2 && y1 <= y && y + height <= y2);
|
||||
}
|
||||
|
||||
public static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dst) {
|
||||
double x1 = Math.max(src1.getMinX(), src2.getMinX());
|
||||
double y1 = Math.max(src1.getMinY(), src2.getMinY());
|
||||
double x2 = Math.min(src1.getMaxX(), src2.getMaxX());
|
||||
double y2 = Math.min(src1.getMaxY(), src2.getMaxY());
|
||||
dst.setFrame(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dst) {
|
||||
double x1 = Math.min(src1.getMinX(), src2.getMinX());
|
||||
double y1 = Math.min(src1.getMinY(), src2.getMinY());
|
||||
double x2 = Math.max(src1.getMaxX(), src2.getMaxX());
|
||||
double y2 = Math.max(src1.getMaxY(), src2.getMaxY());
|
||||
dst.setFrame(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public void add(double x, double y) {
|
||||
double x1 = Math.min(getMinX(), x);
|
||||
double y1 = Math.min(getMinY(), y);
|
||||
double x2 = Math.max(getMaxX(), x);
|
||||
double y2 = Math.max(getMaxY(), y);
|
||||
setRect(x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public void add(Point2D p) {
|
||||
add(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public void add(Rectangle2D r) {
|
||||
union(this, r, this);
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t) {
|
||||
return new Iterator(this, t);
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t, double flatness) {
|
||||
return new Iterator(this, t);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
HashCode hash = new HashCode();
|
||||
hash.append(getX());
|
||||
hash.append(getY());
|
||||
hash.append(getWidth());
|
||||
hash.append(getHeight());
|
||||
return hash.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof Rectangle2D) {
|
||||
Rectangle2D r = (Rectangle2D)obj;
|
||||
return (
|
||||
getX() == r.getX() &&
|
||||
getY() == r.getY() &&
|
||||
getWidth() == r.getWidth() &&
|
||||
getHeight() == r.getHeight());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public abstract class RectangularShape implements Shape, Cloneable {
|
||||
public abstract double getX();
|
||||
|
||||
public abstract double getY();
|
||||
|
||||
public abstract double getWidth();
|
||||
|
||||
public abstract double getHeight();
|
||||
|
||||
public abstract boolean isEmpty();
|
||||
|
||||
public abstract void setFrame(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4);
|
||||
|
||||
public double getMinX() {
|
||||
return getX();
|
||||
}
|
||||
|
||||
public double getMinY() {
|
||||
return getY();
|
||||
}
|
||||
|
||||
public double getMaxX() {
|
||||
return getX() + getWidth();
|
||||
}
|
||||
|
||||
public double getMaxY() {
|
||||
return getY() + getHeight();
|
||||
}
|
||||
|
||||
public double getCenterX() {
|
||||
return getX() + getWidth() / 2.0D;
|
||||
}
|
||||
|
||||
public double getCenterY() {
|
||||
return getY() + getHeight() / 2.0D;
|
||||
}
|
||||
|
||||
public Rectangle2D getFrame() {
|
||||
return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight());
|
||||
}
|
||||
|
||||
public void setFrame(Point2D loc, Dimension2D size) {
|
||||
setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
|
||||
}
|
||||
|
||||
public void setFrame(Rectangle2D r) {
|
||||
setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
||||
}
|
||||
|
||||
public void setFrameFromDiagonal(double x1, double y1, double x2, double y2) {
|
||||
double rx, ry, rw, rh;
|
||||
if (x1 < x2) {
|
||||
rx = x1;
|
||||
rw = x2 - x1;
|
||||
} else {
|
||||
rx = x2;
|
||||
rw = x1 - x2;
|
||||
}
|
||||
if (y1 < y2) {
|
||||
ry = y1;
|
||||
rh = y2 - y1;
|
||||
} else {
|
||||
ry = y2;
|
||||
rh = y1 - y2;
|
||||
}
|
||||
setFrame(rx, ry, rw, rh);
|
||||
}
|
||||
|
||||
public void setFrameFromDiagonal(Point2D p1, Point2D p2) {
|
||||
setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
||||
}
|
||||
|
||||
public void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY) {
|
||||
double width = Math.abs(cornerX - centerX);
|
||||
double height = Math.abs(cornerY - centerY);
|
||||
setFrame(centerX - width, centerY - height, width * 2.0D, height * 2.0D);
|
||||
}
|
||||
|
||||
public void setFrameFromCenter(Point2D center, Point2D corner) {
|
||||
setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY());
|
||||
}
|
||||
|
||||
public boolean contains(Point2D point) {
|
||||
return contains(point.getX(), point.getY());
|
||||
}
|
||||
|
||||
public boolean intersects(Rectangle2D rect) {
|
||||
return intersects(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
|
||||
}
|
||||
|
||||
public boolean contains(Rectangle2D rect) {
|
||||
return contains(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
int x1 = (int)Math.floor(getMinX());
|
||||
int y1 = (int)Math.floor(getMinY());
|
||||
int x2 = (int)Math.ceil(getMaxX());
|
||||
int y2 = (int)Math.ceil(getMaxY());
|
||||
return new Rectangle((double)x1, (double)y1, (double)(x2 - x1), (double)(y2 - y1));
|
||||
}
|
||||
|
||||
public PathIterator getPathIterator(AffineTransform t, double flatness) {
|
||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.itextpdf.awt.geom;
|
||||
|
||||
public interface Shape {
|
||||
boolean contains(double paramDouble1, double paramDouble2);
|
||||
|
||||
boolean contains(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4);
|
||||
|
||||
boolean contains(Point2D paramPoint2D);
|
||||
|
||||
boolean contains(Rectangle2D paramRectangle2D);
|
||||
|
||||
Rectangle getBounds();
|
||||
|
||||
Rectangle2D getBounds2D();
|
||||
|
||||
PathIterator getPathIterator(AffineTransform paramAffineTransform);
|
||||
|
||||
PathIterator getPathIterator(AffineTransform paramAffineTransform, double paramDouble);
|
||||
|
||||
boolean intersects(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4);
|
||||
|
||||
boolean intersects(Rectangle2D paramRectangle2D);
|
||||
}
|
||||
|
|
@ -0,0 +1,611 @@
|
|||
package com.itextpdf.awt.geom.gl;
|
||||
|
||||
import com.itextpdf.awt.geom.PathIterator;
|
||||
import com.itextpdf.awt.geom.Shape;
|
||||
|
||||
public class Crossing {
|
||||
static final double DELTA = 1.0E-5D;
|
||||
|
||||
static final double ROOT_DELTA = 1.0E-10D;
|
||||
|
||||
public static final int CROSSING = 255;
|
||||
|
||||
static final int UNKNOWN = 254;
|
||||
|
||||
public static int solveQuad(double[] eqn, double[] res) {
|
||||
double a = eqn[2];
|
||||
double b = eqn[1];
|
||||
double c = eqn[0];
|
||||
int rc = 0;
|
||||
if (a == 0.0D) {
|
||||
if (b == 0.0D)
|
||||
return -1;
|
||||
res[rc++] = -c / b;
|
||||
} else {
|
||||
double d = b * b - 4.0D * a * c;
|
||||
if (d < 0.0D)
|
||||
return 0;
|
||||
d = Math.sqrt(d);
|
||||
res[rc++] = (-b + d) / (a * 2.0D);
|
||||
if (d != 0.0D)
|
||||
res[rc++] = (-b - d) / (a * 2.0D);
|
||||
}
|
||||
return fixRoots(res, rc);
|
||||
}
|
||||
|
||||
public static int solveCubic(double[] eqn, double[] res) {
|
||||
double d = eqn[3];
|
||||
if (d == 0.0D)
|
||||
return solveQuad(eqn, res);
|
||||
double a = eqn[2] / d;
|
||||
double b = eqn[1] / d;
|
||||
double c = eqn[0] / d;
|
||||
int rc = 0;
|
||||
double Q = (a * a - 3.0D * b) / 9.0D;
|
||||
double R = (2.0D * a * a * a - 9.0D * a * b + 27.0D * c) / 54.0D;
|
||||
double Q3 = Q * Q * Q;
|
||||
double R2 = R * R;
|
||||
double n = -a / 3.0D;
|
||||
if (R2 < Q3) {
|
||||
double t = Math.acos(R / Math.sqrt(Q3)) / 3.0D;
|
||||
double p = 2.0943951023931953D;
|
||||
double m = -2.0D * Math.sqrt(Q);
|
||||
res[rc++] = m * Math.cos(t) + n;
|
||||
res[rc++] = m * Math.cos(t + p) + n;
|
||||
res[rc++] = m * Math.cos(t - p) + n;
|
||||
} else {
|
||||
double A = Math.pow(Math.abs(R) + Math.sqrt(R2 - Q3), 0.3333333333333333D);
|
||||
if (R > 0.0D)
|
||||
A = -A;
|
||||
if (-1.0E-10D < A && A < 1.0E-10D) {
|
||||
res[rc++] = n;
|
||||
} else {
|
||||
double B = Q / A;
|
||||
res[rc++] = A + B + n;
|
||||
double delta = R2 - Q3;
|
||||
if (-1.0E-10D < delta && delta < 1.0E-10D)
|
||||
res[rc++] = -(A + B) / 2.0D + n;
|
||||
}
|
||||
}
|
||||
return fixRoots(res, rc);
|
||||
}
|
||||
|
||||
static int fixRoots(double[] res, int rc) {
|
||||
int tc = 0;
|
||||
for (int i = 0; i < rc; i++) {
|
||||
int j = i + 1;
|
||||
while (true) {
|
||||
if (j < rc) {
|
||||
if (isZero(res[i] - res[j]))
|
||||
break;
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
res[tc++] = res[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
|
||||
public static class QuadCurve {
|
||||
double ax;
|
||||
|
||||
double ay;
|
||||
|
||||
double bx;
|
||||
|
||||
double by;
|
||||
|
||||
double Ax;
|
||||
|
||||
double Ay;
|
||||
|
||||
double Bx;
|
||||
|
||||
double By;
|
||||
|
||||
public QuadCurve(double x1, double y1, double cx, double cy, double x2, double y2) {
|
||||
this.ax = x2 - x1;
|
||||
this.ay = y2 - y1;
|
||||
this.bx = cx - x1;
|
||||
this.by = cy - y1;
|
||||
this.Bx = this.bx + this.bx;
|
||||
this.Ax = this.ax - this.Bx;
|
||||
this.By = this.by + this.by;
|
||||
this.Ay = this.ay - this.By;
|
||||
}
|
||||
|
||||
int cross(double[] res, int rc, double py1, double py2) {
|
||||
int cross = 0;
|
||||
for (int i = 0; i < rc; i++) {
|
||||
double t = res[i];
|
||||
if (t >= -1.0E-5D && t <= 1.00001D)
|
||||
if (t < 1.0E-5D) {
|
||||
if (py1 < 0.0D && ((this.bx != 0.0D) ? this.bx : (this.ax - this.bx)) < 0.0D)
|
||||
cross--;
|
||||
} else if (t > 0.99999D) {
|
||||
if (py1 < this.ay && ((this.ax != this.bx) ? (this.ax - this.bx) : this.bx) > 0.0D)
|
||||
cross++;
|
||||
} else {
|
||||
double ry = t * (t * this.Ay + this.By);
|
||||
if (ry > py2) {
|
||||
double rxt = t * this.Ax + this.bx;
|
||||
if (rxt <= -1.0E-5D || rxt >= 1.0E-5D)
|
||||
cross += (rxt > 0.0D) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cross;
|
||||
}
|
||||
|
||||
int solvePoint(double[] res, double px) {
|
||||
double[] eqn = { -px, this.Bx, this.Ax };
|
||||
return Crossing.solveQuad(eqn, res);
|
||||
}
|
||||
|
||||
int solveExtrem(double[] res) {
|
||||
int rc = 0;
|
||||
if (this.Ax != 0.0D)
|
||||
res[rc++] = -this.Bx / (this.Ax + this.Ax);
|
||||
if (this.Ay != 0.0D)
|
||||
res[rc++] = -this.By / (this.Ay + this.Ay);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int addBound(double[] bound, int bc, double[] res, int rc, double minX, double maxX, boolean changeId, int id) {
|
||||
for (int i = 0; i < rc; i++) {
|
||||
double t = res[i];
|
||||
if (t > -1.0E-5D && t < 1.00001D) {
|
||||
double rx = t * (t * this.Ax + this.Bx);
|
||||
if (minX <= rx && rx <= maxX) {
|
||||
bound[bc++] = t;
|
||||
bound[bc++] = rx;
|
||||
bound[bc++] = t * (t * this.Ay + this.By);
|
||||
bound[bc++] = (double)id;
|
||||
if (changeId)
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CubicCurve {
|
||||
double ax;
|
||||
|
||||
double ay;
|
||||
|
||||
double bx;
|
||||
|
||||
double by;
|
||||
|
||||
double cx;
|
||||
|
||||
double cy;
|
||||
|
||||
double Ax;
|
||||
|
||||
double Ay;
|
||||
|
||||
double Bx;
|
||||
|
||||
double By;
|
||||
|
||||
double Cx;
|
||||
|
||||
double Cy;
|
||||
|
||||
double Ax3;
|
||||
|
||||
double Bx2;
|
||||
|
||||
public CubicCurve(double x1, double y1, double cx1, double cy1, double cx2, double cy2, double x2, double y2) {
|
||||
this.ax = x2 - x1;
|
||||
this.ay = y2 - y1;
|
||||
this.bx = cx1 - x1;
|
||||
this.by = cy1 - y1;
|
||||
this.cx = cx2 - x1;
|
||||
this.cy = cy2 - y1;
|
||||
this.Cx = this.bx + this.bx + this.bx;
|
||||
this.Bx = this.cx + this.cx + this.cx - this.Cx - this.Cx;
|
||||
this.Ax = this.ax - this.Bx - this.Cx;
|
||||
this.Cy = this.by + this.by + this.by;
|
||||
this.By = this.cy + this.cy + this.cy - this.Cy - this.Cy;
|
||||
this.Ay = this.ay - this.By - this.Cy;
|
||||
this.Ax3 = this.Ax + this.Ax + this.Ax;
|
||||
this.Bx2 = this.Bx + this.Bx;
|
||||
}
|
||||
|
||||
int cross(double[] res, int rc, double py1, double py2) {
|
||||
int cross = 0;
|
||||
for (int i = 0; i < rc; i++) {
|
||||
double t = res[i];
|
||||
if (t < -1.0E-5D || t > 1.00001D)
|
||||
continue;
|
||||
if (t < 1.0E-5D) {
|
||||
if (py1 < 0.0D)
|
||||
if (((this.bx != 0.0D) ? this.bx : ((this.cx != this.bx) ? (this.cx - this.bx) : (this.ax - this.cx))) < 0.0D)
|
||||
cross--;
|
||||
continue;
|
||||
}
|
||||
if (t > 0.99999D) {
|
||||
if (py1 < this.ay)
|
||||
if (((this.ax != this.cx) ? (this.ax - this.cx) : ((this.cx != this.bx) ? (this.cx - this.bx) : this.bx)) > 0.0D)
|
||||
cross++;
|
||||
continue;
|
||||
}
|
||||
double ry = t * (t * (t * this.Ay + this.By) + this.Cy);
|
||||
if (ry > py2) {
|
||||
double rxt = t * (t * this.Ax3 + this.Bx2) + this.Cx;
|
||||
if (rxt > -1.0E-5D && rxt < 1.0E-5D) {
|
||||
rxt = t * (this.Ax3 + this.Ax3) + this.Bx2;
|
||||
if (rxt < -1.0E-5D || rxt > 1.0E-5D)
|
||||
continue;
|
||||
rxt = this.ax;
|
||||
}
|
||||
cross += (rxt > 0.0D) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
return cross;
|
||||
}
|
||||
|
||||
int solvePoint(double[] res, double px) {
|
||||
double[] eqn = { -px, this.Cx, this.Bx, this.Ax };
|
||||
return Crossing.solveCubic(eqn, res);
|
||||
}
|
||||
|
||||
int solveExtremX(double[] res) {
|
||||
double[] eqn = { this.Cx, this.Bx2, this.Ax3 };
|
||||
return Crossing.solveQuad(eqn, res);
|
||||
}
|
||||
|
||||
int solveExtremY(double[] res) {
|
||||
double[] eqn = { this.Cy, this.By + this.By, this.Ay + this.Ay + this.Ay };
|
||||
return Crossing.solveQuad(eqn, res);
|
||||
}
|
||||
|
||||
int addBound(double[] bound, int bc, double[] res, int rc, double minX, double maxX, boolean changeId, int id) {
|
||||
for (int i = 0; i < rc; i++) {
|
||||
double t = res[i];
|
||||
if (t > -1.0E-5D && t < 1.00001D) {
|
||||
double rx = t * (t * (t * this.Ax + this.Bx) + this.Cx);
|
||||
if (minX <= rx && rx <= maxX) {
|
||||
bound[bc++] = t;
|
||||
bound[bc++] = rx;
|
||||
bound[bc++] = t * (t * (t * this.Ay + this.By) + this.Cy);
|
||||
bound[bc++] = (double)id;
|
||||
if (changeId)
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bc;
|
||||
}
|
||||
}
|
||||
|
||||
public static int crossLine(double x1, double y1, double x2, double y2, double x, double y) {
|
||||
if ((x < x1 && x < x2) || (x > x1 && x > x2) || (y > y1 && y > y2) || x1 == x2)
|
||||
return 0;
|
||||
if (y >= y1 || y >= y2)
|
||||
if ((y2 - y1) * (x - x1) / (x2 - x1) <= y - y1)
|
||||
return 0;
|
||||
if (x == x1)
|
||||
return (x1 < x2) ? 0 : -1;
|
||||
if (x == x2)
|
||||
return (x1 < x2) ? 1 : 0;
|
||||
return (x1 < x2) ? 1 : -1;
|
||||
}
|
||||
|
||||
public static int crossQuad(double x1, double y1, double cx, double cy, double x2, double y2, double x, double y) {
|
||||
if ((x < x1 && x < cx && x < x2) || (x > x1 && x > cx && x > x2) || (y > y1 && y > cy && y > y2) || (x1 == cx && cx == x2))
|
||||
return 0;
|
||||
if (y < y1 && y < cy && y < y2 && x != x1 && x != x2) {
|
||||
if (x1 < x2)
|
||||
return (x1 < x && x < x2) ? 1 : 0;
|
||||
return (x2 < x && x < x1) ? -1 : 0;
|
||||
}
|
||||
QuadCurve c = new QuadCurve(x1, y1, cx, cy, x2, y2);
|
||||
double px = x - x1;
|
||||
double py = y - y1;
|
||||
double[] res = new double[3];
|
||||
int rc = c.solvePoint(res, px);
|
||||
return c.cross(res, rc, py, py);
|
||||
}
|
||||
|
||||
public static int crossCubic(double x1, double y1, double cx1, double cy1, double cx2, double cy2, double x2, double y2, double x, double y) {
|
||||
if ((x < x1 && x < cx1 && x < cx2 && x < x2) || (x > x1 && x > cx1 && x > cx2 && x > x2) || (y > y1 && y > cy1 && y > cy2 && y > y2) || (x1 == cx1 && cx1 == cx2 && cx2 == x2))
|
||||
return 0;
|
||||
if (y < y1 && y < cy1 && y < cy2 && y < y2 && x != x1 && x != x2) {
|
||||
if (x1 < x2)
|
||||
return (x1 < x && x < x2) ? 1 : 0;
|
||||
return (x2 < x && x < x1) ? -1 : 0;
|
||||
}
|
||||
CubicCurve c = new CubicCurve(x1, y1, cx1, cy1, cx2, cy2, x2, y2);
|
||||
double px = x - x1;
|
||||
double py = y - y1;
|
||||
double[] res = new double[3];
|
||||
int rc = c.solvePoint(res, px);
|
||||
return c.cross(res, rc, py, py);
|
||||
}
|
||||
|
||||
public static int crossPath(PathIterator p, double x, double y) {
|
||||
int cross = 0;
|
||||
double cy = 0.0D, cx = cy, my = cx, mx = my;
|
||||
double[] coords = new double[6];
|
||||
while (!p.isDone()) {
|
||||
switch (p.currentSegment(coords)) {
|
||||
case 0:
|
||||
if (cx != mx || cy != my)
|
||||
cross += crossLine(cx, cy, mx, my, x, y);
|
||||
mx = cx = coords[0];
|
||||
my = cy = coords[1];
|
||||
case 1:
|
||||
cross += crossLine(cx, cy, cx = coords[0], cy = coords[1], x, y);
|
||||
case 2:
|
||||
cross += crossQuad(cx, cy, coords[0], coords[1], cx = coords[2], cy = coords[3], x, y);
|
||||
case 3:
|
||||
cross += crossCubic(cx, cy, coords[0], coords[1], coords[2], coords[3], cx = coords[4], cy = coords[5], x, y);
|
||||
case 4:
|
||||
if (cy != my || cx != mx)
|
||||
cross += crossLine(cx, cy, cx = mx, cy = my, x, y);
|
||||
break;
|
||||
}
|
||||
if (x == cx && y == cy) {
|
||||
cross = 0;
|
||||
cy = my;
|
||||
break;
|
||||
}
|
||||
p.next();
|
||||
}
|
||||
if (cy != my)
|
||||
cross += crossLine(cx, cy, mx, my, x, y);
|
||||
return cross;
|
||||
}
|
||||
|
||||
public static int crossShape(Shape s, double x, double y) {
|
||||
if (!s.getBounds2D().contains(x, y))
|
||||
return 0;
|
||||
return crossPath(s.getPathIterator(null), x, y);
|
||||
}
|
||||
|
||||
public static boolean isZero(double val) {
|
||||
return (-1.0E-5D < val && val < 1.0E-5D);
|
||||
}
|
||||
|
||||
static void sortBound(double[] bound, int bc) {
|
||||
for (int i = 0; i < bc - 4; i += 4) {
|
||||
int k = i;
|
||||
for (int j = i + 4; j < bc; j += 4) {
|
||||
if (bound[k] > bound[j])
|
||||
k = j;
|
||||
}
|
||||
if (k != i) {
|
||||
double tmp = bound[i];
|
||||
bound[i] = bound[k];
|
||||
bound[k] = tmp;
|
||||
tmp = bound[i + 1];
|
||||
bound[i + 1] = bound[k + 1];
|
||||
bound[k + 1] = tmp;
|
||||
tmp = bound[i + 2];
|
||||
bound[i + 2] = bound[k + 2];
|
||||
bound[k + 2] = tmp;
|
||||
tmp = bound[i + 3];
|
||||
bound[i + 3] = bound[k + 3];
|
||||
bound[k + 3] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int crossBound(double[] bound, int bc, double py1, double py2) {
|
||||
if (bc == 0)
|
||||
return 0;
|
||||
int up = 0;
|
||||
int down = 0;
|
||||
for (int i = 2; i < bc; i += 4) {
|
||||
if (bound[i] < py1) {
|
||||
up++;
|
||||
} else if (bound[i] > py2) {
|
||||
down++;
|
||||
} else {
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
if (down == 0)
|
||||
return 0;
|
||||
if (up != 0) {
|
||||
sortBound(bound, bc);
|
||||
boolean sign = (bound[2] > py2);
|
||||
for (int j = 6; j < bc; j += 4) {
|
||||
boolean sign2 = (bound[j] > py2);
|
||||
if (sign != sign2 && bound[j + 1] != bound[j - 3])
|
||||
return 255;
|
||||
sign = sign2;
|
||||
}
|
||||
}
|
||||
return 254;
|
||||
}
|
||||
|
||||
public static int intersectLine(double x1, double y1, double x2, double y2, double rx1, double ry1, double rx2, double ry2) {
|
||||
if ((rx2 < x1 && rx2 < x2) || (rx1 > x1 && rx1 > x2) || (ry1 > y1 && ry1 > y2))
|
||||
return 0;
|
||||
if (ry2 >= y1 || ry2 >= y2) {
|
||||
double bx1, bx2;
|
||||
if (x1 == x2)
|
||||
return 255;
|
||||
if (x1 < x2) {
|
||||
bx1 = (x1 < rx1) ? rx1 : x1;
|
||||
bx2 = (x2 < rx2) ? x2 : rx2;
|
||||
} else {
|
||||
bx1 = (x2 < rx1) ? rx1 : x2;
|
||||
bx2 = (x1 < rx2) ? x1 : rx2;
|
||||
}
|
||||
double k = (y2 - y1) / (x2 - x1);
|
||||
double by1 = k * (bx1 - x1) + y1;
|
||||
double by2 = k * (bx2 - x1) + y1;
|
||||
if (by1 < ry1 && by2 < ry1)
|
||||
return 0;
|
||||
if (by1 <= ry2 || by2 <= ry2)
|
||||
return 255;
|
||||
}
|
||||
if (x1 == x2)
|
||||
return 0;
|
||||
if (rx1 == x1)
|
||||
return (x1 < x2) ? 0 : -1;
|
||||
if (rx1 == x2)
|
||||
return (x1 < x2) ? 1 : 0;
|
||||
if (x1 < x2)
|
||||
return (x1 < rx1 && rx1 < x2) ? 1 : 0;
|
||||
return (x2 < rx1 && rx1 < x1) ? -1 : 0;
|
||||
}
|
||||
|
||||
public static int intersectQuad(double x1, double y1, double cx, double cy, double x2, double y2, double rx1, double ry1, double rx2, double ry2) {
|
||||
if ((rx2 < x1 && rx2 < cx && rx2 < x2) || (rx1 > x1 && rx1 > cx && rx1 > x2) || (ry1 > y1 && ry1 > cy && ry1 > y2))
|
||||
return 0;
|
||||
if (ry2 < y1 && ry2 < cy && ry2 < y2 && rx1 != x1 && rx1 != x2) {
|
||||
if (x1 < x2)
|
||||
return (x1 < rx1 && rx1 < x2) ? 1 : 0;
|
||||
return (x2 < rx1 && rx1 < x1) ? -1 : 0;
|
||||
}
|
||||
QuadCurve c = new QuadCurve(x1, y1, cx, cy, x2, y2);
|
||||
double px1 = rx1 - x1;
|
||||
double py1 = ry1 - y1;
|
||||
double px2 = rx2 - x1;
|
||||
double py2 = ry2 - y1;
|
||||
double[] res1 = new double[3];
|
||||
double[] res2 = new double[3];
|
||||
int rc1 = c.solvePoint(res1, px1);
|
||||
int rc2 = c.solvePoint(res2, px2);
|
||||
if (rc1 == 0 && rc2 == 0)
|
||||
return 0;
|
||||
double minX = px1 - 1.0E-5D;
|
||||
double maxX = px2 + 1.0E-5D;
|
||||
double[] bound = new double[28];
|
||||
int bc = 0;
|
||||
bc = c.addBound(bound, bc, res1, rc1, minX, maxX, false, 0);
|
||||
bc = c.addBound(bound, bc, res2, rc2, minX, maxX, false, 1);
|
||||
rc2 = c.solveExtrem(res2);
|
||||
bc = c.addBound(bound, bc, res2, rc2, minX, maxX, true, 2);
|
||||
if (rx1 < x1 && x1 < rx2) {
|
||||
bound[bc++] = 0.0D;
|
||||
bound[bc++] = 0.0D;
|
||||
bound[bc++] = 0.0D;
|
||||
bound[bc++] = 4.0D;
|
||||
}
|
||||
if (rx1 < x2 && x2 < rx2) {
|
||||
bound[bc++] = 1.0D;
|
||||
bound[bc++] = c.ax;
|
||||
bound[bc++] = c.ay;
|
||||
bound[bc++] = 5.0D;
|
||||
}
|
||||
int cross = crossBound(bound, bc, py1, py2);
|
||||
if (cross != 254)
|
||||
return cross;
|
||||
return c.cross(res1, rc1, py1, py2);
|
||||
}
|
||||
|
||||
public static int intersectCubic(double x1, double y1, double cx1, double cy1, double cx2, double cy2, double x2, double y2, double rx1, double ry1, double rx2, double ry2) {
|
||||
if ((rx2 < x1 && rx2 < cx1 && rx2 < cx2 && rx2 < x2) || (rx1 > x1 && rx1 > cx1 && rx1 > cx2 && rx1 > x2) || (ry1 > y1 && ry1 > cy1 && ry1 > cy2 && ry1 > y2))
|
||||
return 0;
|
||||
if (ry2 < y1 && ry2 < cy1 && ry2 < cy2 && ry2 < y2 && rx1 != x1 && rx1 != x2) {
|
||||
if (x1 < x2)
|
||||
return (x1 < rx1 && rx1 < x2) ? 1 : 0;
|
||||
return (x2 < rx1 && rx1 < x1) ? -1 : 0;
|
||||
}
|
||||
CubicCurve c = new CubicCurve(x1, y1, cx1, cy1, cx2, cy2, x2, y2);
|
||||
double px1 = rx1 - x1;
|
||||
double py1 = ry1 - y1;
|
||||
double px2 = rx2 - x1;
|
||||
double py2 = ry2 - y1;
|
||||
double[] res1 = new double[3];
|
||||
double[] res2 = new double[3];
|
||||
int rc1 = c.solvePoint(res1, px1);
|
||||
int rc2 = c.solvePoint(res2, px2);
|
||||
if (rc1 == 0 && rc2 == 0)
|
||||
return 0;
|
||||
double minX = px1 - 1.0E-5D;
|
||||
double maxX = px2 + 1.0E-5D;
|
||||
double[] bound = new double[40];
|
||||
int bc = 0;
|
||||
bc = c.addBound(bound, bc, res1, rc1, minX, maxX, false, 0);
|
||||
bc = c.addBound(bound, bc, res2, rc2, minX, maxX, false, 1);
|
||||
rc2 = c.solveExtremX(res2);
|
||||
bc = c.addBound(bound, bc, res2, rc2, minX, maxX, true, 2);
|
||||
rc2 = c.solveExtremY(res2);
|
||||
bc = c.addBound(bound, bc, res2, rc2, minX, maxX, true, 4);
|
||||
if (rx1 < x1 && x1 < rx2) {
|
||||
bound[bc++] = 0.0D;
|
||||
bound[bc++] = 0.0D;
|
||||
bound[bc++] = 0.0D;
|
||||
bound[bc++] = 6.0D;
|
||||
}
|
||||
if (rx1 < x2 && x2 < rx2) {
|
||||
bound[bc++] = 1.0D;
|
||||
bound[bc++] = c.ax;
|
||||
bound[bc++] = c.ay;
|
||||
bound[bc++] = 7.0D;
|
||||
}
|
||||
int cross = crossBound(bound, bc, py1, py2);
|
||||
if (cross != 254)
|
||||
return cross;
|
||||
return c.cross(res1, rc1, py1, py2);
|
||||
}
|
||||
|
||||
public static int intersectPath(PathIterator p, double x, double y, double w, double h) {
|
||||
int cross = 0;
|
||||
double cy = 0.0D, cx = cy, my = cx, mx = my;
|
||||
double[] coords = new double[6];
|
||||
double rx1 = x;
|
||||
double ry1 = y;
|
||||
double rx2 = x + w;
|
||||
double ry2 = y + h;
|
||||
while (!p.isDone()) {
|
||||
int count = 0;
|
||||
switch (p.currentSegment(coords)) {
|
||||
case 0:
|
||||
if (cx != mx || cy != my)
|
||||
count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
|
||||
mx = cx = coords[0];
|
||||
my = cy = coords[1];
|
||||
case 1:
|
||||
count = intersectLine(cx, cy, cx = coords[0], cy = coords[1], rx1, ry1, rx2, ry2);
|
||||
case 2:
|
||||
count = intersectQuad(cx, cy, coords[0], coords[1], cx = coords[2], cy = coords[3], rx1, ry1, rx2, ry2);
|
||||
case 3:
|
||||
count = intersectCubic(cx, cy, coords[0], coords[1], coords[2], coords[3], cx = coords[4], cy = coords[5], rx1, ry1, rx2, ry2);
|
||||
case 4:
|
||||
if (cy != my || cx != mx)
|
||||
count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
|
||||
cx = mx;
|
||||
cy = my;
|
||||
break;
|
||||
}
|
||||
if (count == 255)
|
||||
return 255;
|
||||
cross += count;
|
||||
p.next();
|
||||
}
|
||||
if (cy != my) {
|
||||
int count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
|
||||
if (count == 255)
|
||||
return 255;
|
||||
cross += count;
|
||||
}
|
||||
return cross;
|
||||
}
|
||||
|
||||
public static int intersectShape(Shape s, double x, double y, double w, double h) {
|
||||
if (!s.getBounds2D().intersects(x, y, w, h))
|
||||
return 0;
|
||||
return intersectPath(s.getPathIterator(null), x, y, w, h);
|
||||
}
|
||||
|
||||
public static boolean isInsideNonZero(int cross) {
|
||||
return (cross != 0);
|
||||
}
|
||||
|
||||
public static boolean isInsideEvenOdd(int cross) {
|
||||
return ((cross & 0x1) != 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.itextpdf.awt.geom.misc;
|
||||
|
||||
public final class HashCode {
|
||||
public static final int EMPTY_HASH_CODE = 1;
|
||||
|
||||
private int hashCode = 1;
|
||||
|
||||
public final int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
public static int combine(int hashCode, boolean value) {
|
||||
int v = value ? 1231 : 1237;
|
||||
return combine(hashCode, v);
|
||||
}
|
||||
|
||||
public static int combine(int hashCode, long value) {
|
||||
int v = (int)(value ^ value >>> 32L);
|
||||
return combine(hashCode, v);
|
||||
}
|
||||
|
||||
public static int combine(int hashCode, float value) {
|
||||
int v = Float.floatToIntBits(value);
|
||||
return combine(hashCode, v);
|
||||
}
|
||||
|
||||
public static int combine(int hashCode, double value) {
|
||||
long v = Double.doubleToLongBits(value);
|
||||
return combine(hashCode, v);
|
||||
}
|
||||
|
||||
public static int combine(int hashCode, Object value) {
|
||||
return combine(hashCode, value.hashCode());
|
||||
}
|
||||
|
||||
public static int combine(int hashCode, int value) {
|
||||
return 31 * hashCode + value;
|
||||
}
|
||||
|
||||
public final HashCode append(int value) {
|
||||
this.hashCode = combine(this.hashCode, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final HashCode append(long value) {
|
||||
this.hashCode = combine(this.hashCode, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final HashCode append(float value) {
|
||||
this.hashCode = combine(this.hashCode, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final HashCode append(double value) {
|
||||
this.hashCode = combine(this.hashCode, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final HashCode append(boolean value) {
|
||||
this.hashCode = combine(this.hashCode, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final HashCode append(Object value) {
|
||||
this.hashCode = combine(this.hashCode, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
package com.itextpdf.awt.geom.misc;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class Messages {
|
||||
private static ResourceBundle bundle = null;
|
||||
|
||||
public static String getString(String msg) {
|
||||
if (bundle == null)
|
||||
return msg;
|
||||
try {
|
||||
return bundle.getString(msg);
|
||||
} catch (MissingResourceException e) {
|
||||
return "Missing message: " + msg;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getString(String msg, Object arg) {
|
||||
return getString(msg, new Object[] { arg });
|
||||
}
|
||||
|
||||
public static String getString(String msg, int arg) {
|
||||
return getString(msg, new Object[] { Integer.toString(arg) });
|
||||
}
|
||||
|
||||
public static String getString(String msg, char arg) {
|
||||
return getString(msg, new Object[] { String.valueOf(arg) });
|
||||
}
|
||||
|
||||
public static String getString(String msg, Object arg1, Object arg2) {
|
||||
return getString(msg, new Object[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
public static String getString(String msg, Object[] args) {
|
||||
String format = msg;
|
||||
if (bundle != null)
|
||||
try {
|
||||
format = bundle.getString(msg);
|
||||
} catch (MissingResourceException e) {}
|
||||
return format(format, args);
|
||||
}
|
||||
|
||||
public static String format(String format, Object[] args) {
|
||||
StringBuilder answer = new StringBuilder(format.length() + args.length * 20);
|
||||
String[] argStrings = new String[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] == null) {
|
||||
argStrings[i] = "<null>";
|
||||
} else {
|
||||
argStrings[i] = args[i].toString();
|
||||
}
|
||||
}
|
||||
int lastI = 0;
|
||||
for (int j = format.indexOf('{', 0); j >= 0; j = format.indexOf('{', lastI)) {
|
||||
if (j != 0 && format.charAt(j - 1) == '\\') {
|
||||
if (j != 1)
|
||||
answer.append(format.substring(lastI, j - 1));
|
||||
answer.append('{');
|
||||
lastI = j + 1;
|
||||
} else if (j > format.length() - 3) {
|
||||
answer.append(format.substring(lastI, format.length()));
|
||||
lastI = format.length();
|
||||
} else {
|
||||
int argnum = (byte)Character.digit(format.charAt(j + 1), 10);
|
||||
if (argnum < 0 || format.charAt(j + 2) != '}') {
|
||||
answer.append(format.substring(lastI, j + 1));
|
||||
lastI = j + 1;
|
||||
} else {
|
||||
answer.append(format.substring(lastI, j));
|
||||
if (argnum >= argStrings.length) {
|
||||
answer.append("<missing argument>");
|
||||
} else {
|
||||
answer.append(argStrings[argnum]);
|
||||
}
|
||||
lastI = j + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastI < format.length())
|
||||
answer.append(format.substring(lastI, format.length()));
|
||||
return answer.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
package com.itextpdf.awt.geom.misc;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class RenderingHints implements Map<Object, Object>, Cloneable {
|
||||
public static final Key KEY_ALPHA_INTERPOLATION = new KeyImpl(1);
|
||||
|
||||
public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT = new KeyValue(KEY_ALPHA_INTERPOLATION);
|
||||
|
||||
public static final Object VALUE_ALPHA_INTERPOLATION_SPEED = new KeyValue(KEY_ALPHA_INTERPOLATION);
|
||||
|
||||
public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY = new KeyValue(KEY_ALPHA_INTERPOLATION);
|
||||
|
||||
public static final Key KEY_ANTIALIASING = new KeyImpl(2);
|
||||
|
||||
public static final Object VALUE_ANTIALIAS_DEFAULT = new KeyValue(KEY_ANTIALIASING);
|
||||
|
||||
public static final Object VALUE_ANTIALIAS_ON = new KeyValue(KEY_ANTIALIASING);
|
||||
|
||||
public static final Object VALUE_ANTIALIAS_OFF = new KeyValue(KEY_ANTIALIASING);
|
||||
|
||||
public static final Key KEY_COLOR_RENDERING = new KeyImpl(3);
|
||||
|
||||
public static final Object VALUE_COLOR_RENDER_DEFAULT = new KeyValue(KEY_COLOR_RENDERING);
|
||||
|
||||
public static final Object VALUE_COLOR_RENDER_SPEED = new KeyValue(KEY_COLOR_RENDERING);
|
||||
|
||||
public static final Object VALUE_COLOR_RENDER_QUALITY = new KeyValue(KEY_COLOR_RENDERING);
|
||||
|
||||
public static final Key KEY_DITHERING = new KeyImpl(4);
|
||||
|
||||
public static final Object VALUE_DITHER_DEFAULT = new KeyValue(KEY_DITHERING);
|
||||
|
||||
public static final Object VALUE_DITHER_DISABLE = new KeyValue(KEY_DITHERING);
|
||||
|
||||
public static final Object VALUE_DITHER_ENABLE = new KeyValue(KEY_DITHERING);
|
||||
|
||||
public static final Key KEY_FRACTIONALMETRICS = new KeyImpl(5);
|
||||
|
||||
public static final Object VALUE_FRACTIONALMETRICS_DEFAULT = new KeyValue(KEY_FRACTIONALMETRICS);
|
||||
|
||||
public static final Object VALUE_FRACTIONALMETRICS_ON = new KeyValue(KEY_FRACTIONALMETRICS);
|
||||
|
||||
public static final Object VALUE_FRACTIONALMETRICS_OFF = new KeyValue(KEY_FRACTIONALMETRICS);
|
||||
|
||||
public static final Key KEY_INTERPOLATION = new KeyImpl(6);
|
||||
|
||||
public static final Object VALUE_INTERPOLATION_BICUBIC = new KeyValue(KEY_INTERPOLATION);
|
||||
|
||||
public static final Object VALUE_INTERPOLATION_BILINEAR = new KeyValue(KEY_INTERPOLATION);
|
||||
|
||||
public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR = new KeyValue(KEY_INTERPOLATION);
|
||||
|
||||
public static final Key KEY_RENDERING = new KeyImpl(7);
|
||||
|
||||
public static final Object VALUE_RENDER_DEFAULT = new KeyValue(KEY_RENDERING);
|
||||
|
||||
public static final Object VALUE_RENDER_SPEED = new KeyValue(KEY_RENDERING);
|
||||
|
||||
public static final Object VALUE_RENDER_QUALITY = new KeyValue(KEY_RENDERING);
|
||||
|
||||
public static final Key KEY_STROKE_CONTROL = new KeyImpl(8);
|
||||
|
||||
public static final Object VALUE_STROKE_DEFAULT = new KeyValue(KEY_STROKE_CONTROL);
|
||||
|
||||
public static final Object VALUE_STROKE_NORMALIZE = new KeyValue(KEY_STROKE_CONTROL);
|
||||
|
||||
public static final Object VALUE_STROKE_PURE = new KeyValue(KEY_STROKE_CONTROL);
|
||||
|
||||
public static final Key KEY_TEXT_ANTIALIASING = new KeyImpl(9);
|
||||
|
||||
public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT = new KeyValue(KEY_TEXT_ANTIALIASING);
|
||||
|
||||
public static final Object VALUE_TEXT_ANTIALIAS_ON = new KeyValue(KEY_TEXT_ANTIALIASING);
|
||||
|
||||
public static final Object VALUE_TEXT_ANTIALIAS_OFF = new KeyValue(KEY_TEXT_ANTIALIASING);
|
||||
|
||||
private HashMap<Object, Object> map = new HashMap<Object, Object>();
|
||||
|
||||
public RenderingHints(Map<Key, ?> map) {
|
||||
if (map != null)
|
||||
putAll(map);
|
||||
}
|
||||
|
||||
public RenderingHints(Key key, Object value) {
|
||||
put(key, value);
|
||||
}
|
||||
|
||||
public void add(RenderingHints hints) {
|
||||
this.map.putAll(hints.map);
|
||||
}
|
||||
|
||||
public Object put(Object key, Object value) {
|
||||
if (!((Key)key).isCompatibleValue(value))
|
||||
throw new IllegalArgumentException();
|
||||
return this.map.put(key, value);
|
||||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
return this.map.remove(key);
|
||||
}
|
||||
|
||||
public Object get(Object key) {
|
||||
return this.map.get(key);
|
||||
}
|
||||
|
||||
public Set<Object> keySet() {
|
||||
return this.map.keySet();
|
||||
}
|
||||
|
||||
public Set<Map.Entry<Object, Object>> entrySet() {
|
||||
return this.map.entrySet();
|
||||
}
|
||||
|
||||
public void putAll(Map<?, ?> m) {
|
||||
if (m instanceof RenderingHints) {
|
||||
this.map.putAll(((RenderingHints)m).map);
|
||||
} else {
|
||||
Set<?> entries = m.entrySet();
|
||||
if (entries != null) {
|
||||
Iterator<?> it = entries.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<?, ?> entry = (Map.Entry<?, ?>)it.next();
|
||||
Key key = (Key)entry.getKey();
|
||||
Object val = entry.getValue();
|
||||
put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Object> values() {
|
||||
return this.map.values();
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return this.map.containsValue(value);
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
if (key == null)
|
||||
throw new NullPointerException();
|
||||
return this.map.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.map.isEmpty();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.map.size();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Map))
|
||||
return false;
|
||||
Map<?, ?> m = (Map<?, ?>)o;
|
||||
Set<?> keys = keySet();
|
||||
if (!keys.equals(m.keySet()))
|
||||
return false;
|
||||
Iterator<?> it = keys.iterator();
|
||||
while (it.hasNext()) {
|
||||
Key key = (Key)it.next();
|
||||
Object v1 = get(key);
|
||||
Object v2 = m.get(key);
|
||||
if ((v1 == null) ? (v2 == null) : v1.equals(v2))
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.map.hashCode();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
RenderingHints clone = new RenderingHints(null);
|
||||
clone.map = (HashMap<Object, Object>)this.map.clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "RenderingHints[" + this.map.toString() + "]";
|
||||
}
|
||||
|
||||
public static abstract class Key {
|
||||
private final int key;
|
||||
|
||||
protected Key(int key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public final boolean equals(Object o) {
|
||||
return (this == o);
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
protected final int intKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public abstract boolean isCompatibleValue(Object param1Object);
|
||||
}
|
||||
|
||||
private static class KeyImpl extends Key {
|
||||
protected KeyImpl(int key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
public boolean isCompatibleValue(Object val) {
|
||||
if (!(val instanceof RenderingHints.KeyValue))
|
||||
return false;
|
||||
return (((RenderingHints.KeyValue)val).key == this);
|
||||
}
|
||||
}
|
||||
|
||||
private static class KeyValue {
|
||||
private final RenderingHints.Key key;
|
||||
|
||||
protected KeyValue(RenderingHints.Key key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,55 @@
|
|||
package com.itextpdf.testutils;
|
||||
|
||||
import com.itextpdf.text.log.Logger;
|
||||
import com.itextpdf.text.log.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class ITextTest {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ITextTest.class.getName());
|
||||
|
||||
public void runTest() throws Exception {
|
||||
LOGGER.info("Starting test.");
|
||||
String outPdf = getOutPdf();
|
||||
if (outPdf == null || outPdf.length() == 0)
|
||||
throw new IOException("outPdf cannot be empty!");
|
||||
makePdf(outPdf);
|
||||
assertPdf(outPdf);
|
||||
comparePdf(outPdf, getCmpPdf());
|
||||
LOGGER.info("Test complete.");
|
||||
}
|
||||
|
||||
protected abstract void makePdf(String paramString) throws Exception;
|
||||
|
||||
protected abstract String getOutPdf();
|
||||
|
||||
protected void assertPdf(String outPdf) throws Exception {}
|
||||
|
||||
protected void comparePdf(String outPdf, String cmpPdf) throws Exception {}
|
||||
|
||||
protected String getCmpPdf() {
|
||||
return "";
|
||||
}
|
||||
|
||||
protected void deleteDirectory(File path) {
|
||||
if (path == null)
|
||||
return;
|
||||
if (path.exists()) {
|
||||
for (File f : path.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
deleteDirectory(f);
|
||||
f.delete();
|
||||
} else {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
path.delete();
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteFiles(File path) {
|
||||
if (path != null && path.exists())
|
||||
for (File f : path.listFiles())
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
661
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/AGPL.txt
Normal file
661
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/AGPL.txt
Normal file
|
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AccessibleElementId implements Comparable<AccessibleElementId>, Serializable {
|
||||
private static int id_counter = 0;
|
||||
|
||||
private int id = 0;
|
||||
|
||||
public AccessibleElementId() {
|
||||
this.id = ++id_counter;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return Integer.toString(this.id);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return (o instanceof AccessibleElementId && this.id == ((AccessibleElementId)o).id);
|
||||
}
|
||||
|
||||
public int compareTo(AccessibleElementId elementId) {
|
||||
if (this.id < elementId.id)
|
||||
return -1;
|
||||
if (this.id > elementId.id)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class Anchor extends Phrase {
|
||||
private static final long serialVersionUID = -852278536049236911L;
|
||||
|
||||
protected String name = null;
|
||||
|
||||
protected String reference = null;
|
||||
|
||||
public Anchor() {
|
||||
super(16.0F);
|
||||
}
|
||||
|
||||
public Anchor(float leading) {
|
||||
super(leading);
|
||||
}
|
||||
|
||||
public Anchor(Chunk chunk) {
|
||||
super(chunk);
|
||||
}
|
||||
|
||||
public Anchor(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public Anchor(String string, Font font) {
|
||||
super(string, font);
|
||||
}
|
||||
|
||||
public Anchor(float leading, Chunk chunk) {
|
||||
super(leading, chunk);
|
||||
}
|
||||
|
||||
public Anchor(float leading, String string) {
|
||||
super(leading, string);
|
||||
}
|
||||
|
||||
public Anchor(float leading, String string, Font font) {
|
||||
super(leading, string, font);
|
||||
}
|
||||
|
||||
public Anchor(Phrase phrase) {
|
||||
super(phrase);
|
||||
if (phrase instanceof Anchor) {
|
||||
Anchor a = (Anchor)phrase;
|
||||
setName(a.name);
|
||||
setReference(a.reference);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
Iterator<Chunk> i = getChunks().iterator();
|
||||
boolean localDestination = (this.reference != null && this.reference.startsWith("#"));
|
||||
boolean notGotoOK = true;
|
||||
while (i.hasNext()) {
|
||||
Chunk chunk = i.next();
|
||||
if (this.name != null && notGotoOK && !chunk.isEmpty()) {
|
||||
chunk.setLocalDestination(this.name);
|
||||
notGotoOK = false;
|
||||
}
|
||||
if (localDestination)
|
||||
chunk.setLocalGoto(this.reference.substring(1));
|
||||
listener.add(chunk);
|
||||
}
|
||||
return true;
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
boolean localDestination = (this.reference != null && this.reference.startsWith("#"));
|
||||
boolean notGotoOK = true;
|
||||
java.util.List<Chunk> tmp = new ArrayList<Chunk>();
|
||||
Iterator<Element> i = iterator();
|
||||
while (i.hasNext()) {
|
||||
Element element = i.next();
|
||||
if (element instanceof Chunk) {
|
||||
Chunk chunk = (Chunk)element;
|
||||
notGotoOK = applyAnchor(chunk, notGotoOK, localDestination);
|
||||
tmp.add(chunk);
|
||||
continue;
|
||||
}
|
||||
for (Chunk c : element.getChunks()) {
|
||||
notGotoOK = applyAnchor(c, notGotoOK, localDestination);
|
||||
tmp.add(c);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
protected boolean applyAnchor(Chunk chunk, boolean notGotoOK, boolean localDestination) {
|
||||
if (this.name != null && notGotoOK && !chunk.isEmpty()) {
|
||||
chunk.setLocalDestination(this.name);
|
||||
notGotoOK = false;
|
||||
}
|
||||
if (localDestination) {
|
||||
chunk.setLocalGoto(this.reference.substring(1));
|
||||
} else if (this.reference != null) {
|
||||
chunk.setAnchor(this.reference);
|
||||
}
|
||||
return notGotoOK;
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 17;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return this.reference;
|
||||
}
|
||||
|
||||
public URL getUrl() {
|
||||
try {
|
||||
return new URL(this.reference);
|
||||
} catch (MalformedURLException mue) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Annotation implements Element {
|
||||
public static final int TEXT = 0;
|
||||
|
||||
public static final int URL_NET = 1;
|
||||
|
||||
public static final int URL_AS_STRING = 2;
|
||||
|
||||
public static final int FILE_DEST = 3;
|
||||
|
||||
public static final int FILE_PAGE = 4;
|
||||
|
||||
public static final int NAMED_DEST = 5;
|
||||
|
||||
public static final int LAUNCH = 6;
|
||||
|
||||
public static final int SCREEN = 7;
|
||||
|
||||
public static final String TITLE = "title";
|
||||
|
||||
public static final String CONTENT = "content";
|
||||
|
||||
public static final String URL = "url";
|
||||
|
||||
public static final String FILE = "file";
|
||||
|
||||
public static final String DESTINATION = "destination";
|
||||
|
||||
public static final String PAGE = "page";
|
||||
|
||||
public static final String NAMED = "named";
|
||||
|
||||
public static final String APPLICATION = "application";
|
||||
|
||||
public static final String PARAMETERS = "parameters";
|
||||
|
||||
public static final String OPERATION = "operation";
|
||||
|
||||
public static final String DEFAULTDIR = "defaultdir";
|
||||
|
||||
public static final String LLX = "llx";
|
||||
|
||||
public static final String LLY = "lly";
|
||||
|
||||
public static final String URX = "urx";
|
||||
|
||||
public static final String URY = "ury";
|
||||
|
||||
public static final String MIMETYPE = "mime";
|
||||
|
||||
protected int annotationtype;
|
||||
|
||||
protected HashMap<String, Object> annotationAttributes = new HashMap<String, Object>();
|
||||
|
||||
protected float llx = Float.NaN;
|
||||
|
||||
protected float lly = Float.NaN;
|
||||
|
||||
protected float urx = Float.NaN;
|
||||
|
||||
protected float ury = Float.NaN;
|
||||
|
||||
private Annotation(float llx, float lly, float urx, float ury) {
|
||||
this.llx = llx;
|
||||
this.lly = lly;
|
||||
this.urx = urx;
|
||||
this.ury = ury;
|
||||
}
|
||||
|
||||
public Annotation(Annotation an) {
|
||||
this.annotationtype = an.annotationtype;
|
||||
this.annotationAttributes = an.annotationAttributes;
|
||||
this.llx = an.llx;
|
||||
this.lly = an.lly;
|
||||
this.urx = an.urx;
|
||||
this.ury = an.ury;
|
||||
}
|
||||
|
||||
public Annotation(String title, String text) {
|
||||
this.annotationtype = 0;
|
||||
this.annotationAttributes.put("title", title);
|
||||
this.annotationAttributes.put("content", text);
|
||||
}
|
||||
|
||||
public Annotation(String title, String text, float llx, float lly, float urx, float ury) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 0;
|
||||
this.annotationAttributes.put("title", title);
|
||||
this.annotationAttributes.put("content", text);
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, URL url) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 1;
|
||||
this.annotationAttributes.put("url", url);
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, String url) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 2;
|
||||
this.annotationAttributes.put("file", url);
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, String file, String dest) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 3;
|
||||
this.annotationAttributes.put("file", file);
|
||||
this.annotationAttributes.put("destination", dest);
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, String moviePath, String mimeType, boolean showOnDisplay) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 7;
|
||||
this.annotationAttributes.put("file", moviePath);
|
||||
this.annotationAttributes.put("mime", mimeType);
|
||||
this.annotationAttributes.put("parameters", new boolean[] { false, showOnDisplay });
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, String file, int page) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 4;
|
||||
this.annotationAttributes.put("file", file);
|
||||
this.annotationAttributes.put("page", Integer.valueOf(page));
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, int named) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 5;
|
||||
this.annotationAttributes.put("named", Integer.valueOf(named));
|
||||
}
|
||||
|
||||
public Annotation(float llx, float lly, float urx, float ury, String application, String parameters, String operation, String defaultdir) {
|
||||
this(llx, lly, urx, ury);
|
||||
this.annotationtype = 6;
|
||||
this.annotationAttributes.put("application", application);
|
||||
this.annotationAttributes.put("parameters", parameters);
|
||||
this.annotationAttributes.put("operation", operation);
|
||||
this.annotationAttributes.put("defaultdir", defaultdir);
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 29;
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
return listener.add(this);
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
return new ArrayList<Chunk>();
|
||||
}
|
||||
|
||||
public void setDimensions(float llx, float lly, float urx, float ury) {
|
||||
this.llx = llx;
|
||||
this.lly = lly;
|
||||
this.urx = urx;
|
||||
this.ury = ury;
|
||||
}
|
||||
|
||||
public float llx() {
|
||||
return this.llx;
|
||||
}
|
||||
|
||||
public float lly() {
|
||||
return this.lly;
|
||||
}
|
||||
|
||||
public float urx() {
|
||||
return this.urx;
|
||||
}
|
||||
|
||||
public float ury() {
|
||||
return this.ury;
|
||||
}
|
||||
|
||||
public float llx(float def) {
|
||||
if (Float.isNaN(this.llx))
|
||||
return def;
|
||||
return this.llx;
|
||||
}
|
||||
|
||||
public float lly(float def) {
|
||||
if (Float.isNaN(this.lly))
|
||||
return def;
|
||||
return this.lly;
|
||||
}
|
||||
|
||||
public float urx(float def) {
|
||||
if (Float.isNaN(this.urx))
|
||||
return def;
|
||||
return this.urx;
|
||||
}
|
||||
|
||||
public float ury(float def) {
|
||||
if (Float.isNaN(this.ury))
|
||||
return def;
|
||||
return this.ury;
|
||||
}
|
||||
|
||||
public int annotationType() {
|
||||
return this.annotationtype;
|
||||
}
|
||||
|
||||
public String title() {
|
||||
String s = (String)this.annotationAttributes.get("title");
|
||||
if (s == null)
|
||||
s = "";
|
||||
return s;
|
||||
}
|
||||
|
||||
public String content() {
|
||||
String s = (String)this.annotationAttributes.get("content");
|
||||
if (s == null)
|
||||
s = "";
|
||||
return s;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> attributes() {
|
||||
return this.annotationAttributes;
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public class BadElementException extends DocumentException {
|
||||
private static final long serialVersionUID = -799006030723822254L;
|
||||
|
||||
public BadElementException(Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
BadElementException() {}
|
||||
|
||||
public BadElementException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
|
||||
public class BaseColor {
|
||||
public static final BaseColor WHITE = new BaseColor(255, 255, 255);
|
||||
|
||||
public static final BaseColor LIGHT_GRAY = new BaseColor(192, 192, 192);
|
||||
|
||||
public static final BaseColor GRAY = new BaseColor(128, 128, 128);
|
||||
|
||||
public static final BaseColor DARK_GRAY = new BaseColor(64, 64, 64);
|
||||
|
||||
public static final BaseColor BLACK = new BaseColor(0, 0, 0);
|
||||
|
||||
public static final BaseColor RED = new BaseColor(255, 0, 0);
|
||||
|
||||
public static final BaseColor PINK = new BaseColor(255, 175, 175);
|
||||
|
||||
public static final BaseColor ORANGE = new BaseColor(255, 200, 0);
|
||||
|
||||
public static final BaseColor YELLOW = new BaseColor(255, 255, 0);
|
||||
|
||||
public static final BaseColor GREEN = new BaseColor(0, 255, 0);
|
||||
|
||||
public static final BaseColor MAGENTA = new BaseColor(255, 0, 255);
|
||||
|
||||
public static final BaseColor CYAN = new BaseColor(0, 255, 255);
|
||||
|
||||
public static final BaseColor BLUE = new BaseColor(0, 0, 255);
|
||||
|
||||
private static final double FACTOR = 0.7D;
|
||||
|
||||
private int value;
|
||||
|
||||
public BaseColor(int red, int green, int blue, int alpha) {
|
||||
setValue(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public BaseColor(int red, int green, int blue) {
|
||||
this(red, green, blue, 255);
|
||||
}
|
||||
|
||||
public BaseColor(float red, float green, float blue, float alpha) {
|
||||
this((int)((double)(red * 255.0F) + 0.5D), (int)((double)(green * 255.0F) + 0.5D), (int)((double)(blue * 255.0F) + 0.5D), (int)((double)(alpha * 255.0F) + 0.5D));
|
||||
}
|
||||
|
||||
public BaseColor(float red, float green, float blue) {
|
||||
this(red, green, blue, 1.0F);
|
||||
}
|
||||
|
||||
public BaseColor(int argb) {
|
||||
this.value = argb;
|
||||
}
|
||||
|
||||
public int getRGB() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int getRed() {
|
||||
return getRGB() >> 16 & 0xFF;
|
||||
}
|
||||
|
||||
public int getGreen() {
|
||||
return getRGB() >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
public int getBlue() {
|
||||
return getRGB() >> 0 & 0xFF;
|
||||
}
|
||||
|
||||
public int getAlpha() {
|
||||
return getRGB() >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
public BaseColor brighter() {
|
||||
int r = getRed();
|
||||
int g = getGreen();
|
||||
int b = getBlue();
|
||||
int i = 3;
|
||||
if (r == 0 && g == 0 && b == 0)
|
||||
return new BaseColor(i, i, i);
|
||||
if (r > 0 && r < i)
|
||||
r = i;
|
||||
if (g > 0 && g < i)
|
||||
g = i;
|
||||
if (b > 0 && b < i)
|
||||
b = i;
|
||||
return new BaseColor(Math.min((int)((double)r / 0.7D), 255),
|
||||
Math.min((int)((double)g / 0.7D), 255),
|
||||
Math.min((int)((double)b / 0.7D), 255));
|
||||
}
|
||||
|
||||
public BaseColor darker() {
|
||||
return new BaseColor(Math.max((int)((double)getRed() * 0.7D), 0),
|
||||
Math.max((int)((double)getGreen() * 0.7D), 0),
|
||||
Math.max((int)((double)getBlue() * 0.7D), 0));
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof BaseColor && ((BaseColor)obj).value == this.value);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
protected void setValue(int red, int green, int blue, int alpha) {
|
||||
validate(red);
|
||||
validate(green);
|
||||
validate(blue);
|
||||
validate(alpha);
|
||||
this.value = (alpha & 0xFF) << 24 | (red & 0xFF) << 16 | (green & 0xFF) << 8 | (blue & 0xFF) << 0;
|
||||
}
|
||||
|
||||
private static void validate(int value) {
|
||||
if (value < 0 || value > 255)
|
||||
throw new IllegalArgumentException(MessageLocalization.getComposedMessage("color.value.outside.range.0.255", new Object[0]));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Color value[" + Integer.toString(this.value, 16) + "]";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Chapter extends Section {
|
||||
private static final long serialVersionUID = 1791000695779357361L;
|
||||
|
||||
public Chapter(int number) {
|
||||
super(null, 1);
|
||||
this.numbers = new ArrayList<Integer>();
|
||||
this.numbers.add(Integer.valueOf(number));
|
||||
this.triggerNewPage = true;
|
||||
}
|
||||
|
||||
public Chapter(Paragraph title, int number) {
|
||||
super(title, 1);
|
||||
this.numbers = new ArrayList<Integer>();
|
||||
this.numbers.add(Integer.valueOf(number));
|
||||
this.triggerNewPage = true;
|
||||
}
|
||||
|
||||
public Chapter(String title, int number) {
|
||||
this(new Paragraph(title), number);
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
|
||||
public class ChapterAutoNumber extends Chapter {
|
||||
private static final long serialVersionUID = -9217457637987854167L;
|
||||
|
||||
protected boolean numberSet = false;
|
||||
|
||||
public ChapterAutoNumber(Paragraph para) {
|
||||
super(para, 0);
|
||||
}
|
||||
|
||||
public ChapterAutoNumber(String title) {
|
||||
super(title, 0);
|
||||
}
|
||||
|
||||
public Section addSection(String title) {
|
||||
if (isAddedCompletely())
|
||||
throw new IllegalStateException(MessageLocalization.getComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
|
||||
return addSection(title, 2);
|
||||
}
|
||||
|
||||
public Section addSection(Paragraph title) {
|
||||
if (isAddedCompletely())
|
||||
throw new IllegalStateException(MessageLocalization.getComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
|
||||
return addSection(title, 2);
|
||||
}
|
||||
|
||||
public int setAutomaticNumber(int number) {
|
||||
if (!this.numberSet) {
|
||||
number++;
|
||||
setChapterNumber(number);
|
||||
this.numberSet = true;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
}
|
||||
519
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Chunk.java
Normal file
519
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Chunk.java
Normal file
|
|
@ -0,0 +1,519 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.HyphenationEvent;
|
||||
import com.itextpdf.text.pdf.PdfAction;
|
||||
import com.itextpdf.text.pdf.PdfAnnotation;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.PdfString;
|
||||
import com.itextpdf.text.pdf.draw.DrawInterface;
|
||||
import com.itextpdf.text.pdf.interfaces.IAccessibleElement;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Chunk implements Element, IAccessibleElement {
|
||||
public static final String OBJECT_REPLACEMENT_CHARACTER = "";
|
||||
|
||||
public static final Chunk NEWLINE = new Chunk("\n");
|
||||
|
||||
static {
|
||||
NEWLINE.setRole(PdfName.P);
|
||||
}
|
||||
|
||||
public static final Chunk NEXTPAGE = new Chunk("");
|
||||
|
||||
static {
|
||||
NEXTPAGE.setNewPage();
|
||||
}
|
||||
|
||||
public static final Chunk TABBING = new Chunk(Float.NaN, false);
|
||||
|
||||
public static final Chunk SPACETABBING = new Chunk(Float.NaN, true);
|
||||
|
||||
protected StringBuffer content = null;
|
||||
|
||||
protected Font font = null;
|
||||
|
||||
protected HashMap<String, Object> attributes = null;
|
||||
|
||||
protected PdfName role = null;
|
||||
|
||||
protected HashMap<PdfName, PdfObject> accessibleAttributes = null;
|
||||
|
||||
private AccessibleElementId id = null;
|
||||
|
||||
public static final String SEPARATOR = "SEPARATOR";
|
||||
|
||||
public static final String TAB = "TAB";
|
||||
|
||||
public static final String TABSETTINGS = "TABSETTINGS";
|
||||
|
||||
public Chunk() {
|
||||
this.content = new StringBuffer();
|
||||
this.font = new Font();
|
||||
this.role = PdfName.SPAN;
|
||||
}
|
||||
|
||||
public Chunk(Chunk ck) {
|
||||
if (ck.content != null)
|
||||
this.content = new StringBuffer(ck.content.toString());
|
||||
if (ck.font != null)
|
||||
this.font = new Font(ck.font);
|
||||
if (ck.attributes != null)
|
||||
this.attributes = new HashMap<String, Object>(ck.attributes);
|
||||
this.role = ck.role;
|
||||
if (ck.accessibleAttributes != null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>(ck.accessibleAttributes);
|
||||
this.id = ck.getId();
|
||||
}
|
||||
|
||||
public Chunk(String content, Font font) {
|
||||
this.content = new StringBuffer(content);
|
||||
this.font = font;
|
||||
this.role = PdfName.SPAN;
|
||||
}
|
||||
|
||||
public Chunk(String content) {
|
||||
this(content, new Font());
|
||||
}
|
||||
|
||||
public Chunk(char c, Font font) {
|
||||
this.content = new StringBuffer();
|
||||
this.content.append(c);
|
||||
this.font = font;
|
||||
this.role = PdfName.SPAN;
|
||||
}
|
||||
|
||||
public Chunk(char c) {
|
||||
this(c, new Font());
|
||||
}
|
||||
|
||||
public Chunk(Image image, float offsetX, float offsetY) {
|
||||
this("", new Font());
|
||||
Image copyImage = Image.getInstance(image);
|
||||
copyImage.setAbsolutePosition(Float.NaN, Float.NaN);
|
||||
setAttribute("IMAGE", new Object[] { copyImage, new Float(offsetX), new Float(offsetY), Boolean.FALSE });
|
||||
this.role = null;
|
||||
}
|
||||
|
||||
public Chunk(DrawInterface separator) {
|
||||
this(separator, false);
|
||||
}
|
||||
|
||||
public Chunk(DrawInterface separator, boolean vertical) {
|
||||
this("", new Font());
|
||||
setAttribute("SEPARATOR", new Object[] { separator, vertical });
|
||||
this.role = null;
|
||||
}
|
||||
|
||||
private String contentWithNoTabs = null;
|
||||
|
||||
public static final String HSCALE = "HSCALE";
|
||||
|
||||
public static final String UNDERLINE = "UNDERLINE";
|
||||
|
||||
public static final String SUBSUPSCRIPT = "SUBSUPSCRIPT";
|
||||
|
||||
public static final String SKEW = "SKEW";
|
||||
|
||||
public static final String BACKGROUND = "BACKGROUND";
|
||||
|
||||
public static final String TEXTRENDERMODE = "TEXTRENDERMODE";
|
||||
|
||||
public static final String SPLITCHARACTER = "SPLITCHARACTER";
|
||||
|
||||
public static final String HYPHENATION = "HYPHENATION";
|
||||
|
||||
public static final String REMOTEGOTO = "REMOTEGOTO";
|
||||
|
||||
public static final String LOCALGOTO = "LOCALGOTO";
|
||||
|
||||
public static final String LOCALDESTINATION = "LOCALDESTINATION";
|
||||
|
||||
public static final String GENERICTAG = "GENERICTAG";
|
||||
|
||||
public static final String LINEHEIGHT = "LINEHEIGHT";
|
||||
|
||||
public static final String IMAGE = "IMAGE";
|
||||
|
||||
public static final String ACTION = "ACTION";
|
||||
|
||||
public static final String NEWPAGE = "NEWPAGE";
|
||||
|
||||
public static final String PDFANNOTATION = "PDFANNOTATION";
|
||||
|
||||
public static final String COLOR = "COLOR";
|
||||
|
||||
public static final String ENCODING = "ENCODING";
|
||||
|
||||
public static final String CHAR_SPACING = "CHAR_SPACING";
|
||||
|
||||
public static final String WORD_SPACING = "WORD_SPACING";
|
||||
|
||||
public static final String WHITESPACE = "WHITESPACE";
|
||||
|
||||
@Deprecated
|
||||
public Chunk(DrawInterface separator, float tabPosition) {
|
||||
this(separator, tabPosition, false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Chunk(DrawInterface separator, float tabPosition, boolean newline) {
|
||||
this("", new Font());
|
||||
if (tabPosition < 0.0F)
|
||||
throw new IllegalArgumentException(MessageLocalization.getComposedMessage("a.tab.position.may.not.be.lower.than.0.yours.is.1", String.valueOf(tabPosition)));
|
||||
setAttribute("TAB", new Object[] { separator, new Float(tabPosition), newline, new Float(0.0F) });
|
||||
this.role = PdfName.ARTIFACT;
|
||||
}
|
||||
|
||||
private Chunk(Float tabInterval, boolean isWhitespace) {
|
||||
this("", new Font());
|
||||
if (tabInterval < 0.0F)
|
||||
throw new IllegalArgumentException(MessageLocalization.getComposedMessage("a.tab.position.may.not.be.lower.than.0.yours.is.1", String.valueOf(tabInterval)));
|
||||
setAttribute("TAB", new Object[] { tabInterval, isWhitespace });
|
||||
setAttribute("SPLITCHARACTER", TabSplitCharacter.TAB);
|
||||
setAttribute("TABSETTINGS", null);
|
||||
this.role = PdfName.ARTIFACT;
|
||||
}
|
||||
|
||||
public Chunk(Image image, float offsetX, float offsetY, boolean changeLeading) {
|
||||
this("", new Font());
|
||||
setAttribute("IMAGE", new Object[] { image, new Float(offsetX), new Float(offsetY), changeLeading });
|
||||
this.role = PdfName.ARTIFACT;
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
return listener.add(this);
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
java.util.List<Chunk> tmp = new ArrayList<Chunk>();
|
||||
tmp.add(this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public StringBuffer append(String string) {
|
||||
this.contentWithNoTabs = null;
|
||||
return this.content.append(string);
|
||||
}
|
||||
|
||||
public void setFont(Font font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public Font getFont() {
|
||||
return this.font;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
if (this.contentWithNoTabs == null)
|
||||
this.contentWithNoTabs = this.content.toString().replaceAll("\t", "");
|
||||
return this.contentWithNoTabs;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getContent();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return (this.content.toString().trim().length() == 0 &&
|
||||
this.content.toString().indexOf("\n") == -1 && this.attributes == null);
|
||||
}
|
||||
|
||||
public float getWidthPoint() {
|
||||
if (getImage() != null)
|
||||
return getImage().getScaledWidth();
|
||||
return this.font.getCalculatedBaseFont(true).getWidthPoint(getContent(), this.font.getCalculatedSize()) * getHorizontalScaling();
|
||||
}
|
||||
|
||||
public boolean hasAttributes() {
|
||||
return (this.attributes != null && !this.attributes.isEmpty());
|
||||
}
|
||||
|
||||
public boolean hasAccessibleAttributes() {
|
||||
return (this.accessibleAttributes != null && !this.accessibleAttributes.isEmpty());
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(HashMap<String, Object> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
private Chunk setAttribute(String name, Object obj) {
|
||||
if (this.attributes == null)
|
||||
this.attributes = new HashMap<String, Object>();
|
||||
this.attributes.put(name, obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Chunk setHorizontalScaling(float scale) {
|
||||
return setAttribute("HSCALE", new Float(scale));
|
||||
}
|
||||
|
||||
public float getHorizontalScaling() {
|
||||
if (this.attributes == null)
|
||||
return 1.0F;
|
||||
Float f = (Float)this.attributes.get("HSCALE");
|
||||
if (f == null)
|
||||
return 1.0F;
|
||||
return f;
|
||||
}
|
||||
|
||||
public Chunk setUnderline(float thickness, float yPosition) {
|
||||
return setUnderline(null, thickness, 0.0F, yPosition, 0.0F, 0);
|
||||
}
|
||||
|
||||
public Chunk setUnderline(BaseColor color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int cap) {
|
||||
if (this.attributes == null)
|
||||
this.attributes = new HashMap<String, Object>();
|
||||
Object[] obj = { color, new float[] { thickness, thicknessMul, yPosition, yPositionMul, (float)cap } };
|
||||
Object[][] unders = Utilities.addToArray((Object[][])this.attributes.get("UNDERLINE"), obj);
|
||||
return setAttribute("UNDERLINE", unders);
|
||||
}
|
||||
|
||||
public Chunk setTextRise(float rise) {
|
||||
return setAttribute("SUBSUPSCRIPT", new Float(rise));
|
||||
}
|
||||
|
||||
public float getTextRise() {
|
||||
if (this.attributes != null && this.attributes.containsKey("SUBSUPSCRIPT")) {
|
||||
Float f = (Float)this.attributes.get("SUBSUPSCRIPT");
|
||||
return f;
|
||||
}
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public Chunk setSkew(float alpha, float beta) {
|
||||
alpha = (float)Math.tan((double)alpha * Math.PI / 180.0D);
|
||||
beta = (float)Math.tan((double)beta * Math.PI / 180.0D);
|
||||
return setAttribute("SKEW", new float[] { alpha, beta });
|
||||
}
|
||||
|
||||
public Chunk setBackground(BaseColor color) {
|
||||
return setBackground(color, 0.0F, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public Chunk setBackground(BaseColor color, float extraLeft, float extraBottom, float extraRight, float extraTop) {
|
||||
return setAttribute("BACKGROUND", new Object[] { color, new float[] { extraLeft, extraBottom, extraRight, extraTop } });
|
||||
}
|
||||
|
||||
public Chunk setTextRenderMode(int mode, float strokeWidth, BaseColor strokeColor) {
|
||||
return setAttribute("TEXTRENDERMODE", new Object[] { mode, new Float(strokeWidth), strokeColor });
|
||||
}
|
||||
|
||||
public Chunk setSplitCharacter(SplitCharacter splitCharacter) {
|
||||
return setAttribute("SPLITCHARACTER", splitCharacter);
|
||||
}
|
||||
|
||||
public Chunk setHyphenation(HyphenationEvent hyphenation) {
|
||||
return setAttribute("HYPHENATION", hyphenation);
|
||||
}
|
||||
|
||||
public Chunk setRemoteGoto(String filename, String name) {
|
||||
return setAttribute("REMOTEGOTO", new Object[] { filename, name });
|
||||
}
|
||||
|
||||
public Chunk setRemoteGoto(String filename, int page) {
|
||||
return setAttribute("REMOTEGOTO", new Object[] { filename, page });
|
||||
}
|
||||
|
||||
public Chunk setLocalGoto(String name) {
|
||||
return setAttribute("LOCALGOTO", name);
|
||||
}
|
||||
|
||||
public Chunk setLocalDestination(String name) {
|
||||
return setAttribute("LOCALDESTINATION", name);
|
||||
}
|
||||
|
||||
public Chunk setGenericTag(String text) {
|
||||
return setAttribute("GENERICTAG", text);
|
||||
}
|
||||
|
||||
public Chunk setLineHeight(float lineheight) {
|
||||
return setAttribute("LINEHEIGHT", Float.valueOf(lineheight));
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
if (this.attributes == null)
|
||||
return null;
|
||||
Object[] obj = (Object[])this.attributes.get("IMAGE");
|
||||
if (obj == null)
|
||||
return null;
|
||||
return (Image)obj[0];
|
||||
}
|
||||
|
||||
public Chunk setAction(PdfAction action) {
|
||||
setRole(PdfName.LINK);
|
||||
return setAttribute("ACTION", action);
|
||||
}
|
||||
|
||||
public Chunk setAnchor(URL url) {
|
||||
setRole(PdfName.LINK);
|
||||
String urlStr = url.toExternalForm();
|
||||
setAccessibleAttribute(PdfName.ALT, new PdfString(urlStr));
|
||||
return setAttribute("ACTION", new PdfAction(urlStr));
|
||||
}
|
||||
|
||||
public Chunk setAnchor(String url) {
|
||||
setRole(PdfName.LINK);
|
||||
setAccessibleAttribute(PdfName.ALT, new PdfString(url));
|
||||
return setAttribute("ACTION", new PdfAction(url));
|
||||
}
|
||||
|
||||
public Chunk setNewPage() {
|
||||
return setAttribute("NEWPAGE", null);
|
||||
}
|
||||
|
||||
public Chunk setAnnotation(PdfAnnotation annotation) {
|
||||
return setAttribute("PDFANNOTATION", annotation);
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public HyphenationEvent getHyphenation() {
|
||||
if (this.attributes == null)
|
||||
return null;
|
||||
return (HyphenationEvent)this.attributes.get("HYPHENATION");
|
||||
}
|
||||
|
||||
public Chunk setCharacterSpacing(float charSpace) {
|
||||
return setAttribute("CHAR_SPACING", new Float(charSpace));
|
||||
}
|
||||
|
||||
public float getCharacterSpacing() {
|
||||
if (this.attributes != null && this.attributes.containsKey("CHAR_SPACING")) {
|
||||
Float f = (Float)this.attributes.get("CHAR_SPACING");
|
||||
return f;
|
||||
}
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public Chunk setWordSpacing(float wordSpace) {
|
||||
return setAttribute("WORD_SPACING", new Float(wordSpace));
|
||||
}
|
||||
|
||||
public float getWordSpacing() {
|
||||
if (this.attributes != null && this.attributes.containsKey("WORD_SPACING")) {
|
||||
Float f = (Float)this.attributes.get("WORD_SPACING");
|
||||
return f;
|
||||
}
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public static Chunk createWhitespace(String content) {
|
||||
return createWhitespace(content, false);
|
||||
}
|
||||
|
||||
public static Chunk createWhitespace(String content, boolean preserve) {
|
||||
Chunk whitespace = null;
|
||||
if (!preserve) {
|
||||
whitespace = new Chunk(' ');
|
||||
whitespace.setAttribute("WHITESPACE", content);
|
||||
} else {
|
||||
whitespace = new Chunk(content);
|
||||
}
|
||||
return whitespace;
|
||||
}
|
||||
|
||||
public boolean isWhitespace() {
|
||||
return (this.attributes != null && this.attributes.containsKey("WHITESPACE"));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Chunk createTabspace() {
|
||||
return createTabspace(60.0F);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Chunk createTabspace(float spacing) {
|
||||
Chunk tabspace = new Chunk(spacing, true);
|
||||
return tabspace;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isTabspace() {
|
||||
return (this.attributes != null && this.attributes.containsKey("TAB"));
|
||||
}
|
||||
|
||||
public PdfObject getAccessibleAttribute(PdfName key) {
|
||||
if (getImage() != null)
|
||||
return getImage().getAccessibleAttribute(key);
|
||||
if (this.accessibleAttributes != null)
|
||||
return this.accessibleAttributes.get(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAccessibleAttribute(PdfName key, PdfObject value) {
|
||||
if (getImage() != null) {
|
||||
getImage().setAccessibleAttribute(key, value);
|
||||
} else {
|
||||
if (this.accessibleAttributes == null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>();
|
||||
this.accessibleAttributes.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<PdfName, PdfObject> getAccessibleAttributes() {
|
||||
if (getImage() != null)
|
||||
return getImage().getAccessibleAttributes();
|
||||
return this.accessibleAttributes;
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
if (getImage() != null)
|
||||
return getImage().getRole();
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
if (getImage() != null) {
|
||||
getImage().setRole(role);
|
||||
} else {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
|
||||
public AccessibleElementId getId() {
|
||||
if (this.id == null)
|
||||
this.id = new AccessibleElementId();
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AccessibleElementId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getTextExpansion() {
|
||||
PdfObject o = getAccessibleAttribute(PdfName.E);
|
||||
if (o instanceof PdfString)
|
||||
return ((PdfString)o).toUnicodeString();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTextExpansion(String value) {
|
||||
setAccessibleAttribute(PdfName.E, new PdfString(value));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public interface DocListener extends ElementListener {
|
||||
void open();
|
||||
|
||||
void close();
|
||||
|
||||
boolean newPage();
|
||||
|
||||
boolean setPageSize(Rectangle paramRectangle);
|
||||
|
||||
boolean setMargins(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4);
|
||||
|
||||
boolean setMarginMirroring(boolean paramBoolean);
|
||||
|
||||
boolean setMarginMirroringTopBottom(boolean paramBoolean);
|
||||
|
||||
void setPageCount(int paramInt);
|
||||
|
||||
void resetPageCount();
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.OutputStreamCounter;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class DocWriter implements DocListener {
|
||||
public static final byte NEWLINE = 10;
|
||||
|
||||
public static final byte TAB = 9;
|
||||
|
||||
public static final byte LT = 60;
|
||||
|
||||
public static final byte SPACE = 32;
|
||||
|
||||
public static final byte EQUALS = 61;
|
||||
|
||||
public static final byte QUOTE = 34;
|
||||
|
||||
public static final byte GT = 62;
|
||||
|
||||
public static final byte FORWARD = 47;
|
||||
|
||||
protected Rectangle pageSize;
|
||||
|
||||
protected Document document;
|
||||
|
||||
protected OutputStreamCounter os;
|
||||
|
||||
protected boolean open = false;
|
||||
|
||||
protected boolean pause = false;
|
||||
|
||||
protected boolean closeStream = true;
|
||||
|
||||
protected DocWriter() {}
|
||||
|
||||
protected DocWriter(Document document, OutputStream os) {
|
||||
this.document = document;
|
||||
this.os = new OutputStreamCounter(new BufferedOutputStream(os));
|
||||
}
|
||||
|
||||
public boolean add(Element element) throws DocumentException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void open() {
|
||||
this.open = true;
|
||||
}
|
||||
|
||||
public boolean setPageSize(Rectangle pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean newPage() {
|
||||
if (!this.open)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetPageCount() {}
|
||||
|
||||
public void setPageCount(int pageN) {}
|
||||
|
||||
public void close() {
|
||||
this.open = false;
|
||||
try {
|
||||
this.os.flush();
|
||||
if (this.closeStream)
|
||||
this.os.close();
|
||||
} catch (IOException ioe) {
|
||||
throw new ExceptionConverter(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte[] getISOBytes(String text) {
|
||||
if (text == null)
|
||||
return null;
|
||||
int len = text.length();
|
||||
byte[] b = new byte[len];
|
||||
for (int k = 0; k < len; k++)
|
||||
b[k] = (byte)text.charAt(k);
|
||||
return b;
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
this.pause = true;
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return this.pause;
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
this.pause = false;
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
try {
|
||||
this.os.flush();
|
||||
} catch (IOException ioe) {
|
||||
throw new ExceptionConverter(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
protected void write(String string) throws IOException {
|
||||
this.os.write(getISOBytes(string));
|
||||
}
|
||||
|
||||
protected void addTabs(int indent) throws IOException {
|
||||
this.os.write(10);
|
||||
for (int i = 0; i < indent; i++)
|
||||
this.os.write(9);
|
||||
}
|
||||
|
||||
protected void write(String key, String value) throws IOException {
|
||||
this.os.write(32);
|
||||
write(key);
|
||||
this.os.write(61);
|
||||
this.os.write(34);
|
||||
write(value);
|
||||
this.os.write(34);
|
||||
}
|
||||
|
||||
protected void writeStart(String tag) throws IOException {
|
||||
this.os.write(60);
|
||||
write(tag);
|
||||
}
|
||||
|
||||
protected void writeEnd(String tag) throws IOException {
|
||||
this.os.write(60);
|
||||
this.os.write(47);
|
||||
write(tag);
|
||||
this.os.write(62);
|
||||
}
|
||||
|
||||
protected void writeEnd() throws IOException {
|
||||
this.os.write(32);
|
||||
this.os.write(47);
|
||||
this.os.write(62);
|
||||
}
|
||||
|
||||
protected boolean writeMarkupAttributes(Properties markup) throws IOException {
|
||||
if (markup == null)
|
||||
return false;
|
||||
Iterator<Object> attributeIterator = markup.keySet().iterator();
|
||||
while (attributeIterator.hasNext()) {
|
||||
String name = String.valueOf(attributeIterator.next());
|
||||
write(name, markup.getProperty(name));
|
||||
}
|
||||
markup.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCloseStream() {
|
||||
return this.closeStream;
|
||||
}
|
||||
|
||||
public void setCloseStream(boolean closeStream) {
|
||||
this.closeStream = closeStream;
|
||||
}
|
||||
|
||||
public boolean setMarginMirroring(boolean MarginMirroring) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setMarginMirroringTopBottom(boolean MarginMirroring) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,375 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.interfaces.IAccessibleElement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Document implements DocListener, IAccessibleElement {
|
||||
public static boolean compress = true;
|
||||
|
||||
public static boolean plainRandomAccess = false;
|
||||
|
||||
public static float wmfFontCorrection = 0.86F;
|
||||
|
||||
protected ArrayList<DocListener> listeners = new ArrayList<DocListener>();
|
||||
|
||||
protected boolean open;
|
||||
|
||||
protected boolean close;
|
||||
|
||||
protected Rectangle pageSize;
|
||||
|
||||
protected float marginLeft = 0.0F;
|
||||
|
||||
protected float marginRight = 0.0F;
|
||||
|
||||
protected float marginTop = 0.0F;
|
||||
|
||||
protected float marginBottom = 0.0F;
|
||||
|
||||
protected boolean marginMirroring = false;
|
||||
|
||||
protected boolean marginMirroringTopBottom = false;
|
||||
|
||||
protected String javaScript_onLoad = null;
|
||||
|
||||
protected String javaScript_onUnLoad = null;
|
||||
|
||||
protected String htmlStyleClass = null;
|
||||
|
||||
protected int pageN = 0;
|
||||
|
||||
protected int chapternumber = 0;
|
||||
|
||||
protected PdfName role = PdfName.DOCUMENT;
|
||||
|
||||
protected HashMap<PdfName, PdfObject> accessibleAttributes = null;
|
||||
|
||||
protected AccessibleElementId id = new AccessibleElementId();
|
||||
|
||||
public Document() {
|
||||
this(PageSize.A4);
|
||||
}
|
||||
|
||||
public Document(Rectangle pageSize) {
|
||||
this(pageSize, 36.0F, 36.0F, 36.0F, 36.0F);
|
||||
}
|
||||
|
||||
public Document(Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom) {
|
||||
this.pageSize = pageSize;
|
||||
this.marginLeft = marginLeft;
|
||||
this.marginRight = marginRight;
|
||||
this.marginTop = marginTop;
|
||||
this.marginBottom = marginBottom;
|
||||
}
|
||||
|
||||
public void addDocListener(DocListener listener) {
|
||||
this.listeners.add(listener);
|
||||
if (listener instanceof IAccessibleElement) {
|
||||
IAccessibleElement ae = (IAccessibleElement)listener;
|
||||
ae.setRole(this.role);
|
||||
ae.setId(this.id);
|
||||
if (this.accessibleAttributes != null)
|
||||
for (PdfName key : this.accessibleAttributes.keySet())
|
||||
ae.setAccessibleAttribute(key, this.accessibleAttributes.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDocListener(DocListener listener) {
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
public boolean add(Element element) throws DocumentException {
|
||||
if (this.close)
|
||||
throw new DocumentException(MessageLocalization.getComposedMessage("the.document.has.been.closed.you.can.t.add.any.elements"));
|
||||
if (!this.open && element.isContent())
|
||||
throw new DocumentException(MessageLocalization.getComposedMessage("the.document.is.not.open.yet.you.can.only.add.meta.information"));
|
||||
boolean success = false;
|
||||
if (element instanceof ChapterAutoNumber)
|
||||
this.chapternumber = ((ChapterAutoNumber)element).setAutomaticNumber(this.chapternumber);
|
||||
for (DocListener listener : this.listeners)
|
||||
success |= listener.add(element);
|
||||
if (element instanceof LargeElement) {
|
||||
LargeElement e = (LargeElement)element;
|
||||
if (!e.isComplete())
|
||||
e.flushContent();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public void open() {
|
||||
if (!this.close)
|
||||
this.open = true;
|
||||
for (DocListener listener : this.listeners) {
|
||||
listener.setPageSize(this.pageSize);
|
||||
listener.setMargins(this.marginLeft, this.marginRight, this.marginTop, this.marginBottom);
|
||||
listener.open();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setPageSize(Rectangle pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
for (DocListener listener : this.listeners)
|
||||
listener.setPageSize(pageSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) {
|
||||
this.marginLeft = marginLeft;
|
||||
this.marginRight = marginRight;
|
||||
this.marginTop = marginTop;
|
||||
this.marginBottom = marginBottom;
|
||||
for (DocListener listener : this.listeners)
|
||||
listener.setMargins(marginLeft, marginRight, marginTop, marginBottom);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean newPage() {
|
||||
if (!this.open || this.close)
|
||||
return false;
|
||||
for (DocListener listener : this.listeners)
|
||||
listener.newPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetPageCount() {
|
||||
this.pageN = 0;
|
||||
for (DocListener listener : this.listeners)
|
||||
listener.resetPageCount();
|
||||
}
|
||||
|
||||
public void setPageCount(int pageN) {
|
||||
this.pageN = pageN;
|
||||
for (DocListener listener : this.listeners)
|
||||
listener.setPageCount(pageN);
|
||||
}
|
||||
|
||||
public int getPageNumber() {
|
||||
return this.pageN;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (!this.close) {
|
||||
this.open = false;
|
||||
this.close = true;
|
||||
}
|
||||
for (DocListener listener : this.listeners)
|
||||
listener.close();
|
||||
}
|
||||
|
||||
public boolean addHeader(String name, String content) {
|
||||
try {
|
||||
return add(new Header(name, content));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addTitle(String title) {
|
||||
try {
|
||||
return add(new Meta(1, title));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addSubject(String subject) {
|
||||
try {
|
||||
return add(new Meta(2, subject));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addKeywords(String keywords) {
|
||||
try {
|
||||
return add(new Meta(3, keywords));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAuthor(String author) {
|
||||
try {
|
||||
return add(new Meta(4, author));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addCreator(String creator) {
|
||||
try {
|
||||
return add(new Meta(7, creator));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addProducer() {
|
||||
try {
|
||||
return add(new Meta(5, Version.getInstance().getVersion()));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addLanguage(String language) {
|
||||
try {
|
||||
return add(new Meta(8, language));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addCreationDate() {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
|
||||
return add(new Meta(6, sdf.format(new Date())));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
}
|
||||
}
|
||||
|
||||
public float leftMargin() {
|
||||
return this.marginLeft;
|
||||
}
|
||||
|
||||
public float rightMargin() {
|
||||
return this.marginRight;
|
||||
}
|
||||
|
||||
public float topMargin() {
|
||||
return this.marginTop;
|
||||
}
|
||||
|
||||
public float bottomMargin() {
|
||||
return this.marginBottom;
|
||||
}
|
||||
|
||||
public float left() {
|
||||
return this.pageSize.getLeft(this.marginLeft);
|
||||
}
|
||||
|
||||
public float right() {
|
||||
return this.pageSize.getRight(this.marginRight);
|
||||
}
|
||||
|
||||
public float top() {
|
||||
return this.pageSize.getTop(this.marginTop);
|
||||
}
|
||||
|
||||
public float bottom() {
|
||||
return this.pageSize.getBottom(this.marginBottom);
|
||||
}
|
||||
|
||||
public float left(float margin) {
|
||||
return this.pageSize.getLeft(this.marginLeft + margin);
|
||||
}
|
||||
|
||||
public float right(float margin) {
|
||||
return this.pageSize.getRight(this.marginRight + margin);
|
||||
}
|
||||
|
||||
public float top(float margin) {
|
||||
return this.pageSize.getTop(this.marginTop + margin);
|
||||
}
|
||||
|
||||
public float bottom(float margin) {
|
||||
return this.pageSize.getBottom(this.marginBottom + margin);
|
||||
}
|
||||
|
||||
public Rectangle getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return this.open;
|
||||
}
|
||||
|
||||
public void setJavaScript_onLoad(String code) {
|
||||
this.javaScript_onLoad = code;
|
||||
}
|
||||
|
||||
public String getJavaScript_onLoad() {
|
||||
return this.javaScript_onLoad;
|
||||
}
|
||||
|
||||
public void setJavaScript_onUnLoad(String code) {
|
||||
this.javaScript_onUnLoad = code;
|
||||
}
|
||||
|
||||
public String getJavaScript_onUnLoad() {
|
||||
return this.javaScript_onUnLoad;
|
||||
}
|
||||
|
||||
public void setHtmlStyleClass(String htmlStyleClass) {
|
||||
this.htmlStyleClass = htmlStyleClass;
|
||||
}
|
||||
|
||||
public String getHtmlStyleClass() {
|
||||
return this.htmlStyleClass;
|
||||
}
|
||||
|
||||
public boolean setMarginMirroring(boolean marginMirroring) {
|
||||
this.marginMirroring = marginMirroring;
|
||||
for (DocListener element : this.listeners) {
|
||||
DocListener listener = element;
|
||||
listener.setMarginMirroring(marginMirroring);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMarginMirroringTopBottom(boolean marginMirroringTopBottom) {
|
||||
this.marginMirroringTopBottom = marginMirroringTopBottom;
|
||||
for (DocListener element : this.listeners) {
|
||||
DocListener listener = element;
|
||||
listener.setMarginMirroringTopBottom(marginMirroringTopBottom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isMarginMirroring() {
|
||||
return this.marginMirroring;
|
||||
}
|
||||
|
||||
public PdfObject getAccessibleAttribute(PdfName key) {
|
||||
if (this.accessibleAttributes != null)
|
||||
return this.accessibleAttributes.get(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAccessibleAttribute(PdfName key, PdfObject value) {
|
||||
if (this.accessibleAttributes == null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>();
|
||||
this.accessibleAttributes.put(key, value);
|
||||
}
|
||||
|
||||
public HashMap<PdfName, PdfObject> getAccessibleAttributes() {
|
||||
return this.accessibleAttributes;
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public AccessibleElementId getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AccessibleElementId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public class DocumentException extends Exception {
|
||||
private static final long serialVersionUID = -2191131489390840739L;
|
||||
|
||||
public DocumentException(Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
public DocumentException() {}
|
||||
|
||||
public DocumentException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DocumentException(String message, Exception ex) {
|
||||
super(message, ex);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public interface Element {
|
||||
public static final int HEADER = 0;
|
||||
|
||||
public static final int TITLE = 1;
|
||||
|
||||
public static final int SUBJECT = 2;
|
||||
|
||||
public static final int KEYWORDS = 3;
|
||||
|
||||
public static final int AUTHOR = 4;
|
||||
|
||||
public static final int PRODUCER = 5;
|
||||
|
||||
public static final int CREATIONDATE = 6;
|
||||
|
||||
public static final int CREATOR = 7;
|
||||
|
||||
public static final int LANGUAGE = 8;
|
||||
|
||||
public static final int CHUNK = 10;
|
||||
|
||||
public static final int PHRASE = 11;
|
||||
|
||||
public static final int PARAGRAPH = 12;
|
||||
|
||||
public static final int SECTION = 13;
|
||||
|
||||
public static final int LIST = 14;
|
||||
|
||||
public static final int LISTITEM = 15;
|
||||
|
||||
public static final int CHAPTER = 16;
|
||||
|
||||
public static final int ANCHOR = 17;
|
||||
|
||||
public static final int PTABLE = 23;
|
||||
|
||||
public static final int ANNOTATION = 29;
|
||||
|
||||
public static final int RECTANGLE = 30;
|
||||
|
||||
public static final int JPEG = 32;
|
||||
|
||||
public static final int JPEG2000 = 33;
|
||||
|
||||
public static final int IMGRAW = 34;
|
||||
|
||||
public static final int IMGTEMPLATE = 35;
|
||||
|
||||
public static final int JBIG2 = 36;
|
||||
|
||||
public static final int DIV = 37;
|
||||
|
||||
public static final int BODY = 38;
|
||||
|
||||
public static final int MARKED = 50;
|
||||
|
||||
public static final int YMARK = 55;
|
||||
|
||||
public static final int WRITABLE_DIRECT = 666;
|
||||
|
||||
public static final int ALIGN_UNDEFINED = -1;
|
||||
|
||||
public static final int ALIGN_LEFT = 0;
|
||||
|
||||
public static final int ALIGN_CENTER = 1;
|
||||
|
||||
public static final int ALIGN_RIGHT = 2;
|
||||
|
||||
public static final int ALIGN_JUSTIFIED = 3;
|
||||
|
||||
public static final int ALIGN_TOP = 4;
|
||||
|
||||
public static final int ALIGN_MIDDLE = 5;
|
||||
|
||||
public static final int ALIGN_BOTTOM = 6;
|
||||
|
||||
public static final int ALIGN_BASELINE = 7;
|
||||
|
||||
public static final int ALIGN_JUSTIFIED_ALL = 8;
|
||||
|
||||
public static final int CCITTG4 = 256;
|
||||
|
||||
public static final int CCITTG3_1D = 257;
|
||||
|
||||
public static final int CCITTG3_2D = 258;
|
||||
|
||||
public static final int CCITT_BLACKIS1 = 1;
|
||||
|
||||
public static final int CCITT_ENCODEDBYTEALIGN = 2;
|
||||
|
||||
public static final int CCITT_ENDOFLINE = 4;
|
||||
|
||||
public static final int CCITT_ENDOFBLOCK = 8;
|
||||
|
||||
boolean process(ElementListener paramElementListener);
|
||||
|
||||
int type();
|
||||
|
||||
boolean isContent();
|
||||
|
||||
boolean isNestable();
|
||||
|
||||
java.util.List<Chunk> getChunks();
|
||||
|
||||
String toString();
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface ElementListener extends EventListener {
|
||||
boolean add(Element paramElement) throws DocumentException;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class ExceptionConverter extends RuntimeException {
|
||||
private static final long serialVersionUID = 8657630363395849399L;
|
||||
|
||||
private Exception ex;
|
||||
|
||||
private String prefix;
|
||||
|
||||
public ExceptionConverter(Exception ex) {
|
||||
super(ex);
|
||||
this.ex = ex;
|
||||
this.prefix = (ex instanceof RuntimeException) ? "" : "ExceptionConverter: ";
|
||||
}
|
||||
|
||||
public static final RuntimeException convertException(Exception ex) {
|
||||
if (ex instanceof RuntimeException)
|
||||
return (RuntimeException)ex;
|
||||
return new ExceptionConverter(ex);
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return this.ex;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.ex.getMessage();
|
||||
}
|
||||
|
||||
public String getLocalizedMessage() {
|
||||
return this.ex.getLocalizedMessage();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.prefix + this.ex;
|
||||
}
|
||||
|
||||
public void printStackTrace() {
|
||||
printStackTrace(System.err);
|
||||
}
|
||||
|
||||
public void printStackTrace(PrintStream s) {
|
||||
synchronized (s) {
|
||||
s.print(this.prefix);
|
||||
this.ex.printStackTrace(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
synchronized (s) {
|
||||
s.print(this.prefix);
|
||||
this.ex.printStackTrace(s);
|
||||
}
|
||||
}
|
||||
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
388
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Font.java
Normal file
388
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Font.java
Normal file
|
|
@ -0,0 +1,388 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
|
||||
public class Font implements Comparable<Font> {
|
||||
public static final int NORMAL = 0;
|
||||
|
||||
public static final int BOLD = 1;
|
||||
|
||||
public static final int ITALIC = 2;
|
||||
|
||||
public static final int UNDERLINE = 4;
|
||||
|
||||
public static final int STRIKETHRU = 8;
|
||||
|
||||
public static final int BOLDITALIC = 3;
|
||||
|
||||
public static final int UNDEFINED = -1;
|
||||
|
||||
public static final int DEFAULTSIZE = 12;
|
||||
|
||||
public enum FontFamily {
|
||||
COURIER, HELVETICA, TIMES_ROMAN, SYMBOL, ZAPFDINGBATS, UNDEFINED;
|
||||
}
|
||||
|
||||
public enum FontStyle {
|
||||
NORMAL("normal"),
|
||||
BOLD("bold"),
|
||||
ITALIC("italic"),
|
||||
OBLIQUE("oblique"),
|
||||
UNDERLINE("underline"),
|
||||
LINETHROUGH("line-through");
|
||||
|
||||
private String code;
|
||||
|
||||
FontStyle(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.code;
|
||||
}
|
||||
}
|
||||
|
||||
private FontFamily family = FontFamily.UNDEFINED;
|
||||
|
||||
private float size = -1.0F;
|
||||
|
||||
private int style = -1;
|
||||
|
||||
private BaseColor color = null;
|
||||
|
||||
private BaseFont baseFont = null;
|
||||
|
||||
public Font(Font other) {
|
||||
this.family = other.family;
|
||||
this.size = other.size;
|
||||
this.style = other.style;
|
||||
this.color = other.color;
|
||||
this.baseFont = other.baseFont;
|
||||
}
|
||||
|
||||
public Font(FontFamily family, float size, int style, BaseColor color) {
|
||||
this.family = family;
|
||||
this.size = size;
|
||||
this.style = style;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Font(BaseFont bf, float size, int style, BaseColor color) {
|
||||
this.baseFont = bf;
|
||||
this.size = size;
|
||||
this.style = style;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Font(BaseFont bf, float size, int style) {
|
||||
this(bf, size, style, null);
|
||||
}
|
||||
|
||||
public Font(BaseFont bf, float size) {
|
||||
this(bf, size, -1, null);
|
||||
}
|
||||
|
||||
public Font(BaseFont bf) {
|
||||
this(bf, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public Font(FontFamily family, float size, int style) {
|
||||
this(family, size, style, null);
|
||||
}
|
||||
|
||||
public Font(FontFamily family, float size) {
|
||||
this(family, size, -1, null);
|
||||
}
|
||||
|
||||
public Font(FontFamily family) {
|
||||
this(family, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public Font() {
|
||||
this(FontFamily.UNDEFINED, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public int compareTo(Font font) {
|
||||
if (font == null)
|
||||
return -1;
|
||||
try {
|
||||
if (this.baseFont != null && !this.baseFont.equals(font.getBaseFont()))
|
||||
return -2;
|
||||
if (this.family != font.getFamily())
|
||||
return 1;
|
||||
if (this.size != font.getSize())
|
||||
return 2;
|
||||
if (this.style != font.getStyle())
|
||||
return 3;
|
||||
if (this.color == null) {
|
||||
if (font.color == null)
|
||||
return 0;
|
||||
return 4;
|
||||
}
|
||||
if (font.color == null)
|
||||
return 4;
|
||||
if (this.color.equals(font.getColor()))
|
||||
return 0;
|
||||
return 4;
|
||||
} catch (ClassCastException cce) {
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
public FontFamily getFamily() {
|
||||
return this.family;
|
||||
}
|
||||
|
||||
public String getFamilyname() {
|
||||
String tmp = "unknown";
|
||||
switch (getFamily()) {
|
||||
case COURIER:
|
||||
return "Courier";
|
||||
case HELVETICA:
|
||||
return "Helvetica";
|
||||
case TIMES_ROMAN:
|
||||
return "Times-Roman";
|
||||
case SYMBOL:
|
||||
return "Symbol";
|
||||
case ZAPFDINGBATS:
|
||||
return "ZapfDingbats";
|
||||
}
|
||||
if (this.baseFont != null) {
|
||||
String[][] names = this.baseFont.getFamilyFontName();
|
||||
for (String[] name : names) {
|
||||
if ("0".equals(name[2]))
|
||||
return name[3];
|
||||
if ("1033".equals(name[2]))
|
||||
tmp = name[3];
|
||||
if ("".equals(name[2]))
|
||||
tmp = name[3];
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void setFamily(String family) {
|
||||
this.family = getFamily(family);
|
||||
}
|
||||
|
||||
public static FontFamily getFamily(String family) {
|
||||
if (family.equalsIgnoreCase("Courier"))
|
||||
return FontFamily.COURIER;
|
||||
if (family.equalsIgnoreCase("Helvetica"))
|
||||
return FontFamily.HELVETICA;
|
||||
if (family.equalsIgnoreCase("Times-Roman"))
|
||||
return FontFamily.TIMES_ROMAN;
|
||||
if (family.equalsIgnoreCase("Symbol"))
|
||||
return FontFamily.SYMBOL;
|
||||
if (family.equalsIgnoreCase("ZapfDingbats"))
|
||||
return FontFamily.ZAPFDINGBATS;
|
||||
return FontFamily.UNDEFINED;
|
||||
}
|
||||
|
||||
public float getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public float getCalculatedSize() {
|
||||
float s = this.size;
|
||||
if (s == -1.0F)
|
||||
s = 12.0F;
|
||||
return s;
|
||||
}
|
||||
|
||||
public float getCalculatedLeading(float multipliedLeading) {
|
||||
return multipliedLeading * getCalculatedSize();
|
||||
}
|
||||
|
||||
public void setSize(float size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public int getStyle() {
|
||||
return this.style;
|
||||
}
|
||||
|
||||
public int getCalculatedStyle() {
|
||||
int style = this.style;
|
||||
if (style == -1)
|
||||
style = 0;
|
||||
if (this.baseFont != null)
|
||||
return style;
|
||||
if (this.family == FontFamily.SYMBOL || this.family == FontFamily.ZAPFDINGBATS)
|
||||
return style;
|
||||
return style & 0xFFFFFFFC;
|
||||
}
|
||||
|
||||
public boolean isBold() {
|
||||
if (this.style == -1)
|
||||
return false;
|
||||
return ((this.style & 0x1) == 1);
|
||||
}
|
||||
|
||||
public boolean isItalic() {
|
||||
if (this.style == -1)
|
||||
return false;
|
||||
return ((this.style & 0x2) == 2);
|
||||
}
|
||||
|
||||
public boolean isUnderlined() {
|
||||
if (this.style == -1)
|
||||
return false;
|
||||
return ((this.style & 0x4) == 4);
|
||||
}
|
||||
|
||||
public boolean isStrikethru() {
|
||||
if (this.style == -1)
|
||||
return false;
|
||||
return ((this.style & 0x8) == 8);
|
||||
}
|
||||
|
||||
public void setStyle(int style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public void setStyle(String style) {
|
||||
if (this.style == -1)
|
||||
this.style = 0;
|
||||
this.style |= getStyleValue(style);
|
||||
}
|
||||
|
||||
public static int getStyleValue(String style) {
|
||||
int s = 0;
|
||||
if (style.indexOf(FontStyle.NORMAL.getValue()) != -1)
|
||||
s |= 0x0;
|
||||
if (style.indexOf(FontStyle.BOLD.getValue()) != -1)
|
||||
s |= 0x1;
|
||||
if (style.indexOf(FontStyle.ITALIC.getValue()) != -1)
|
||||
s |= 0x2;
|
||||
if (style.indexOf(FontStyle.OBLIQUE.getValue()) != -1)
|
||||
s |= 0x2;
|
||||
if (style.indexOf(FontStyle.UNDERLINE.getValue()) != -1)
|
||||
s |= 0x4;
|
||||
if (style.indexOf(FontStyle.LINETHROUGH.getValue()) != -1)
|
||||
s |= 0x8;
|
||||
return s;
|
||||
}
|
||||
|
||||
public BaseColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setColor(BaseColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setColor(int red, int green, int blue) {
|
||||
this.color = new BaseColor(red, green, blue);
|
||||
}
|
||||
|
||||
public BaseFont getBaseFont() {
|
||||
return this.baseFont;
|
||||
}
|
||||
|
||||
public BaseFont getCalculatedBaseFont(boolean specialEncoding) {
|
||||
if (this.baseFont != null)
|
||||
return this.baseFont;
|
||||
int style = this.style;
|
||||
if (style == -1)
|
||||
style = 0;
|
||||
String fontName = "Helvetica";
|
||||
String encoding = "Cp1252";
|
||||
BaseFont cfont = null;
|
||||
switch (this.family) {
|
||||
case COURIER:
|
||||
switch (style & 0x3) {
|
||||
case 1:
|
||||
fontName = "Courier-Bold";
|
||||
break;
|
||||
case 2:
|
||||
fontName = "Courier-Oblique";
|
||||
break;
|
||||
case 3:
|
||||
fontName = "Courier-BoldOblique";
|
||||
break;
|
||||
}
|
||||
fontName = "Courier";
|
||||
break;
|
||||
case TIMES_ROMAN:
|
||||
switch (style & 0x3) {
|
||||
case 1:
|
||||
fontName = "Times-Bold";
|
||||
break;
|
||||
case 2:
|
||||
fontName = "Times-Italic";
|
||||
break;
|
||||
case 3:
|
||||
fontName = "Times-BoldItalic";
|
||||
break;
|
||||
}
|
||||
fontName = "Times-Roman";
|
||||
break;
|
||||
case SYMBOL:
|
||||
fontName = "Symbol";
|
||||
if (specialEncoding)
|
||||
encoding = "Symbol";
|
||||
break;
|
||||
case ZAPFDINGBATS:
|
||||
fontName = "ZapfDingbats";
|
||||
if (specialEncoding)
|
||||
encoding = "ZapfDingbats";
|
||||
break;
|
||||
default:
|
||||
switch (style & 0x3) {
|
||||
case 1:
|
||||
fontName = "Helvetica-Bold";
|
||||
break;
|
||||
case 2:
|
||||
fontName = "Helvetica-Oblique";
|
||||
break;
|
||||
case 3:
|
||||
fontName = "Helvetica-BoldOblique";
|
||||
break;
|
||||
}
|
||||
fontName = "Helvetica";
|
||||
break;
|
||||
}
|
||||
try {
|
||||
cfont = BaseFont.createFont(fontName, encoding, false);
|
||||
} catch (Exception ee) {
|
||||
throw new ExceptionConverter(ee);
|
||||
}
|
||||
return cfont;
|
||||
}
|
||||
|
||||
public boolean isStandardFont() {
|
||||
return (this.family == FontFamily.UNDEFINED && this.size == -1.0F && this.style == -1 && this.color == null && this.baseFont == null);
|
||||
}
|
||||
|
||||
public Font difference(Font font) {
|
||||
if (font == null)
|
||||
return this;
|
||||
float dSize = font.size;
|
||||
if (dSize == -1.0F)
|
||||
dSize = this.size;
|
||||
int dStyle = -1;
|
||||
int style1 = this.style;
|
||||
int style2 = font.getStyle();
|
||||
if (style1 != -1 || style2 != -1) {
|
||||
if (style1 == -1)
|
||||
style1 = 0;
|
||||
if (style2 == -1)
|
||||
style2 = 0;
|
||||
dStyle = style1 | style2;
|
||||
}
|
||||
BaseColor dColor = font.color;
|
||||
if (dColor == null)
|
||||
dColor = this.color;
|
||||
if (font.baseFont != null)
|
||||
return new Font(font.baseFont, dSize, dStyle, dColor);
|
||||
if (font.getFamily() != FontFamily.UNDEFINED)
|
||||
return new Font(font.family, dSize, dStyle, dColor);
|
||||
if (this.baseFont != null) {
|
||||
if (dStyle == style1)
|
||||
return new Font(this.baseFont, dSize, dStyle, dColor);
|
||||
return FontFactory.getFont(getFamilyname(), dSize, dStyle, dColor);
|
||||
}
|
||||
return new Font(this.family, dSize, dStyle, dColor);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import java.util.Set;
|
||||
|
||||
public final class FontFactory {
|
||||
public static final String COURIER = "Courier";
|
||||
|
||||
public static final String COURIER_BOLD = "Courier-Bold";
|
||||
|
||||
public static final String COURIER_OBLIQUE = "Courier-Oblique";
|
||||
|
||||
public static final String COURIER_BOLDOBLIQUE = "Courier-BoldOblique";
|
||||
|
||||
public static final String HELVETICA = "Helvetica";
|
||||
|
||||
public static final String HELVETICA_BOLD = "Helvetica-Bold";
|
||||
|
||||
public static final String HELVETICA_OBLIQUE = "Helvetica-Oblique";
|
||||
|
||||
public static final String HELVETICA_BOLDOBLIQUE = "Helvetica-BoldOblique";
|
||||
|
||||
public static final String SYMBOL = "Symbol";
|
||||
|
||||
public static final String TIMES = "Times";
|
||||
|
||||
public static final String TIMES_ROMAN = "Times-Roman";
|
||||
|
||||
public static final String TIMES_BOLD = "Times-Bold";
|
||||
|
||||
public static final String TIMES_ITALIC = "Times-Italic";
|
||||
|
||||
public static final String TIMES_BOLDITALIC = "Times-BoldItalic";
|
||||
|
||||
public static final String ZAPFDINGBATS = "ZapfDingbats";
|
||||
|
||||
private static FontFactoryImp fontImp = new FontFactoryImp();
|
||||
|
||||
public static String defaultEncoding = "Cp1252";
|
||||
|
||||
public static boolean defaultEmbedding = false;
|
||||
|
||||
public static Font getFont(String fontname, String encoding, boolean embedded, float size, int style, BaseColor color) {
|
||||
return fontImp.getFont(fontname, encoding, embedded, size, style, color);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, boolean embedded, float size, int style, BaseColor color, boolean cached) {
|
||||
return fontImp.getFont(fontname, encoding, embedded, size, style, color, cached);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, boolean embedded, float size, int style) {
|
||||
return getFont(fontname, encoding, embedded, size, style, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, boolean embedded, float size) {
|
||||
return getFont(fontname, encoding, embedded, size, -1, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, boolean embedded) {
|
||||
return getFont(fontname, encoding, embedded, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, float size, int style, BaseColor color) {
|
||||
return getFont(fontname, encoding, defaultEmbedding, size, style, color);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, float size, int style) {
|
||||
return getFont(fontname, encoding, defaultEmbedding, size, style, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding, float size) {
|
||||
return getFont(fontname, encoding, defaultEmbedding, size, -1, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, String encoding) {
|
||||
return getFont(fontname, encoding, defaultEmbedding, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, float size, int style, BaseColor color) {
|
||||
return getFont(fontname, defaultEncoding, defaultEmbedding, size, style, color);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, float size, BaseColor color) {
|
||||
return getFont(fontname, defaultEncoding, defaultEmbedding, size, -1, color);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, float size, int style) {
|
||||
return getFont(fontname, defaultEncoding, defaultEmbedding, size, style, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname, float size) {
|
||||
return getFont(fontname, defaultEncoding, defaultEmbedding, size, -1, null);
|
||||
}
|
||||
|
||||
public static Font getFont(String fontname) {
|
||||
return getFont(fontname, defaultEncoding, defaultEmbedding, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public static void registerFamily(String familyName, String fullName, String path) {
|
||||
fontImp.registerFamily(familyName, fullName, path);
|
||||
}
|
||||
|
||||
public static void register(String path) {
|
||||
register(path, null);
|
||||
}
|
||||
|
||||
public static void register(String path, String alias) {
|
||||
fontImp.register(path, alias);
|
||||
}
|
||||
|
||||
public static int registerDirectory(String dir) {
|
||||
return fontImp.registerDirectory(dir);
|
||||
}
|
||||
|
||||
public static int registerDirectory(String dir, boolean scanSubdirectories) {
|
||||
return fontImp.registerDirectory(dir, scanSubdirectories);
|
||||
}
|
||||
|
||||
public static int registerDirectories() {
|
||||
return fontImp.registerDirectories();
|
||||
}
|
||||
|
||||
public static Set<String> getRegisteredFonts() {
|
||||
return fontImp.getRegisteredFonts();
|
||||
}
|
||||
|
||||
public static Set<String> getRegisteredFamilies() {
|
||||
return fontImp.getRegisteredFamilies();
|
||||
}
|
||||
|
||||
public static boolean contains(String fontname) {
|
||||
return fontImp.isRegistered(fontname);
|
||||
}
|
||||
|
||||
public static boolean isRegistered(String fontname) {
|
||||
return fontImp.isRegistered(fontname);
|
||||
}
|
||||
|
||||
public static FontFactoryImp getFontImp() {
|
||||
return fontImp;
|
||||
}
|
||||
|
||||
public static void setFontImp(FontFactoryImp fontImp) {
|
||||
if (fontImp == null)
|
||||
throw new NullPointerException(MessageLocalization.getComposedMessage("fontfactoryimp.cannot.be.null", new Object[0]));
|
||||
FontFactory.fontImp = fontImp;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,361 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.log.Level;
|
||||
import com.itextpdf.text.log.Logger;
|
||||
import com.itextpdf.text.log.LoggerFactory;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
public class FontFactoryImp implements FontProvider {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FontFactoryImp.class);
|
||||
|
||||
private final Hashtable<String, String> trueTypeFonts = new Hashtable<String, String>();
|
||||
|
||||
private static String[] TTFamilyOrder = new String[] {
|
||||
"3", "1", "1033", "3", "0", "1033", "1", "0", "0", "0",
|
||||
"3", "0" };
|
||||
|
||||
private final Hashtable<String, ArrayList<String>> fontFamilies = new Hashtable<String, ArrayList<String>>();
|
||||
|
||||
public String defaultEncoding = "Cp1252";
|
||||
|
||||
public boolean defaultEmbedding = false;
|
||||
|
||||
public FontFactoryImp() {
|
||||
this.trueTypeFonts.put("Courier".toLowerCase(), "Courier");
|
||||
this.trueTypeFonts.put("Courier-Bold".toLowerCase(), "Courier-Bold");
|
||||
this.trueTypeFonts.put("Courier-Oblique".toLowerCase(), "Courier-Oblique");
|
||||
this.trueTypeFonts.put("Courier-BoldOblique".toLowerCase(), "Courier-BoldOblique");
|
||||
this.trueTypeFonts.put("Helvetica".toLowerCase(), "Helvetica");
|
||||
this.trueTypeFonts.put("Helvetica-Bold".toLowerCase(), "Helvetica-Bold");
|
||||
this.trueTypeFonts.put("Helvetica-Oblique".toLowerCase(), "Helvetica-Oblique");
|
||||
this.trueTypeFonts.put("Helvetica-BoldOblique".toLowerCase(), "Helvetica-BoldOblique");
|
||||
this.trueTypeFonts.put("Symbol".toLowerCase(), "Symbol");
|
||||
this.trueTypeFonts.put("Times-Roman".toLowerCase(), "Times-Roman");
|
||||
this.trueTypeFonts.put("Times-Bold".toLowerCase(), "Times-Bold");
|
||||
this.trueTypeFonts.put("Times-Italic".toLowerCase(), "Times-Italic");
|
||||
this.trueTypeFonts.put("Times-BoldItalic".toLowerCase(), "Times-BoldItalic");
|
||||
this.trueTypeFonts.put("ZapfDingbats".toLowerCase(), "ZapfDingbats");
|
||||
ArrayList<String> tmp = new ArrayList<String>();
|
||||
tmp.add("Courier");
|
||||
tmp.add("Courier-Bold");
|
||||
tmp.add("Courier-Oblique");
|
||||
tmp.add("Courier-BoldOblique");
|
||||
this.fontFamilies.put("Courier".toLowerCase(), tmp);
|
||||
tmp = new ArrayList<String>();
|
||||
tmp.add("Helvetica");
|
||||
tmp.add("Helvetica-Bold");
|
||||
tmp.add("Helvetica-Oblique");
|
||||
tmp.add("Helvetica-BoldOblique");
|
||||
this.fontFamilies.put("Helvetica".toLowerCase(), tmp);
|
||||
tmp = new ArrayList<String>();
|
||||
tmp.add("Symbol");
|
||||
this.fontFamilies.put("Symbol".toLowerCase(), tmp);
|
||||
tmp = new ArrayList<String>();
|
||||
tmp.add("Times-Roman");
|
||||
tmp.add("Times-Bold");
|
||||
tmp.add("Times-Italic");
|
||||
tmp.add("Times-BoldItalic");
|
||||
this.fontFamilies.put("Times".toLowerCase(), tmp);
|
||||
this.fontFamilies.put("Times-Roman".toLowerCase(), tmp);
|
||||
tmp = new ArrayList<String>();
|
||||
tmp.add("ZapfDingbats");
|
||||
this.fontFamilies.put("ZapfDingbats".toLowerCase(), tmp);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, boolean embedded, float size, int style, BaseColor color) {
|
||||
return getFont(fontname, encoding, embedded, size, style, color, true);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, boolean embedded, float size, int style, BaseColor color, boolean cached) {
|
||||
if (fontname == null)
|
||||
return new Font(Font.FontFamily.UNDEFINED, size, style, color);
|
||||
String lowercasefontname = fontname.toLowerCase();
|
||||
ArrayList<String> tmp = this.fontFamilies.get(lowercasefontname);
|
||||
if (tmp != null)
|
||||
synchronized (tmp) {
|
||||
int s = (style == -1) ? 0 : style;
|
||||
int fs = 0;
|
||||
boolean found = false;
|
||||
for (String f : tmp) {
|
||||
String lcf = f.toLowerCase();
|
||||
fs = 0;
|
||||
if (lcf.indexOf("bold") != -1)
|
||||
fs |= 0x1;
|
||||
if (lcf.indexOf("italic") != -1 || lcf.indexOf("oblique") != -1)
|
||||
fs |= 0x2;
|
||||
if ((s & 0x3) == fs) {
|
||||
fontname = f;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (style != -1 && found)
|
||||
style &= fs ^ 0xFFFFFFFF;
|
||||
}
|
||||
BaseFont basefont = null;
|
||||
try {
|
||||
basefont = getBaseFont(fontname, encoding, embedded, cached);
|
||||
if (basefont == null)
|
||||
return new Font(Font.FontFamily.UNDEFINED, size, style, color);
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
} catch (IOException ioe) {
|
||||
return new Font(Font.FontFamily.UNDEFINED, size, style, color);
|
||||
} catch (NullPointerException npe) {
|
||||
return new Font(Font.FontFamily.UNDEFINED, size, style, color);
|
||||
}
|
||||
return new Font(basefont, size, style, color);
|
||||
}
|
||||
|
||||
protected BaseFont getBaseFont(String fontname, String encoding, boolean embedded, boolean cached) throws IOException, DocumentException {
|
||||
BaseFont basefont = null;
|
||||
try {
|
||||
basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null, true);
|
||||
} catch (DocumentException e) {}
|
||||
if (basefont == null) {
|
||||
fontname = this.trueTypeFonts.get(fontname.toLowerCase());
|
||||
if (fontname != null)
|
||||
basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null);
|
||||
}
|
||||
return basefont;
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, boolean embedded, float size, int style) {
|
||||
return getFont(fontname, encoding, embedded, size, style, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, boolean embedded, float size) {
|
||||
return getFont(fontname, encoding, embedded, size, -1, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, boolean embedded) {
|
||||
return getFont(fontname, encoding, embedded, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, float size, int style, BaseColor color) {
|
||||
return getFont(fontname, encoding, this.defaultEmbedding, size, style, color);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, float size, int style) {
|
||||
return getFont(fontname, encoding, this.defaultEmbedding, size, style, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding, float size) {
|
||||
return getFont(fontname, encoding, this.defaultEmbedding, size, -1, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, float size, BaseColor color) {
|
||||
return getFont(fontname, this.defaultEncoding, this.defaultEmbedding, size, -1, color);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, String encoding) {
|
||||
return getFont(fontname, encoding, this.defaultEmbedding, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, float size, int style, BaseColor color) {
|
||||
return getFont(fontname, this.defaultEncoding, this.defaultEmbedding, size, style, color);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, float size, int style) {
|
||||
return getFont(fontname, this.defaultEncoding, this.defaultEmbedding, size, style, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname, float size) {
|
||||
return getFont(fontname, this.defaultEncoding, this.defaultEmbedding, size, -1, null);
|
||||
}
|
||||
|
||||
public Font getFont(String fontname) {
|
||||
return getFont(fontname, this.defaultEncoding, this.defaultEmbedding, -1.0F, -1, null);
|
||||
}
|
||||
|
||||
public void registerFamily(String familyName, String fullName, String path) {
|
||||
ArrayList<String> tmp;
|
||||
if (path != null)
|
||||
this.trueTypeFonts.put(fullName, path);
|
||||
synchronized (this.fontFamilies) {
|
||||
tmp = this.fontFamilies.get(familyName);
|
||||
if (tmp == null) {
|
||||
tmp = new ArrayList<String>();
|
||||
this.fontFamilies.put(familyName, tmp);
|
||||
}
|
||||
}
|
||||
synchronized (tmp) {
|
||||
if (!tmp.contains(fullName)) {
|
||||
int fullNameLength = fullName.length();
|
||||
boolean inserted = false;
|
||||
for (int j = 0; j < tmp.size(); j++) {
|
||||
if (tmp.get(j).length() >= fullNameLength) {
|
||||
tmp.add(j, fullName);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inserted) {
|
||||
tmp.add(fullName);
|
||||
String newFullName = fullName.toLowerCase();
|
||||
if (newFullName.endsWith("regular")) {
|
||||
newFullName = newFullName.substring(0, newFullName.length() - 7).trim();
|
||||
tmp.add(0, fullName.substring(0, newFullName.length()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register(String path) {
|
||||
register(path, null);
|
||||
}
|
||||
|
||||
public void register(String path, String alias) {
|
||||
try {
|
||||
if (path.toLowerCase().endsWith(".ttf") || path.toLowerCase().endsWith(".otf") || path.toLowerCase().indexOf(".ttc,") > 0) {
|
||||
Object[] allNames = BaseFont.getAllFontNames(path, "Cp1252", null);
|
||||
this.trueTypeFonts.put(((String)allNames[0]).toLowerCase(), path);
|
||||
if (alias != null) {
|
||||
String lcAlias = alias.toLowerCase();
|
||||
this.trueTypeFonts.put(lcAlias, path);
|
||||
if (lcAlias.endsWith("regular"))
|
||||
saveCopyOfRegularFont(lcAlias, path);
|
||||
}
|
||||
String[][] names = (String[][])allNames[2];
|
||||
for (String[] name : names) {
|
||||
String lcName = name[3].toLowerCase();
|
||||
this.trueTypeFonts.put(lcName, path);
|
||||
if (lcName.endsWith("regular"))
|
||||
saveCopyOfRegularFont(lcName, path);
|
||||
}
|
||||
String fullName = null;
|
||||
String familyName = null;
|
||||
names = (String[][])allNames[1];
|
||||
for (int k = 0; k < TTFamilyOrder.length; k += 3) {
|
||||
for (String[] name : names) {
|
||||
if (TTFamilyOrder[k].equals(name[0]) && TTFamilyOrder[k + 1].equals(name[1]) && TTFamilyOrder[k + 2].equals(name[2])) {
|
||||
familyName = name[3].toLowerCase();
|
||||
k = TTFamilyOrder.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (familyName != null) {
|
||||
String lastName = "";
|
||||
names = (String[][])allNames[2];
|
||||
for (String[] name : names) {
|
||||
for (int i = 0; i < TTFamilyOrder.length; i += 3) {
|
||||
if (TTFamilyOrder[i].equals(name[0]) && TTFamilyOrder[i + 1].equals(name[1]) && TTFamilyOrder[i + 2].equals(name[2])) {
|
||||
fullName = name[3];
|
||||
if (!fullName.equals(lastName)) {
|
||||
lastName = fullName;
|
||||
registerFamily(familyName, fullName, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (path.toLowerCase().endsWith(".ttc")) {
|
||||
if (alias != null)
|
||||
LOGGER.error("You can't define an alias for a true type collection.");
|
||||
String[] names = BaseFont.enumerateTTCNames(path);
|
||||
for (int i = 0; i < names.length; i++)
|
||||
register(path + "," + i);
|
||||
} else if (path.toLowerCase().endsWith(".afm") || path.toLowerCase().endsWith(".pfm")) {
|
||||
BaseFont bf = BaseFont.createFont(path, "Cp1252", false);
|
||||
String fullName = bf.getFullFontName()[0][3].toLowerCase();
|
||||
String familyName = bf.getFamilyFontName()[0][3].toLowerCase();
|
||||
String psName = bf.getPostscriptFontName().toLowerCase();
|
||||
registerFamily(familyName, fullName, null);
|
||||
this.trueTypeFonts.put(psName, path);
|
||||
this.trueTypeFonts.put(fullName, path);
|
||||
}
|
||||
if (LOGGER.isLogging(Level.TRACE))
|
||||
LOGGER.trace(String.format("Registered %s", path));
|
||||
} catch (DocumentException de) {
|
||||
throw new ExceptionConverter(de);
|
||||
} catch (IOException ioe) {
|
||||
throw new ExceptionConverter(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean saveCopyOfRegularFont(String regularFontName, String path) {
|
||||
String alias = regularFontName.substring(0, regularFontName.length() - 7).trim();
|
||||
if (!this.trueTypeFonts.containsKey(alias)) {
|
||||
this.trueTypeFonts.put(alias, path);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int registerDirectory(String dir) {
|
||||
return registerDirectory(dir, false);
|
||||
}
|
||||
|
||||
public int registerDirectory(String dir, boolean scanSubdirectories) {
|
||||
if (LOGGER.isLogging(Level.DEBUG))
|
||||
LOGGER.debug(String.format("Registering directory %s, looking for fonts", dir));
|
||||
int count = 0;
|
||||
try {
|
||||
File file = new File(dir);
|
||||
if (!file.exists() || !file.isDirectory())
|
||||
return 0;
|
||||
String[] files = file.list();
|
||||
if (files == null)
|
||||
return 0;
|
||||
for (int k = 0; k < files.length; k++) {
|
||||
try {
|
||||
file = new File(dir, files[k]);
|
||||
if (file.isDirectory()) {
|
||||
if (scanSubdirectories)
|
||||
count += registerDirectory(file.getAbsolutePath(), true);
|
||||
} else {
|
||||
String name = file.getPath();
|
||||
String suffix = (name.length() < 4) ? null : name.substring(name.length() - 4).toLowerCase();
|
||||
if (".afm".equals(suffix) || ".pfm".equals(suffix)) {
|
||||
File pfb = new File(name.substring(0, name.length() - 4) + ".pfb");
|
||||
if (pfb.exists()) {
|
||||
register(name, null);
|
||||
count++;
|
||||
}
|
||||
} else if (".ttf".equals(suffix) || ".otf".equals(suffix) || ".ttc".equals(suffix)) {
|
||||
register(name, null);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int registerDirectories() {
|
||||
int count = 0;
|
||||
String windir = System.getenv("windir");
|
||||
String fileseparator = System.getProperty("file.separator");
|
||||
if (windir != null && fileseparator != null)
|
||||
count += registerDirectory(windir + fileseparator + "fonts");
|
||||
count += registerDirectory("/usr/share/X11/fonts", true);
|
||||
count += registerDirectory("/usr/X/lib/X11/fonts", true);
|
||||
count += registerDirectory("/usr/openwin/lib/X11/fonts", true);
|
||||
count += registerDirectory("/usr/share/fonts", true);
|
||||
count += registerDirectory("/usr/X11R6/lib/X11/fonts", true);
|
||||
count += registerDirectory("/Library/Fonts");
|
||||
count += registerDirectory("/System/Library/Fonts");
|
||||
return count;
|
||||
}
|
||||
|
||||
public Set<String> getRegisteredFonts() {
|
||||
return this.trueTypeFonts.keySet();
|
||||
}
|
||||
|
||||
public Set<String> getRegisteredFamilies() {
|
||||
return this.fontFamilies.keySet();
|
||||
}
|
||||
|
||||
public boolean isRegistered(String fontname) {
|
||||
return this.trueTypeFonts.containsKey(fontname.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public interface FontProvider {
|
||||
boolean isRegistered(String paramString);
|
||||
|
||||
Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat, int paramInt, BaseColor paramBaseColor);
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.factories.GreekAlphabetFactory;
|
||||
|
||||
public class GreekList extends List {
|
||||
public GreekList() {
|
||||
super(true);
|
||||
setGreekFont();
|
||||
}
|
||||
|
||||
public GreekList(int symbolIndent) {
|
||||
super(true, (float)symbolIndent);
|
||||
setGreekFont();
|
||||
}
|
||||
|
||||
public GreekList(boolean greeklower, int symbolIndent) {
|
||||
super(true, (float)symbolIndent);
|
||||
this.lowercase = greeklower;
|
||||
setGreekFont();
|
||||
}
|
||||
|
||||
protected void setGreekFont() {
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("Symbol", fontsize, 0));
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
if (o instanceof ListItem) {
|
||||
ListItem item = (ListItem)o;
|
||||
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
|
||||
chunk.setAttributes(this.symbol.getAttributes());
|
||||
chunk.append(GreekAlphabetFactory.getString(this.first + this.list.size(), this.lowercase));
|
||||
chunk.append(this.postSymbol);
|
||||
item.setListSymbol(chunk);
|
||||
item.setIndentationLeft(this.symbolIndent, this.autoindent);
|
||||
item.setIndentationRight(0.0F);
|
||||
this.list.add(item);
|
||||
} else if (o instanceof List) {
|
||||
List nested = (List)o;
|
||||
nested.setIndentationLeft(nested.getIndentationLeft() + this.symbolIndent);
|
||||
this.first--;
|
||||
return this.list.add(nested);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List cloneShallow() {
|
||||
GreekList clone = new GreekList();
|
||||
populateProperties(clone);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public class Header extends Meta {
|
||||
private StringBuffer name;
|
||||
|
||||
public Header(String name, String content) {
|
||||
super(0, content);
|
||||
this.name = new StringBuffer(name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name.toString();
|
||||
}
|
||||
}
|
||||
1208
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Image.java
Normal file
1208
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Image.java
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,29 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.codec.TIFFFaxDecoder;
|
||||
import java.net.URL;
|
||||
|
||||
public class ImgCCITT extends Image {
|
||||
ImgCCITT(Image image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public ImgCCITT(int width, int height, boolean reverseBits, int typeCCITT, int parameters, byte[] data) throws BadElementException {
|
||||
super((URL)null);
|
||||
if (typeCCITT != 256 && typeCCITT != 257 && typeCCITT != 258)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("the.ccitt.compression.type.must.be.ccittg4.ccittg3.1d.or.ccittg3.2d", new Object[0]));
|
||||
if (reverseBits)
|
||||
TIFFFaxDecoder.reverseBits(data);
|
||||
this.type = 34;
|
||||
this.scaledHeight = (float)height;
|
||||
setTop(this.scaledHeight);
|
||||
this.scaledWidth = (float)width;
|
||||
setRight(this.scaledWidth);
|
||||
this.colorspace = parameters;
|
||||
this.bpc = typeCCITT;
|
||||
this.rawData = data;
|
||||
this.plainWidth = getWidth();
|
||||
this.plainHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class ImgJBIG2 extends Image {
|
||||
private byte[] global;
|
||||
|
||||
private byte[] globalHash;
|
||||
|
||||
ImgJBIG2(Image image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public ImgJBIG2() {
|
||||
super((Image)null);
|
||||
}
|
||||
|
||||
public ImgJBIG2(int width, int height, byte[] data, byte[] globals) {
|
||||
super((URL)null);
|
||||
this.type = 36;
|
||||
this.originalType = 9;
|
||||
this.scaledHeight = (float)height;
|
||||
setTop(this.scaledHeight);
|
||||
this.scaledWidth = (float)width;
|
||||
setRight(this.scaledWidth);
|
||||
this.bpc = 1;
|
||||
this.colorspace = 1;
|
||||
this.rawData = data;
|
||||
this.plainWidth = getWidth();
|
||||
this.plainHeight = getHeight();
|
||||
if (globals != null) {
|
||||
this.global = globals;
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(this.global);
|
||||
this.globalHash = md.digest();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getGlobalBytes() {
|
||||
return this.global;
|
||||
}
|
||||
|
||||
public byte[] getGlobalHash() {
|
||||
return this.globalHash;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import java.net.URL;
|
||||
|
||||
public class ImgRaw extends Image {
|
||||
ImgRaw(Image image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public ImgRaw(int width, int height, int components, int bpc, byte[] data) throws BadElementException {
|
||||
super((URL)null);
|
||||
this.type = 34;
|
||||
this.scaledHeight = (float)height;
|
||||
setTop(this.scaledHeight);
|
||||
this.scaledWidth = (float)width;
|
||||
setRight(this.scaledWidth);
|
||||
if (components != 1 && components != 3 && components != 4)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("components.must.be.1.3.or.4", new Object[0]));
|
||||
if (bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("bits.per.component.must.be.1.2.4.or.8", new Object[0]));
|
||||
this.colorspace = components;
|
||||
this.bpc = bpc;
|
||||
this.rawData = data;
|
||||
this.plainWidth = getWidth();
|
||||
this.plainHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.PdfTemplate;
|
||||
import java.net.URL;
|
||||
|
||||
public class ImgTemplate extends Image {
|
||||
ImgTemplate(Image image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public ImgTemplate(PdfTemplate template) throws BadElementException {
|
||||
super((URL)null);
|
||||
if (template == null)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("the.template.can.not.be.null"));
|
||||
if (template.getType() == 3)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("a.pattern.can.not.be.used.as.a.template.to.create.an.image"));
|
||||
this.type = 35;
|
||||
this.scaledHeight = template.getHeight();
|
||||
setTop(this.scaledHeight);
|
||||
this.scaledWidth = template.getWidth();
|
||||
setRight(this.scaledWidth);
|
||||
setTemplateData(template);
|
||||
this.plainWidth = getWidth();
|
||||
this.plainHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.PdfTemplate;
|
||||
import com.itextpdf.text.pdf.codec.wmf.InputMeta;
|
||||
import com.itextpdf.text.pdf.codec.wmf.MetaDo;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class ImgWMF extends Image {
|
||||
ImgWMF(Image image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public ImgWMF(URL url) throws BadElementException, IOException {
|
||||
super(url);
|
||||
processParameters();
|
||||
}
|
||||
|
||||
public ImgWMF(String filename) throws BadElementException, MalformedURLException, IOException {
|
||||
this(Utilities.toURL(filename));
|
||||
}
|
||||
|
||||
public ImgWMF(byte[] img) throws BadElementException, IOException {
|
||||
super((URL)null);
|
||||
this.rawData = img;
|
||||
this.originalData = img;
|
||||
processParameters();
|
||||
}
|
||||
|
||||
private void processParameters() throws BadElementException, IOException {
|
||||
this.type = 35;
|
||||
this.originalType = 6;
|
||||
InputStream is = null;
|
||||
try {
|
||||
String errorID;
|
||||
if (this.rawData == null) {
|
||||
is = this.url.openStream();
|
||||
errorID = this.url.toString();
|
||||
} else {
|
||||
is = new ByteArrayInputStream(this.rawData);
|
||||
errorID = "Byte array";
|
||||
}
|
||||
InputMeta in = new InputMeta(is);
|
||||
if (in.readInt() != -1698247209)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("1.is.not.a.valid.placeable.windows.metafile", new Object[] { errorID }));
|
||||
in.readWord();
|
||||
int left = in.readShort();
|
||||
int top = in.readShort();
|
||||
int right = in.readShort();
|
||||
int bottom = in.readShort();
|
||||
int inch = in.readWord();
|
||||
this.dpiX = 72;
|
||||
this.dpiY = 72;
|
||||
this.scaledHeight = (float)(bottom - top) / (float)inch * 72.0F;
|
||||
setTop(this.scaledHeight);
|
||||
this.scaledWidth = (float)(right - left) / (float)inch * 72.0F;
|
||||
setRight(this.scaledWidth);
|
||||
} finally {
|
||||
if (is != null)
|
||||
is.close();
|
||||
this.plainWidth = getWidth();
|
||||
this.plainHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void readWMF(PdfTemplate template) throws IOException, DocumentException {
|
||||
setTemplateData(template);
|
||||
template.setWidth(getWidth());
|
||||
template.setHeight(getHeight());
|
||||
InputStream is = null;
|
||||
try {
|
||||
if (this.rawData == null) {
|
||||
is = this.url.openStream();
|
||||
} else {
|
||||
is = new ByteArrayInputStream(this.rawData);
|
||||
}
|
||||
MetaDo meta = new MetaDo(is, template);
|
||||
meta.readAll();
|
||||
} finally {
|
||||
if (is != null)
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
275
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Jpeg.java
Normal file
275
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/Jpeg.java
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.ICC_Profile;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class Jpeg extends Image {
|
||||
public static final int NOT_A_MARKER = -1;
|
||||
|
||||
public static final int VALID_MARKER = 0;
|
||||
|
||||
public static final int[] VALID_MARKERS = new int[] { 192, 193, 194 };
|
||||
|
||||
public static final int UNSUPPORTED_MARKER = 1;
|
||||
|
||||
public static final int[] UNSUPPORTED_MARKERS = new int[] {
|
||||
195, 197, 198, 199, 200, 201, 202, 203, 205, 206,
|
||||
207 };
|
||||
|
||||
public static final int NOPARAM_MARKER = 2;
|
||||
|
||||
public static final int[] NOPARAM_MARKERS = new int[] { 208, 209, 210, 211, 212, 213, 214, 215, 216, 1 };
|
||||
|
||||
public static final int M_APP0 = 224;
|
||||
|
||||
public static final int M_APP2 = 226;
|
||||
|
||||
public static final int M_APPE = 238;
|
||||
|
||||
public static final int M_APPD = 237;
|
||||
|
||||
public static final byte[] JFIF_ID = new byte[] { 74, 70, 73, 70, 0 };
|
||||
|
||||
public static final byte[] PS_8BIM_RESO = new byte[] { 56, 66, 73, 77, 3, -19 };
|
||||
|
||||
private byte[][] icc;
|
||||
|
||||
Jpeg(Image image) {
|
||||
super(image);
|
||||
}
|
||||
|
||||
public Jpeg(URL url) throws BadElementException, IOException {
|
||||
super(url);
|
||||
processParameters();
|
||||
}
|
||||
|
||||
public Jpeg(byte[] img) throws BadElementException, IOException {
|
||||
super((URL)null);
|
||||
this.rawData = img;
|
||||
this.originalData = img;
|
||||
processParameters();
|
||||
}
|
||||
|
||||
public Jpeg(byte[] img, float width, float height) throws BadElementException, IOException {
|
||||
this(img);
|
||||
this.scaledWidth = width;
|
||||
this.scaledHeight = height;
|
||||
}
|
||||
|
||||
private static final int getShort(InputStream is) throws IOException {
|
||||
return (is.read() << 8) + is.read();
|
||||
}
|
||||
|
||||
private static final int marker(int marker) {
|
||||
for (int k = 0; k < VALID_MARKERS.length; k++) {
|
||||
if (marker == VALID_MARKERS[k])
|
||||
return 0;
|
||||
}
|
||||
for (int j = 0; j < NOPARAM_MARKERS.length; j++) {
|
||||
if (marker == NOPARAM_MARKERS[j])
|
||||
return 2;
|
||||
}
|
||||
for (int i = 0; i < UNSUPPORTED_MARKERS.length; i++) {
|
||||
if (marker == UNSUPPORTED_MARKERS[i])
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void processParameters() throws BadElementException, IOException {
|
||||
this.type = 32;
|
||||
this.originalType = 1;
|
||||
InputStream is = null;
|
||||
try {
|
||||
String errorID;
|
||||
if (this.rawData == null) {
|
||||
is = this.url.openStream();
|
||||
errorID = this.url.toString();
|
||||
} else {
|
||||
is = new ByteArrayInputStream(this.rawData);
|
||||
errorID = "Byte array";
|
||||
}
|
||||
if (is.read() != 255 || is.read() != 216)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("1.is.not.a.valid.jpeg.file", errorID));
|
||||
boolean firstPass = true;
|
||||
while (true) {
|
||||
int v = is.read();
|
||||
if (v < 0)
|
||||
throw new IOException(MessageLocalization.getComposedMessage("premature.eof.while.reading.jpg"));
|
||||
if (v == 255) {
|
||||
int marker = is.read();
|
||||
if (firstPass && marker == 224) {
|
||||
firstPass = false;
|
||||
int len = getShort(is);
|
||||
if (len < 16) {
|
||||
Utilities.skip(is, len - 2);
|
||||
continue;
|
||||
}
|
||||
byte[] bcomp = new byte[JFIF_ID.length];
|
||||
int r = is.read(bcomp);
|
||||
if (r != bcomp.length)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("1.corrupted.jfif.marker", errorID));
|
||||
boolean found = true;
|
||||
for (int k = 0; k < bcomp.length; k++) {
|
||||
if (bcomp[k] != JFIF_ID[k]) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
Utilities.skip(is, len - 2 - bcomp.length);
|
||||
continue;
|
||||
}
|
||||
Utilities.skip(is, 2);
|
||||
int units = is.read();
|
||||
int dx = getShort(is);
|
||||
int dy = getShort(is);
|
||||
if (units == 1) {
|
||||
this.dpiX = dx;
|
||||
this.dpiY = dy;
|
||||
} else if (units == 2) {
|
||||
this.dpiX = (int)((float)dx * 2.54F + 0.5F);
|
||||
this.dpiY = (int)((float)dy * 2.54F + 0.5F);
|
||||
}
|
||||
Utilities.skip(is, len - 2 - bcomp.length - 7);
|
||||
continue;
|
||||
}
|
||||
if (marker == 238) {
|
||||
int len = getShort(is) - 2;
|
||||
byte[] byteappe = new byte[len];
|
||||
for (int k = 0; k < len; k++)
|
||||
byteappe[k] = (byte)is.read();
|
||||
if (byteappe.length >= 12) {
|
||||
String appe = new String(byteappe, 0, 5, "ISO-8859-1");
|
||||
if (appe.equals("Adobe"))
|
||||
this.invert = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (marker == 226) {
|
||||
int len = getShort(is) - 2;
|
||||
byte[] byteapp2 = new byte[len];
|
||||
for (int k = 0; k < len; k++)
|
||||
byteapp2[k] = (byte)is.read();
|
||||
if (byteapp2.length >= 14) {
|
||||
String app2 = new String(byteapp2, 0, 11, "ISO-8859-1");
|
||||
if (app2.equals("ICC_PROFILE")) {
|
||||
int order = byteapp2[12] & 0xFF;
|
||||
int count = byteapp2[13] & 0xFF;
|
||||
if (order < 1)
|
||||
order = 1;
|
||||
if (count < 1)
|
||||
count = 1;
|
||||
if (this.icc == null)
|
||||
this.icc = new byte[count][];
|
||||
this.icc[order - 1] = byteapp2;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (marker == 237) {
|
||||
int len = getShort(is) - 2;
|
||||
byte[] byteappd = new byte[len];
|
||||
int k;
|
||||
for (k = 0; k < len; k++)
|
||||
byteappd[k] = (byte)is.read();
|
||||
k = 0;
|
||||
for (k = 0; k < len - PS_8BIM_RESO.length; k++) {
|
||||
boolean found = true;
|
||||
for (int j = 0; j < PS_8BIM_RESO.length; j++) {
|
||||
if (byteappd[k + j] != PS_8BIM_RESO[j]) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
k += PS_8BIM_RESO.length;
|
||||
if (k < len - PS_8BIM_RESO.length) {
|
||||
byte namelength = byteappd[k];
|
||||
namelength = (byte)(namelength + 1);
|
||||
if (namelength % 2 == 1)
|
||||
namelength = (byte)(namelength + 1);
|
||||
k += namelength;
|
||||
int resosize = (byteappd[k] << 24) + (byteappd[k + 1] << 16) + (byteappd[k + 2] << 8) + byteappd[k + 3];
|
||||
if (resosize != 16)
|
||||
continue;
|
||||
k += 4;
|
||||
int dx = (byteappd[k] << 8) + (byteappd[k + 1] & 0xFF);
|
||||
k += 2;
|
||||
k += 2;
|
||||
int unitsx = (byteappd[k] << 8) + (byteappd[k + 1] & 0xFF);
|
||||
k += 2;
|
||||
k += 2;
|
||||
int dy = (byteappd[k] << 8) + (byteappd[k + 1] & 0xFF);
|
||||
k += 2;
|
||||
k += 2;
|
||||
int unitsy = (byteappd[k] << 8) + (byteappd[k + 1] & 0xFF);
|
||||
if (unitsx == 1 || unitsx == 2) {
|
||||
dx = (unitsx == 2) ? (int)((float)dx * 2.54F + 0.5F) : dx;
|
||||
if (this.dpiX == 0 || this.dpiX == dx)
|
||||
this.dpiX = dx;
|
||||
}
|
||||
if (unitsy == 1 || unitsy == 2) {
|
||||
dy = (unitsy == 2) ? (int)((float)dy * 2.54F + 0.5F) : dy;
|
||||
if (this.dpiY != 0 && this.dpiY != dy)
|
||||
continue;
|
||||
this.dpiY = dy;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
firstPass = false;
|
||||
int markertype = marker(marker);
|
||||
if (markertype == 0) {
|
||||
Utilities.skip(is, 2);
|
||||
if (is.read() != 8)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("1.must.have.8.bits.per.component", errorID));
|
||||
this.scaledHeight = (float)getShort(is);
|
||||
setTop(this.scaledHeight);
|
||||
this.scaledWidth = (float)getShort(is);
|
||||
setRight(this.scaledWidth);
|
||||
this.colorspace = is.read();
|
||||
this.bpc = 8;
|
||||
break;
|
||||
}
|
||||
if (markertype == 1)
|
||||
throw new BadElementException(MessageLocalization.getComposedMessage("1.unsupported.jpeg.marker.2", errorID, String.valueOf(marker)));
|
||||
if (markertype != 2)
|
||||
Utilities.skip(is, getShort(is) - 2);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (is != null)
|
||||
is.close();
|
||||
}
|
||||
this.plainWidth = getWidth();
|
||||
this.plainHeight = getHeight();
|
||||
if (this.icc != null) {
|
||||
int total = 0;
|
||||
for (int k = 0; k < this.icc.length; k++) {
|
||||
if (this.icc[k] == null) {
|
||||
this.icc = null;
|
||||
return;
|
||||
}
|
||||
total += (this.icc[k]).length - 14;
|
||||
}
|
||||
byte[] ficc = new byte[total];
|
||||
total = 0;
|
||||
for (int i = 0; i < this.icc.length; i++) {
|
||||
System.arraycopy(this.icc[i], 14, ficc, total, (this.icc[i]).length - 14);
|
||||
total += (this.icc[i]).length - 14;
|
||||
}
|
||||
try {
|
||||
ICC_Profile icc_prof = ICC_Profile.getInstance(ficc, this.colorspace);
|
||||
tagICC(icc_prof);
|
||||
} catch (IllegalArgumentException e) {}
|
||||
this.icc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Jpeg2000 extends Image {
|
||||
public static final int JP2_JP = 1783636000;
|
||||
|
||||
public static final int JP2_IHDR = 1768449138;
|
||||
|
||||
public static final int JPIP_JPIP = 1785751920;
|
||||
|
||||
public static final int JP2_FTYP = 1718909296;
|
||||
|
||||
public static final int JP2_JP2H = 1785737832;
|
||||
|
||||
public static final int JP2_COLR = 1668246642;
|
||||
|
||||
public static final int JP2_JP2C = 1785737827;
|
||||
|
||||
public static final int JP2_URL = 1970433056;
|
||||
|
||||
public static final int JP2_DBTL = 1685348972;
|
||||
|
||||
public static final int JP2_BPCC = 1651532643;
|
||||
|
||||
public static final int JP2_JP2 = 1785737760;
|
||||
|
||||
InputStream inp;
|
||||
|
||||
int boxLength;
|
||||
|
||||
int boxType;
|
||||
|
||||
int numOfComps;
|
||||
|
||||
ArrayList<ColorSpecBox> colorSpecBoxes = null;
|
||||
|
||||
boolean isJp2 = false;
|
||||
|
||||
byte[] bpcBoxData;
|
||||
|
||||
Jpeg2000(Image image) {
|
||||
super(image);
|
||||
if (image instanceof Jpeg2000) {
|
||||
Jpeg2000 jpeg2000 = (Jpeg2000)image;
|
||||
this.numOfComps = jpeg2000.numOfComps;
|
||||
if (this.colorSpecBoxes != null)
|
||||
this.colorSpecBoxes = (ArrayList<ColorSpecBox>)jpeg2000.colorSpecBoxes.clone();
|
||||
this.isJp2 = jpeg2000.isJp2;
|
||||
if (this.bpcBoxData != null)
|
||||
this.bpcBoxData = (byte[])jpeg2000.bpcBoxData.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public Jpeg2000(URL url) throws BadElementException, IOException {
|
||||
super(url);
|
||||
processParameters();
|
||||
}
|
||||
|
||||
public Jpeg2000(byte[] img) throws BadElementException, IOException {
|
||||
super((URL)null);
|
||||
this.rawData = img;
|
||||
this.originalData = img;
|
||||
processParameters();
|
||||
}
|
||||
|
||||
public Jpeg2000(byte[] img, float width, float height) throws BadElementException, IOException {
|
||||
this(img);
|
||||
this.scaledWidth = width;
|
||||
this.scaledHeight = height;
|
||||
}
|
||||
|
||||
private int cio_read(int n) throws IOException {
|
||||
int v = 0;
|
||||
for (int i = n - 1; i >= 0; i--)
|
||||
v += this.inp.read() << i << 3;
|
||||
return v;
|
||||
}
|
||||
|
||||
public void jp2_read_boxhdr() throws IOException {
|
||||
this.boxLength = cio_read(4);
|
||||
this.boxType = cio_read(4);
|
||||
if (this.boxLength == 1) {
|
||||
if (cio_read(4) != 0)
|
||||
throw new IOException(MessageLocalization.getComposedMessage("cannot.handle.box.sizes.higher.than.2.32"));
|
||||
this.boxLength = cio_read(4);
|
||||
if (this.boxLength == 0)
|
||||
throw new IOException(MessageLocalization.getComposedMessage("unsupported.box.size.eq.eq.0"));
|
||||
} else if (this.boxLength == 0) {
|
||||
throw new ZeroBoxSizeException(MessageLocalization.getComposedMessage("unsupported.box.size.eq.eq.0"));
|
||||
}
|
||||
}
|
||||
|
||||
private void processParameters() throws IOException {
|
||||
assert false : "Decompilation failed at line #174 -> offsets [0]";
|
||||
assert false : "Decompilation failed at line #175 -> offsets [6]";
|
||||
assert false : "Decompilation failed at line #176 -> offsets [12]";
|
||||
assert false : "Decompilation failed at line #178 -> offsets [17]";
|
||||
assert false : "Decompilation failed at line #179 -> offsets [24]";
|
||||
assert false : "Decompilation failed at line #182 -> offsets [38]";
|
||||
assert false : "Decompilation failed at line #184 -> offsets [53]";
|
||||
assert false : "Decompilation failed at line #185 -> offsets [62]";
|
||||
assert false : "Decompilation failed at line #186 -> offsets [71]";
|
||||
assert false : "Decompilation failed at line #187 -> offsets [76]";
|
||||
assert false : "Decompilation failed at line #188 -> offsets [85]";
|
||||
assert false : "Decompilation failed at line #189 -> offsets [94]";
|
||||
assert false : "Decompilation failed at line #191 -> offsets [111]";
|
||||
assert false : "Decompilation failed at line #192 -> offsets [121]";
|
||||
assert false : "Decompilation failed at line #195 -> offsets [138]";
|
||||
assert false : "Decompilation failed at line #196 -> offsets [142]";
|
||||
assert false : "Decompilation failed at line #197 -> offsets [151]";
|
||||
assert false : "Decompilation failed at line #199 -> offsets [168]";
|
||||
assert false : "Decompilation failed at line #200 -> offsets [182]";
|
||||
assert false : "Decompilation failed at line #202 -> offsets [186]";
|
||||
assert false : "Decompilation failed at line #203 -> offsets [195]";
|
||||
assert false : "Decompilation failed at line #204 -> offsets [204]";
|
||||
assert false : "Decompilation failed at line #206 -> offsets [221]";
|
||||
assert false : "Decompilation failed at line #207 -> offsets [235]";
|
||||
assert false : "Decompilation failed at line #209 -> offsets [239]";
|
||||
assert false : "Decompilation failed at line #210 -> offsets [248]";
|
||||
assert false : "Decompilation failed at line #211 -> offsets [252]";
|
||||
assert false : "Decompilation failed at line #212 -> offsets [261]";
|
||||
assert false : "Decompilation failed at line #214 -> offsets [278]";
|
||||
assert false : "Decompilation failed at line #215 -> offsets [288]";
|
||||
assert false : "Decompilation failed at line #216 -> offsets [296]";
|
||||
assert false : "Decompilation failed at line #217 -> offsets [306]";
|
||||
assert false : "Decompilation failed at line #218 -> offsets [314]";
|
||||
assert false : "Decompilation failed at line #219 -> offsets [323]";
|
||||
assert false : "Decompilation failed at line #220 -> offsets [328]";
|
||||
assert false : "Decompilation failed at line #222 -> offsets [337]";
|
||||
assert false : "Decompilation failed at line #224 -> offsets [345]";
|
||||
assert false : "Decompilation failed at line #225 -> offsets [349]";
|
||||
assert false : "Decompilation failed at line #226 -> offsets [358]";
|
||||
assert false : "Decompilation failed at line #227 -> offsets [371]";
|
||||
assert false : "Decompilation failed at line #228 -> offsets [394]";
|
||||
assert false : "Decompilation failed at line #230 -> offsets [403]";
|
||||
assert false : "Decompilation failed at line #231 -> offsets [410]";
|
||||
assert false : "Decompilation failed at line #232 -> offsets [421]";
|
||||
assert false : "Decompilation failed at line #234 -> offsets [433]";
|
||||
assert false : "Decompilation failed at line #235 -> offsets [440]";
|
||||
assert false : "Decompilation failed at line #237 -> offsets [437]";
|
||||
assert false : "Decompilation failed at line #238 -> offsets [441]";
|
||||
assert false : "Decompilation failed at line #241 -> offsets [453]";
|
||||
assert false : "Decompilation failed at line #242 -> offsets [462]";
|
||||
assert false : "Decompilation failed at line #243 -> offsets [470]";
|
||||
assert false : "Decompilation failed at line #244 -> offsets [476]";
|
||||
assert false : "Decompilation failed at line #245 -> offsets [482]";
|
||||
assert false : "Decompilation failed at line #246 -> offsets [488]";
|
||||
assert false : "Decompilation failed at line #247 -> offsets [495]";
|
||||
assert false : "Decompilation failed at line #248 -> offsets [504]";
|
||||
assert false : "Decompilation failed at line #249 -> offsets [513]";
|
||||
assert false : "Decompilation failed at line #250 -> offsets [519]";
|
||||
assert false : "Decompilation failed at line #251 -> offsets [528]";
|
||||
assert false : "Decompilation failed at line #252 -> offsets [536]";
|
||||
assert false : "Decompilation failed at line #253 -> offsets [544]";
|
||||
assert false : "Decompilation failed at line #254 -> offsets [552]";
|
||||
assert false : "Decompilation failed at line #256 -> offsets [555]";
|
||||
assert false : "Decompilation failed at line #260 -> offsets [572, 598]";
|
||||
assert false : "Decompilation failed at line #261 -> offsets [579, 607]";
|
||||
assert false : "Decompilation failed at line #262 -> offsets [590, 619]";
|
||||
assert false : "Decompilation failed at line #265 -> offsets [627]";
|
||||
assert false : "Decompilation failed at line #266 -> offsets [635]";
|
||||
assert false : "Decompilation failed at line #267 -> offsets [643]";
|
||||
}
|
||||
|
||||
private ColorSpecBox jp2_read_colr() throws IOException {
|
||||
int readBytes = 8;
|
||||
ColorSpecBox colr = new ColorSpecBox();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
colr.add(Integer.valueOf(cio_read(1)));
|
||||
readBytes++;
|
||||
}
|
||||
if (colr.getMeth() == 1) {
|
||||
colr.add(Integer.valueOf(cio_read(4)));
|
||||
readBytes += 4;
|
||||
} else {
|
||||
colr.add(Integer.valueOf(0));
|
||||
}
|
||||
if (this.boxLength - readBytes > 0) {
|
||||
byte[] colorProfile = new byte[this.boxLength - readBytes];
|
||||
this.inp.read(colorProfile, 0, this.boxLength - readBytes);
|
||||
colr.setColorProfile(colorProfile);
|
||||
}
|
||||
return colr;
|
||||
}
|
||||
|
||||
public int getNumOfComps() {
|
||||
return this.numOfComps;
|
||||
}
|
||||
|
||||
public byte[] getBpcBoxData() {
|
||||
return this.bpcBoxData;
|
||||
}
|
||||
|
||||
public ArrayList<ColorSpecBox> getColorSpecBoxes() {
|
||||
return this.colorSpecBoxes;
|
||||
}
|
||||
|
||||
public boolean isJp2() {
|
||||
return this.isJp2;
|
||||
}
|
||||
|
||||
public static class ColorSpecBox extends ArrayList<Integer> {
|
||||
private byte[] colorProfile;
|
||||
|
||||
public int getMeth() {
|
||||
return get(0);
|
||||
}
|
||||
|
||||
public int getPrec() {
|
||||
return get(1);
|
||||
}
|
||||
|
||||
public int getApprox() {
|
||||
return get(2);
|
||||
}
|
||||
|
||||
public int getEnumCs() {
|
||||
return get(3);
|
||||
}
|
||||
|
||||
public byte[] getColorProfile() {
|
||||
return this.colorProfile;
|
||||
}
|
||||
|
||||
void setColorProfile(byte[] colorProfile) {
|
||||
this.colorProfile = colorProfile;
|
||||
}
|
||||
}
|
||||
|
||||
private class ZeroBoxSizeException extends IOException {
|
||||
public ZeroBoxSizeException() {}
|
||||
|
||||
public ZeroBoxSizeException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation with the addition of the following permission added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY iText Group NV, iText Group NV DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License along with this program; if not, see http://www.gnu.org/licenses or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||
|
||||
http://itextpdf.com/terms-of-use/
|
||||
|
||||
The interactive user interfaces in modified source and object code versions of this program must display Appropriate Legal Notices, as required under Section 5 of the GNU Affero General Public License.
|
||||
|
||||
In accordance with Section 7(b) of the GNU Affero General Public License, a covered work must retain the producer line in every PDF that is created or manipulated using iText.
|
||||
|
||||
You can be released from the requirements of the license by purchasing a commercial license. Buying such a license is mandatory as soon as you develop commercial activities involving the iText software without disclosing the source code of your own applications.
|
||||
These activities include: offering paid services to customers as an ASP, serving PDFs on the fly in a web application, shipping iText with a closed source product.
|
||||
|
||||
For more information, please contact iText Software Corp. at this address: sales@itextpdf.com
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public interface LargeElement extends Element {
|
||||
void setComplete(boolean paramBoolean);
|
||||
|
||||
boolean isComplete();
|
||||
|
||||
void flushContent();
|
||||
}
|
||||
355
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/List.java
Normal file
355
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/List.java
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.api.Indentable;
|
||||
import com.itextpdf.text.factories.RomanAlphabetFactory;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.interfaces.IAccessibleElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class List implements TextElementArray, Indentable, IAccessibleElement {
|
||||
public static final boolean ORDERED = true;
|
||||
|
||||
public static final boolean UNORDERED = false;
|
||||
|
||||
public static final boolean NUMERICAL = false;
|
||||
|
||||
public static final boolean ALPHABETICAL = true;
|
||||
|
||||
public static final boolean UPPERCASE = false;
|
||||
|
||||
public static final boolean LOWERCASE = true;
|
||||
|
||||
protected ArrayList<Element> list = new ArrayList<Element>();
|
||||
|
||||
protected boolean numbered = false;
|
||||
|
||||
protected boolean lettered = false;
|
||||
|
||||
protected boolean lowercase = false;
|
||||
|
||||
protected boolean autoindent = false;
|
||||
|
||||
protected boolean alignindent = false;
|
||||
|
||||
protected int first = 1;
|
||||
|
||||
protected Chunk symbol = new Chunk("- ");
|
||||
|
||||
protected String preSymbol = "";
|
||||
|
||||
protected String postSymbol = ". ";
|
||||
|
||||
protected float indentationLeft = 0.0F;
|
||||
|
||||
protected float indentationRight = 0.0F;
|
||||
|
||||
protected float symbolIndent = 0.0F;
|
||||
|
||||
protected PdfName role = PdfName.L;
|
||||
|
||||
protected HashMap<PdfName, PdfObject> accessibleAttributes = null;
|
||||
|
||||
private AccessibleElementId id = null;
|
||||
|
||||
public List() {
|
||||
this(false, false);
|
||||
}
|
||||
|
||||
public List(float symbolIndent) {
|
||||
this.symbolIndent = symbolIndent;
|
||||
}
|
||||
|
||||
public List(boolean numbered) {
|
||||
this(numbered, false);
|
||||
}
|
||||
|
||||
public List(boolean numbered, boolean lettered) {
|
||||
this.numbered = numbered;
|
||||
this.lettered = lettered;
|
||||
this.autoindent = true;
|
||||
this.alignindent = true;
|
||||
}
|
||||
|
||||
public List(boolean numbered, float symbolIndent) {
|
||||
this(numbered, false, symbolIndent);
|
||||
}
|
||||
|
||||
public List(boolean numbered, boolean lettered, float symbolIndent) {
|
||||
this.numbered = numbered;
|
||||
this.lettered = lettered;
|
||||
this.symbolIndent = symbolIndent;
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
for (Element element : this.list)
|
||||
listener.add(element);
|
||||
return true;
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 14;
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
java.util.List<Chunk> tmp = new ArrayList<Chunk>();
|
||||
for (Element element : this.list)
|
||||
tmp.addAll(element.getChunks());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public boolean add(String s) {
|
||||
if (s != null)
|
||||
return add(new ListItem(s));
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
if (o instanceof ListItem) {
|
||||
ListItem item = (ListItem)o;
|
||||
if (this.numbered || this.lettered) {
|
||||
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
|
||||
chunk.setAttributes(this.symbol.getAttributes());
|
||||
int index = this.first + this.list.size();
|
||||
if (this.lettered) {
|
||||
chunk.append(RomanAlphabetFactory.getString(index, this.lowercase));
|
||||
} else {
|
||||
chunk.append(String.valueOf(index));
|
||||
}
|
||||
chunk.append(this.postSymbol);
|
||||
item.setListSymbol(chunk);
|
||||
} else {
|
||||
item.setListSymbol(this.symbol);
|
||||
}
|
||||
item.setIndentationLeft(this.symbolIndent, this.autoindent);
|
||||
item.setIndentationRight(0.0F);
|
||||
return this.list.add(item);
|
||||
}
|
||||
if (o instanceof List) {
|
||||
List nested = (List)o;
|
||||
nested.setIndentationLeft(nested.getIndentationLeft() + this.symbolIndent);
|
||||
this.first--;
|
||||
return this.list.add(nested);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List cloneShallow() {
|
||||
List clone = new List();
|
||||
populateProperties(clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
protected void populateProperties(List clone) {
|
||||
clone.indentationLeft = this.indentationLeft;
|
||||
clone.indentationRight = this.indentationRight;
|
||||
clone.autoindent = this.autoindent;
|
||||
clone.alignindent = this.alignindent;
|
||||
clone.symbolIndent = this.symbolIndent;
|
||||
clone.symbol = this.symbol;
|
||||
}
|
||||
|
||||
public void normalizeIndentation() {
|
||||
float max = 0.0F;
|
||||
for (Element o : this.list) {
|
||||
if (o instanceof ListItem)
|
||||
max = Math.max(max, ((ListItem)o).getIndentationLeft());
|
||||
}
|
||||
for (Element o : this.list) {
|
||||
if (o instanceof ListItem)
|
||||
((ListItem)o).setIndentationLeft(max);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNumbered(boolean numbered) {
|
||||
this.numbered = numbered;
|
||||
}
|
||||
|
||||
public void setLettered(boolean lettered) {
|
||||
this.lettered = lettered;
|
||||
}
|
||||
|
||||
public void setLowercase(boolean uppercase) {
|
||||
this.lowercase = uppercase;
|
||||
}
|
||||
|
||||
public void setAutoindent(boolean autoindent) {
|
||||
this.autoindent = autoindent;
|
||||
}
|
||||
|
||||
public void setAlignindent(boolean alignindent) {
|
||||
this.alignindent = alignindent;
|
||||
}
|
||||
|
||||
public void setFirst(int first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public void setListSymbol(Chunk symbol) {
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
public void setListSymbol(String symbol) {
|
||||
this.symbol = new Chunk(symbol);
|
||||
}
|
||||
|
||||
public void setIndentationLeft(float indentation) {
|
||||
this.indentationLeft = indentation;
|
||||
}
|
||||
|
||||
public void setIndentationRight(float indentation) {
|
||||
this.indentationRight = indentation;
|
||||
}
|
||||
|
||||
public void setSymbolIndent(float symbolIndent) {
|
||||
this.symbolIndent = symbolIndent;
|
||||
}
|
||||
|
||||
public ArrayList<Element> getItems() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.list.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.list.isEmpty();
|
||||
}
|
||||
|
||||
public float getTotalLeading() {
|
||||
if (this.list.size() < 1)
|
||||
return -1.0F;
|
||||
ListItem item = (ListItem)this.list.get(0);
|
||||
return item.getTotalLeading();
|
||||
}
|
||||
|
||||
public boolean isNumbered() {
|
||||
return this.numbered;
|
||||
}
|
||||
|
||||
public boolean isLettered() {
|
||||
return this.lettered;
|
||||
}
|
||||
|
||||
public boolean isLowercase() {
|
||||
return this.lowercase;
|
||||
}
|
||||
|
||||
public boolean isAutoindent() {
|
||||
return this.autoindent;
|
||||
}
|
||||
|
||||
public boolean isAlignindent() {
|
||||
return this.alignindent;
|
||||
}
|
||||
|
||||
public int getFirst() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public Chunk getSymbol() {
|
||||
return this.symbol;
|
||||
}
|
||||
|
||||
public float getIndentationLeft() {
|
||||
return this.indentationLeft;
|
||||
}
|
||||
|
||||
public float getIndentationRight() {
|
||||
return this.indentationRight;
|
||||
}
|
||||
|
||||
public float getSymbolIndent() {
|
||||
return this.symbolIndent;
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getPostSymbol() {
|
||||
return this.postSymbol;
|
||||
}
|
||||
|
||||
public void setPostSymbol(String postSymbol) {
|
||||
this.postSymbol = postSymbol;
|
||||
}
|
||||
|
||||
public String getPreSymbol() {
|
||||
return this.preSymbol;
|
||||
}
|
||||
|
||||
public void setPreSymbol(String preSymbol) {
|
||||
this.preSymbol = preSymbol;
|
||||
}
|
||||
|
||||
public ListItem getFirstItem() {
|
||||
Element lastElement = (this.list.size() > 0) ? this.list.get(0) : null;
|
||||
if (lastElement != null) {
|
||||
if (lastElement instanceof ListItem)
|
||||
return (ListItem)lastElement;
|
||||
if (lastElement instanceof List)
|
||||
return ((List)lastElement).getFirstItem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ListItem getLastItem() {
|
||||
Element lastElement = (this.list.size() > 0) ? this.list.get(this.list.size() - 1) : null;
|
||||
if (lastElement != null) {
|
||||
if (lastElement instanceof ListItem)
|
||||
return (ListItem)lastElement;
|
||||
if (lastElement instanceof List)
|
||||
return ((List)lastElement).getLastItem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PdfObject getAccessibleAttribute(PdfName key) {
|
||||
if (this.accessibleAttributes != null)
|
||||
return this.accessibleAttributes.get(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAccessibleAttribute(PdfName key, PdfObject value) {
|
||||
if (this.accessibleAttributes == null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>();
|
||||
this.accessibleAttributes.put(key, value);
|
||||
}
|
||||
|
||||
public HashMap<PdfName, PdfObject> getAccessibleAttributes() {
|
||||
return this.accessibleAttributes;
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public AccessibleElementId getId() {
|
||||
if (this.id == null)
|
||||
this.id = new AccessibleElementId();
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AccessibleElementId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.interfaces.IAccessibleElement;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ListBody implements IAccessibleElement {
|
||||
protected PdfName role = PdfName.LBODY;
|
||||
|
||||
private AccessibleElementId id = null;
|
||||
|
||||
protected HashMap<PdfName, PdfObject> accessibleAttributes = null;
|
||||
|
||||
protected ListItem parentItem = null;
|
||||
|
||||
protected ListBody(ListItem parentItem) {
|
||||
this.parentItem = parentItem;
|
||||
}
|
||||
|
||||
public PdfObject getAccessibleAttribute(PdfName key) {
|
||||
if (this.accessibleAttributes != null)
|
||||
return this.accessibleAttributes.get(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAccessibleAttribute(PdfName key, PdfObject value) {
|
||||
if (this.accessibleAttributes == null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>();
|
||||
this.accessibleAttributes.put(key, value);
|
||||
}
|
||||
|
||||
public HashMap<PdfName, PdfObject> getAccessibleAttributes() {
|
||||
return this.accessibleAttributes;
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public AccessibleElementId getId() {
|
||||
if (this.id == null)
|
||||
this.id = new AccessibleElementId();
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AccessibleElementId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
|
||||
public class ListItem extends Paragraph {
|
||||
private static final long serialVersionUID = 1970670787169329006L;
|
||||
|
||||
protected Chunk symbol;
|
||||
|
||||
private ListBody listBody = null;
|
||||
|
||||
private ListLabel listLabel = null;
|
||||
|
||||
public ListItem() {
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(float leading) {
|
||||
super(leading);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(Chunk chunk) {
|
||||
super(chunk);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(String string) {
|
||||
super(string);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(String string, Font font) {
|
||||
super(string, font);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(float leading, Chunk chunk) {
|
||||
super(leading, chunk);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(float leading, String string) {
|
||||
super(leading, string);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(float leading, String string, Font font) {
|
||||
super(leading, string, font);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public ListItem(Phrase phrase) {
|
||||
super(phrase);
|
||||
setRole(PdfName.LI);
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
public Paragraph cloneShallow(boolean spacingBefore) {
|
||||
ListItem copy = new ListItem();
|
||||
populateProperties(copy, spacingBefore);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public void setListSymbol(Chunk symbol) {
|
||||
if (this.symbol == null) {
|
||||
this.symbol = symbol;
|
||||
if (this.symbol.getFont().isStandardFont())
|
||||
this.symbol.setFont(this.font);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIndentationLeft(float indentation, boolean autoindent) {
|
||||
if (autoindent) {
|
||||
setIndentationLeft(getListSymbol().getWidthPoint());
|
||||
} else {
|
||||
setIndentationLeft(indentation);
|
||||
}
|
||||
}
|
||||
|
||||
public void adjustListSymbolFont() {
|
||||
java.util.List<Chunk> cks = getChunks();
|
||||
if (!cks.isEmpty() && this.symbol != null)
|
||||
this.symbol.setFont(cks.get(0).getFont());
|
||||
}
|
||||
|
||||
public Chunk getListSymbol() {
|
||||
return this.symbol;
|
||||
}
|
||||
|
||||
public ListBody getListBody() {
|
||||
if (this.listBody == null)
|
||||
this.listBody = new ListBody(this);
|
||||
return this.listBody;
|
||||
}
|
||||
|
||||
public ListLabel getListLabel() {
|
||||
if (this.listLabel == null)
|
||||
this.listLabel = new ListLabel(this);
|
||||
return this.listLabel;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
|
||||
public class ListLabel extends ListBody {
|
||||
protected PdfName role = PdfName.LBL;
|
||||
|
||||
protected float indentation = 0.0F;
|
||||
|
||||
protected ListLabel(ListItem parentItem) {
|
||||
super(parentItem);
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public float getIndentation() {
|
||||
return this.indentation;
|
||||
}
|
||||
|
||||
public void setIndentation(float indentation) {
|
||||
this.indentation = indentation;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getTagLabelContent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTagLabelContent(boolean tagLabelContent) {}
|
||||
|
||||
public boolean isInline() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Deprecated
|
||||
public class MarkedObject implements Element {
|
||||
protected Element element;
|
||||
|
||||
protected Properties markupAttributes = new Properties();
|
||||
|
||||
protected MarkedObject() {
|
||||
this.element = null;
|
||||
}
|
||||
|
||||
public MarkedObject(Element element) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
return this.element.getChunks();
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
return listener.add(this.element);
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Properties getMarkupAttributes() {
|
||||
return this.markupAttributes;
|
||||
}
|
||||
|
||||
public void setMarkupAttribute(String key, String value) {
|
||||
this.markupAttributes.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.api.Indentable;
|
||||
import java.util.Collection;
|
||||
|
||||
@Deprecated
|
||||
public class MarkedSection extends MarkedObject implements Indentable {
|
||||
protected MarkedObject title = null;
|
||||
|
||||
public MarkedSection(Section section) {
|
||||
if (section.title != null) {
|
||||
this.title = new MarkedObject(section.title);
|
||||
section.setTitle(null);
|
||||
}
|
||||
this.element = section;
|
||||
}
|
||||
|
||||
public void add(int index, Element o) {
|
||||
((Section)this.element).add(index, o);
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
return ((Section)this.element).add(o);
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
for (Element element : (Iterable<Element>)this.element)
|
||||
listener.add(element);
|
||||
return true;
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends Element> collection) {
|
||||
return ((Section)this.element).addAll(collection);
|
||||
}
|
||||
|
||||
public MarkedSection addSection(float indentation, int numberDepth) {
|
||||
MarkedSection section = ((Section)this.element).addMarkedSection();
|
||||
section.setIndentation(indentation);
|
||||
section.setNumberDepth(numberDepth);
|
||||
return section;
|
||||
}
|
||||
|
||||
public MarkedSection addSection(float indentation) {
|
||||
MarkedSection section = ((Section)this.element).addMarkedSection();
|
||||
section.setIndentation(indentation);
|
||||
return section;
|
||||
}
|
||||
|
||||
public MarkedSection addSection(int numberDepth) {
|
||||
MarkedSection section = ((Section)this.element).addMarkedSection();
|
||||
section.setNumberDepth(numberDepth);
|
||||
return section;
|
||||
}
|
||||
|
||||
public MarkedSection addSection() {
|
||||
return ((Section)this.element).addMarkedSection();
|
||||
}
|
||||
|
||||
public void setTitle(MarkedObject title) {
|
||||
if (title.element instanceof Paragraph)
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public MarkedObject getTitle() {
|
||||
Paragraph result = Section.constructTitle((Paragraph)this.title.element, ((Section)this.element).numbers, ((Section)this.element).numberDepth, ((Section)this.element).numberStyle);
|
||||
MarkedObject mo = new MarkedObject(result);
|
||||
mo.markupAttributes = this.title.markupAttributes;
|
||||
return mo;
|
||||
}
|
||||
|
||||
public void setNumberDepth(int numberDepth) {
|
||||
((Section)this.element).setNumberDepth(numberDepth);
|
||||
}
|
||||
|
||||
public void setIndentationLeft(float indentation) {
|
||||
((Section)this.element).setIndentationLeft(indentation);
|
||||
}
|
||||
|
||||
public void setIndentationRight(float indentation) {
|
||||
((Section)this.element).setIndentationRight(indentation);
|
||||
}
|
||||
|
||||
public void setIndentation(float indentation) {
|
||||
((Section)this.element).setIndentation(indentation);
|
||||
}
|
||||
|
||||
public void setBookmarkOpen(boolean bookmarkOpen) {
|
||||
((Section)this.element).setBookmarkOpen(bookmarkOpen);
|
||||
}
|
||||
|
||||
public void setTriggerNewPage(boolean triggerNewPage) {
|
||||
((Section)this.element).setTriggerNewPage(triggerNewPage);
|
||||
}
|
||||
|
||||
public void setBookmarkTitle(String bookmarkTitle) {
|
||||
((Section)this.element).setBookmarkTitle(bookmarkTitle);
|
||||
}
|
||||
|
||||
public void newPage() {
|
||||
((Section)this.element).newPage();
|
||||
}
|
||||
|
||||
public float getIndentationLeft() {
|
||||
return ((Section)this.element).getIndentationLeft();
|
||||
}
|
||||
|
||||
public float getIndentationRight() {
|
||||
return ((Section)this.element).getIndentationRight();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Meta implements Element {
|
||||
private final int type;
|
||||
|
||||
private final StringBuffer content;
|
||||
|
||||
public static final String UNKNOWN = "unknown";
|
||||
|
||||
public static final String PRODUCER = "producer";
|
||||
|
||||
public static final String CREATIONDATE = "creationdate";
|
||||
|
||||
public static final String AUTHOR = "author";
|
||||
|
||||
public static final String KEYWORDS = "keywords";
|
||||
|
||||
public static final String SUBJECT = "subject";
|
||||
|
||||
public static final String TITLE = "title";
|
||||
|
||||
Meta(int type, String content) {
|
||||
this.type = type;
|
||||
this.content = new StringBuffer(content);
|
||||
}
|
||||
|
||||
public Meta(String tag, String content) {
|
||||
this.type = getType(tag);
|
||||
this.content = new StringBuffer(content);
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
return listener.add(this);
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
return new ArrayList<Chunk>();
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public StringBuffer append(String string) {
|
||||
return this.content.append(string);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return this.content.toString();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
switch (this.type) {
|
||||
case 2:
|
||||
return "subject";
|
||||
case 3:
|
||||
return "keywords";
|
||||
case 4:
|
||||
return "author";
|
||||
case 1:
|
||||
return "title";
|
||||
case 5:
|
||||
return "producer";
|
||||
case 6:
|
||||
return "creationdate";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
public static int getType(String tag) {
|
||||
if ("subject".equals(tag))
|
||||
return 2;
|
||||
if ("keywords".equals(tag))
|
||||
return 3;
|
||||
if ("author".equals(tag))
|
||||
return 4;
|
||||
if ("title".equals(tag))
|
||||
return 1;
|
||||
if ("producer".equals(tag))
|
||||
return 5;
|
||||
if ("creationdate".equals(tag))
|
||||
return 6;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
454
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/NOTICE.txt
Normal file
454
rus/WEB-INF/lib/itextpdf-5.5.10_src/com/itextpdf/text/NOTICE.txt
Normal file
|
|
@ -0,0 +1,454 @@
|
|||
(1)
|
||||
|
||||
ExceptionConverter:
|
||||
The original version of this class was published in an article by Heinz Kabutz.
|
||||
Read http://www.javaspecialists.eu/archive/Issue033.html
|
||||
"This material from The Java(tm) Specialists' Newsletter by Maximum Solutions
|
||||
(South Africa). Please contact Maximum Solutions for more information.
|
||||
Heinz Kabutz granted permission to use the example we've built on.
|
||||
|
||||
(2)
|
||||
|
||||
SimpleXMLParser:
|
||||
The original version of this class was published in a JavaWorld article by Steven Brandt:
|
||||
http://www.javaworld.com/javaworld/javatips/jw-javatip128.html
|
||||
Jennifer Orr (JavaWorld) wrote: "You have permission to use the code appearing in
|
||||
Steven Brandt's JavaWorld article, 'Java Tip 128: Create a quick-and-dirty XML parser.'
|
||||
We ask that you reference the author as the creator and JavaWorld as the original publisher
|
||||
of the code." Steven Brandt also agreed with the use of this class.
|
||||
|
||||
(3)
|
||||
|
||||
The following files contain material that was copyrighted by SUN:
|
||||
|
||||
com/itextpdf/text/pdf/LZWDecoder.java (first appearance in iText: 2002-02-08)
|
||||
com/itextpdf/text/pdf/codec/BmpImage.java (first appearance in iText: 2003-06-20)
|
||||
com/itextpdf/text/pdf/codec/PngImage.java (first appearance in iText: 2003-04-25)
|
||||
com/itextpdf/text/pdf/codec/TIFFDirectory.java (first appearance in iText: 2003-04-09)
|
||||
com/itextpdf/text/pdf/codec/TIFFFaxDecoder.java (first appearance in iText: 2003-04-09)
|
||||
com/itextpdf/text/pdf/codec/TIFFField.java (first appearance in iText: 2003-04-09)
|
||||
com/itextpdf/text/pdf/codec/TIFFLZWDecoder.java (first appearance in iText: 2003-04-09)
|
||||
|
||||
The original code was released under the BSD license, and contained the following
|
||||
extra restriction: "You acknowledge that Software is not designed, licensed or intended
|
||||
for use in the design, construction, operation or maintenance of any nuclear facility."
|
||||
|
||||
In a mail sent to Bruno Lowagie on January 23, 2008, Brian Burkhalter (@sun.com)
|
||||
writes: "This code is under a BSD license and supersedes the older codec packages
|
||||
on which your code is based. It also includes numerous fixes among them being the
|
||||
ability to handle a lot of 'broken' TIFFs."
|
||||
|
||||
Note that numerous fixes were applied to the code used in iText by Paulo Soares,
|
||||
but apart from the fixes there were no essential changes between the code that
|
||||
was originally adapted and the code that is now available under the following
|
||||
license:
|
||||
|
||||
Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistribution of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistribution in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
Neither the name of Sun Microsystems, Inc. or the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
This software is provided "AS IS," without a warranty of any
|
||||
kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
|
||||
WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
|
||||
EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
|
||||
NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
|
||||
USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
|
||||
DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
|
||||
ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
|
||||
CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
|
||||
REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
|
||||
INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
You acknowledge that this software is not designed or intended for
|
||||
use in the design, construction, operation or maintenance of any
|
||||
nuclear facility.
|
||||
|
||||
The main difference can be found in the final paragraph: the restriction
|
||||
that the source code is not "licensed" in this particular situation has
|
||||
been removed.
|
||||
|
||||
FYI: Brian also added: "A bit of history might be in order.
|
||||
The codec classes that you used originally were based on some
|
||||
classes included with JAI but not strictly part of JAI.
|
||||
As of Java SE 1.4 an official Image I/O framework was
|
||||
added in javax.imageio.... This frameork supports these formats:
|
||||
|
||||
Java 1.4: GIF (read only), JPEG, PNG
|
||||
Java 1.5: Added support for BMP and WBMP
|
||||
Java 1.6: Added support for writing GIF
|
||||
|
||||
The JAI Image I/O Tools packages (jai-imageio-core) were created
|
||||
to support formats handled by JAI but not included in Java SE
|
||||
as well as some new things like JPEG2000."
|
||||
|
||||
(4) the file com/itextpdf/text/pdf/codec/TIFFConstants
|
||||
and some other TIFF related code is derived from LIBTIFF:
|
||||
|
||||
Copyright (c) 1988-1997 Sam Leffler
|
||||
Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and
|
||||
its documentation for any purpose is hereby granted without fee, provided
|
||||
that (i) the above copyright notices and this permission notice appear in
|
||||
all copies of the software and related documentation, and (ii) the names of
|
||||
Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
publicity relating to the software without the specific, prior written
|
||||
permission of Sam Leffler and Silicon Graphics.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
||||
|
||||
(5)
|
||||
|
||||
BidiOrder:
|
||||
As stated in the Javadoc comments, materials from Unicode.org
|
||||
are used in the class com/itextpdf/text/pdf/BidiOrder.java
|
||||
The following license applies to these materials:
|
||||
http://www.unicode.org/copyright.html#Exhibit1
|
||||
|
||||
EXHIBIT 1
|
||||
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
|
||||
|
||||
Unicode Data Files include all data files under the directories
|
||||
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
and http://www.unicode.org/cldr/data/ .
|
||||
Unicode Software includes any source code published in the Unicode Standard
|
||||
or under the directories http://www.unicode.org/Public/, http://www.unicode.org/reports/,
|
||||
and http://www.unicode.org/cldr/data/.
|
||||
|
||||
NOTICE TO USER: Carefully read the following legal agreement. BY DOWNLOADING,
|
||||
INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES ("DATA FILES"),
|
||||
AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY,
|
||||
ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
|
||||
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
|
||||
|
||||
COPYRIGHT AND PERMISSION NOTICE
|
||||
Copyright (C) 1991-2007 Unicode, Inc. All rights reserved. Distributed under
|
||||
the Terms of Use in http://www.unicode.org/copyright.html.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of the Unicode data files and any associated documentation (the "Data Files")
|
||||
or Unicode software and any associated documentation (the "Software") to deal
|
||||
in the Data Files or Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, and/or sell copies
|
||||
of the Data Files or Software, and to permit persons to whom the Data Files
|
||||
or Software are furnished to do so, provided that (a) the above copyright
|
||||
notice(s) and this permission notice appear with all copies of the Data Files
|
||||
or Software, (b) both the above copyright notice(s) and this permission notice
|
||||
appear in associated documentation, and (c) there is clear notice in each
|
||||
modified Data File or in the Software as well as in the documentation associated
|
||||
with the Data File(s) or Software that the data or software has been modified.
|
||||
|
||||
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE
|
||||
LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of a copyright holder shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in these Data Files or Software without prior written authorization of the
|
||||
copyright holder.
|
||||
|
||||
(6) Contributions by Deutsche Bahn
|
||||
|
||||
Our customer Deutsche Bahn provided a patch regarding tables using an agreement
|
||||
different from the custom Contributor License Agreement, but as liberal as an
|
||||
MIT-style license agreement.
|
||||
|
||||
This contribution involves:
|
||||
a. extra colspan functionality added to the following classes:
|
||||
ColumnText, PdfPTable, and PdfPRow.
|
||||
b. an extra table event: PdfPTableEventAfterSplit (also involving
|
||||
PdfPTableEventForwarder).
|
||||
|
||||
(7) Adobe XMP library
|
||||
|
||||
In package com.itextpdf.xmp, we're using the Adobe XMP library.
|
||||
This library was released under the following terms:
|
||||
|
||||
Copyright (c) 2006, Adobe Systems Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
This product includes software developed by the Adobe Systems Incorporated.
|
||||
4. Neither the name of the Adobe Systems Incorporated nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ADOBE SYSTEMS INCORPORATED ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL ADOBE SYSTEMS INCORPORATED BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
http://www.adobe.com/devnet/xmp/library/eula-xmp-library-java.html
|
||||
|
||||
(8)
|
||||
Some files use code from different Apache projects.
|
||||
The source code of these files contains the appropriate copyright notices
|
||||
as described in the Appendix of http://www.apache.org/licenses/LICENSE-2.0
|
||||
This is a copy of the text that can be found at that specific URL:
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License.
|
||||
|
||||
Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License.
|
||||
|
||||
Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution.
|
||||
|
||||
You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
* You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
* You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
* You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
* If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions.
|
||||
|
||||
Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks.
|
||||
|
||||
This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty.
|
||||
|
||||
Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability.
|
||||
|
||||
In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability.
|
||||
|
||||
While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Extra information:
|
||||
|
||||
if you use the PdfCleanUp tool in the xtra package, you also need the
|
||||
following Apache libraries:
|
||||
|
||||
- Apache Commons: commons-imaging
|
||||
- Apache Commons: commons-io
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class PageSize {
|
||||
public static final Rectangle LETTER = new RectangleReadOnly(612.0F, 792.0F);
|
||||
|
||||
public static final Rectangle NOTE = new RectangleReadOnly(540.0F, 720.0F);
|
||||
|
||||
public static final Rectangle LEGAL = new RectangleReadOnly(612.0F, 1008.0F);
|
||||
|
||||
public static final Rectangle TABLOID = new RectangleReadOnly(792.0F, 1224.0F);
|
||||
|
||||
public static final Rectangle EXECUTIVE = new RectangleReadOnly(522.0F, 756.0F);
|
||||
|
||||
public static final Rectangle POSTCARD = new RectangleReadOnly(283.0F, 416.0F);
|
||||
|
||||
public static final Rectangle A0 = new RectangleReadOnly(2384.0F, 3370.0F);
|
||||
|
||||
public static final Rectangle A1 = new RectangleReadOnly(1684.0F, 2384.0F);
|
||||
|
||||
public static final Rectangle A2 = new RectangleReadOnly(1191.0F, 1684.0F);
|
||||
|
||||
public static final Rectangle A3 = new RectangleReadOnly(842.0F, 1191.0F);
|
||||
|
||||
public static final Rectangle A4 = new RectangleReadOnly(595.0F, 842.0F);
|
||||
|
||||
public static final Rectangle A5 = new RectangleReadOnly(420.0F, 595.0F);
|
||||
|
||||
public static final Rectangle A6 = new RectangleReadOnly(297.0F, 420.0F);
|
||||
|
||||
public static final Rectangle A7 = new RectangleReadOnly(210.0F, 297.0F);
|
||||
|
||||
public static final Rectangle A8 = new RectangleReadOnly(148.0F, 210.0F);
|
||||
|
||||
public static final Rectangle A9 = new RectangleReadOnly(105.0F, 148.0F);
|
||||
|
||||
public static final Rectangle A10 = new RectangleReadOnly(73.0F, 105.0F);
|
||||
|
||||
public static final Rectangle B0 = new RectangleReadOnly(2834.0F, 4008.0F);
|
||||
|
||||
public static final Rectangle B1 = new RectangleReadOnly(2004.0F, 2834.0F);
|
||||
|
||||
public static final Rectangle B2 = new RectangleReadOnly(1417.0F, 2004.0F);
|
||||
|
||||
public static final Rectangle B3 = new RectangleReadOnly(1000.0F, 1417.0F);
|
||||
|
||||
public static final Rectangle B4 = new RectangleReadOnly(708.0F, 1000.0F);
|
||||
|
||||
public static final Rectangle B5 = new RectangleReadOnly(498.0F, 708.0F);
|
||||
|
||||
public static final Rectangle B6 = new RectangleReadOnly(354.0F, 498.0F);
|
||||
|
||||
public static final Rectangle B7 = new RectangleReadOnly(249.0F, 354.0F);
|
||||
|
||||
public static final Rectangle B8 = new RectangleReadOnly(175.0F, 249.0F);
|
||||
|
||||
public static final Rectangle B9 = new RectangleReadOnly(124.0F, 175.0F);
|
||||
|
||||
public static final Rectangle B10 = new RectangleReadOnly(87.0F, 124.0F);
|
||||
|
||||
public static final Rectangle ARCH_E = new RectangleReadOnly(2592.0F, 3456.0F);
|
||||
|
||||
public static final Rectangle ARCH_D = new RectangleReadOnly(1728.0F, 2592.0F);
|
||||
|
||||
public static final Rectangle ARCH_C = new RectangleReadOnly(1296.0F, 1728.0F);
|
||||
|
||||
public static final Rectangle ARCH_B = new RectangleReadOnly(864.0F, 1296.0F);
|
||||
|
||||
public static final Rectangle ARCH_A = new RectangleReadOnly(648.0F, 864.0F);
|
||||
|
||||
public static final Rectangle FLSA = new RectangleReadOnly(612.0F, 936.0F);
|
||||
|
||||
public static final Rectangle FLSE = new RectangleReadOnly(648.0F, 936.0F);
|
||||
|
||||
public static final Rectangle HALFLETTER = new RectangleReadOnly(396.0F, 612.0F);
|
||||
|
||||
public static final Rectangle _11X17 = new RectangleReadOnly(792.0F, 1224.0F);
|
||||
|
||||
public static final Rectangle ID_1 = new RectangleReadOnly(242.65F, 153.0F);
|
||||
|
||||
public static final Rectangle ID_2 = new RectangleReadOnly(297.0F, 210.0F);
|
||||
|
||||
public static final Rectangle ID_3 = new RectangleReadOnly(354.0F, 249.0F);
|
||||
|
||||
public static final Rectangle LEDGER = new RectangleReadOnly(1224.0F, 792.0F);
|
||||
|
||||
public static final Rectangle CROWN_QUARTO = new RectangleReadOnly(535.0F, 697.0F);
|
||||
|
||||
public static final Rectangle LARGE_CROWN_QUARTO = new RectangleReadOnly(569.0F, 731.0F);
|
||||
|
||||
public static final Rectangle DEMY_QUARTO = new RectangleReadOnly(620.0F, 782.0F);
|
||||
|
||||
public static final Rectangle ROYAL_QUARTO = new RectangleReadOnly(671.0F, 884.0F);
|
||||
|
||||
public static final Rectangle CROWN_OCTAVO = new RectangleReadOnly(348.0F, 527.0F);
|
||||
|
||||
public static final Rectangle LARGE_CROWN_OCTAVO = new RectangleReadOnly(365.0F, 561.0F);
|
||||
|
||||
public static final Rectangle DEMY_OCTAVO = new RectangleReadOnly(391.0F, 612.0F);
|
||||
|
||||
public static final Rectangle ROYAL_OCTAVO = new RectangleReadOnly(442.0F, 663.0F);
|
||||
|
||||
public static final Rectangle SMALL_PAPERBACK = new RectangleReadOnly(314.0F, 504.0F);
|
||||
|
||||
public static final Rectangle PENGUIN_SMALL_PAPERBACK = new RectangleReadOnly(314.0F, 513.0F);
|
||||
|
||||
public static final Rectangle PENGUIN_LARGE_PAPERBACK = new RectangleReadOnly(365.0F, 561.0F);
|
||||
|
||||
public static final Rectangle LETTER_LANDSCAPE = new RectangleReadOnly(612.0F, 792.0F, 90);
|
||||
|
||||
public static final Rectangle LEGAL_LANDSCAPE = new RectangleReadOnly(612.0F, 1008.0F, 90);
|
||||
|
||||
public static final Rectangle A4_LANDSCAPE = new RectangleReadOnly(595.0F, 842.0F, 90);
|
||||
|
||||
public static Rectangle getRectangle(String name) {
|
||||
name = name.trim().toUpperCase();
|
||||
int pos = name.indexOf(' ');
|
||||
if (pos == -1)
|
||||
try {
|
||||
Field field = PageSize.class.getDeclaredField(name.toUpperCase());
|
||||
return (Rectangle)field.get(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(MessageLocalization.getComposedMessage("can.t.find.page.size.1", name));
|
||||
}
|
||||
try {
|
||||
String width = name.substring(0, pos);
|
||||
String height = name.substring(pos + 1);
|
||||
return new Rectangle(Float.parseFloat(width), Float.parseFloat(height));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(MessageLocalization.getComposedMessage("1.is.not.a.valid.page.size.format.2", name, e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,308 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.api.Indentable;
|
||||
import com.itextpdf.text.api.Spaceable;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.PdfPTable;
|
||||
import com.itextpdf.text.pdf.interfaces.IAccessibleElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Paragraph extends Phrase implements Indentable, Spaceable, IAccessibleElement {
|
||||
private static final long serialVersionUID = 7852314969733375514L;
|
||||
|
||||
protected int alignment = -1;
|
||||
|
||||
protected float indentationLeft;
|
||||
|
||||
protected float indentationRight;
|
||||
|
||||
private float firstLineIndent = 0.0F;
|
||||
|
||||
protected float spacingBefore;
|
||||
|
||||
protected float spacingAfter;
|
||||
|
||||
private float extraParagraphSpace = 0.0F;
|
||||
|
||||
protected boolean keeptogether = false;
|
||||
|
||||
protected float paddingTop;
|
||||
|
||||
protected PdfName role = PdfName.P;
|
||||
|
||||
protected HashMap<PdfName, PdfObject> accessibleAttributes = null;
|
||||
|
||||
protected AccessibleElementId id = null;
|
||||
|
||||
public Paragraph(float leading) {
|
||||
super(leading);
|
||||
}
|
||||
|
||||
public Paragraph(Chunk chunk) {
|
||||
super(chunk);
|
||||
}
|
||||
|
||||
public Paragraph(float leading, Chunk chunk) {
|
||||
super(leading, chunk);
|
||||
}
|
||||
|
||||
public Paragraph(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public Paragraph(String string, Font font) {
|
||||
super(string, font);
|
||||
}
|
||||
|
||||
public Paragraph(float leading, String string) {
|
||||
super(leading, string);
|
||||
}
|
||||
|
||||
public Paragraph(float leading, String string, Font font) {
|
||||
super(leading, string, font);
|
||||
}
|
||||
|
||||
public Paragraph(Phrase phrase) {
|
||||
super(phrase);
|
||||
if (phrase instanceof Paragraph) {
|
||||
Paragraph p = (Paragraph)phrase;
|
||||
setAlignment(p.alignment);
|
||||
setIndentationLeft(p.getIndentationLeft());
|
||||
setIndentationRight(p.getIndentationRight());
|
||||
setFirstLineIndent(p.getFirstLineIndent());
|
||||
setSpacingAfter(p.getSpacingAfter());
|
||||
setSpacingBefore(p.getSpacingBefore());
|
||||
setExtraParagraphSpace(p.getExtraParagraphSpace());
|
||||
setRole(p.role);
|
||||
this.id = p.getId();
|
||||
if (p.accessibleAttributes != null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>(p.accessibleAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public Paragraph cloneShallow(boolean spacingBefore) {
|
||||
Paragraph copy = new Paragraph();
|
||||
populateProperties(copy, spacingBefore);
|
||||
return copy;
|
||||
}
|
||||
|
||||
protected void populateProperties(Paragraph copy, boolean spacingBefore) {
|
||||
copy.setFont(getFont());
|
||||
copy.setAlignment(getAlignment());
|
||||
copy.setLeading(getLeading(), this.multipliedLeading);
|
||||
copy.setIndentationLeft(getIndentationLeft());
|
||||
copy.setIndentationRight(getIndentationRight());
|
||||
copy.setFirstLineIndent(getFirstLineIndent());
|
||||
copy.setSpacingAfter(getSpacingAfter());
|
||||
if (spacingBefore)
|
||||
copy.setSpacingBefore(getSpacingBefore());
|
||||
copy.setExtraParagraphSpace(getExtraParagraphSpace());
|
||||
copy.setRole(this.role);
|
||||
copy.id = getId();
|
||||
if (this.accessibleAttributes != null)
|
||||
copy.accessibleAttributes = new HashMap<PdfName, PdfObject>(this.accessibleAttributes);
|
||||
copy.setTabSettings(getTabSettings());
|
||||
copy.setKeepTogether(getKeepTogether());
|
||||
}
|
||||
|
||||
public java.util.List<Element> breakUp() {
|
||||
java.util.List<Element> list = new ArrayList<Element>();
|
||||
Paragraph tmp = null;
|
||||
for (Element e : (Iterable<Element>)this) {
|
||||
if (e.type() == 14 || e.type() == 23 || e.type() == 12) {
|
||||
if (tmp != null && tmp.size() > 0) {
|
||||
tmp.setSpacingAfter(0.0F);
|
||||
list.add(tmp);
|
||||
tmp = cloneShallow(false);
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
ListItem firstItem;
|
||||
switch (e.type()) {
|
||||
case 23:
|
||||
((PdfPTable)e).setSpacingBefore(getSpacingBefore());
|
||||
break;
|
||||
case 12:
|
||||
((Paragraph)e).setSpacingBefore(getSpacingBefore());
|
||||
break;
|
||||
case 14:
|
||||
firstItem = ((List)e).getFirstItem();
|
||||
if (firstItem != null)
|
||||
firstItem.setSpacingBefore(getSpacingBefore());
|
||||
break;
|
||||
}
|
||||
}
|
||||
list.add(e);
|
||||
continue;
|
||||
}
|
||||
if (tmp == null)
|
||||
tmp = cloneShallow((list.size() == 0));
|
||||
tmp.add(e);
|
||||
}
|
||||
if (tmp != null && tmp.size() > 0)
|
||||
list.add(tmp);
|
||||
if (list.size() != 0) {
|
||||
ListItem lastItem;
|
||||
Element lastElement = list.get(list.size() - 1);
|
||||
switch (lastElement.type()) {
|
||||
case 23:
|
||||
((PdfPTable)lastElement).setSpacingAfter(getSpacingAfter());
|
||||
break;
|
||||
case 12:
|
||||
((Paragraph)lastElement).setSpacingAfter(getSpacingAfter());
|
||||
break;
|
||||
case 14:
|
||||
lastItem = ((List)lastElement).getLastItem();
|
||||
if (lastItem != null)
|
||||
lastItem.setSpacingAfter(getSpacingAfter());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
if (o instanceof List) {
|
||||
List list = (List)o;
|
||||
list.setIndentationLeft(list.getIndentationLeft() + this.indentationLeft);
|
||||
list.setIndentationRight(this.indentationRight);
|
||||
return super.add(list);
|
||||
}
|
||||
if (o instanceof Image) {
|
||||
addSpecial(o);
|
||||
return true;
|
||||
}
|
||||
if (o instanceof Paragraph) {
|
||||
addSpecial(o);
|
||||
return true;
|
||||
}
|
||||
return super.add(o);
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public void setIndentationLeft(float indentation) {
|
||||
this.indentationLeft = indentation;
|
||||
}
|
||||
|
||||
public void setIndentationRight(float indentation) {
|
||||
this.indentationRight = indentation;
|
||||
}
|
||||
|
||||
public void setFirstLineIndent(float firstLineIndent) {
|
||||
this.firstLineIndent = firstLineIndent;
|
||||
}
|
||||
|
||||
public void setSpacingBefore(float spacing) {
|
||||
this.spacingBefore = spacing;
|
||||
}
|
||||
|
||||
public void setSpacingAfter(float spacing) {
|
||||
this.spacingAfter = spacing;
|
||||
}
|
||||
|
||||
public void setKeepTogether(boolean keeptogether) {
|
||||
this.keeptogether = keeptogether;
|
||||
}
|
||||
|
||||
public boolean getKeepTogether() {
|
||||
return this.keeptogether;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return this.alignment;
|
||||
}
|
||||
|
||||
public float getIndentationLeft() {
|
||||
return this.indentationLeft;
|
||||
}
|
||||
|
||||
public float getIndentationRight() {
|
||||
return this.indentationRight;
|
||||
}
|
||||
|
||||
public float getFirstLineIndent() {
|
||||
return this.firstLineIndent;
|
||||
}
|
||||
|
||||
public float getSpacingBefore() {
|
||||
return this.spacingBefore;
|
||||
}
|
||||
|
||||
public float getSpacingAfter() {
|
||||
return this.spacingAfter;
|
||||
}
|
||||
|
||||
public float getExtraParagraphSpace() {
|
||||
return this.extraParagraphSpace;
|
||||
}
|
||||
|
||||
public void setExtraParagraphSpace(float extraParagraphSpace) {
|
||||
this.extraParagraphSpace = extraParagraphSpace;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public float spacingBefore() {
|
||||
return getSpacingBefore();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public float spacingAfter() {
|
||||
return this.spacingAfter;
|
||||
}
|
||||
|
||||
public PdfObject getAccessibleAttribute(PdfName key) {
|
||||
if (this.accessibleAttributes != null)
|
||||
return this.accessibleAttributes.get(key);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setAccessibleAttribute(PdfName key, PdfObject value) {
|
||||
if (this.accessibleAttributes == null)
|
||||
this.accessibleAttributes = new HashMap<PdfName, PdfObject>();
|
||||
this.accessibleAttributes.put(key, value);
|
||||
}
|
||||
|
||||
public HashMap<PdfName, PdfObject> getAccessibleAttributes() {
|
||||
return this.accessibleAttributes;
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public AccessibleElementId getId() {
|
||||
if (this.id == null)
|
||||
this.id = new AccessibleElementId();
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AccessibleElementId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getPaddingTop() {
|
||||
return this.paddingTop;
|
||||
}
|
||||
|
||||
public void setPaddingTop(float paddingTop) {
|
||||
this.paddingTop = paddingTop;
|
||||
}
|
||||
|
||||
public Paragraph() {}
|
||||
}
|
||||
|
|
@ -0,0 +1,358 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.HyphenationEvent;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class Phrase extends ArrayList<Element> implements TextElementArray {
|
||||
private static final long serialVersionUID = 2643594602455068231L;
|
||||
|
||||
protected float leading = Float.NaN;
|
||||
|
||||
protected float multipliedLeading = 0.0F;
|
||||
|
||||
protected Font font;
|
||||
|
||||
protected HyphenationEvent hyphenation = null;
|
||||
|
||||
protected TabSettings tabSettings = null;
|
||||
|
||||
public Phrase() {
|
||||
this(16.0F);
|
||||
}
|
||||
|
||||
public Phrase(Phrase phrase) {
|
||||
addAll(phrase);
|
||||
setLeading(phrase.getLeading(), phrase.getMultipliedLeading());
|
||||
this.font = phrase.getFont();
|
||||
this.tabSettings = phrase.getTabSettings();
|
||||
setHyphenation(phrase.getHyphenation());
|
||||
}
|
||||
|
||||
public Phrase(float leading) {
|
||||
this.leading = leading;
|
||||
this.font = new Font();
|
||||
}
|
||||
|
||||
public Phrase(Chunk chunk) {
|
||||
super.add(chunk);
|
||||
this.font = chunk.getFont();
|
||||
setHyphenation(chunk.getHyphenation());
|
||||
}
|
||||
|
||||
public Phrase(float leading, Chunk chunk) {
|
||||
this.leading = leading;
|
||||
super.add(chunk);
|
||||
this.font = chunk.getFont();
|
||||
setHyphenation(chunk.getHyphenation());
|
||||
}
|
||||
|
||||
public Phrase(String string) {
|
||||
this(Float.NaN, string, new Font());
|
||||
}
|
||||
|
||||
public Phrase(String string, Font font) {
|
||||
this(Float.NaN, string, font);
|
||||
}
|
||||
|
||||
public Phrase(float leading, String string) {
|
||||
this(leading, string, new Font());
|
||||
}
|
||||
|
||||
public Phrase(float leading, String string, Font font) {
|
||||
this.leading = leading;
|
||||
this.font = font;
|
||||
if (string != null && string.length() != 0)
|
||||
super.add(new Chunk(string, font));
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
for (Object element : (Iterable<Object>)this)
|
||||
listener.add((Element)element);
|
||||
return true;
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 11;
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
java.util.List<Chunk> tmp = new ArrayList<Chunk>();
|
||||
for (Element element : (Iterable<Element>)this)
|
||||
tmp.addAll(element.getChunks());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void add(int index, Element element) {
|
||||
Chunk chunk;
|
||||
if (element == null)
|
||||
return;
|
||||
switch (element.type()) {
|
||||
case 10:
|
||||
chunk = (Chunk)element;
|
||||
if (!this.font.isStandardFont())
|
||||
chunk.setFont(this.font.difference(chunk.getFont()));
|
||||
if (this.hyphenation != null && chunk.getHyphenation() == null && !chunk.isEmpty())
|
||||
chunk.setHyphenation(this.hyphenation);
|
||||
super.add(index, chunk);
|
||||
return;
|
||||
case 11:
|
||||
case 12:
|
||||
case 14:
|
||||
case 17:
|
||||
case 23:
|
||||
case 29:
|
||||
case 37:
|
||||
case 50:
|
||||
case 55:
|
||||
case 666:
|
||||
super.add(index, element);
|
||||
return;
|
||||
}
|
||||
throw new ClassCastException(MessageLocalization.getComposedMessage("insertion.of.illegal.element.1", element.getClass().getName()));
|
||||
}
|
||||
|
||||
public boolean add(String s) {
|
||||
if (s == null)
|
||||
return false;
|
||||
return super.add(new Chunk(s, this.font));
|
||||
}
|
||||
|
||||
public boolean add(Element element) {
|
||||
if (element == null)
|
||||
return false;
|
||||
try {
|
||||
Phrase phrase;
|
||||
boolean success;
|
||||
switch (element.type()) {
|
||||
case 10:
|
||||
return addChunk((Chunk)element);
|
||||
case 11:
|
||||
case 12:
|
||||
phrase = (Phrase)element;
|
||||
success = true;
|
||||
for (Object element2 : (Iterable<Object>)phrase) {
|
||||
Element e = (Element)element2;
|
||||
if (e instanceof Chunk) {
|
||||
success &= addChunk((Chunk)e);
|
||||
continue;
|
||||
}
|
||||
success &= add(e);
|
||||
}
|
||||
return success;
|
||||
case 14:
|
||||
case 17:
|
||||
case 23:
|
||||
case 29:
|
||||
case 37:
|
||||
case 50:
|
||||
case 55:
|
||||
case 666:
|
||||
return super.add(element);
|
||||
}
|
||||
throw new ClassCastException(String.valueOf(element.type()));
|
||||
} catch (ClassCastException cce) {
|
||||
throw new ClassCastException(MessageLocalization.getComposedMessage("insertion.of.illegal.element.1", cce.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends Element> collection) {
|
||||
for (Element e : collection)
|
||||
add(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean addChunk(Chunk chunk) {
|
||||
Font f = chunk.getFont();
|
||||
String c = chunk.getContent();
|
||||
if (this.font != null && !this.font.isStandardFont())
|
||||
f = this.font.difference(chunk.getFont());
|
||||
if (size() > 0 && !chunk.hasAttributes())
|
||||
try {
|
||||
boolean sameRole;
|
||||
Chunk previous = (Chunk)get(size() - 1);
|
||||
PdfName previousRole = previous.getRole();
|
||||
PdfName chunkRole = chunk.getRole();
|
||||
if (previousRole == null || chunkRole == null) {
|
||||
sameRole = true;
|
||||
} else {
|
||||
sameRole = previousRole.equals(chunkRole);
|
||||
}
|
||||
if (sameRole && !previous.hasAttributes() && !chunk.hasAccessibleAttributes() && !previous.hasAccessibleAttributes() && (f == null ||
|
||||
|
||||
f.compareTo(previous.getFont()) == 0) &&
|
||||
!"".equals(previous.getContent().trim()) &&
|
||||
!"".equals(c.trim())) {
|
||||
previous.append(c);
|
||||
return true;
|
||||
}
|
||||
} catch (ClassCastException e) {}
|
||||
Chunk newChunk = new Chunk(c, f);
|
||||
newChunk.setAttributes(chunk.getAttributes());
|
||||
newChunk.role = chunk.getRole();
|
||||
newChunk.accessibleAttributes = chunk.getAccessibleAttributes();
|
||||
if (this.hyphenation != null && newChunk.getHyphenation() == null && !newChunk.isEmpty())
|
||||
newChunk.setHyphenation(this.hyphenation);
|
||||
return super.add(newChunk);
|
||||
}
|
||||
|
||||
protected void addSpecial(Element object) {
|
||||
super.add(object);
|
||||
}
|
||||
|
||||
public void setLeading(float fixedLeading, float multipliedLeading) {
|
||||
this.leading = fixedLeading;
|
||||
this.multipliedLeading = multipliedLeading;
|
||||
}
|
||||
|
||||
public void setLeading(float fixedLeading) {
|
||||
this.leading = fixedLeading;
|
||||
this.multipliedLeading = 0.0F;
|
||||
}
|
||||
|
||||
public void setMultipliedLeading(float multipliedLeading) {
|
||||
this.leading = 0.0F;
|
||||
this.multipliedLeading = multipliedLeading;
|
||||
}
|
||||
|
||||
public void setFont(Font font) {
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public float getLeading() {
|
||||
if (Float.isNaN(this.leading) && this.font != null)
|
||||
return this.font.getCalculatedLeading(1.5F);
|
||||
return this.leading;
|
||||
}
|
||||
|
||||
public float getMultipliedLeading() {
|
||||
return this.multipliedLeading;
|
||||
}
|
||||
|
||||
public float getTotalLeading() {
|
||||
float m = (this.font == null) ? (12.0F * this.multipliedLeading) :
|
||||
this.font.getCalculatedLeading(this.multipliedLeading);
|
||||
if (m > 0.0F && !hasLeading())
|
||||
return m;
|
||||
return getLeading() + m;
|
||||
}
|
||||
|
||||
public boolean hasLeading() {
|
||||
if (Float.isNaN(this.leading))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public Font getFont() {
|
||||
return this.font;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (Chunk c : getChunks())
|
||||
buf.append(c.toString());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
Element element;
|
||||
switch (size()) {
|
||||
case 0:
|
||||
return true;
|
||||
case 1:
|
||||
element = get(0);
|
||||
if (element.type() == 10 && ((Chunk)element).isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public HyphenationEvent getHyphenation() {
|
||||
return this.hyphenation;
|
||||
}
|
||||
|
||||
public void setHyphenation(HyphenationEvent hyphenation) {
|
||||
this.hyphenation = hyphenation;
|
||||
}
|
||||
|
||||
public TabSettings getTabSettings() {
|
||||
return this.tabSettings;
|
||||
}
|
||||
|
||||
public void setTabSettings(TabSettings tabSettings) {
|
||||
this.tabSettings = tabSettings;
|
||||
}
|
||||
|
||||
public static final Phrase getInstance(String string) {
|
||||
return getInstance(16, string, new Font());
|
||||
}
|
||||
|
||||
public static final Phrase getInstance(int leading, String string) {
|
||||
return getInstance(leading, string, new Font());
|
||||
}
|
||||
|
||||
public static final Phrase getInstance(int leading, String string, Font font) {
|
||||
Phrase p = new Phrase(true);
|
||||
p.setLeading((float)leading);
|
||||
p.font = font;
|
||||
if (font.getFamily() != Font.FontFamily.SYMBOL && font.getFamily() != Font.FontFamily.ZAPFDINGBATS && font.getBaseFont() == null) {
|
||||
int index;
|
||||
while ((index = SpecialSymbol.index(string)) > -1) {
|
||||
if (index > 0) {
|
||||
String firstPart = string.substring(0, index);
|
||||
p.add(new Chunk(firstPart, font));
|
||||
string = string.substring(index);
|
||||
}
|
||||
Font symbol = new Font(Font.FontFamily.SYMBOL, font.getSize(), font.getStyle(), font.getColor());
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(SpecialSymbol.getCorrespondingSymbol(string.charAt(0)));
|
||||
string = string.substring(1);
|
||||
while (SpecialSymbol.index(string) == 0) {
|
||||
buf.append(SpecialSymbol.getCorrespondingSymbol(string.charAt(0)));
|
||||
string = string.substring(1);
|
||||
}
|
||||
p.add(new Chunk(buf.toString(), symbol));
|
||||
}
|
||||
}
|
||||
if (string != null && string.length() != 0)
|
||||
p.add(new Chunk(string, font));
|
||||
return p;
|
||||
}
|
||||
|
||||
public boolean trim() {
|
||||
while (size() > 0) {
|
||||
Element firstChunk = get(0);
|
||||
if (firstChunk instanceof Chunk && ((Chunk)firstChunk).isWhitespace()) {
|
||||
remove(firstChunk);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
while (size() > 0) {
|
||||
Element lastChunk = get(size() - 1);
|
||||
if (lastChunk instanceof Chunk && ((Chunk)lastChunk).isWhitespace()) {
|
||||
remove(lastChunk);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (size() > 0);
|
||||
}
|
||||
|
||||
private Phrase(boolean dummy) {}
|
||||
}
|
||||
|
|
@ -0,0 +1,449 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.GrayColor;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Rectangle implements Element {
|
||||
public static final int UNDEFINED = -1;
|
||||
|
||||
public static final int TOP = 1;
|
||||
|
||||
public static final int BOTTOM = 2;
|
||||
|
||||
public static final int LEFT = 4;
|
||||
|
||||
public static final int RIGHT = 8;
|
||||
|
||||
public static final int NO_BORDER = 0;
|
||||
|
||||
public static final int BOX = 15;
|
||||
|
||||
protected float llx;
|
||||
|
||||
protected float lly;
|
||||
|
||||
protected float urx;
|
||||
|
||||
protected float ury;
|
||||
|
||||
protected int rotation = 0;
|
||||
|
||||
protected BaseColor backgroundColor = null;
|
||||
|
||||
protected int border = -1;
|
||||
|
||||
protected boolean useVariableBorders = false;
|
||||
|
||||
protected float borderWidth = -1.0F;
|
||||
|
||||
protected float borderWidthLeft = -1.0F;
|
||||
|
||||
protected float borderWidthRight = -1.0F;
|
||||
|
||||
protected float borderWidthTop = -1.0F;
|
||||
|
||||
protected float borderWidthBottom = -1.0F;
|
||||
|
||||
protected BaseColor borderColor = null;
|
||||
|
||||
protected BaseColor borderColorLeft = null;
|
||||
|
||||
protected BaseColor borderColorRight = null;
|
||||
|
||||
protected BaseColor borderColorTop = null;
|
||||
|
||||
protected BaseColor borderColorBottom = null;
|
||||
|
||||
public Rectangle(float llx, float lly, float urx, float ury) {
|
||||
this.llx = llx;
|
||||
this.lly = lly;
|
||||
this.urx = urx;
|
||||
this.ury = ury;
|
||||
}
|
||||
|
||||
public Rectangle(float llx, float lly, float urx, float ury, int rotation) {
|
||||
this(llx, lly, urx, ury);
|
||||
setRotation(rotation);
|
||||
}
|
||||
|
||||
public Rectangle(float urx, float ury) {
|
||||
this(0.0F, 0.0F, urx, ury);
|
||||
}
|
||||
|
||||
public Rectangle(float urx, float ury, int rotation) {
|
||||
this(0.0F, 0.0F, urx, ury, rotation);
|
||||
}
|
||||
|
||||
public Rectangle(Rectangle rect) {
|
||||
this(rect.llx, rect.lly, rect.urx, rect.ury);
|
||||
cloneNonPositionParameters(rect);
|
||||
}
|
||||
|
||||
public Rectangle(com.itextpdf.awt.geom.Rectangle rect) {
|
||||
this((float)rect.getX(), (float)rect.getY(), (float)(rect.getX() + rect.getWidth()), (float)(rect.getY() + rect.getHeight()));
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
return listener.add(this);
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
return new ArrayList<Chunk>();
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLeft(float llx) {
|
||||
this.llx = llx;
|
||||
}
|
||||
|
||||
public float getLeft() {
|
||||
return this.llx;
|
||||
}
|
||||
|
||||
public float getLeft(float margin) {
|
||||
return this.llx + margin;
|
||||
}
|
||||
|
||||
public void setRight(float urx) {
|
||||
this.urx = urx;
|
||||
}
|
||||
|
||||
public float getRight() {
|
||||
return this.urx;
|
||||
}
|
||||
|
||||
public float getRight(float margin) {
|
||||
return this.urx - margin;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return this.urx - this.llx;
|
||||
}
|
||||
|
||||
public void setTop(float ury) {
|
||||
this.ury = ury;
|
||||
}
|
||||
|
||||
public float getTop() {
|
||||
return this.ury;
|
||||
}
|
||||
|
||||
public float getTop(float margin) {
|
||||
return this.ury - margin;
|
||||
}
|
||||
|
||||
public void setBottom(float lly) {
|
||||
this.lly = lly;
|
||||
}
|
||||
|
||||
public float getBottom() {
|
||||
return this.lly;
|
||||
}
|
||||
|
||||
public float getBottom(float margin) {
|
||||
return this.lly + margin;
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return this.ury - this.lly;
|
||||
}
|
||||
|
||||
public void normalize() {
|
||||
if (this.llx > this.urx) {
|
||||
float a = this.llx;
|
||||
this.llx = this.urx;
|
||||
this.urx = a;
|
||||
}
|
||||
if (this.lly > this.ury) {
|
||||
float a = this.lly;
|
||||
this.lly = this.ury;
|
||||
this.ury = a;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
public void setRotation(int rotation) {
|
||||
this.rotation = rotation % 360;
|
||||
switch (this.rotation) {
|
||||
case 90:
|
||||
case 180:
|
||||
case 270:
|
||||
break;
|
||||
default:
|
||||
this.rotation = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle rotate() {
|
||||
Rectangle rect = new Rectangle(this.lly, this.llx, this.ury, this.urx);
|
||||
rect.setRotation(this.rotation + 90);
|
||||
return rect;
|
||||
}
|
||||
|
||||
public BaseColor getBackgroundColor() {
|
||||
return this.backgroundColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(BaseColor backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public float getGrayFill() {
|
||||
if (this.backgroundColor instanceof GrayColor)
|
||||
return ((GrayColor)this.backgroundColor).getGray();
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public void setGrayFill(float value) {
|
||||
this.backgroundColor = new GrayColor(value);
|
||||
}
|
||||
|
||||
public int getBorder() {
|
||||
return this.border;
|
||||
}
|
||||
|
||||
public boolean hasBorders() {
|
||||
switch (this.border) {
|
||||
case -1:
|
||||
case 0:
|
||||
return false;
|
||||
}
|
||||
return (this.borderWidth > 0.0F || this.borderWidthLeft > 0.0F || this.borderWidthRight > 0.0F || this.borderWidthTop > 0.0F || this.borderWidthBottom > 0.0F);
|
||||
}
|
||||
|
||||
public boolean hasBorder(int type) {
|
||||
if (this.border == -1)
|
||||
return false;
|
||||
return ((this.border & type) == type);
|
||||
}
|
||||
|
||||
public void setBorder(int border) {
|
||||
this.border = border;
|
||||
}
|
||||
|
||||
public boolean isUseVariableBorders() {
|
||||
return this.useVariableBorders;
|
||||
}
|
||||
|
||||
public void setUseVariableBorders(boolean useVariableBorders) {
|
||||
this.useVariableBorders = useVariableBorders;
|
||||
}
|
||||
|
||||
public void enableBorderSide(int side) {
|
||||
if (this.border == -1)
|
||||
this.border = 0;
|
||||
this.border |= side;
|
||||
}
|
||||
|
||||
public void disableBorderSide(int side) {
|
||||
if (this.border == -1)
|
||||
this.border = 0;
|
||||
this.border &= side ^ 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
public float getBorderWidth() {
|
||||
return this.borderWidth;
|
||||
}
|
||||
|
||||
public void setBorderWidth(float borderWidth) {
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
private float getVariableBorderWidth(float variableWidthValue, int side) {
|
||||
if ((this.border & side) != 0)
|
||||
return (variableWidthValue != -1.0F) ? variableWidthValue : this.borderWidth;
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
private void updateBorderBasedOnWidth(float width, int side) {
|
||||
this.useVariableBorders = true;
|
||||
if (width > 0.0F) {
|
||||
enableBorderSide(side);
|
||||
} else {
|
||||
disableBorderSide(side);
|
||||
}
|
||||
}
|
||||
|
||||
public float getBorderWidthLeft() {
|
||||
return getVariableBorderWidth(this.borderWidthLeft, 4);
|
||||
}
|
||||
|
||||
public void setBorderWidthLeft(float borderWidthLeft) {
|
||||
this.borderWidthLeft = borderWidthLeft;
|
||||
updateBorderBasedOnWidth(borderWidthLeft, 4);
|
||||
}
|
||||
|
||||
public float getBorderWidthRight() {
|
||||
return getVariableBorderWidth(this.borderWidthRight, 8);
|
||||
}
|
||||
|
||||
public void setBorderWidthRight(float borderWidthRight) {
|
||||
this.borderWidthRight = borderWidthRight;
|
||||
updateBorderBasedOnWidth(borderWidthRight, 8);
|
||||
}
|
||||
|
||||
public float getBorderWidthTop() {
|
||||
return getVariableBorderWidth(this.borderWidthTop, 1);
|
||||
}
|
||||
|
||||
public void setBorderWidthTop(float borderWidthTop) {
|
||||
this.borderWidthTop = borderWidthTop;
|
||||
updateBorderBasedOnWidth(borderWidthTop, 1);
|
||||
}
|
||||
|
||||
public float getBorderWidthBottom() {
|
||||
return getVariableBorderWidth(this.borderWidthBottom, 2);
|
||||
}
|
||||
|
||||
public void setBorderWidthBottom(float borderWidthBottom) {
|
||||
this.borderWidthBottom = borderWidthBottom;
|
||||
updateBorderBasedOnWidth(borderWidthBottom, 2);
|
||||
}
|
||||
|
||||
public BaseColor getBorderColor() {
|
||||
return this.borderColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(BaseColor borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
public BaseColor getBorderColorLeft() {
|
||||
if (this.borderColorLeft == null)
|
||||
return this.borderColor;
|
||||
return this.borderColorLeft;
|
||||
}
|
||||
|
||||
public void setBorderColorLeft(BaseColor borderColorLeft) {
|
||||
this.borderColorLeft = borderColorLeft;
|
||||
}
|
||||
|
||||
public BaseColor getBorderColorRight() {
|
||||
if (this.borderColorRight == null)
|
||||
return this.borderColor;
|
||||
return this.borderColorRight;
|
||||
}
|
||||
|
||||
public void setBorderColorRight(BaseColor borderColorRight) {
|
||||
this.borderColorRight = borderColorRight;
|
||||
}
|
||||
|
||||
public BaseColor getBorderColorTop() {
|
||||
if (this.borderColorTop == null)
|
||||
return this.borderColor;
|
||||
return this.borderColorTop;
|
||||
}
|
||||
|
||||
public void setBorderColorTop(BaseColor borderColorTop) {
|
||||
this.borderColorTop = borderColorTop;
|
||||
}
|
||||
|
||||
public BaseColor getBorderColorBottom() {
|
||||
if (this.borderColorBottom == null)
|
||||
return this.borderColor;
|
||||
return this.borderColorBottom;
|
||||
}
|
||||
|
||||
public void setBorderColorBottom(BaseColor borderColorBottom) {
|
||||
this.borderColorBottom = borderColorBottom;
|
||||
}
|
||||
|
||||
public Rectangle rectangle(float top, float bottom) {
|
||||
Rectangle tmp = new Rectangle(this);
|
||||
if (getTop() > top) {
|
||||
tmp.setTop(top);
|
||||
tmp.disableBorderSide(1);
|
||||
}
|
||||
if (getBottom() < bottom) {
|
||||
tmp.setBottom(bottom);
|
||||
tmp.disableBorderSide(2);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void cloneNonPositionParameters(Rectangle rect) {
|
||||
this.rotation = rect.rotation;
|
||||
this.backgroundColor = rect.backgroundColor;
|
||||
this.border = rect.border;
|
||||
this.useVariableBorders = rect.useVariableBorders;
|
||||
this.borderWidth = rect.borderWidth;
|
||||
this.borderWidthLeft = rect.borderWidthLeft;
|
||||
this.borderWidthRight = rect.borderWidthRight;
|
||||
this.borderWidthTop = rect.borderWidthTop;
|
||||
this.borderWidthBottom = rect.borderWidthBottom;
|
||||
this.borderColor = rect.borderColor;
|
||||
this.borderColorLeft = rect.borderColorLeft;
|
||||
this.borderColorRight = rect.borderColorRight;
|
||||
this.borderColorTop = rect.borderColorTop;
|
||||
this.borderColorBottom = rect.borderColorBottom;
|
||||
}
|
||||
|
||||
public void softCloneNonPositionParameters(Rectangle rect) {
|
||||
if (rect.rotation != 0)
|
||||
this.rotation = rect.rotation;
|
||||
if (rect.backgroundColor != null)
|
||||
this.backgroundColor = rect.backgroundColor;
|
||||
if (rect.border != -1)
|
||||
this.border = rect.border;
|
||||
if (this.useVariableBorders)
|
||||
this.useVariableBorders = rect.useVariableBorders;
|
||||
if (rect.borderWidth != -1.0F)
|
||||
this.borderWidth = rect.borderWidth;
|
||||
if (rect.borderWidthLeft != -1.0F)
|
||||
this.borderWidthLeft = rect.borderWidthLeft;
|
||||
if (rect.borderWidthRight != -1.0F)
|
||||
this.borderWidthRight = rect.borderWidthRight;
|
||||
if (rect.borderWidthTop != -1.0F)
|
||||
this.borderWidthTop = rect.borderWidthTop;
|
||||
if (rect.borderWidthBottom != -1.0F)
|
||||
this.borderWidthBottom = rect.borderWidthBottom;
|
||||
if (rect.borderColor != null)
|
||||
this.borderColor = rect.borderColor;
|
||||
if (rect.borderColorLeft != null)
|
||||
this.borderColorLeft = rect.borderColorLeft;
|
||||
if (rect.borderColorRight != null)
|
||||
this.borderColorRight = rect.borderColorRight;
|
||||
if (rect.borderColorTop != null)
|
||||
this.borderColorTop = rect.borderColorTop;
|
||||
if (rect.borderColorBottom != null)
|
||||
this.borderColorBottom = rect.borderColorBottom;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer("Rectangle: ");
|
||||
buf.append(getWidth());
|
||||
buf.append('x');
|
||||
buf.append(getHeight());
|
||||
buf.append(" (rot: ");
|
||||
buf.append(this.rotation);
|
||||
buf.append(" degrees)");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Rectangle) {
|
||||
Rectangle other = (Rectangle)obj;
|
||||
return (other.llx == this.llx && other.lly == this.lly && other.urx == this.urx && other.ury == this.ury && other.rotation == this.rotation);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
|
||||
public class RectangleReadOnly extends Rectangle {
|
||||
public RectangleReadOnly(float llx, float lly, float urx, float ury) {
|
||||
super(llx, lly, urx, ury);
|
||||
}
|
||||
|
||||
public RectangleReadOnly(float llx, float lly, float urx, float ury, int rotation) {
|
||||
super(llx, lly, urx, ury);
|
||||
super.setRotation(rotation);
|
||||
}
|
||||
|
||||
public RectangleReadOnly(float urx, float ury) {
|
||||
super(0.0F, 0.0F, urx, ury);
|
||||
}
|
||||
|
||||
public RectangleReadOnly(float urx, float ury, int rotation) {
|
||||
super(0.0F, 0.0F, urx, ury);
|
||||
super.setRotation(rotation);
|
||||
}
|
||||
|
||||
public RectangleReadOnly(Rectangle rect) {
|
||||
super(rect.llx, rect.lly, rect.urx, rect.ury);
|
||||
super.cloneNonPositionParameters(rect);
|
||||
}
|
||||
|
||||
private void throwReadOnlyError() {
|
||||
throw new UnsupportedOperationException(MessageLocalization.getComposedMessage("rectanglereadonly.this.rectangle.is.read.only"));
|
||||
}
|
||||
|
||||
public void setRotation(int rotation) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setLeft(float llx) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setRight(float urx) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setTop(float ury) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBottom(float lly) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void normalize() {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBackgroundColor(BaseColor value) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setGrayFill(float value) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorder(int border) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setUseVariableBorders(boolean useVariableBorders) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void enableBorderSide(int side) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void disableBorderSide(int side) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderWidth(float borderWidth) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderWidthLeft(float borderWidthLeft) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderWidthRight(float borderWidthRight) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderWidthTop(float borderWidthTop) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderWidthBottom(float borderWidthBottom) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderColor(BaseColor borderColor) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderColorLeft(BaseColor borderColorLeft) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderColorRight(BaseColor borderColorRight) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderColorTop(BaseColor borderColorTop) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void setBorderColorBottom(BaseColor borderColorBottom) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void cloneNonPositionParameters(Rectangle rect) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public void softCloneNonPositionParameters(Rectangle rect) {
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer("RectangleReadOnly: ");
|
||||
buf.append(getWidth());
|
||||
buf.append('x');
|
||||
buf.append(getHeight());
|
||||
buf.append(" (rot: ");
|
||||
buf.append(this.rotation);
|
||||
buf.append(" degrees)");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.factories.RomanNumberFactory;
|
||||
|
||||
public class RomanList extends List {
|
||||
public RomanList() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public RomanList(int symbolIndent) {
|
||||
super(true, (float)symbolIndent);
|
||||
}
|
||||
|
||||
public RomanList(boolean lowercase, int symbolIndent) {
|
||||
super(true, (float)symbolIndent);
|
||||
this.lowercase = lowercase;
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
if (o instanceof ListItem) {
|
||||
ListItem item = (ListItem)o;
|
||||
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
|
||||
chunk.setAttributes(this.symbol.getAttributes());
|
||||
chunk.append(RomanNumberFactory.getString(this.first + this.list.size(), this.lowercase));
|
||||
chunk.append(this.postSymbol);
|
||||
item.setListSymbol(chunk);
|
||||
item.setIndentationLeft(this.symbolIndent, this.autoindent);
|
||||
item.setIndentationRight(0.0F);
|
||||
this.list.add(item);
|
||||
} else if (o instanceof List) {
|
||||
List nested = (List)o;
|
||||
nested.setIndentationLeft(nested.getIndentationLeft() + this.symbolIndent);
|
||||
this.first--;
|
||||
return this.list.add(nested);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List cloneShallow() {
|
||||
RomanList clone = new RomanList();
|
||||
populateProperties(clone);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,374 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.api.Indentable;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.interfaces.IAccessibleElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class Section extends ArrayList<Element> implements TextElementArray, LargeElement, Indentable, IAccessibleElement {
|
||||
public static final int NUMBERSTYLE_DOTTED = 0;
|
||||
|
||||
public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT = 1;
|
||||
|
||||
private static final long serialVersionUID = 3324172577544748043L;
|
||||
|
||||
protected Paragraph title;
|
||||
|
||||
protected String bookmarkTitle;
|
||||
|
||||
protected int numberDepth;
|
||||
|
||||
protected int numberStyle = 0;
|
||||
|
||||
protected float indentationLeft;
|
||||
|
||||
protected float indentationRight;
|
||||
|
||||
protected float indentation;
|
||||
|
||||
protected boolean bookmarkOpen = true;
|
||||
|
||||
protected boolean triggerNewPage = false;
|
||||
|
||||
protected int subsections = 0;
|
||||
|
||||
protected ArrayList<Integer> numbers = null;
|
||||
|
||||
protected boolean complete = true;
|
||||
|
||||
protected boolean addedCompletely = false;
|
||||
|
||||
protected boolean notAddedYet = true;
|
||||
|
||||
protected Section() {
|
||||
this.title = new Paragraph();
|
||||
this.numberDepth = 1;
|
||||
this.title.setRole(new PdfName("H" + this.numberDepth));
|
||||
}
|
||||
|
||||
protected Section(Paragraph title, int numberDepth) {
|
||||
this.numberDepth = numberDepth;
|
||||
this.title = title;
|
||||
if (title != null)
|
||||
title.setRole(new PdfName("H" + numberDepth));
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
try {
|
||||
for (Object element2 : (Iterable<Object>)this) {
|
||||
Element element = (Element)element2;
|
||||
listener.add(element);
|
||||
}
|
||||
return true;
|
||||
} catch (DocumentException de) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 13;
|
||||
}
|
||||
|
||||
public boolean isChapter() {
|
||||
return (type() == 16);
|
||||
}
|
||||
|
||||
public boolean isSection() {
|
||||
return (type() == 13);
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
java.util.List<Chunk> tmp = new ArrayList<Chunk>();
|
||||
for (Object element : (Iterable<Object>)this)
|
||||
tmp.addAll(((Element)element).getChunks());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void add(int index, Element element) {
|
||||
if (isAddedCompletely())
|
||||
throw new IllegalStateException(MessageLocalization.getComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
|
||||
try {
|
||||
if (element.isNestable()) {
|
||||
super.add(index, element);
|
||||
} else {
|
||||
throw new ClassCastException(MessageLocalization.getComposedMessage("you.can.t.add.a.1.to.a.section", element.getClass().getName()));
|
||||
}
|
||||
} catch (ClassCastException cce) {
|
||||
throw new ClassCastException(MessageLocalization.getComposedMessage("insertion.of.illegal.element.1", cce.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(Element element) {
|
||||
if (isAddedCompletely())
|
||||
throw new IllegalStateException(MessageLocalization.getComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
|
||||
try {
|
||||
if (element.type() == 13) {
|
||||
Section section = (Section)element;
|
||||
section.setNumbers(++this.subsections, this.numbers);
|
||||
return super.add(section);
|
||||
}
|
||||
if (element instanceof MarkedSection && ((MarkedObject)element).element.type() == 13) {
|
||||
MarkedSection mo = (MarkedSection)element;
|
||||
Section section = (Section)mo.element;
|
||||
section.setNumbers(++this.subsections, this.numbers);
|
||||
return super.add(mo);
|
||||
}
|
||||
if (element.isNestable())
|
||||
return super.add(element);
|
||||
throw new ClassCastException(MessageLocalization.getComposedMessage("you.can.t.add.a.1.to.a.section", element.getClass().getName()));
|
||||
} catch (ClassCastException cce) {
|
||||
throw new ClassCastException(MessageLocalization.getComposedMessage("insertion.of.illegal.element.1", cce.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends Element> collection) {
|
||||
if (collection.size() == 0)
|
||||
return false;
|
||||
for (Element element : collection)
|
||||
add(element);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Section addSection(float indentation, Paragraph title, int numberDepth) {
|
||||
if (isAddedCompletely())
|
||||
throw new IllegalStateException(MessageLocalization.getComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
|
||||
Section section = new Section(title, numberDepth);
|
||||
section.setIndentation(indentation);
|
||||
add(section);
|
||||
return section;
|
||||
}
|
||||
|
||||
public Section addSection(float indentation, Paragraph title) {
|
||||
return addSection(indentation, title, this.numberDepth + 1);
|
||||
}
|
||||
|
||||
public Section addSection(Paragraph title, int numberDepth) {
|
||||
return addSection(0.0F, title, numberDepth);
|
||||
}
|
||||
|
||||
protected MarkedSection addMarkedSection() {
|
||||
MarkedSection section = new MarkedSection(new Section(null, this.numberDepth + 1));
|
||||
add(section);
|
||||
return section;
|
||||
}
|
||||
|
||||
public Section addSection(Paragraph title) {
|
||||
return addSection(0.0F, title, this.numberDepth + 1);
|
||||
}
|
||||
|
||||
public Section addSection(float indentation, String title, int numberDepth) {
|
||||
return addSection(indentation, new Paragraph(title), numberDepth);
|
||||
}
|
||||
|
||||
public Section addSection(String title, int numberDepth) {
|
||||
return addSection(new Paragraph(title), numberDepth);
|
||||
}
|
||||
|
||||
public Section addSection(float indentation, String title) {
|
||||
return addSection(indentation, new Paragraph(title));
|
||||
}
|
||||
|
||||
public Section addSection(String title) {
|
||||
return addSection(new Paragraph(title));
|
||||
}
|
||||
|
||||
public void setTitle(Paragraph title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Paragraph getTitle() {
|
||||
return constructTitle(this.title, this.numbers, this.numberDepth, this.numberStyle);
|
||||
}
|
||||
|
||||
public static Paragraph constructTitle(Paragraph title, ArrayList<Integer> numbers, int numberDepth, int numberStyle) {
|
||||
if (title == null)
|
||||
return null;
|
||||
int depth = Math.min(numbers.size(), numberDepth);
|
||||
if (depth < 1)
|
||||
return title;
|
||||
StringBuffer buf = new StringBuffer(" ");
|
||||
for (int i = 0; i < depth; i++) {
|
||||
buf.insert(0, ".");
|
||||
buf.insert(0, numbers.get(i).intValue());
|
||||
}
|
||||
if (numberStyle == 1)
|
||||
buf.deleteCharAt(buf.length() - 2);
|
||||
Paragraph result = new Paragraph(title);
|
||||
result.add(0, new Chunk(buf.toString(), title.getFont()));
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setNumberDepth(int numberDepth) {
|
||||
this.numberDepth = numberDepth;
|
||||
}
|
||||
|
||||
public int getNumberDepth() {
|
||||
return this.numberDepth;
|
||||
}
|
||||
|
||||
public void setNumberStyle(int numberStyle) {
|
||||
this.numberStyle = numberStyle;
|
||||
}
|
||||
|
||||
public int getNumberStyle() {
|
||||
return this.numberStyle;
|
||||
}
|
||||
|
||||
public void setIndentationLeft(float indentation) {
|
||||
this.indentationLeft = indentation;
|
||||
}
|
||||
|
||||
public float getIndentationLeft() {
|
||||
return this.indentationLeft;
|
||||
}
|
||||
|
||||
public void setIndentationRight(float indentation) {
|
||||
this.indentationRight = indentation;
|
||||
}
|
||||
|
||||
public float getIndentationRight() {
|
||||
return this.indentationRight;
|
||||
}
|
||||
|
||||
public void setIndentation(float indentation) {
|
||||
this.indentation = indentation;
|
||||
}
|
||||
|
||||
public float getIndentation() {
|
||||
return this.indentation;
|
||||
}
|
||||
|
||||
public void setBookmarkOpen(boolean bookmarkOpen) {
|
||||
this.bookmarkOpen = bookmarkOpen;
|
||||
}
|
||||
|
||||
public boolean isBookmarkOpen() {
|
||||
return this.bookmarkOpen;
|
||||
}
|
||||
|
||||
public void setTriggerNewPage(boolean triggerNewPage) {
|
||||
this.triggerNewPage = triggerNewPage;
|
||||
}
|
||||
|
||||
public boolean isTriggerNewPage() {
|
||||
return (this.triggerNewPage && this.notAddedYet);
|
||||
}
|
||||
|
||||
public void setBookmarkTitle(String bookmarkTitle) {
|
||||
this.bookmarkTitle = bookmarkTitle;
|
||||
}
|
||||
|
||||
public Paragraph getBookmarkTitle() {
|
||||
if (this.bookmarkTitle == null)
|
||||
return getTitle();
|
||||
return new Paragraph(this.bookmarkTitle);
|
||||
}
|
||||
|
||||
public void setChapterNumber(int number) {
|
||||
this.numbers.set(this.numbers.size() - 1, Integer.valueOf(number));
|
||||
for (Object s : (Iterable<Object>)this) {
|
||||
if (s instanceof Section)
|
||||
((Section)s).setChapterNumber(number);
|
||||
}
|
||||
}
|
||||
|
||||
public int getDepth() {
|
||||
return this.numbers.size();
|
||||
}
|
||||
|
||||
private void setNumbers(int number, ArrayList<Integer> numbers) {
|
||||
this.numbers = new ArrayList<Integer>();
|
||||
this.numbers.add(Integer.valueOf(number));
|
||||
this.numbers.addAll(numbers);
|
||||
}
|
||||
|
||||
public boolean isNotAddedYet() {
|
||||
return this.notAddedYet;
|
||||
}
|
||||
|
||||
public void setNotAddedYet(boolean notAddedYet) {
|
||||
this.notAddedYet = notAddedYet;
|
||||
}
|
||||
|
||||
protected boolean isAddedCompletely() {
|
||||
return this.addedCompletely;
|
||||
}
|
||||
|
||||
protected void setAddedCompletely(boolean addedCompletely) {
|
||||
this.addedCompletely = addedCompletely;
|
||||
}
|
||||
|
||||
public void flushContent() {
|
||||
setNotAddedYet(false);
|
||||
this.title = null;
|
||||
for (Iterator<Element> i = iterator(); i.hasNext(); ) {
|
||||
Element element = i.next();
|
||||
if (element instanceof Section) {
|
||||
Section s = (Section)element;
|
||||
if (!s.isComplete() && size() == 1) {
|
||||
s.flushContent();
|
||||
return;
|
||||
}
|
||||
s.setAddedCompletely(true);
|
||||
}
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return this.complete;
|
||||
}
|
||||
|
||||
public void setComplete(boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
public void newPage() {
|
||||
add(Chunk.NEXTPAGE);
|
||||
}
|
||||
|
||||
public PdfObject getAccessibleAttribute(PdfName key) {
|
||||
return this.title.getAccessibleAttribute(key);
|
||||
}
|
||||
|
||||
public void setAccessibleAttribute(PdfName key, PdfObject value) {
|
||||
this.title.setAccessibleAttribute(key, value);
|
||||
}
|
||||
|
||||
public HashMap<PdfName, PdfObject> getAccessibleAttributes() {
|
||||
return this.title.getAccessibleAttributes();
|
||||
}
|
||||
|
||||
public PdfName getRole() {
|
||||
return this.title.getRole();
|
||||
}
|
||||
|
||||
public void setRole(PdfName role) {
|
||||
this.title.setRole(role);
|
||||
}
|
||||
|
||||
public AccessibleElementId getId() {
|
||||
return this.title.getId();
|
||||
}
|
||||
|
||||
public void setId(AccessibleElementId id) {
|
||||
this.title.setId(id);
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public class SpecialSymbol {
|
||||
public static int index(String string) {
|
||||
int length = string.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (getCorrespondingSymbol(string.charAt(i)) != ' ')
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static Chunk get(char c, Font font) {
|
||||
char greek = getCorrespondingSymbol(c);
|
||||
if (greek == ' ')
|
||||
return new Chunk(String.valueOf(c), font);
|
||||
Font symbol = new Font(Font.FontFamily.SYMBOL, font.getSize(), font.getStyle(), font.getColor());
|
||||
String s = String.valueOf(greek);
|
||||
return new Chunk(s, symbol);
|
||||
}
|
||||
|
||||
public static char getCorrespondingSymbol(char c) {
|
||||
switch (c) {
|
||||
case 'Α':
|
||||
return 'A';
|
||||
case 'Β':
|
||||
return 'B';
|
||||
case 'Γ':
|
||||
return 'G';
|
||||
case 'Δ':
|
||||
return 'D';
|
||||
case 'Ε':
|
||||
return 'E';
|
||||
case 'Ζ':
|
||||
return 'Z';
|
||||
case 'Η':
|
||||
return 'H';
|
||||
case 'Θ':
|
||||
return 'Q';
|
||||
case 'Ι':
|
||||
return 'I';
|
||||
case 'Κ':
|
||||
return 'K';
|
||||
case 'Λ':
|
||||
return 'L';
|
||||
case 'Μ':
|
||||
return 'M';
|
||||
case 'Ν':
|
||||
return 'N';
|
||||
case 'Ξ':
|
||||
return 'X';
|
||||
case 'Ο':
|
||||
return 'O';
|
||||
case 'Π':
|
||||
return 'P';
|
||||
case 'Ρ':
|
||||
return 'R';
|
||||
case 'Σ':
|
||||
return 'S';
|
||||
case 'Τ':
|
||||
return 'T';
|
||||
case 'Υ':
|
||||
return 'U';
|
||||
case 'Φ':
|
||||
return 'F';
|
||||
case 'Χ':
|
||||
return 'C';
|
||||
case 'Ψ':
|
||||
return 'Y';
|
||||
case 'Ω':
|
||||
return 'W';
|
||||
case 'α':
|
||||
return 'a';
|
||||
case 'β':
|
||||
return 'b';
|
||||
case 'γ':
|
||||
return 'g';
|
||||
case 'δ':
|
||||
return 'd';
|
||||
case 'ε':
|
||||
return 'e';
|
||||
case 'ζ':
|
||||
return 'z';
|
||||
case 'η':
|
||||
return 'h';
|
||||
case 'θ':
|
||||
return 'q';
|
||||
case 'ι':
|
||||
return 'i';
|
||||
case 'κ':
|
||||
return 'k';
|
||||
case 'λ':
|
||||
return 'l';
|
||||
case 'μ':
|
||||
return 'm';
|
||||
case 'ν':
|
||||
return 'n';
|
||||
case 'ξ':
|
||||
return 'x';
|
||||
case 'ο':
|
||||
return 'o';
|
||||
case 'π':
|
||||
return 'p';
|
||||
case 'ρ':
|
||||
return 'r';
|
||||
case 'ς':
|
||||
return 'V';
|
||||
case 'σ':
|
||||
return 's';
|
||||
case 'τ':
|
||||
return 't';
|
||||
case 'υ':
|
||||
return 'u';
|
||||
case 'φ':
|
||||
return 'f';
|
||||
case 'χ':
|
||||
return 'c';
|
||||
case 'ψ':
|
||||
return 'y';
|
||||
case 'ω':
|
||||
return 'w';
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfChunk;
|
||||
|
||||
public interface SplitCharacter {
|
||||
boolean isSplitCharacter(int paramInt1, int paramInt2, int paramInt3, char[] paramArrayOfchar, PdfChunk[] paramArrayOfPdfChunk);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TabSettings {
|
||||
public static final float DEFAULT_TAB_INTERVAL = 36.0F;
|
||||
|
||||
public static TabStop getTabStopNewInstance(float currentPosition, TabSettings tabSettings) {
|
||||
if (tabSettings != null)
|
||||
return tabSettings.getTabStopNewInstance(currentPosition);
|
||||
return TabStop.newInstance(currentPosition, 36.0F);
|
||||
}
|
||||
|
||||
private java.util.List<TabStop> tabStops = new ArrayList<TabStop>();
|
||||
|
||||
private float tabInterval = 36.0F;
|
||||
|
||||
public TabSettings() {}
|
||||
|
||||
public TabSettings(java.util.List<TabStop> tabStops) {
|
||||
this.tabStops = tabStops;
|
||||
}
|
||||
|
||||
public TabSettings(float tabInterval) {
|
||||
this.tabInterval = tabInterval;
|
||||
}
|
||||
|
||||
public TabSettings(java.util.List<TabStop> tabStops, float tabInterval) {
|
||||
this.tabStops = tabStops;
|
||||
this.tabInterval = tabInterval;
|
||||
}
|
||||
|
||||
public java.util.List<TabStop> getTabStops() {
|
||||
return this.tabStops;
|
||||
}
|
||||
|
||||
public void setTabStops(java.util.List<TabStop> tabStops) {
|
||||
this.tabStops = tabStops;
|
||||
}
|
||||
|
||||
public float getTabInterval() {
|
||||
return this.tabInterval;
|
||||
}
|
||||
|
||||
public void setTabInterval(float tabInterval) {
|
||||
this.tabInterval = tabInterval;
|
||||
}
|
||||
|
||||
public TabStop getTabStopNewInstance(float currentPosition) {
|
||||
TabStop tabStop = null;
|
||||
if (this.tabStops != null)
|
||||
for (TabStop currentTabStop : this.tabStops) {
|
||||
if ((double)(currentTabStop.getPosition() - currentPosition) > 0.001D) {
|
||||
tabStop = new TabStop(currentTabStop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tabStop == null)
|
||||
tabStop = TabStop.newInstance(currentPosition, this.tabInterval);
|
||||
return tabStop;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfChunk;
|
||||
|
||||
public class TabSplitCharacter implements SplitCharacter {
|
||||
public static final SplitCharacter TAB = new TabSplitCharacter();
|
||||
|
||||
public boolean isSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.draw.DrawInterface;
|
||||
|
||||
public class TabStop {
|
||||
protected float position;
|
||||
|
||||
public static TabStop newInstance(float currentPosition, float tabInterval) {
|
||||
currentPosition = (float)Math.round(currentPosition * 1000.0F) / 1000.0F;
|
||||
tabInterval = (float)Math.round(tabInterval * 1000.0F) / 1000.0F;
|
||||
TabStop tabStop = new TabStop(currentPosition + tabInterval - currentPosition % tabInterval);
|
||||
return tabStop;
|
||||
}
|
||||
|
||||
public enum Alignment {
|
||||
LEFT, RIGHT, CENTER, ANCHOR;
|
||||
}
|
||||
|
||||
protected Alignment alignment = Alignment.LEFT;
|
||||
|
||||
protected DrawInterface leader;
|
||||
|
||||
protected char anchorChar = '.';
|
||||
|
||||
public TabStop(float position) {
|
||||
this(position, Alignment.LEFT);
|
||||
}
|
||||
|
||||
public TabStop(float position, DrawInterface leader) {
|
||||
this(position, leader, Alignment.LEFT);
|
||||
}
|
||||
|
||||
public TabStop(float position, Alignment alignment) {
|
||||
this(position, null, alignment);
|
||||
}
|
||||
|
||||
public TabStop(float position, Alignment alignment, char anchorChar) {
|
||||
this(position, null, alignment, anchorChar);
|
||||
}
|
||||
|
||||
public TabStop(float position, DrawInterface leader, Alignment alignment) {
|
||||
this(position, leader, alignment, '.');
|
||||
}
|
||||
|
||||
public TabStop(float position, DrawInterface leader, Alignment alignment, char anchorChar) {
|
||||
this.position = position;
|
||||
this.leader = leader;
|
||||
this.alignment = alignment;
|
||||
this.anchorChar = anchorChar;
|
||||
}
|
||||
|
||||
public TabStop(TabStop tabStop) {
|
||||
this(tabStop.getPosition(), tabStop.getLeader(), tabStop.getAlignment(), tabStop.getAnchorChar());
|
||||
}
|
||||
|
||||
public float getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public void setPosition(float position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public Alignment getAlignment() {
|
||||
return this.alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(Alignment alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public DrawInterface getLeader() {
|
||||
return this.leader;
|
||||
}
|
||||
|
||||
public void setLeader(DrawInterface leader) {
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
public char getAnchorChar() {
|
||||
return this.anchorChar;
|
||||
}
|
||||
|
||||
public void setAnchorChar(char anchorChar) {
|
||||
this.anchorChar = anchorChar;
|
||||
}
|
||||
|
||||
public float getPosition(float tabPosition, float currentPosition, float anchorPosition) {
|
||||
float newPosition = this.position;
|
||||
float textWidth = currentPosition - tabPosition;
|
||||
switch (this.alignment) {
|
||||
case RIGHT:
|
||||
if (tabPosition + textWidth < this.position) {
|
||||
newPosition = this.position - textWidth;
|
||||
} else {
|
||||
newPosition = tabPosition;
|
||||
}
|
||||
break;
|
||||
case CENTER:
|
||||
if (tabPosition + textWidth / 2.0F < this.position) {
|
||||
newPosition = this.position - textWidth / 2.0F;
|
||||
} else {
|
||||
newPosition = tabPosition;
|
||||
}
|
||||
break;
|
||||
case ANCHOR:
|
||||
if (!Float.isNaN(anchorPosition)) {
|
||||
if (anchorPosition < this.position) {
|
||||
newPosition = this.position - (anchorPosition - tabPosition);
|
||||
} else {
|
||||
newPosition = tabPosition;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (tabPosition + textWidth < this.position) {
|
||||
newPosition = this.position - textWidth;
|
||||
} else {
|
||||
newPosition = tabPosition;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return newPosition;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public interface TextElementArray extends Element {
|
||||
boolean add(Element paramElement);
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.pdf.ByteBuffer;
|
||||
import com.itextpdf.text.pdf.PRTokeniser;
|
||||
import com.itextpdf.text.pdf.PdfEncodings;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
public class Utilities {
|
||||
@Deprecated
|
||||
public static <K, V> Set<K> getKeySet(Hashtable<K, V> table) {
|
||||
return (table == null) ? Collections.<K>emptySet() : table.keySet();
|
||||
}
|
||||
|
||||
public static Object[][] addToArray(Object[][] original, Object[] item) {
|
||||
if (original == null) {
|
||||
original = new Object[1][];
|
||||
original[0] = item;
|
||||
return original;
|
||||
}
|
||||
Object[][] original2 = new Object[original.length + 1][];
|
||||
System.arraycopy(original, 0, original2, 0, original.length);
|
||||
original2[original.length] = item;
|
||||
return original2;
|
||||
}
|
||||
|
||||
public static boolean checkTrueOrFalse(Properties attributes, String key) {
|
||||
return "true".equalsIgnoreCase(attributes.getProperty(key));
|
||||
}
|
||||
|
||||
public static String unEscapeURL(String src) {
|
||||
StringBuffer bf = new StringBuffer();
|
||||
char[] s = src.toCharArray();
|
||||
for (int k = 0; k < s.length; k++) {
|
||||
char c = s[k];
|
||||
if (c == '%') {
|
||||
if (k + 2 >= s.length) {
|
||||
bf.append(c);
|
||||
} else {
|
||||
int a0 = PRTokeniser.getHex(s[k + 1]);
|
||||
int a1 = PRTokeniser.getHex(s[k + 2]);
|
||||
if (a0 < 0 || a1 < 0) {
|
||||
bf.append(c);
|
||||
} else {
|
||||
bf.append((char)(a0 * 16 + a1));
|
||||
k += 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bf.append(c);
|
||||
}
|
||||
}
|
||||
return bf.toString();
|
||||
}
|
||||
|
||||
public static URL toURL(String filename) throws MalformedURLException {
|
||||
try {
|
||||
return new URL(filename);
|
||||
} catch (Exception e) {
|
||||
return new File(filename).toURI().toURL();
|
||||
}
|
||||
}
|
||||
|
||||
public static void skip(InputStream is, int size) throws IOException {
|
||||
while (size > 0) {
|
||||
long n = is.skip((long)size);
|
||||
if (n <= 0L)
|
||||
break;
|
||||
size = (int)((long)size - n);
|
||||
}
|
||||
}
|
||||
|
||||
public static final float millimetersToPoints(float value) {
|
||||
return inchesToPoints(millimetersToInches(value));
|
||||
}
|
||||
|
||||
public static final float millimetersToInches(float value) {
|
||||
return value / 25.4F;
|
||||
}
|
||||
|
||||
public static final float pointsToMillimeters(float value) {
|
||||
return inchesToMillimeters(pointsToInches(value));
|
||||
}
|
||||
|
||||
public static final float pointsToInches(float value) {
|
||||
return value / 72.0F;
|
||||
}
|
||||
|
||||
public static final float inchesToMillimeters(float value) {
|
||||
return value * 25.4F;
|
||||
}
|
||||
|
||||
public static final float inchesToPoints(float value) {
|
||||
return value * 72.0F;
|
||||
}
|
||||
|
||||
public static boolean isSurrogateHigh(char c) {
|
||||
return (c >= '?' && c <= '?');
|
||||
}
|
||||
|
||||
public static boolean isSurrogateLow(char c) {
|
||||
return (c >= '?' && c <= '?');
|
||||
}
|
||||
|
||||
public static boolean isSurrogatePair(String text, int idx) {
|
||||
if (idx < 0 || idx > text.length() - 2)
|
||||
return false;
|
||||
return (isSurrogateHigh(text.charAt(idx)) && isSurrogateLow(text.charAt(idx + 1)));
|
||||
}
|
||||
|
||||
public static boolean isSurrogatePair(char[] text, int idx) {
|
||||
if (idx < 0 || idx > text.length - 2)
|
||||
return false;
|
||||
return (isSurrogateHigh(text[idx]) && isSurrogateLow(text[idx + 1]));
|
||||
}
|
||||
|
||||
public static int convertToUtf32(char highSurrogate, char lowSurrogate) {
|
||||
return (highSurrogate - 55296) * 1024 + lowSurrogate - 56320 + 65536;
|
||||
}
|
||||
|
||||
public static int convertToUtf32(char[] text, int idx) {
|
||||
return (text[idx] - 55296) * 1024 + text[idx + 1] - 56320 + 65536;
|
||||
}
|
||||
|
||||
public static int convertToUtf32(String text, int idx) {
|
||||
return (text.charAt(idx) - 55296) * 1024 + text.charAt(idx + 1) - 56320 + 65536;
|
||||
}
|
||||
|
||||
public static String convertFromUtf32(int codePoint) {
|
||||
if (codePoint < 65536)
|
||||
return Character.toString((char)codePoint);
|
||||
codePoint -= 65536;
|
||||
return new String(new char[] { (char)(codePoint / 1024 + 55296), (char)(codePoint % 1024 + 56320) });
|
||||
}
|
||||
|
||||
public static String readFileToString(String path) throws IOException {
|
||||
return readFileToString(new File(path));
|
||||
}
|
||||
|
||||
public static String readFileToString(File file) throws IOException {
|
||||
byte[] jsBytes = new byte[(int)file.length()];
|
||||
FileInputStream f = new FileInputStream(file);
|
||||
f.read(jsBytes);
|
||||
return new String(jsBytes);
|
||||
}
|
||||
|
||||
public static String convertToHex(byte[] bytes) {
|
||||
ByteBuffer buf = new ByteBuffer();
|
||||
for (byte b : bytes)
|
||||
buf.appendHex(b);
|
||||
return PdfEncodings.convertToString(buf.toByteArray(), null).toUpperCase();
|
||||
}
|
||||
|
||||
public static char[] copyOfRange(char[] original, int from, int to) {
|
||||
int newLength = to - from;
|
||||
if (newLength < 0)
|
||||
throw new IllegalArgumentException(from + " > " + to);
|
||||
char[] copy = new char[newLength];
|
||||
System.arraycopy(original, from, copy, 0,
|
||||
Math.min(original.length - from, newLength));
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class Version {
|
||||
public static String AGPL = " (AGPL-version)";
|
||||
|
||||
private static Version version = null;
|
||||
|
||||
private String iText = "iText®";
|
||||
|
||||
private String release = "5.5.10";
|
||||
|
||||
private String iTextVersion = this.iText + " " + this.release + " ©2000-2015 iText Group NV";
|
||||
|
||||
private String key = null;
|
||||
|
||||
public static Version getInstance() {
|
||||
if (version == null) {
|
||||
version = new Version();
|
||||
synchronized (version) {
|
||||
try {
|
||||
Class<?> klass = Class.forName("com.itextpdf.license.LicenseKey");
|
||||
Method m = klass.getMethod("getLicenseeInfo");
|
||||
String[] info = (String[])m.invoke(klass.newInstance());
|
||||
if (info[3] != null && info[3].trim().length() > 0) {
|
||||
version.key = info[3];
|
||||
} else {
|
||||
version.key = "Trial version ";
|
||||
if (info[5] == null) {
|
||||
version.key += "unauthorised";
|
||||
} else {
|
||||
version.key += info[5];
|
||||
}
|
||||
}
|
||||
if (info[4] != null && info[4].trim().length() > 0) {
|
||||
version.iTextVersion = info[4];
|
||||
} else if (info[2] != null && info[2].trim().length() > 0) {
|
||||
version.iTextVersion += " (" + info[2];
|
||||
if (!version.key.toLowerCase().startsWith("trial")) {
|
||||
version.iTextVersion += "; licensed version)";
|
||||
} else {
|
||||
version.iTextVersion += "; " + version.key + ")";
|
||||
}
|
||||
} else if (info[0] != null && info[0].trim().length() > 0) {
|
||||
version.iTextVersion += " (" + info[0];
|
||||
if (!version.key.toLowerCase().startsWith("trial")) {
|
||||
version.iTextVersion += "; licensed version)";
|
||||
} else {
|
||||
version.iTextVersion += "; " + version.key + ")";
|
||||
}
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
version.iTextVersion += AGPL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getProduct() {
|
||||
return this.iText;
|
||||
}
|
||||
|
||||
public String getRelease() {
|
||||
return this.release;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.iTextVersion;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public static boolean isAGPLVersion() {
|
||||
return (getInstance().getVersion().indexOf(AGPL) > 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
import com.itextpdf.text.api.WriterOperation;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class WritableDirectElement implements Element, WriterOperation {
|
||||
public static final int DIRECT_ELEMENT_TYPE_UNKNOWN = 0;
|
||||
|
||||
public static final int DIRECT_ELEMENT_TYPE_HEADER = 1;
|
||||
|
||||
protected int directElementType = 0;
|
||||
|
||||
public WritableDirectElement() {}
|
||||
|
||||
public WritableDirectElement(int directElementType) {
|
||||
this.directElementType = directElementType;
|
||||
}
|
||||
|
||||
public boolean process(ElementListener listener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return 666;
|
||||
}
|
||||
|
||||
public boolean isContent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNestable() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public java.util.List<Chunk> getChunks() {
|
||||
return new ArrayList<Chunk>(0);
|
||||
}
|
||||
|
||||
public int getDirectElementType() {
|
||||
return this.directElementType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public class ZapfDingbatsList extends List {
|
||||
protected int zn;
|
||||
|
||||
public ZapfDingbatsList(int zn) {
|
||||
super(true);
|
||||
this.zn = zn;
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", fontsize, 0));
|
||||
this.postSymbol = " ";
|
||||
}
|
||||
|
||||
public ZapfDingbatsList(int zn, int symbolIndent) {
|
||||
super(true, (float)symbolIndent);
|
||||
this.zn = zn;
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", fontsize, 0));
|
||||
this.postSymbol = " ";
|
||||
}
|
||||
|
||||
public ZapfDingbatsList(int zn, int symbolIndent, BaseColor zapfDingbatColor) {
|
||||
super(true, (float)symbolIndent);
|
||||
this.zn = zn;
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", fontsize, 0, zapfDingbatColor));
|
||||
this.postSymbol = " ";
|
||||
}
|
||||
|
||||
public void setDingbatColor(BaseColor zapfDingbatColor) {
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", fontsize, 0, zapfDingbatColor));
|
||||
}
|
||||
|
||||
public void setCharNumber(int zn) {
|
||||
this.zn = zn;
|
||||
}
|
||||
|
||||
public int getCharNumber() {
|
||||
return this.zn;
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
if (o instanceof ListItem) {
|
||||
ListItem item = (ListItem)o;
|
||||
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
|
||||
chunk.setAttributes(this.symbol.getAttributes());
|
||||
chunk.append(String.valueOf((char)this.zn));
|
||||
chunk.append(this.postSymbol);
|
||||
item.setListSymbol(chunk);
|
||||
item.setIndentationLeft(this.symbolIndent, this.autoindent);
|
||||
item.setIndentationRight(0.0F);
|
||||
this.list.add(item);
|
||||
} else if (o instanceof List) {
|
||||
List nested = (List)o;
|
||||
nested.setIndentationLeft(nested.getIndentationLeft() + this.symbolIndent);
|
||||
this.first--;
|
||||
return this.list.add(nested);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List cloneShallow() {
|
||||
ZapfDingbatsList clone = new ZapfDingbatsList(this.zn);
|
||||
populateProperties(clone);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.itextpdf.text;
|
||||
|
||||
public class ZapfDingbatsNumberList extends List {
|
||||
protected int type;
|
||||
|
||||
public ZapfDingbatsNumberList(int type) {
|
||||
super(true);
|
||||
this.type = type;
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", fontsize, 0));
|
||||
this.postSymbol = " ";
|
||||
}
|
||||
|
||||
public ZapfDingbatsNumberList(int type, int symbolIndent) {
|
||||
super(true, (float)symbolIndent);
|
||||
this.type = type;
|
||||
float fontsize = this.symbol.getFont().getSize();
|
||||
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", fontsize, 0));
|
||||
this.postSymbol = " ";
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean add(Element o) {
|
||||
if (o instanceof ListItem) {
|
||||
ListItem item = (ListItem)o;
|
||||
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
|
||||
chunk.setAttributes(this.symbol.getAttributes());
|
||||
switch (this.type) {
|
||||
case 0:
|
||||
chunk.append(String.valueOf((char)(this.first + this.list.size() + 171)));
|
||||
break;
|
||||
case 1:
|
||||
chunk.append(String.valueOf((char)(this.first + this.list.size() + 181)));
|
||||
break;
|
||||
case 2:
|
||||
chunk.append(String.valueOf((char)(this.first + this.list.size() + 191)));
|
||||
break;
|
||||
default:
|
||||
chunk.append(String.valueOf((char)(this.first + this.list.size() + 201)));
|
||||
break;
|
||||
}
|
||||
chunk.append(this.postSymbol);
|
||||
item.setListSymbol(chunk);
|
||||
item.setIndentationLeft(this.symbolIndent, this.autoindent);
|
||||
item.setIndentationRight(0.0F);
|
||||
this.list.add(item);
|
||||
} else if (o instanceof List) {
|
||||
List nested = (List)o;
|
||||
nested.setIndentationLeft(nested.getIndentationLeft() + this.symbolIndent);
|
||||
this.first--;
|
||||
return this.list.add(nested);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List cloneShallow() {
|
||||
ZapfDingbatsNumberList clone = new ZapfDingbatsNumberList(this.type);
|
||||
populateProperties(clone);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.itextpdf.text.api;
|
||||
|
||||
public interface Indentable {
|
||||
void setIndentationLeft(float paramFloat);
|
||||
|
||||
void setIndentationRight(float paramFloat);
|
||||
|
||||
float getIndentationLeft();
|
||||
|
||||
float getIndentationRight();
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.itextpdf.text.api;
|
||||
|
||||
public interface Spaceable {
|
||||
void setSpacingBefore(float paramFloat);
|
||||
|
||||
void setSpacingAfter(float paramFloat);
|
||||
|
||||
void setPaddingTop(float paramFloat);
|
||||
|
||||
float getSpacingBefore();
|
||||
|
||||
float getSpacingAfter();
|
||||
|
||||
float getPaddingTop();
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.api;
|
||||
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
|
||||
public interface WriterOperation {
|
||||
void write(PdfWriter paramPdfWriter, Document paramDocument) throws DocumentException;
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.itextpdf.text.error_messages;
|
||||
|
||||
import com.itextpdf.text.io.StreamUtil;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class MessageLocalization {
|
||||
private static HashMap<String, String> defaultLanguage = new HashMap<String, String>();
|
||||
|
||||
private static HashMap<String, String> currentLanguage;
|
||||
|
||||
private static final String BASE_PATH = "com/itextpdf/text/l10n/error/";
|
||||
|
||||
static {
|
||||
try {
|
||||
defaultLanguage = getLanguageMessages("en", null);
|
||||
} catch (Exception e) {}
|
||||
if (defaultLanguage == null)
|
||||
defaultLanguage = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public static String getMessage(String key) {
|
||||
return getMessage(key, true);
|
||||
}
|
||||
|
||||
public static String getMessage(String key, boolean useDefaultLanguageIfMessageNotFound) {
|
||||
HashMap<String, String> cl = currentLanguage;
|
||||
if (cl != null) {
|
||||
String val = cl.get(key);
|
||||
if (val != null)
|
||||
return val;
|
||||
}
|
||||
if (useDefaultLanguageIfMessageNotFound) {
|
||||
cl = defaultLanguage;
|
||||
String val = cl.get(key);
|
||||
if (val != null)
|
||||
return val;
|
||||
}
|
||||
return "No message found for " + key;
|
||||
}
|
||||
|
||||
public static String getComposedMessage(String key, int p1) {
|
||||
return getComposedMessage(key, new Object[] { String.valueOf(p1), null, null, null });
|
||||
}
|
||||
|
||||
public static String getComposedMessage(String key, Object... param) {
|
||||
String msg = getMessage(key);
|
||||
if (null != param) {
|
||||
int i = 1;
|
||||
for (Object o : param) {
|
||||
if (null != o)
|
||||
msg = msg.replace("{" + i + "}", o.toString());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static boolean setLanguage(String language, String country) throws IOException {
|
||||
HashMap<String, String> lang = getLanguageMessages(language, country);
|
||||
if (lang == null)
|
||||
return false;
|
||||
currentLanguage = lang;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setMessages(Reader r) throws IOException {
|
||||
currentLanguage = readLanguageStream(r);
|
||||
}
|
||||
|
||||
private static HashMap<String, String> getLanguageMessages(String language, String country) throws IOException {
|
||||
if (language == null)
|
||||
throw new IllegalArgumentException("The language cannot be null.");
|
||||
InputStream is = null;
|
||||
try {
|
||||
if (country != null) {
|
||||
file = language + "_" + country + ".lng";
|
||||
} else {
|
||||
file = language + ".lng";
|
||||
}
|
||||
is = StreamUtil.getResourceStream("com/itextpdf/text/l10n/error/" + file, new MessageLocalization().getClass().getClassLoader());
|
||||
if (is != null)
|
||||
return readLanguageStream(is);
|
||||
if (country == null)
|
||||
return null;
|
||||
String file = language + ".lng";
|
||||
is = StreamUtil.getResourceStream("com/itextpdf/text/l10n/error/" + file, new MessageLocalization().getClass().getClassLoader());
|
||||
if (is != null)
|
||||
return readLanguageStream(is);
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (null != is)
|
||||
is.close();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
private static HashMap<String, String> readLanguageStream(InputStream is) throws IOException {
|
||||
return readLanguageStream(new InputStreamReader(is, "UTF-8"));
|
||||
}
|
||||
|
||||
private static HashMap<String, String> readLanguageStream(Reader r) throws IOException {
|
||||
HashMap<String, String> lang = new HashMap<String, String>();
|
||||
BufferedReader br = new BufferedReader(r);
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
int idxeq = line.indexOf('=');
|
||||
if (idxeq < 0)
|
||||
continue;
|
||||
String key = line.substring(0, idxeq).trim();
|
||||
if (key.startsWith("#"))
|
||||
continue;
|
||||
lang.put(key, line.substring(idxeq + 1));
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.itextpdf.text.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BadPasswordException extends IOException {
|
||||
private static final long serialVersionUID = -4333706268155063964L;
|
||||
|
||||
public BadPasswordException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.exceptions;
|
||||
|
||||
public class IllegalPdfSyntaxException extends IllegalArgumentException {
|
||||
private static final long serialVersionUID = -643024246596031671L;
|
||||
|
||||
public IllegalPdfSyntaxException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.itextpdf.text.exceptions;
|
||||
|
||||
public class InvalidImageException extends RuntimeException {
|
||||
private static final long serialVersionUID = -1319471492541702697L;
|
||||
|
||||
private final Throwable cause;
|
||||
|
||||
public InvalidImageException(String message) {
|
||||
this(message, null);
|
||||
}
|
||||
|
||||
public InvalidImageException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
public Throwable getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.itextpdf.text.exceptions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvalidPdfException extends IOException {
|
||||
private static final long serialVersionUID = -2319614911517026938L;
|
||||
|
||||
private final Throwable cause;
|
||||
|
||||
public InvalidPdfException(String message) {
|
||||
this(message, null);
|
||||
}
|
||||
|
||||
public InvalidPdfException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
public Throwable getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.exceptions;
|
||||
|
||||
public class UnsupportedPdfException extends InvalidPdfException {
|
||||
private static final long serialVersionUID = 2180764250839096628L;
|
||||
|
||||
public UnsupportedPdfException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.itextpdf.text.factories;
|
||||
|
||||
import com.itextpdf.text.SpecialSymbol;
|
||||
|
||||
public class GreekAlphabetFactory {
|
||||
public static final String getString(int index) {
|
||||
return getString(index, true);
|
||||
}
|
||||
|
||||
public static final String getLowerCaseString(int index) {
|
||||
return getString(index);
|
||||
}
|
||||
|
||||
public static final String getUpperCaseString(int index) {
|
||||
return getString(index).toUpperCase();
|
||||
}
|
||||
|
||||
public static final String getString(int index, boolean lowercase) {
|
||||
if (index < 1)
|
||||
return "";
|
||||
index--;
|
||||
int bytes = 1;
|
||||
int start = 0;
|
||||
int symbols = 24;
|
||||
while (index >= symbols + start) {
|
||||
bytes++;
|
||||
start += symbols;
|
||||
symbols *= 24;
|
||||
}
|
||||
int c = index - start;
|
||||
char[] value = new char[bytes];
|
||||
while (bytes > 0) {
|
||||
bytes--;
|
||||
value[bytes] = (char)(c % 24);
|
||||
if (value[bytes] > '\020')
|
||||
value[bytes] = (char)(value[bytes] + 1);
|
||||
value[bytes] = (char)(value[bytes] + (lowercase ? 945 : 913));
|
||||
value[bytes] = SpecialSymbol.getCorrespondingSymbol(value[bytes]);
|
||||
c /= 24;
|
||||
}
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.itextpdf.text.factories;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
|
||||
public class RomanAlphabetFactory {
|
||||
public static final String getString(int index) {
|
||||
if (index < 1)
|
||||
throw new NumberFormatException(MessageLocalization.getComposedMessage("you.can.t.translate.a.negative.number.into.an.alphabetical.value"));
|
||||
index--;
|
||||
int bytes = 1;
|
||||
int start = 0;
|
||||
int symbols = 26;
|
||||
while (index >= symbols + start) {
|
||||
bytes++;
|
||||
start += symbols;
|
||||
symbols *= 26;
|
||||
}
|
||||
int c = index - start;
|
||||
char[] value = new char[bytes];
|
||||
while (bytes > 0) {
|
||||
value[--bytes] = (char)(97 + c % 26);
|
||||
c /= 26;
|
||||
}
|
||||
return new String(value);
|
||||
}
|
||||
|
||||
public static final String getLowerCaseString(int index) {
|
||||
return getString(index);
|
||||
}
|
||||
|
||||
public static final String getUpperCaseString(int index) {
|
||||
return getString(index).toUpperCase();
|
||||
}
|
||||
|
||||
public static final String getString(int index, boolean lowercase) {
|
||||
if (lowercase)
|
||||
return getLowerCaseString(index);
|
||||
return getUpperCaseString(index);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.itextpdf.text.factories;
|
||||
|
||||
public class RomanNumberFactory {
|
||||
private static class RomanDigit {
|
||||
public char digit;
|
||||
|
||||
public int value;
|
||||
|
||||
public boolean pre;
|
||||
|
||||
RomanDigit(char digit, int value, boolean pre) {
|
||||
this.digit = digit;
|
||||
this.value = value;
|
||||
this.pre = pre;
|
||||
}
|
||||
}
|
||||
|
||||
private static final RomanDigit[] roman = new RomanDigit[] { new RomanDigit('m', 1000, false), new RomanDigit('d', 500, false), new RomanDigit('c', 100, true), new RomanDigit('l', 50, false), new RomanDigit('x', 10, true), new RomanDigit('v', 5, false), new RomanDigit('i', 1, true) };
|
||||
|
||||
public static final String getString(int index) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (index < 0) {
|
||||
buf.append('-');
|
||||
index = -index;
|
||||
}
|
||||
if (index > 3000) {
|
||||
buf.append('|');
|
||||
buf.append(getString(index / 1000));
|
||||
buf.append('|');
|
||||
index -= index / 1000 * 1000;
|
||||
}
|
||||
int pos = 0;
|
||||
while (true) {
|
||||
RomanDigit dig = roman[pos];
|
||||
while (index >= dig.value) {
|
||||
buf.append(dig.digit);
|
||||
index -= dig.value;
|
||||
}
|
||||
if (index <= 0)
|
||||
break;
|
||||
int j = pos;
|
||||
while (!(roman[++j]).pre);
|
||||
if (index + (roman[j]).value >= dig.value) {
|
||||
buf.append((roman[j]).digit).append(dig.digit);
|
||||
index -= dig.value - (roman[j]).value;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static final String getLowerCaseString(int index) {
|
||||
return getString(index);
|
||||
}
|
||||
|
||||
public static final String getUpperCaseString(int index) {
|
||||
return getString(index).toUpperCase();
|
||||
}
|
||||
|
||||
public static final String getString(int index, boolean lowercase) {
|
||||
if (lowercase)
|
||||
return getLowerCaseString(index);
|
||||
return getUpperCaseString(index);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue