+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-// Author : Seshadri G
-
-package org.apache.fop.mif;
-
-// images are the one place that FOP classes outside this package get
-// referenced and I'd rather not do it
-
-import org.apache.fop.image.FopImage;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.layout.LinkSet;
-import org.apache.fop.datatypes.ColorSpace;
-
-import org.apache.fop.datatypes.IDReferences;
-import org.apache.fop.layout.Page;
-import org.apache.fop.layout.FontMetric;
-import org.apache.fop.layout.FontDescriptor;
-// Java
-import java.io.*;
-import java.io.PrintWriter;
-import java.util.*;
-import java.awt.Rectangle;
-
-/**
- * class representing a MIF document.
- *
- * The document is built up by calling various methods and then finally
- * output to given filehandle using output method.
- *
- */
-public class MIFDocument {
-
- /**
- * the version of MIF supported
- */
-
-
- protected static final String mifVersion = "5.5";
- protected BookComponent bookComponent;
- private Flow curFlow; // this is a ref to the current flow which could be a textflow or
- // a table
- private ID curIDCounter = new ID();
-
- class ID {
-
- private int idCounter = 1;
- public int getnewID() {
-
- return idCounter++;
- }
-
- }
-
- class FontFormat {
-
- public FontFormat() {}
-
- }
-
- class ParagraphFormat extends FontFormat {
-
- public ParagraphFormat() {}
-
- int startIndent;
- int endIndent;
-
-
-
- }
-
- class Document {
- protected int height;
- protected int width;
- public Document() {}
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<Document " + "\n<DPageSize " + width / 1000f
- + " " + height / 1000f + " >\n>";
- byte buf[] = mif.getBytes();
-
- stream.write(buf);
-
- }
-
- }
-
-
- class PolyLine {
-
- public PolyLine() {}
-
- }
-
- class ImportObject {
-
- private String url;
- private int x, y, w, h;
-
- public ImportObject(String url, int x, int y, int w, int h) {
-
- this.url = url;
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
-
- }
-
-
- public void output(OutputStream stream) throws IOException {
-
-
- String path = this.url;
-
- // Strip 'file:'
- path = path.substring(5);
- String result = "";
- int i;
- do { // replace all matching '/'
-
- i = path.indexOf("/");
- if (i != -1) {
- result = path.substring(0, i);
- result += "<c\\>";
- result += path.substring(i + 1);
- path = result;
- }
-
- } while (i != -1);
-
- String mif = "\n<ImportObject" + "\n<ImportObFixedSize Yes>";
- mif += "\n\t<ImportObFileDI " + "`<c\\>" + path + "'" + " >";
- mif += "\n\t<ShapeRect " + this.x / 1000f + " " + this.y / 1000f
- + " " + this.w / 1000f + " " + this.h / 1000f + " >";
-
- mif += "\n> #End ImportObj";
- stream.write(mif.getBytes());
-
- }
-
- }
-
-
- class Frame {
-
- private int ID;
- private int x, y, w, h;
- Vector content = new Vector();
- public Frame(int x, int y, int w, int h) {
-
- this.ID = curIDCounter.getnewID();
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
-
- }
-
- public void addContent(ImportObject obj) {
-
- content.addElement(obj);
-
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<Frame" + "\n\t<ID " + this.ID + " >";
- mif +=
- "\n\t<Pen 15>\n\t<Fill 7>\n\t<PenWidth 1.0 >\n\t<Separation 0>\n\t<ObColor `Black'>\n\t<DashedPattern \n\t <DashedStyle Solid> \n >";
-
- mif +=
- "\n\t<RunaroundGap 6.0 pt>\n\t<RunaroundType None>\n\t<Angle 360.0>\n\t<Float No>\n\t<NSOffset 0.0>\n\t<BLOffset 0>\n\t<Cropped No>\n\t<FrameType Below>\n\t<AnchorAlign Center>";
-
- mif += "\n\t<ShapeRect " + this.x / 1000f + " " + this.y / 1000f
- + " " + this.w / 1000f + " " + this.h / 1000f + " >";
-
-
- stream.write(mif.getBytes());
-
- Enumeration e = content.elements();
- while (e.hasMoreElements()) {
-
- ((ImportObject)e.nextElement()).output(stream);
- }
- mif = "\n> #End Frame";
- stream.write(mif.getBytes());
-
-
-
- }
-
- public int getID() {
-
- return this.ID;
- }
-
- }
-
- class TextRect {
- private int rx, ry, w, h;
- private int numCols;
- private int curCol = 0; // Current column being processed
- private int colGap = 0;
- private int textRectID;
- public TextRect(int numCols) {
-
- this.numCols = numCols;
- this.curCol = 0;
- this.textRectID = curIDCounter.getnewID();
-
- }
-
-
- public int getTextRectID() {
-
- return textRectID;
-
- }
-
-
- public void setTextRectProp(int left, int top, int width,
- int height) {
-
- if (curCol == 0) {
-
- // Use the left and top margins
-
- rx = left;
- ry = top;
- w = width; // current column width , not the entire span
- h = height;
- curCol++;
-
- } else if (curCol == 1) {
- // Figure out the column gap and the span of the textrect
- colGap = left - rx - width;
- // Next the entire width
- w = numCols * width + (numCols - 1) * colGap;
- curCol++;
-
-
- }
-
- }
-
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<TextRect" + "\n\t<ID " + textRectID + ">"
- + "\n\t<ShapeRect " + rx / 1000f + " " + ry / 1000f
- + " " + w / 1000f + " " + h / 1000f + ">";
-
- if (numCols > 1) {
- mif += "\n<TRNumColumns " + numCols + ">";
- mif += "\n<TRColumnGap " + colGap / 1000f + ">";
- }
-
- mif += "\n> #End TextRect";
- byte buf[] = mif.getBytes();
- stream.write(buf);
- }
-
- }
-
- class Page {
- private String pageType;
- private String pageTag;
- private String pageBackground;
- private Vector textRects;
- public Page(String pageType, String pageTag, String pageBackground) {
-
- this.pageType = pageType;
- this.pageTag = pageTag;
- this.pageBackground = pageBackground;
- this.textRects = new Vector();
- }
-
- public Page() {
-
- this.pageType = "BodyPage";
- this.pageBackground = "Default";
- this.textRects = new Vector();
-
- }
-
-
- public void addTextRect(int numCols) {
-
- TextRect textRect = new TextRect(numCols);
- this.textRects.addElement(textRect);
- }
-
- public TextRect curTextRect() {
-
- return (TextRect)textRects.lastElement();
-
- }
-
-
-
- public void output(OutputStream stream) throws IOException {
-
-
- String mif = "\n<Page" + "\n\t<PageType " + pageType + ">"
- + "\n\t<PageBackground " + "`" + pageBackground
- + "'" + ">";
-
- byte buf[] = mif.getBytes();
-
- stream.write(buf);
-
- Enumeration e = textRects.elements();
-
- while (e.hasMoreElements()) {
-
- ((TextRect)e.nextElement()).output(stream);
-
- }
- mif = "\n> #End Page\n";
- stream.write(mif.getBytes());
-
- }
-
-
- }
-
- abstract class Flow {
-
- public Flow() {}
-
- public abstract Para curPara();
- public abstract void startPara();
- }
-
-
- class TextFlow extends Flow {
-
- Vector paras;
- private int ID; // This ID is used within ParaLine, however it is
- // logical to keep it unique to a textflow
-
- public TextFlow() {
-
-
- // The current textrect into which the textflow goes
- // is the last created.
-
- this.ID =
- ((bookComponent.curPage()).curTextRect()).getTextRectID();
- this.paras = new Vector();
-
- }
-
-
- public int getTextRectID() {
-
- return ID;
-
- }
-
- public Para curPara() {
-
- return (Para)paras.lastElement();
- }
-
- public void startPara() {
-
- this.paras.addElement(new Para(ID));
- }
-
- public void output(OutputStream stream) throws IOException {
- String mif = "\n<TextFlow";
- stream.write(mif.getBytes());
- Enumeration e = paras.elements();
- while (e.hasMoreElements()) {
-
- ((Para)e.nextElement()).output(stream);
- }
- mif = "\n> #End TextFlow";
- stream.write(mif.getBytes());
- }
-
- }
-
-
- class Para {
-
- Vector paraLines;
- int ID; // Same as TextRectID
- ParagraphFormat pgf =
- null; // This corresponds to to the block properties
- public Para() {
-
- this.ID = 0;
- this.paraLines = new Vector();
- }
-
-
- public Para(int ID) {
-
- this.ID = ID;
- this.paraLines = new Vector();
-
- }
-
- public ParaLine curParaLine() {
- if (paraLines.isEmpty()) {
- return null;
- } else {
- return (ParaLine)paraLines.lastElement();
- }
- }
-
- void startParaLine() {
-
- this.paraLines.addElement(new ParaLine(ID));
-
- }
-
-
- public void setBlockProp(int startIndent, int endIndent) {
-
- pgf = new ParagraphFormat();
- pgf.startIndent = startIndent;
- pgf.endIndent = endIndent;
-
-
- }
-
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<Para";
- // Is there a block property?
-
- if (pgf != null) {
- mif += "\n<Pgf";
- mif += "\n<PgfTag `Body'>";
- mif += "\n<PgfLIndent " + pgf.startIndent / 1000f + ">";
- mif += "\n<PgfRIndent " + pgf.endIndent / 1000f + ">";
- mif += "\n>";
- }
- stream.write(mif.getBytes());
- Enumeration e = paraLines.elements();
- while (e.hasMoreElements()) {
-
- ((ParaLine)e.nextElement()).output(stream);
- }
- mif = "\n> #End ParaLine";
- stream.write(mif.getBytes());
-
- }
-
- }
-
- class ParaLine {
- Vector content;
- int textRectID;
- String tableID;
- String aFrameID;
- public ParaLine(int textRectID) {
-
- this.textRectID = textRectID;
- this.content = new Vector();
-
- }
-
- public ParaLine() {
-
- this.textRectID = 0; // There is no ID used, in tables
- this.content = new Vector();
- }
-
- public void addContent(Object obj) {
-
- this.content.addElement(obj);
-
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<ParaLine";
-
- // tables dont need the textrectid
- if (textRectID != 0)
- mif += "\n\t<TextRectID " + textRectID + ">";
-
- stream.write(mif.getBytes());
- Enumeration e = this.content.elements();
- while (e.hasMoreElements()) {
-
- Object elem = (Object)e.nextElement();
- if (elem instanceof String) {
-
- // Output newlines as char hard return
-
- if (elem == "\n") {
-
- mif = "\n<Char HardReturn>";
- } else {
- mif = "\n\t<String `" + elem + "'>";
- }
- stream.write(mif.getBytes());
-
- } else if (elem instanceof Frame) {
-
- mif = "\n\t<AFrame " + ((Frame)elem).getID() + " >";
- stream.write(mif.getBytes());
- } else if (elem instanceof Tbl) {
- mif = "\n\t<ATbl " + ((Tbl)elem).getID() + " >";
- stream.write(mif.getBytes());
- }
- }
- mif = "\n> #End ParaLine";
- stream.write(mif.getBytes());
-
- }
-
- }
-
- class PgfCatalog {
-
- Vector pgfs; // Paragraph formats
- public PgfCatalog() {}
-
- public void output(OutputStream stream) throws IOException {
- String mif = "\n<PgfCatalog" + "\n<Pgf" + "\n<PgfTag `Body'>"
- + "\n>" + "\n>";
- stream.write(mif.getBytes());
- }
-
- }
-
- class Color {
-
- public Color() {}
-
- }
-
- class ColorCatalog {
-
- public ColorCatalog() {}
-
- }
-
- class Ruling {
-
- int penWidth;
- int pen;
- int lines;
- public Ruling() {
- // Default ruling
- penWidth = 1;
- pen = 0;
- lines = 1;
-
-
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<Ruling \n<RulingTag `Default'>";
- mif += "\n<RulingPenWidth " + penWidth + ">";
- mif += "\n<RulingPen " + pen + ">";
- mif += "\n<RulingLines " + lines + ">";
- mif += "\n>";
- stream.write(mif.getBytes());
- }
-
- }
-
- class RulingCatalog {
- // Contains multiple rulings
-
- Vector ruling = new Vector();
- public RulingCatalog() {
-
- // Add the defualt ruling to the catalog
-
- ruling.addElement(new Ruling());
-
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<RulingCatalog";
- stream.write(mif.getBytes());
- Enumeration e = ruling.elements();
- while (e.hasMoreElements()) {
- ((Ruling)e.nextElement()).output(stream);
- }
- mif = "\n> #End RulingCatalog";
- stream.write(mif.getBytes());
-
- }
-
- }
-
- class TblFormat {
- public TblFormat() {}
-
- }
-
- class TblCatalog {
- public TblCatalog() {}
-
- }
-
- class Tbl extends Flow {
-
- class TblColumn {
- private int width;
- public TblColumn(int width) {
-
- this.width = width;
-
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n\t<TblColumnWidth " + width + " >";
- stream.write(mif.getBytes());
-
- }
-
-
- }
-
- class Row {
-
- class Cell {
-
- private int rowSpan, colSpan;
- private Vector paras; // Paras
- public Cell(int rowSpan, int colSpan) {
-
- this.rowSpan = rowSpan;
- this.colSpan = colSpan;
- paras = new Vector();
-
- }
-
- public void startPara() {
-
- this.paras.addElement(new Para());
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n\t\t<Cell" + "\n\t\t<CellContent";
- stream.write(mif.getBytes());
- Enumeration e = paras.elements();
- while (e.hasMoreElements()) {
- ((Para)e.nextElement()).output(stream);
- }
- mif = "\n\t\t> #End CellContent";
- mif += "\n\t> #End Cell";
- stream.write(mif.getBytes());
- }
-
- }
- private Vector cells;
-
- public void addCell(int rowSpan, int colSpan) {
-
- cells.addElement(new Cell(rowSpan, colSpan));
- }
-
- public Row() {
-
- cells = new Vector();
-
- }
-
- public Cell curCell() {
-
- return (Cell)this.cells.lastElement();
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n\t<Row";
- stream.write(mif.getBytes());
- Enumeration e = cells.elements();
- while (e.hasMoreElements()) {
- ((Cell)e.nextElement()).output(stream);
- }
- mif = "\n\t> #End Row";
- stream.write(mif.getBytes());
-
- }
-
-
- }
-
- private int ID;
- private Vector tblColumns = new Vector();
- private Vector tblBody, tblHead, tblFoot;
- private Vector current; // is a reference to one of tblHead,tblBody or tblFoot
- public void addColumn(int colWidth) {
-
- tblColumns.addElement(new TblColumn(colWidth));
-
- }
-
- public void setCurrent(String current) {
-
- if (current == "fo:table-body") {
- this.current = this.tblBody;
- } else if (current == "tablehead") {
- this.current = this.tblHead;
- } else if (current == "tablefoot") {
- this.current = this.tblFoot;
- }
- }
-
- public void startRow() {
-
- this.current.addElement(new Row());
- }
-
- public void startCell(int rowSpan, int colSpan) {
-
- // Add a cell into the current row
-
- ((Row)this.current.lastElement()).addCell(rowSpan, colSpan);
-
- }
-
- public Tbl() {
-
- this.ID = curIDCounter.getnewID();
- tblBody = new Vector();
- tblHead = new Vector();
- tblFoot = new Vector();
-
- }
-
- public int getID() {
-
- return this.ID;
- }
-
- public Para curPara() {
-
- // Return the last para of the current cell
-
- Row curRow;
- curRow = (Row)this.current.lastElement();
- return (Para)curRow.curCell().paras.lastElement();
-
-
- }
-
- public void startPara() {
-
- // start a new para in the current cell
- Row curRow;
- curRow = (Row)this.current.lastElement();
- curRow.curCell().startPara();
-
- }
-
- public void output(OutputStream stream) throws IOException {
-
- String mif = "\n<Tbl" + "\n\t<TblID " + ID + " >";
-
- // note tbl format to be added in a later release
- mif += "\n<TblTag Body>" + "\n<TblFormat";
- mif += "\n<TblColumnRuling `Default'>";
- mif += "\n<TblBodyRowRuling `Default'>";
- mif += "\n<TblLRuling `Default'>";
- mif += "\n<TblBRuling `Default'>";
- mif += "\n<TblRRuling `Default'>";
- mif += "\n<TblTRuling `Default'>";
-
- mif += "\n> #End TblFormat";
- ;
- mif += "\n\t<TblNumColumns " + tblColumns.size() + " >";
- stream.write(mif.getBytes());
-
- if (!tblHead.isEmpty()) {
- Enumeration e = tblHead.elements();
- while (e.hasMoreElements()) {
- ((Row)e.nextElement()).output(stream);
- }
- }
- if (!tblFoot.isEmpty()) {
- Enumeration e = tblFoot.elements();
- while (e.hasMoreElements()) {
- ((Row)e.nextElement()).output(stream);
- }
- }
- if (!tblBody.isEmpty()) {
- mif = "\n\t<TblBody";
- stream.write(mif.getBytes());
- Enumeration e = tblBody.elements();
- while (e.hasMoreElements()) {
- ((Row)e.nextElement()).output(stream);
- }
- mif = "\n\t> #End tblBody";
- }
- mif += "\n> #End Table";
- stream.write(mif.getBytes());
- }
-
- }
-
- class XRefFormat {
-
- public XRefFormat() {}
-
- }
-
- class CrossRefInfo {
-
- public CrossRefInfo() {}
-
- }
-
- class XRef {
-
- public XRef() {}
-
- }
-
- class Marker {
-
- public Marker() {}
-
- }
-
- class BookComponent {
-
- Document document;
- ColorCatalog colorCatalog;
- RulingCatalog rulingCatalog;
- PgfCatalog pgfCatalog;
- TblCatalog tblCatalog;
- Vector aFrames = new Vector();
- Vector tables = new Vector();
- Vector pages = new Vector();
- Vector textFlows = new Vector();
-
-
- public BookComponent() {
-
- document = null; // Initially no values are available
- pgfCatalog = new PgfCatalog();
- rulingCatalog = new RulingCatalog();
- }
-
-
- public Frame createFrame(int x, int y, int w, int h) {
-
- Frame frame = new Frame(x, y, w, h);
- aFrames.addElement(frame);
- return frame;
-
- }
-
- public Frame curFrame() {
-
- return (Frame)aFrames.lastElement();
-
- }
-
- public TextFlow curTextFlow() {
-
- return (TextFlow)textFlows.lastElement();
-
- }
-
- public Tbl createTable() {
-
- Tbl table = new Tbl();
- tables.addElement(table);
- return table;
- }
-
- public Tbl curTable() {
-
- return (Tbl)tables.lastElement();
- }
-
- public void output(OutputStream stream) throws IOException {
- String mif = "<MIFFile 5.00>" + "\n<Units Upt>";
- stream.write(mif.getBytes());
- pgfCatalog.output(stream);
- rulingCatalog.output(stream);
- document.output(stream);
-
- if (!aFrames.isEmpty()) {
-
- mif = "\n<AFrames";
- stream.write(mif.getBytes());
- Enumeration e = aFrames.elements();
- while (e.hasMoreElements()) {
-
- ((Frame)e.nextElement()).output(stream);
- }
-
- mif = "\n>";
- stream.write(mif.getBytes());
- }
-
- if (!tables.isEmpty()) {
-
- mif = "\n<Tbls";
- stream.write(mif.getBytes());
- Enumeration e = tables.elements();
- while (e.hasMoreElements()) {
-
- ((Tbl)e.nextElement()).output(stream);
- }
-
- mif = "\n>";
- stream.write(mif.getBytes());
- }
-
-
- Enumeration e = pages.elements();
- while (e.hasMoreElements()) {
-
- ((Page)e.nextElement()).output(stream);
- }
-
- e = textFlows.elements();
- while (e.hasMoreElements()) {
-
- ((TextFlow)e.nextElement()).output(stream);
-
- }
- }
-
- private Page curPage() {
- return (Page)pages.lastElement();
- }
-
- }
-
- class ElementSet {
- public ElementSet() {}
-
- }
-
- /**
- * creates an empty MIF document
- */
- public MIFDocument() {
-
- bookComponent = new BookComponent();
-
- }
-
- public void createPage() {
-
- bookComponent.pages.addElement(new Page());
-
- }
-
- public void addToStream(String s) {
-
- // Add this string to the curent flow
-
- Para para = curFlow.curPara();
- ParaLine paraLine = para.curParaLine();
- paraLine.addContent(s);
-
- }
-
- public void output(OutputStream stream) throws IOException {
- // Output the contents of bookComponent
-
- this.bookComponent.output(stream);
-
- }
-
- public void setDocumentHeightWidth(int height, int width) {
-
- if (bookComponent.document == null) {
-
- bookComponent.document = new Document();
- bookComponent.document.height = height;
- bookComponent.document.width = width;
- } else if (bookComponent.document.height != height
- || bookComponent.document.width != width) {
-
- MessageHandler.logln("Warning : FrameMaker doesnt support different page-sizes in a document");
- }
-
- }
-
- public void createTextRect(int numCols) {
-
- // Create a textrect on the bodypage with these dimensions
- // This default behaviour will later be changed to reflect on
- // the master-page
-
-
- (bookComponent.curPage()).addTextRect(numCols);
-
-
- // Then create a textflow corresponding to this textrect
-
- curFlow = new TextFlow();
- bookComponent.textFlows.addElement(curFlow);
- }
-
- public void setTextRectProp(int left, int top, int width, int height) {
-
- (bookComponent.curPage()).curTextRect().setTextRectProp(left, top,
- width, height);
-
-
- }
-
- public void startLine() {
-
- if (curFlow.curPara().curParaLine() != null) {
- this.addToStream("\n");
- curFlow.curPara().startParaLine();
- } else
- curFlow.curPara().startParaLine();
-
-
- }
-
- public void setBlockProp(int startIndent, int endIndent) {
-
-
- curFlow.startPara(); // Start a para
- curFlow.curPara().setBlockProp(startIndent, endIndent);
-
- }
-
- public void createFrame(int x, int y, int w, int h) {
-
- // Create a new anchored frame
-
- bookComponent.createFrame(x, y, w, h);
-
- }
-
- public void addImage(String url, int x, int y, int w, int h) {
-
- Frame frame = bookComponent.createFrame(x, y, w, h);
- ImportObject imageObject = new ImportObject(url, 0, 0, w, h);
- frame.addContent(imageObject);
- if (curFlow.curPara().curParaLine() == null) {
- curFlow.curPara().startParaLine();
-
- }
- curFlow.curPara().curParaLine().addContent(frame);
-
-
- }
-
- public void createTable() {
-
- // First create a table with an ID, then add it to the textflow
-
- Tbl table = bookComponent.createTable();
- if (curFlow.curPara().curParaLine() == null) {
- curFlow.curPara().startParaLine();
-
- }
- curFlow.curPara().curParaLine().addContent(table);
-
- /*
- * The above would have added the table to the textflow
- * But now the flow goes into the table, so ...
- */
-
- curFlow = table;
-
- }
-
- public void setColumnProp(int colWidth) {
-
-
- // Get the current table
-
- Tbl table = bookComponent.curTable();
- table.addColumn(colWidth);
-
-
- }
-
- public void setCurrent(String current) {
-
- // Start the table body or header or footer
- Tbl table = bookComponent.curTable();
- table.setCurrent(current);
-
- }
-
- public void startRow() {
-
- Tbl table = bookComponent.curTable();
- table.startRow();
-
-
- }
-
- public void startCell(int rowSpan, int colSpan) {
-
- Tbl table = bookComponent.curTable();
- table.startCell(rowSpan, colSpan);
-
- }
-
- public void endTable() {
-
- // Switch the ref back to the current textflow
-
- curFlow = bookComponent.curTextFlow();
-
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-public class ASCII85Filter extends PDFFilter {
- private static final char ASCII85_ZERO = 'z';
- private static final char ASCII85_START = '!';
- private static final String ASCII85_EOD = "~>";
-
- private static final long base85_4 = 85;
- private static final long base85_3 = base85_4 * base85_4;
- private static final long base85_2 = base85_3 * base85_4;
- private static final long base85_1 = base85_2 * base85_4;
-
-
-
- public String getName() {
- return "/ASCII85Decode";
- }
-
- public String getDecodeParms() {
- return null;
- }
-
- public byte[] encode(byte[] data) {
-
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-
- int i;
- int total = 0;
- int diff = 0;
-
- // first encode the majority of the data
- // each 4 byte group becomes a 5 byte group
- for (i = 0; i + 3 < data.length; i += 4) {
-
- long val = ((data[i] << 24)
- & 0xff000000L) // note: must have the L at the
- + ((data[i + 1] << 16) & 0xff0000L) // end, otherwise you get into
- + ((data[i + 2] << 8) & 0xff00L) // weird signed value problems
- + (data[i + 3] & 0xffL); // cause we're using a full 32 bits
- byte[] conv = convertWord(val);
-
- buffer.write(conv, 0, conv.length);
-
- }
-
- // now take care of the trailing few bytes.
- // with n leftover bytes, we append 0 bytes to make a full group of 4
- // then convert like normal (except not applying the special zero rule)
- // and write out the first n+1 bytes from the result
- if (i < data.length) {
- int n = data.length - i;
- byte[] lastdata = new byte[4];
- for (int j = 0; j < 4; j++) {
- if (j < n) {
- lastdata[j] = data[i++];
- } else {
- lastdata[j] = 0;
- }
- }
-
- long val = ((lastdata[0] << 24) & 0xff000000L)
- + ((lastdata[1] << 16) & 0xff0000L)
- + ((lastdata[2] << 8) & 0xff00L)
- + (lastdata[3] & 0xffL);
- byte[] conv = convertWord(val);
-
- // special rule for handling zeros at the end
- if (val == 0) {
- conv = new byte[5];
- for (int j = 0; j < 5; j++) {
- conv[j] = (byte)'!';
- }
- }
- // assert n+1 <= 5
- buffer.write(conv, 0, n + 1);
- // System.out.println("ASCII85 end of data was "+n+" bytes long");
-
- }
- // finally write the two character end of data marker
- buffer.write(ASCII85_EOD.getBytes(), 0,
- ASCII85_EOD.getBytes().length);
-
-
- byte[] result = buffer.toByteArray();
-
-
- // assert that we have the correct outgoing length
- /*
- * int in = (data.length % 4);
- * int out = (result.length-ASCII85_EOD.getBytes().length) % 5;
- * if ((in+1 != out) && !(in == 0 && out == 0)) {
- * System.out.println("ASCII85 assertion failed:");
- * System.out.println(" inlength = "+data.length+" inlength % 4 = "+(data.length % 4)+" outlength = "+(result.length-ASCII85_EOD.getBytes().length)+" outlength % 5 = "+((result.length-ASCII85_EOD.getBytes().length) % 5));
- * }
- */
- return result;
-
- }
-
- /**
- * This converts a 32 bit value (4 bytes) into 5 bytes using base 85.
- * each byte in the result starts with zero at the '!' character so
- * the resulting base85 number fits into printable ascii chars
- *
- * @param word the 32 bit unsigned (hence the long datatype) word
- * @return 5 bytes (or a single byte of the 'z' character for word
- * values of 0)
- */
- private byte[] convertWord(long word) {
- word = word & 0xffffffff;
- if (word < 0) {
- word = -word;
- }
-
- if (word == 0) {
- byte[] result = {
- (byte)ASCII85_ZERO
- };
- return result;
- } else {
- byte c1 = (byte)((word / base85_1) & 0xFF);
- byte c2 = (byte)(((word - (c1 * base85_1)) / base85_2) & 0xFF);
- byte c3 =
- (byte)(((word - (c1 * base85_1) - (c2 * base85_2)) / base85_3)
- & 0xFF);
- byte c4 =
- (byte)(((word - (c1 * base85_1) - (c2 * base85_2) - (c3 * base85_3)) / base85_4)
- & 0xFF);
- byte c5 =
- (byte)(((word - (c1 * base85_1) - (c2 * base85_2) - (c3 * base85_3) - (c4 * base85_4)))
- & 0xFF);
-
- byte[] ret = {
- (byte)(c1 + ASCII85_START), (byte)(c2 + ASCII85_START),
- (byte)(c3 + ASCII85_START), (byte)(c4 + ASCII85_START),
- (byte)(c5 + ASCII85_START)
- };
- for (int i = 0; i < ret.length; i++) {
- if (ret[i] < 33 || ret[i] > 117) {
- System.out.println("illegal char value "
- + new Integer(ret[i]));
- }
- }
-
- return ret;
-
-
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-package org.apache.fop.pdf;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-public class ASCIIHexFilter extends PDFFilter {
- private static final String ASCIIHEX_EOD = ">";
-
-
- public String getName() {
- return "/ASCIIHexDecode";
- }
-
- public String getDecodeParms() {
- return null;
- }
-
- public byte[] encode(byte[] data) {
-
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < data.length; i++) {
- int val = (int)(data[i] & 0xFF);
- if (val < 16)
- buffer.append("0");
- buffer.append(Integer.toHexString(val));
- }
- buffer.append(ASCIIHEX_EOD);
-
- return buffer.toString().getBytes();
-
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.zip.DeflaterOutputStream;
-
-/**
- * A filter to deflate a stream. Note that the attributes for
- * prediction, colors, bitsPerComponent, and columns are not supported
- * when this filter is used to handle the data compression. They are
- * only valid for externally encoded data such as that from a graphics
- * file.
- */
-public class FlateFilter extends PDFFilter {
-
- public static final int PREDICTION_NONE = 1;
- public static final int PREDICTION_TIFF2 = 2;
- public static final int PREDICTION_PNG_NONE = 10;
- public static final int PREDICTION_PNG_SUB = 11;
- public static final int PREDICTION_PNG_UP = 12;
- public static final int PREDICTION_PNG_AVG = 13;
- public static final int PREDICTION_PNG_PAETH = 14;
- public static final int PREDICTION_PNG_OPT = 15;
-
-
- private int _predictor = PREDICTION_NONE;
- private int _colors;
- private int _bitsPerComponent;
- private int _columns;
-
- public String getName() {
- return "/FlateDecode";
- }
-
- public String getDecodeParms() {
- if (_predictor > PREDICTION_NONE) {
- StringBuffer sb = new StringBuffer();
- sb.append("<< /Predictor ");
- sb.append(_predictor);
- if (_colors > 0) {
- sb.append(" /Colors " + _colors);
- }
- if (_bitsPerComponent > 0) {
- sb.append(" /BitsPerComponent " + _bitsPerComponent);
- }
- if (_columns > 0) {
- sb.append(" /Columns " + _columns);
- }
- sb.append(" >> ");
- return sb.toString();
- }
- return null;
- }
-
-
- /**
- * Encode the given data and return it. Note: a side effect of
- * this method is that it resets the prediction to the default
- * because these attributes are not supported. So the DecodeParms
- * should be retrieved after calling this method.
- */
- public byte[] encode(byte[] data) {
- ByteArrayOutputStream outArrayStream = new ByteArrayOutputStream();
- _predictor = PREDICTION_NONE;
- try {
- DeflaterOutputStream compressedStream =
- new DeflaterOutputStream(outArrayStream);
- compressedStream.write(data, 0, data.length);
- compressedStream.flush();
- compressedStream.close();
- } catch (IOException e) {
- org.apache.fop.messaging.MessageHandler.error("Fatal error: "
- + e.getMessage());
- e.printStackTrace();
- }
-
- return outArrayStream.toByteArray();
- }
-
- public void setPredictor(int predictor) throws PDFFilterException {
- _predictor = predictor;
-
- }
-
- public int getPredictor() {
- return _predictor;
- }
-
-
- public void setColors(int colors) throws PDFFilterException {
- if (_predictor != PREDICTION_NONE) {
- _colors = colors;
- } else {
- throw new PDFFilterException("Prediction must not be PREDICTION_NONE in order to set Colors");
- }
- }
-
- public int getColors() {
- return _colors;
- }
-
-
- public void setBitsPerComponent(int bits) throws PDFFilterException {
- if (_predictor != PREDICTION_NONE) {
- _bitsPerComponent = bits;
- } else {
- throw new PDFFilterException("Prediction must not be PREDICTION_NONE in order to set bitsPerComponent");
- }
- }
-
- public int getBitsPerComponent() {
- return _bitsPerComponent;
- }
-
-
- public void setColumns(int columns) throws PDFFilterException {
- if (_predictor != PREDICTION_NONE) {
- _columns = columns;
- } else {
- throw new PDFFilterException("Prediction must not be PREDICTION_NONE in order to set Columns");
- }
- }
-
- public int getColumns() {
- return _columns;
- }
-
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing an action object.
- */
-public abstract class PDFAction extends PDFObject {
-
-
- /**
- * create an Action object.
- * this constructor is used for passing on the object number to the PDFObject
- *
- * @param number the object's number
- */
- public PDFAction(int number) {
-
- /* generic creation of object */
- super(number);
- }
-
- /**
- * empty constructor for PDFAction.
- * this constructor is used when there is no additional object being created
- *
- */
- public PDFAction() {}
-
- /**
- * represent the action to call
- * this method should be implemented to return the action which gets
- * called by the Link Object. This could be a reference to another object
- * or the specific destination of the link
- *
- * @return the action to place next to /A within a Link
- */
- abstract public String getAction();
-
-
- /**
- * represent the object in PDF
- * this method should be implemented to return the PDF which is to be
- * generated by the Action object
- *
- * @return the PDF string
- */
- abstract public byte[] toPDF();
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.util.Vector;
-
-/**
- * class representing an object which is a list of annotations.
- *
- * This PDF object is a list of references to /Annot objects. So far we
- * are dealing only with links.
- */
-public class PDFAnnotList extends PDFObject {
-
- /**
- * the /Annot objects
- */
- protected Vector links = new Vector();
-
- /**
- * the number of /Annot objects
- */
- protected int count = 0;
-
- /**
- * create a /Annots object.
- *
- * @param number the object's number
- */
- public PDFAnnotList(int number) {
-
- /* generic creation of object */
- super(number);
- }
-
- /**
- * add an /Annot object of /Subtype /Link.
- *
- * @param link the PDFLink to add.
- */
- public void addLink(PDFLink link) {
- this.links.addElement(link);
- this.count++;
- }
-
- /**
- * get the count of /Annot objects
- *
- * @return the number of links
- */
- public int getCount() {
- return this.count;
- }
-
- /**
- * represent the object in PDF
- *
- * @return the PDF string
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer(this.number + " " + this.generation
- + " obj\n[\n");
- for (int i = 0; i < this.count; i++) {
- p = p.append(((PDFObject)links.elementAt(i)).referencePDF()
- + "\n");
- }
- p = p.append("]\nendobj\n");
- return p.toString().getBytes();
- }
-
- /*
- * example
- * 20 0 obj
- * [
- * 19 0 R
- * ]
- * endobj
- */
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing an array object
- */
-public class PDFArray extends PDFObject {
-
- protected int[] values;
-
- /**
- * create the array object
- *
- * @param number the object's number
- * @param values the actual array wrapped by this object
- */
- public PDFArray(int number, int[] values) {
-
- /* generic creation of PDF object */
- super(number);
-
- /* set fields using paramaters */
- this.values = values;
- }
-
- /**
- * produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation + " obj\n[");
- for (int i = 0; i < values.length; i++) {
- p.append(" ");
- p.append(values[i]);
- }
- p.append("]\nendobj\n");
- return p.toString().getBytes();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// based on work by Takayuki Takeuchi
-
-/**
- * class representing a "character identifier" font (p 210 and onwards).
- */
-public class PDFCIDFont extends PDFObject {
-
- public static final byte CID_TYPE0 = 0;
- public static final byte CID_TYPE2 = 1;
- protected static final String[] TYPE_NAMES = {
- "CIDFontType0", "CIDFontType2"
- };
-
- protected String basefont;
-
- protected String cidtype;
- protected Integer dw;
- protected PDFWArray w;
- protected int[] dw2;
- protected PDFWArray w2;
- protected PDFCIDSystemInfo systemInfo;
- protected PDFCIDFontDescriptor descriptor;
- protected PDFCMap cmap;
-
- /**
- * /CIDToGIDMap (only for CIDFontType2, see p 212)
- * can be either "Identity" (default) or a PDFStream
- */
- protected PDFStream cidMap;
-
- // compatibility with Takayuki Takeuchi
-
- /**
- * create the /Font object
- */
- public PDFCIDFont(int number, String basefont, byte cidtype, int dw,
- int[] w, String registry, String ordering,
- int supplement, PDFCIDFontDescriptor descriptor) {
-
- super(number);
-
- this.basefont = basefont;
- this.cidtype = TYPE_NAMES[(int)cidtype];
- this.dw = new Integer(dw);
- this.w = new PDFWArray();
- this.w.addEntry(0, w);
- this.dw2 = null;
- this.w2 = null;
- this.systemInfo = new PDFCIDSystemInfo(registry, ordering,
- supplement);
- this.descriptor = descriptor;
- this.cidMap = null;
- this.cmap = null;
- }
-
- /**
- * create the /Font object
- */
- public PDFCIDFont(int number, String basefont, byte cidtype, int dw,
- PDFWArray w, PDFCIDSystemInfo systemInfo,
- PDFCIDFontDescriptor descriptor) {
-
- super(number);
-
- this.basefont = basefont;
- this.cidtype = TYPE_NAMES[(int)cidtype];
- this.dw = new Integer(dw);
- this.w = w;
- this.dw2 = null;
- this.w2 = null;
- this.systemInfo = systemInfo;
- this.descriptor = descriptor;
- this.cidMap = null;
- this.cmap = null;
- }
-
- /**
- * set the /DW attribute
- */
- public void setDW(int dw) {
- this.dw = new Integer(dw);
- }
-
- /**
- * set the /W array
- */
- public void setW(PDFWArray w) {
- this.w = w;
- }
-
- /**
- * set the (two elements) /DW2 array
- */
- public void setDW2(int[] dw2) {
- this.dw2 = dw2;
- }
-
- /**
- * set the two elements of the /DW2 array
- */
- public void setDW2(int posY, int displacementY) {
- this.dw2 = new int[] {
- posY, displacementY
- };
- }
-
- /**
- * Set the CMap used as /ToUnicode cmap
- */
- public void setCMAP(PDFCMap cmap) {
- this.cmap = cmap;
- }
-
- /**
- * set the /W2 array
- */
- public void setW2(PDFWArray w2) {
- this.w2 = w2;
- }
-
- /**
- * set the /CIDToGIDMap (to be used only for CIDFontType2)
- */
- public void setCIDMap(PDFStream map) {
- this.cidMap = map;
- }
-
- /**
- * set the /CIDToGIDMap (to be used only for CIDFontType2) to "Identity"
- */
- public void setCIDMapIdentity() {
- this.cidMap = null; // not an error here, simply use the default
- }
-
- /**
- * produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- return toPDFString().getBytes();
- }
-
- public String toPDFString() {
- StringBuffer p = new StringBuffer();
- p.append(this.number);
- p.append(" ");
- p.append(this.generation);
- p.append(" obj\n<< /Type /Font");
- p.append("\n/BaseFont /");
- p.append(this.basefont);
- if (cidMap != null) {
- p.append(" \n/CIDToGIDMap ");
- p.append(cidMap.referencePDF());
- }
- p.append(" \n/Subtype /");
- p.append(this.cidtype);
- p.append("\n");
- p.append(systemInfo.toPDFString());
- p.append("\n/FontDescriptor ");
- p.append(this.descriptor.referencePDF());
-
- if (cmap != null) {
- p.append("\n/ToUnicode ");
- p.append(cmap.referencePDF());
- }
- if (dw != null) {
- p.append("\n/DW ");
- p.append(this.dw);
- }
- if (w != null) {
- p.append("\n/W ");
- p.append(w.toPDFString());
- }
- if (dw2 != null) {
- p.append("\n/DW2 ["); // always two values, see p 211
- p.append(this.dw2[0]);
- p.append(this.dw2[1]);
- p.append("] \n>>\nendobj\n");
- }
- if (w2 != null) {
- p.append("\n/W2 ");
- p.append(w2.toPDFString());
- p.append(" \n>>\nendobj\n");
- }
- p.append(" \n>>\nendobj\n");
- return p.toString();
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// based on work by Takayuki Takeuchi
-
-/**
- * class representing a font descriptor for CID fonts.
- *
- * Font descriptors for CID fonts are specified on page 227 and onwards of the PDF 1.3 spec.
- */
-public class PDFCIDFontDescriptor extends PDFFontDescriptor {
-
- protected String lang;
- protected PDFStream cidSet;
-
- /**
- * create the /FontDescriptor object
- *
- * @param number the object's number
- * @param basefont the base font name
- * @param fontBBox the bounding box for the described font
- * @param flags various characteristics of the font
- * @param capHeight height of the capital letters
- * @param stemV the width of the dominant vertical stems of glyphs
- * @param italicAngle the angle of the vertical dominant strokes
- * @param lang the language
- */
- public PDFCIDFontDescriptor(int number, String basefont, int[] fontBBox,
- int capHeight, int flags, int italicAngle,
- int stemV, String lang) {
-
- super(number, basefont, fontBBox[3], fontBBox[1], capHeight, flags,
- new PDFRectangle(fontBBox), italicAngle, stemV);
-
- this.lang = lang;
- }
-
- public void setCIDSet(PDFStream cidSet) {
- this.cidSet = cidSet;
- }
-
- protected void fillInPDF(StringBuffer p) {
- p.append("\n/MissingWidth 500\n");
- if (lang != null) {
- p.append("\n/Lang /");
- p.append(lang);
- }
- if (cidSet != null) {
- p.append("\n/CIDSet /");
- this.cidSet.referencePDF();
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// based on work by Takayuki Takeuchi
-
-/**
- * class representing system information for "character identifier" fonts.
- *
- * this small object is used in the CID fonts and in the CMaps.
- */
-public class PDFCIDSystemInfo extends PDFObject {
- private static final StringBuffer p = new StringBuffer();
- protected String registry;
- protected String ordering;
- protected int supplement;
-
- public PDFCIDSystemInfo(String registry, String ordering,
- int supplement) {
- this.registry = registry;
- this.ordering = ordering;
- this.supplement = supplement;
- }
-
- /**
- * produce the PDF representation for the object.
- *
- * unlike the other objects, the CIDSystemInfo is written directly inside
- * the referencing object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- return toPDFString().getBytes();
- }
-
- public String toPDFString() {
- p.setLength(0);
- p.append("/CIDSystemInfo << /Registry (");
- p.append(registry);
- p.append(")/Ordering (");
- p.append(ordering);
- p.append(")/Supplement ");
- p.append(supplement);
- p.append(" >>");
- return p.toString();
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing the CMap encodings.
- *
- * CMaps are defined on page 215 and onwards.
- * The predefined CMap names are drawn from Table 7.20
- * on pages 215, 216 and 217 .
- */
-public class PDFCMap extends PDFStream {
-
- /**
- * Chinese (simplified)
- */
- public static final String GB_EUC_H = "GB-EUC-H";
- public static final String GB_EUC_V = "GB_EUC_V";
- public static final String GBpc_EUC_H = "GBpc-EUC-H";
- public static final String GBpc_EUC_V = "GBpc-EUC-V";
- public static final String GBK_EUC_H = "GBK-EUC-H";
- public static final String GBK_EUC_V = "GBK-EUC-V";
- public static final String UniGB_UCS2_H = "UniGB-UCS2-H";
- public static final String UniGB_UCS2_V = "UniGB-UCS2-V";
-
- /**
- * Chinese (traditional)
- */
- public static final String B5pc_H = "B5pc-H";
- public static final String B5pc_V = "B5pc-V";
- public static final String ETen_B5_H = "ETen-B5-H";
- public static final String ETen_B5_V = "ETen-B5-V";
- public static final String ETenms_B5_H = "ETenms-B5-H";
- public static final String ETenms_B5_V = "ETenms-B5-V";
- public static final String CNS_EUC_H = "CNS-EUC-H";
- public static final String CNS_EUC_V = "CNS-EUC-V";
- public static final String UniCNS_UCS2_H = "UniCNS-UCS2-H";
- public static final String UniCNS_UCS2_V = "UniCNS-UCS2-V";
-
- /**
- * Japanese
- */
- public static final String _83pv_RKSJ_H = "83pv-RKSJ-H"; // no V version
- public static final String _90ms_RKSJ_H = "90ms-RKSJ-H";
- public static final String _90ms_RKSJ_V = "90ms-RKSJ-V";
- public static final String _90msp_RKSJ_H = "90msp-RKSJ-H";
- public static final String _90msp_RKSJ_V = "90msp-RKSJ-V";
- public static final String _90pv_RKSJ_H = "90pv-RKSJ-H"; // no V version
- public static final String Add_RKSJ_H = "Add-RKSJ-H";
- public static final String Add_RKSJ_V = "Add-RKSJ-V";
- public static final String EUC_H = "EUC-H";
- public static final String EUC_V = "EUC-V";
- public static final String Ext_RKSJ_H = "Ext-RKSJ-H";
- public static final String Ext_RKSJ_V = "Ext-RKSJ-V";
- public static final String H = "H";
- public static final String V = "V";
- public static final String UniJIS_UCS2_H = "UniJIS-UCS2-H";
- public static final String UniJIS_UCS2_V = "UniJIS-UCS2-V";
- public static final String UniJIS_UCS2_HW_H = "UniJIS-UCS2-HW-H";
- public static final String UniJIS_UCS2_HW_V = "UniJIS-UCS2-HW-V";
-
- /**
- * Korean
- */
- public static final String KSC_EUC_H = "KSC-EUC-H";
- public static final String KSC_EUC_V = "KSC-EUC-V";
- public static final String KSCms_UHC_H = "KSCms-UHC-H";
- public static final String KSCms_UHC_V = "KSCms-UHC-V";
- public static final String KSCms_UHC_HW_H = "KSCms-UHC-HW-H";
- public static final String KSCms_UHC_HW_V = "KSCms-UHC-HW-V";
- public static final String KSCpc_EUC_H = "KSCpc-EUC-H"; // no V version
- public static final String UniKSC_UCS2_H = "UniKSC-UCS2-H";
- public static final String UniKSC_UCS2_V = "UniKSC-UCS2-V";
-
- /**
- * Generic
- */
- public static final String Identity_H = "Identity-H";
- public static final String Identity_V = "Identity-V";
-
- /**
- * /CMapName attribute, one of the predefined constants
- */
- protected String name;
-
- /**
- * /CIDSystemInfo attribute
- */
- protected PDFCIDSystemInfo sysInfo;
-
- /**
- * horizontal writing direction
- */
- public static final byte WMODE_HORIZONTAL = 0;
-
- /**
- * vertical writing direction
- */
- public static final byte WMODE_VERTICAL = 1;
-
- /**
- * font's writing direction
- */
- protected byte wMode = WMODE_HORIZONTAL;
-
- /**
- * base CMap (String or PDFStream)
- */
- protected Object base;
-
- /**
- * create the /CMap object
- *
- * @param name one the registered names (see Table 7.20 on p 215)
- * @param sysInfo the attributes of the character collection of the CIDFont
- */
- public PDFCMap(int number, String name, PDFCIDSystemInfo sysInfo) {
- super(number);
- this.name = name;
- this.sysInfo = sysInfo;
- this.base = null;
- }
-
- /**
- * set the writing direction
- *
- * @param mode is either <code>WMODE_HORIZONTAL</code>
- * or <code>WMODE_VERTICAL</code>
- */
- public void setWMode(byte mode) {
- this.wMode = mode;
- }
-
- public void addContents() {
- StringBuffer p = new StringBuffer();
- fillInPDF(p);
- add(p.toString());
- }
-
- /**
- * set the base CMap
- *
- * @param base the name of the base CMap (see Table 7.20)
- */
- public void setUseCMap(String base) {
- this.base = base;
- }
-
- /**
- * set the base CMap
- *
- * @param base the stream to be used as base CMap
- */
- public void setUseCMap(PDFStream base) {
- this.base = base;
- }
-
- public void fillInPDF(StringBuffer p) {
- // p.append("/Type /CMap\n");
- // p.append(sysInfo.toPDFString());
- // p.append("/CMapName /" + name);
- // p.append("\n");
- p.append("%!PS-Adobe-3.0 Resource-CMap\n");
- p.append("%%DocumentNeededResources: ProcSet (CIDInit)\n");
- p.append("%%IncludeResource: ProcSet (CIDInit)\n");
- p.append("%%BeginResource: CMap (" + name + ")\n");
- p.append("%%EndComments\n");
-
- p.append("/CIDInit /ProcSet findresource begin\n");
- p.append("12 dict begin\n");
- p.append("begincmap\n");
-
- p.append("/CIDSystemInfo 3 dict dup begin\n");
- p.append(" /Registry (Adobe) def\n");
- p.append(" /Ordering (Identity) def\n");
- p.append(" /Supplement 0 def\n");
- p.append("end def\n");
-
- p.append("/CMapVersion 1 def\n");
- p.append("/CMapType 1 def\n");
- p.append("/CMapName /" + name + " def\n");
-
- p.append("1 begincodespacerange\n");
- p.append("<0000> <FFFF>\n");
- p.append("endcodespacerange\n");
- p.append("1 begincidrange\n");
- p.append("<0000> <FFFF> 0\n");
- p.append("endcidrange\n");
-
- // p.append("1 beginbfrange\n");
- // p.append("<0020> <0100> <0000>\n");
- // p.append("endbfrange\n");
-
- p.append("endcmap\n");
- p.append("CMapName currentdict /CMap defineresource pop\n");
- p.append("end\n");
- p.append("end\n");
- p.append("%%EndResource\n");
- p.append("%%EOF\n");
- /*
- * p.append(" /Type /CMap\n/CMapName /" + name);
- * p.append("\n");
- * p.append("\n/WMode "); p.append(wMode);
- * if (base != null) {
- * p.append("\n/UseCMap ");
- * if (base instanceof String) {
- * p.append("/"+base);
- * } else { // base instanceof PDFStream
- * p.append(((PDFStream)base).referencePDF());
- * }
- * }
- */
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import java.util.Hashtable;
-
-/**
- * class representing a /CharProcs dictionary for Type3 fonts.
- *
- * <p><b>CAUTION: this is not yet fully implemented!!!!!!!</b>
- * I miss an exemple of <i>how</i> to output this dictionary.
- * </p>
- *
- * Type3 fonts are specified on page 206 and onwards of the PDF 1.3 spec.
- */
-public class PDFCharProcs extends PDFObject {
-
- /**
- * the (character name, drawing stream) pairs for a Type3 font
- */
- protected Hashtable keys;
-
- public PDFCharProcs() {
- keys = new Hashtable();
- }
-
- /**
- * add a character definition in the dictionary
- *
- * @param name the character name
- * @param stream the stream that draws the character
- */
- public void addCharacter(String name, PDFStream stream) {
- keys.put(name, stream);
- }
-
- /**
- * not done yet
- */
- public byte[] toPDF() {
- // TODO: implement this org.apache.fop.pdf.PDFObject abstract method
- return new byte[0];
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.util.Vector;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-// FOP
-import org.apache.fop.datatypes.ColorType;
-import org.apache.fop.datatypes.ColorSpace;
-
-public class PDFColor extends PDFPathPaint {
- protected static double blackFactor = 2.0; // could be 3.0 as well.
- protected double red = -1.0;
- protected double green = -1.0;
- protected double blue = -1.0;
-
- protected double cyan = -1.0;
- protected double magenta = -1.0;
- protected double yellow = -1.0;
- protected double black = -1.0;
-
- public PDFColor(org.apache.fop.datatypes.ColorType theColor) {
- this.colorSpace = new ColorSpace(ColorSpace.DEVICE_RGB);
- // super(theNumber)
- this.red = (double)theColor.red();
- this.green = (double)theColor.green();
- this.blue = (double)theColor.blue();
-
- }
-
- public PDFColor(double theRed, double theGreen, double theBlue) {
- // super(theNumber);
- this.colorSpace = new ColorSpace(ColorSpace.DEVICE_RGB);
-
- this.red = theRed;
- this.green = theGreen;
- this.blue = theBlue;
- }
-
- // components from 0 to 255
- public PDFColor(int theRed, int theGreen, int theBlue) {
- this(((double)theRed) / 255d, ((double)theGreen) / 255d,
- ((double)theBlue) / 255d);
-
- }
-
- public PDFColor(double theCyan, double theMagenta, double theYellow,
- double theBlack) {
- // super(theNumber);//?
-
- this.colorSpace = new ColorSpace(ColorSpace.DEVICE_CMYK);
-
- this.cyan = theCyan;
- this.magenta = theMagenta;
- this.yellow = theYellow;
- this.black = theBlack;
- }
-
-
- public Vector getVector() { // return a vector representation of the color
- // in the appropriate colorspace.
- Vector theColorVector = new Vector();
- if (this.colorSpace.getColorSpace() == ColorSpace.DEVICE_RGB) { // RGB
- theColorVector.addElement(new Double(this.red));
- theColorVector.addElement(new Double(this.green));
- theColorVector.addElement(new Double(this.blue));
- } else if (this.colorSpace.getColorSpace()
- == ColorSpace.DEVICE_CMYK) { // CMYK
- theColorVector.addElement(new Double(this.cyan));
- theColorVector.addElement(new Double(this.magenta));
- theColorVector.addElement(new Double(this.yellow));
- theColorVector.addElement(new Double(this.black));
- } else { // GRAY
- theColorVector.addElement(new Double(this.black));
- }
- return (theColorVector);
- }
-
- public double red() {
- return (this.red);
- }
-
- public double green() {
- return (this.green);
- }
-
- public double blue() {
- return (this.blue);
- }
-
- public int red255() {
- return (int)(this.red * 255d);
- }
-
- public int green255() {
- return (int)(this.green * 255d);
- }
-
- public int blue255() {
- return (int)(this.blue * 255d);
- }
-
- public double cyan() {
- return (this.cyan);
- }
-
- public double magenta() {
- return (this.magenta);
- }
-
- public double yellow() {
- return (this.yellow);
- }
-
- public double black() {
- return (this.black);
- }
-
- public void setColorSpace(int theColorSpace) {
- int theOldColorSpace = this.colorSpace.getColorSpace();
- if (theOldColorSpace != theColorSpace) {
- if (theOldColorSpace == ColorSpace.DEVICE_RGB) {
- if (theColorSpace == ColorSpace.DEVICE_CMYK) {
- this.convertRGBtoCMYK();
- } else // convert to Gray?
- {
- this.convertRGBtoGRAY();
- }
-
- } else if (theOldColorSpace == ColorSpace.DEVICE_CMYK) {
- if (theColorSpace == ColorSpace.DEVICE_RGB) {
- this.convertCMYKtoRGB();
- } else // convert to Gray?
- {
- this.convertCMYKtoGRAY();
- }
- } else // used to be Gray
- {
- if (theColorSpace == ColorSpace.DEVICE_RGB) {
- this.convertGRAYtoRGB();
- } else // convert to CMYK?
- {
- this.convertGRAYtoCMYK();
- }
- }
- this.colorSpace.setColorSpace(theColorSpace);
- }
- }
-
- public String getColorSpaceOut(boolean fillNotStroke) {
- StringBuffer p = new StringBuffer("");
-
- double tempDouble;
-
- if (this.colorSpace.getColorSpace()
- == ColorSpace.DEVICE_RGB) { // colorspace is RGB
- // according to pdfspec 12.1 p.399
- // if the colors are the same then just use the g or G operator
- boolean same = false;
- if (this.red == this.green && this.red == this.blue) {
- same = true;
- }
- // output RGB
- if (fillNotStroke) { // fill
- if (same) {
- p.append(PDFNumber.doubleOut(this.red) + " g\n");
- } else {
- p.append(PDFNumber.doubleOut(this.red) + " "
- + PDFNumber.doubleOut(this.green) + " "
- + PDFNumber.doubleOut(this.blue) + " "
- + " rg \n");
- }
- } else { // stroke/border
- if (same) {
- p.append(PDFNumber.doubleOut(this.red) + " G\n");
- } else {
- p.append(PDFNumber.doubleOut(this.red) + " "
- + PDFNumber.doubleOut(this.green) + " "
- + PDFNumber.doubleOut(this.blue) + " "
- + " RG \n");
- }
- }
- } // end of output RGB
- else if (this.colorSpace.getColorSpace()
- == ColorSpace.DEVICE_CMYK) { // colorspace is CMYK
-
- if (fillNotStroke) { // fill
- p.append(PDFNumber.doubleOut(this.cyan) + " "
- + PDFNumber.doubleOut(this.magenta) + " "
- + PDFNumber.doubleOut(this.yellow) + " "
- + PDFNumber.doubleOut(this.black) + " k \n");
- } else { // fill
- p.append(PDFNumber.doubleOut(this.cyan) + " "
- + PDFNumber.doubleOut(this.magenta) + " "
- + PDFNumber.doubleOut(this.yellow) + " "
- + PDFNumber.doubleOut(this.black) + " K \n");
- }
-
- } // end of if CMYK
- else { // means we're in DeviceGray or Unknown.
- // assume we're in DeviceGray, because otherwise we're screwed.
-
- if (fillNotStroke) {
- p.append(PDFNumber.doubleOut(this.black) + " g \n");
- } else {
- p.append(PDFNumber.doubleOut(this.black) + " G \n");
- }
-
- }
- return (p.toString());
- }
-
-
-
-
- protected void convertCMYKtoRGB() {
- // convert CMYK to RGB
- this.red = 1.0 - this.cyan;
- this.green = 1.0 - this.green;
- this.blue = 1.0 - this.yellow;
-
- this.red = (this.black / this.blackFactor) + this.red;
- this.green = (this.black / this.blackFactor) + this.green;
- this.blue = (this.black / this.blackFactor) + this.blue;
-
- }
-
- protected void convertRGBtoCMYK() {
- // convert RGB to CMYK
- this.cyan = 1.0 - this.red;
- this.magenta = 1.0 - this.green;
- this.yellow = 1.0 - this.blue;
-
- this.black = 0.0;
- /*
- * If you want to calculate black, uncomment this
- * //pick the lowest color
- * tempDouble = this.red;
- *
- * if (this.green < tempDouble)
- * tempDouble = this.green;
- *
- * if (this.blue < tempDouble)
- * tempDouble = this.blue;
- *
- * this.black = tempDouble / this.blackFactor;
- */
- }
-
- protected void convertGRAYtoRGB() {
- this.red = 1.0 - this.black;
- this.green = 1.0 - this.black;
- this.blue = 1.0 - this.black;
- }
-
- protected void convertGRAYtoCMYK() {
- this.cyan = this.black;
- this.magenta = this.black;
- this.yellow = this.black;
- // this.black=0.0;//?
- }
-
- protected void convertCMYKtoGRAY() {
- double tempDouble = 0.0;
-
- // pick the lowest color
- tempDouble = this.cyan;
-
- if (this.magenta < tempDouble)
- tempDouble = this.magenta;
-
- if (this.yellow < tempDouble)
- tempDouble = this.yellow;
-
- this.black = (tempDouble / this.blackFactor);
-
- }
-
- protected void convertRGBtoGRAY() {
- double tempDouble = 0.0;
-
- // pick the lowest color
- tempDouble = this.red;
-
- if (this.green < tempDouble)
- tempDouble = this.green;
-
- if (this.blue < tempDouble)
- tempDouble = this.blue;
-
- this.black = 1.0 - (tempDouble / this.blackFactor);
-
- }
-
- byte[] toPDF() {
- return (new byte[0]);
-
- } // end of toPDF
-
- public boolean equals(Object obj) {
- if (!(obj instanceof PDFColor)) {
- return false;
- }
- PDFColor color = (PDFColor)obj;
-
- if (color.red == this.red && color.green == this.green
- && color.blue == this.blue) {
- return true;
- }
- return false;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-/* image support modified from work of BoBoGi */
-/* font support based on work by Takayuki Takeuchi */
-
-package org.apache.fop.pdf;
-
-// images are the one place that FOP classes outside this package get
-// referenced and I'd rather not do it
-import org.apache.fop.image.FopImage;
-
-import org.apache.fop.layout.LinkSet;
-import org.apache.fop.datatypes.ColorSpace;
-
-import org.apache.fop.render.pdf.CIDFont;
-import org.apache.fop.render.pdf.fonts.LazyFont;
-
-import org.apache.fop.datatypes.IDReferences;
-import org.apache.fop.layout.Page;
-import org.apache.fop.layout.FontMetric;
-import org.apache.fop.layout.FontDescriptor;
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Vector;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.awt.Rectangle;
-
-/**
- * class representing a PDF document.
- *
- * The document is built up by calling various methods and then finally
- * output to given filehandle using output method.
- *
- * A PDF document consists of a series of numbered objects preceded by a
- * header and followed by an xref table and trailer. The xref table
- * allows for quick access to objects by listing their character
- * positions within the document. For this reason the PDF document must
- * keep track of the character position of each object. The document
- * also keeps direct track of the /Root, /Info and /Resources objects.
- *
- * Modified by Mark Lillywhite, mark-fop@inomial.com. The changes
- * involve: ability to output pages one-at-a-time in a streaming
- * fashion (rather than storing them all for output at the end);
- * ability to write the /Pages object after writing the rest
- * of the document; ability to write to a stream and flush
- * the object list; enhanced trailer output; cleanups.
- */
-public class PDFDocument {
- private static final Integer locationPlaceholder = new Integer(0);
- /**
- * the version of PDF supported
- */
- protected static final String pdfVersion = "1.3";
-
- /**
- * the current character position
- */
- protected int position = 0;
-
- /**
- * the character position of each object
- */
- protected Vector location = new Vector();
-
- /** List of objects to write in the trailer */
- private Vector trailerObjects = new Vector();
-
- /**
- * the counter for object numbering
- */
- protected int objectcount = 0;
-
- /**
- * the objects themselves
- */
- protected Vector objects = new Vector();
-
- /**
- * character position of xref table
- */
- protected int xref;
-
- /**
- * the /Root object
- */
- protected PDFRoot root;
-
- /** The root outline object */
- private PDFOutline outlineRoot = null;
-
- /** The /Pages object (mark-fop@inomial.com) */
- private PDFPages pages;
-
- /**
- * the /Info object
- */
- protected PDFInfo info;
-
- /**
- * the /Resources object
- */
- protected PDFResources resources;
-
- /**
- * the documents idReferences
- */
- protected IDReferences idReferences;
-
- /**
- * the colorspace (0=RGB, 1=CMYK)
- */
- // protected int colorspace = 0;
- protected ColorSpace colorspace = new ColorSpace(ColorSpace.DEVICE_RGB);
-
- /**
- * the counter for Pattern name numbering (e.g. 'Pattern1')
- */
- protected int patternCount = 0;
-
- /**
- * the counter for Shading name numbering
- */
- protected int shadingCount = 0;
-
- /**
- * the counter for XObject numbering
- */
- protected int xObjectCount = 0;
-
- /**
- * the XObjects
- */
- protected Vector xObjects = new Vector();
-
- /**
- * the XObjects Map.
- * Should be modified (works only for image subtype)
- */
- protected Hashtable xObjectsMap = new Hashtable();
-
- /**
- * creates an empty PDF document <p>
- *
- * The constructor creates a /Root and /Pages object to
- * track the document but does not write these objects until
- * the trailer is written. Note that the object ID of the
- * pages object is determined now, and the xref table is
- * updated later. This allows Pages to refer to their
- * Parent before we write it out. This took me a long
- * time to work out, and is so obvious now. Sigh.
- * mark-fop@inomial.com. Maybe I should do a PDF course.
- */
- public PDFDocument() {
-
- /* create the /Root, /Info and /Resources objects */
- this.pages = makePages();
-
- // Create the Root object
- this.root = makeRoot(pages);
-
- // Create the Resources object
- this.resources = makeResources();
-
- // Make the /Info record
- this.info = makeInfo();
- }
-
- /**
- * set the producer of the document
- *
- * @param producer string indicating application producing the PDF
- */
- public void setProducer(String producer) {
- this.info.setProducer(producer);
- }
-
- /**
- * Make a /Catalog (Root) object. This object is written in
- * the trailer.
- */
- public PDFRoot makeRoot(PDFPages pages) {
-
- /*
- * Make a /Pages object. This object is written in the trailer.
- */
- PDFRoot pdfRoot = new PDFRoot(++this.objectcount, pages);
- addTrailerObject(pdfRoot);
- return pdfRoot;
- }
-
- /**
- * Make a /Pages object. This object is written in the trailer.
- */
-
- public PDFPages makePages() {
- PDFPages pdfPages = new PDFPages(++this.objectcount);
- addTrailerObject(pdfPages);
- return pdfPages;
- }
-
- /**
- * Make a /Resources object. This object is written in the trailer.
- */
- public PDFResources makeResources() {
- PDFResources pdfResources = new PDFResources(++this.objectcount);
- addTrailerObject(pdfResources);
- return pdfResources;
- }
-
- /**
- * make an /Info object
- *
- * @param producer string indicating application producing the PDF
- * @return the created /Info object
- */
- protected PDFInfo makeInfo() {
-
- /*
- * create a PDFInfo with the next object number and add to
- * list of objects
- */
- PDFInfo pdfInfo = new PDFInfo(++this.objectcount);
- // set the default producer
- pdfInfo.setProducer(org.apache.fop.apps.Version.getVersion());
- this.objects.addElement(pdfInfo);
- return pdfInfo;
- }
-
- /**
- * Make a Type 0 sampled function
- *
- * @param theDomain Vector objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theSize A Vector object of Integer objects.
- * This is the number of samples in each input dimension.
- * I can't imagine there being more or less than two input dimensions,
- * so maybe this should be an array of length 2.
- *
- * See page 265 of the PDF 1.3 Spec.
- * @param theBitsPerSample An int specifying the number of bits user to represent each sample value.
- * Limited to 1,2,4,8,12,16,24 or 32.
- * See page 265 of the 1.3 PDF Spec.
- * @param theOrder The order of interpolation between samples. Default is 1 (one). Limited
- * to 1 (one) or 3, which means linear or cubic-spline interpolation.
- *
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theEncode Vector objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theDecode Vector objects of Double objects.
- * This is a linear mapping of sample values into the range.
- * The default is just the range.
- *
- * This attribute is optional.
- * Read about it on page 265 of the PDF 1.3 spec.
- * @param theFunctionDataStream The sample values that specify the function are provided in a stream.
- *
- * This is optional, but is almost always used.
- *
- * Page 265 of the PDF 1.3 spec has more.
- * @param theFilter This is a vector of String objects which are the various filters that
- * have are to be applied to the stream to make sense of it. Order matters,
- * so watch out.
- *
- * This is not documented in the Function section of the PDF 1.3 spec,
- * it was deduced from samples that this is sometimes used, even if we may never
- * use it in FOP. It is added for completeness sake.
- * @param theNumber The object number of this PDF object.
- * @param theFunctionType This is the type of function (0,2,3, or 4).
- * It should be 0 as this is the constructor for sampled functions.
- */
- public PDFFunction makeFunction(int theFunctionType, Vector theDomain,
- Vector theRange, Vector theSize,
- int theBitsPerSample, int theOrder,
- Vector theEncode, Vector theDecode,
- StringBuffer theFunctionDataStream,
- Vector theFilter) { // Type 0 function
- PDFFunction function = new PDFFunction(++this.objectcount,
- theFunctionType, theDomain,
- theRange, theSize,
- theBitsPerSample, theOrder,
- theEncode, theDecode,
- theFunctionDataStream,
- theFilter);
-
- this.objects.addElement(function);
- return (function);
- }
-
- /**
- * make a type Exponential interpolation function
- * (for shading usually)
- *
- * @param theDomain Vector objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector of Doubles that is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theCZero This is a vector of Double objects which defines the function result
- * when x=0.
- *
- * This attribute is optional.
- * It's described on page 268 of the PDF 1.3 spec.
- * @param theCOne This is a vector of Double objects which defines the function result
- * when x=1.
- *
- * This attribute is optional.
- * It's described on page 268 of the PDF 1.3 spec.
- * @param theInterpolationExponentN This is the inerpolation exponent.
- *
- * This attribute is required.
- * PDF Spec page 268
- * @param theFunctionType The type of the function, which should be 2.
- */
- public PDFFunction makeFunction(int theFunctionType, Vector theDomain,
- Vector theRange, Vector theCZero,
- Vector theCOne,
- double theInterpolationExponentN) { // type 2
- PDFFunction function = new PDFFunction(++this.objectcount,
- theFunctionType, theDomain,
- theRange, theCZero, theCOne,
- theInterpolationExponentN);
-
- this.objects.addElement(function);
- return (function);
- }
-
- /**
- * Make a Type 3 Stitching function
- *
- * @param theDomain Vector objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theFunctions A Vector of the PDFFunction objects that the stitching function stitches.
- *
- * This attributed is required.
- * It is described on page 269 of the PDF spec.
- * @param theBounds This is a vector of Doubles representing the numbers that,
- * in conjunction with Domain define the intervals to which each function from
- * the 'functions' object applies. It must be in order of increasing magnitude,
- * and each must be within Domain.
- *
- * It basically sets how much of the gradient each function handles.
- *
- * This attributed is required.
- * It's described on page 269 of the PDF 1.3 spec.
- * @param theEncode Vector objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is required.
- *
- * See page 270 in the PDF 1.3 spec.
- * @param theFunctionType This is the function type. It should be 3,
- * for a stitching function.
- */
- public PDFFunction makeFunction(int theFunctionType, Vector theDomain,
- Vector theRange, Vector theFunctions,
- Vector theBounds,
- Vector theEncode) { // Type 3
-
- PDFFunction function = new PDFFunction(++this.objectcount,
- theFunctionType, theDomain,
- theRange, theFunctions,
- theBounds, theEncode);
-
- this.objects.addElement(function);
- return (function);
- }
-
- /**
- * make a postscript calculator function
- *
- * @param theNumber
- * @param theFunctionType
- * @param theDomain
- * @param theRange
- * @param theFunctionDataStream
- */
- public PDFFunction makeFunction(int theNumber, int theFunctionType,
- Vector theDomain, Vector theRange,
- StringBuffer theFunctionDataStream) { // Type 4
- PDFFunction function = new PDFFunction(++this.objectcount,
- theFunctionType, theDomain,
- theRange,
- theFunctionDataStream);
-
- this.objects.addElement(function);
- return (function);
-
- }
-
- /**
- * make a function based shading object
- *
- * @param theShadingType The type of shading object, which should be 1 for function
- * based shading.
- * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
- * @param theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Whether or not to anti-alias.
- * @param theDomain Optional vector of Doubles specifying the domain.
- * @param theMatrix Vector of Doubles specifying the matrix.
- * If it's a pattern, then the matrix maps it to pattern space.
- * If it's a shading, then it maps it to current user space.
- * It's optional, the default is the identity matrix
- * @param theFunction The PDF Function that maps an (x,y) location to a color
- */
- public PDFShading makeShading(int theShadingType,
- ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias, Vector theDomain,
- Vector theMatrix,
- PDFFunction theFunction) { // make Shading of Type 1
- String theShadingName = new String("Sh" + (++this.shadingCount));
-
- PDFShading shading = new PDFShading(++this.objectcount,
- theShadingName, theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias, theDomain,
- theMatrix, theFunction);
- this.objects.addElement(shading);
-
- // add this shading to resources
- this.resources.addShading(shading);
-
- return (shading);
- }
-
- /**
- * Make an axial or radial shading object.
- *
- * @param theShadingType 2 or 3 for axial or radial shading
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theCoords Vector of four (type 2) or 6 (type 3) Double
- * @param theDomain Vector of Doubles specifying the domain
- * @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function
- * @param theExtend Vector of Booleans of whether to extend teh start and end colors past the start and end points
- * The default is [false, false]
- */
- public PDFShading makeShading(int theShadingType,
- ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias, Vector theCoords,
- Vector theDomain, PDFFunction theFunction,
- Vector theExtend) { // make Shading of Type 2 or 3
- String theShadingName = new String("Sh" + (++this.shadingCount));
-
- PDFShading shading = new PDFShading(++this.objectcount,
- theShadingName, theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias, theCoords,
- theDomain, theFunction,
- theExtend);
-
- this.resources.addShading(shading);
-
- this.objects.addElement(shading);
- return (shading);
- }
-
- /**
- * Make a free-form gouraud shaded triangle mesh, coons patch mesh, or tensor patch mesh
- * shading object
- *
- * @param theShadingType 4, 6, or 7 depending on whether it's
- * Free-form gouraud-shaded triangle meshes, coons patch meshes,
- * or tensor product patch meshes, respectively.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32.
- * @param theBitsPerComponent 1,2,4,8,12, and 16
- * @param theBitsPerFlag 2,4,8.
- * @param theDecode Vector of Doubles see PDF 1.3 spec pages 303 to 312.
- * @param theFunction the PDFFunction
- */
- public PDFShading makeShading(int theShadingType,
- ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent,
- int theBitsPerFlag, Vector theDecode,
- PDFFunction theFunction) { // make Shading of type 4,6 or 7
- String theShadingName = new String("Sh" + (++this.shadingCount));
-
- PDFShading shading = new PDFShading(++this.objectcount,
- theShadingName, theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias,
- theBitsPerCoordinate,
- theBitsPerComponent,
- theBitsPerFlag, theDecode,
- theFunction);
-
- this.resources.addShading(shading);
-
- this.objects.addElement(shading);
- return (shading);
- }
-
- /**
- * make a Lattice-Form Gouraud mesh shading object
- *
- * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
- * without spaces. "Shading1" or "Sh1" are good examples.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32
- * @param theBitsPerComponent 1,2,4,8,12,24,32
- * @param theDecode Vector of Doubles. See page 305 in PDF 1.3 spec.
- * @param theVerticesPerRow number of vertices in each "row" of the lattice.
- * @param theFunction The PDFFunction that's mapped on to this shape
- */
- public PDFShading makeShading(int theShadingType,
- ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent, Vector theDecode,
- int theVerticesPerRow,
- PDFFunction theFunction) { // make shading of Type 5
- String theShadingName = new String("Sh" + (++this.shadingCount));
-
- PDFShading shading = new PDFShading(++this.objectcount,
- theShadingName, theShadingType,
- theColorSpace, theBackground,
- theBBox, theAntiAlias,
- theBitsPerCoordinate,
- theBitsPerComponent, theDecode,
- theVerticesPerRow, theFunction);
-
- this.resources.addShading(shading);
-
- this.objects.addElement(shading);
-
- return (shading);
- }
-
- /**
- * Make a tiling pattern
- *
- * @param thePatternType the type of pattern, which is 1 for tiling.
- * @param theResources the resources associated with this pattern
- * @param thePaintType 1 or 2, colored or uncolored.
- * @param theTilingType 1, 2, or 3, constant spacing, no distortion, or faster tiling
- * @param theBBox Vector of Doubles: The pattern cell bounding box
- * @param theXStep horizontal spacing
- * @param theYStep vertical spacing
- * @param theMatrix Optional Vector of Doubles transformation matrix
- * @param theXUID Optional vector of Integers that uniquely identify the pattern
- * @param thePatternDataStream The stream of pattern data to be tiled.
- */
- public PDFPattern makePattern(int thePatternType, // 1
- PDFResources theResources, int thePaintType, int theTilingType,
- Vector theBBox, double theXStep, double theYStep, Vector theMatrix,
- Vector theXUID, StringBuffer thePatternDataStream) {
- String thePatternName = new String("Pa" + (++this.patternCount));
- // int theNumber, String thePatternName,
- // PDFResources theResources
- PDFPattern pattern = new PDFPattern(++this.objectcount,
- thePatternName, theResources, 1,
- thePaintType, theTilingType,
- theBBox, theXStep, theYStep,
- theMatrix, theXUID,
- thePatternDataStream);
-
- this.resources.addPattern(pattern);
- this.objects.addElement(pattern);
-
- return (pattern);
- }
-
- /**
- * Make a smooth shading pattern
- *
- * @param thePatternType the type of the pattern, which is 2, smooth shading
- * @param theShading the PDF Shading object that comprises this pattern
- * @param theXUID optional:the extended unique Identifier if used.
- * @param theExtGState optional: the extended graphics state, if used.
- * @param theMatrix Optional:Vector of Doubles that specify the matrix.
- */
- public PDFPattern makePattern(int thePatternType, PDFShading theShading,
- Vector theXUID, StringBuffer theExtGState,
- Vector theMatrix) {
- String thePatternName = new String("Pa" + (++this.patternCount));
-
- PDFPattern pattern = new PDFPattern(++this.objectcount,
- thePatternName, 2, theShading,
- theXUID, theExtGState, theMatrix);
-
- this.resources.addPattern(pattern);
- this.objects.addElement(pattern);
-
- return (pattern);
- }
-
- public int getColorSpace() {
- return (this.colorspace.getColorSpace());
- }
-
- public void setColorSpace(int theColorspace) {
- this.colorspace.setColorSpace(theColorspace);
- return;
- }
-
- public PDFPattern createGradient(boolean radial,
- ColorSpace theColorspace,
- Vector theColors, Vector theBounds,
- Vector theCoords) {
- PDFShading myShad;
- PDFFunction myfunky;
- PDFFunction myfunc;
- Vector theCzero;
- Vector theCone;
- PDFPattern myPattern;
- ColorSpace theColorSpace;
- double interpolation = (double)1.000;
- Vector theFunctions = new Vector();
-
- int currentPosition;
- int lastPosition = theColors.size() - 1;
-
-
- // if 5 elements, the penultimate element is 3.
- // do not go beyond that, because you always need
- // to have a next color when creating the function.
-
- for (currentPosition = 0; currentPosition < lastPosition;
- currentPosition++) { // for every consecutive color pair
- PDFColor currentColor =
- (PDFColor)theColors.elementAt(currentPosition);
- PDFColor nextColor = (PDFColor)theColors.elementAt(currentPosition
- + 1);
- // colorspace must be consistant
- if (this.colorspace.getColorSpace()
- != currentColor.getColorSpace())
- currentColor.setColorSpace(this.colorspace.getColorSpace());
-
- if (this.colorspace.getColorSpace() != nextColor.getColorSpace())
- nextColor.setColorSpace(this.colorspace.getColorSpace());
-
- theCzero = currentColor.getVector();
- theCone = nextColor.getVector();
-
- myfunc = this.makeFunction(2, null, null, theCzero, theCone,
- interpolation);
-
- theFunctions.addElement(myfunc);
-
- } // end of for every consecutive color pair
-
- myfunky = this.makeFunction(3, null, null, theFunctions, theBounds,
- null);
-
- if (radial) {
- if (theCoords.size() == 6) {
- myShad = this.makeShading(3, this.colorspace, null, null,
- false, theCoords, null, myfunky,
- null);
- } else { // if the center x, center y, and radius specifiy
- // the gradient, then assume the same center x, center y,
- // and radius of zero for the other necessary component
- Vector newCoords = new Vector();
- newCoords.addElement(theCoords.elementAt(0));
- newCoords.addElement(theCoords.elementAt(1));
- newCoords.addElement(theCoords.elementAt(2));
- newCoords.addElement(theCoords.elementAt(0));
- newCoords.addElement(theCoords.elementAt(1));
- newCoords.addElement(new Double(0.0));
-
- myShad = this.makeShading(3, this.colorspace, null, null,
- false, newCoords, null, myfunky,
- null);
-
- }
- } else {
- myShad = this.makeShading(2, this.colorspace, null, null, false,
- theCoords, null, myfunky, null);
-
- }
-
- myPattern = this.makePattern(2, myShad, null, null, null);
-
- return (myPattern);
- }
-
-
- /**
- * make a /Encoding object
- *
- * @param encodingName character encoding scheme name
- * @return the created /Encoding object
- */
- public PDFEncoding makeEncoding(String encodingName) {
-
- /*
- * create a PDFEncoding with the next object number and add to the
- * list of objects
- */
- PDFEncoding encoding = new PDFEncoding(++this.objectcount,
- encodingName);
- this.objects.addElement(encoding);
- return encoding;
- }
-
-
- /**
- * make a Type1 /Font object
- *
- * @param fontname internal name to use for this font (eg "F1")
- * @param basefont name of the base font (eg "Helvetica")
- * @param encoding character encoding scheme used by the font
- * @param metrics additional information about the font
- * @param descriptor additional information about the font
- * @return the created /Font object
- */
- public PDFFont makeFont(String fontname, String basefont,
- String encoding, FontMetric metrics,
- FontDescriptor descriptor) {
-
- /*
- * create a PDFFont with the next object number and add to the
- * list of objects
- */
- if (descriptor == null) {
- PDFFont font = new PDFFont(++this.objectcount, fontname,
- PDFFont.TYPE1, basefont, encoding);
- this.objects.addElement(font);
- return font;
- } else {
- byte subtype = PDFFont.TYPE1;
- if (metrics instanceof org.apache.fop.render.pdf.Font)
- subtype =
- ((org.apache.fop.render.pdf.Font)metrics).getSubType();
-
- PDFFontDescriptor pdfdesc = makeFontDescriptor(descriptor,
- subtype);
-
- PDFFontNonBase14 font = null;
- if (subtype == PDFFont.TYPE0) {
- /*
- * Temporary commented out - customized CMaps
- * isn't needed until /ToUnicode support is added
- * PDFCMap cmap = new PDFCMap(++this.objectcount,
- * "fop-ucs-H",
- * new PDFCIDSystemInfo("Adobe",
- * "Identity",
- * 0));
- * cmap.addContents();
- * this.objects.addElement(cmap);
- */
- font =
- (PDFFontNonBase14)PDFFont.createFont(++this.objectcount,
- fontname, subtype,
- basefont,
- "Identity-H");
- } else {
-
- font =
- (PDFFontNonBase14)PDFFont.createFont(++this.objectcount,
- fontname, subtype,
- basefont, encoding);
- }
- this.objects.addElement(font);
-
- font.setDescriptor(pdfdesc);
-
- if (subtype == PDFFont.TYPE0) {
- CIDFont cidMetrics;
- if(metrics instanceof LazyFont){
- cidMetrics = (CIDFont) ((LazyFont) metrics).getRealFont();
- }else{
- cidMetrics = (CIDFont)metrics;
- }
- PDFCIDSystemInfo sysInfo =
- new PDFCIDSystemInfo(cidMetrics.getRegistry(),
- cidMetrics.getOrdering(),
- cidMetrics.getSupplement());
- PDFCIDFont cidFont =
- new PDFCIDFont(++this.objectcount, basefont,
- cidMetrics.getCidType(),
- cidMetrics.getDefaultWidth(),
- cidMetrics.getWidths(), sysInfo,
- (PDFCIDFontDescriptor)pdfdesc);
- this.objects.addElement(cidFont);
-
- // ((PDFFontType0)font).setCMAP(cmap);
-
- ((PDFFontType0)font).setDescendantFonts(cidFont);
- } else {
- font.setWidthMetrics(metrics.getFirstChar(),
- metrics.getLastChar(),
- makeArray(metrics.getWidths(1)));
- }
-
- return font;
- }
- }
-
-
- /**
- * make a /FontDescriptor object
- */
- public PDFFontDescriptor makeFontDescriptor(FontDescriptor desc,
- byte subtype) {
- PDFFontDescriptor font = null;
-
- if (subtype == PDFFont.TYPE0) {
- // CID Font
- font = new PDFCIDFontDescriptor(++this.objectcount,
- desc.fontName(),
- desc.getFontBBox(),
- // desc.getAscender(),
- // desc.getDescender(),
- desc.getCapHeight(), desc.getFlags(),
- // new PDFRectangle(desc.getFontBBox()),
- desc.getItalicAngle(), desc.getStemV(), null); // desc.getLang(),
- // null);//desc.getPanose());
- }
- else {
- // Create normal FontDescriptor
- font = new PDFFontDescriptor(++this.objectcount, desc.fontName(),
- desc.getAscender(),
- desc.getDescender(),
- desc.getCapHeight(),
- desc.getFlags(),
- new PDFRectangle(desc.getFontBBox()),
- desc.getStemV(),
- desc.getItalicAngle());
- }
- this.objects.addElement(font);
-
- // Check if the font is embeddable
- if (desc.isEmbeddable()) {
- PDFStream stream = desc.getFontFile(this.objectcount + 1);
- if (stream != null) {
- this.objectcount++;
- font.setFontFile(desc.getSubType(), stream);
- this.objects.addElement(stream);
- }
- }
- return font;
- }
-
-
- /**
- * make an Array object (ex. Widths array for a font)
- */
- public PDFArray makeArray(int[] values) {
-
- PDFArray array = new PDFArray(++this.objectcount, values);
- this.objects.addElement(array);
- return array;
- }
-
-
- public int addImage(FopImage img) {
- // check if already created
- String url = img.getURL();
- PDFXObject xObject = (PDFXObject)this.xObjectsMap.get(url);
- if (xObject != null)
- return xObject.getXNumber();
- // else, create a new one
- xObject = new PDFXObject(++this.objectcount, ++this.xObjectCount,
- img);
- this.objects.addElement(xObject);
- this.xObjects.addElement(xObject);
- this.xObjectsMap.put(url, xObject);
- return xObjectCount;
- }
-
- /**
- * make a /Page object
- *
- * @param resources resources object to use
- * @param contents stream object with content
- * @param pagewidth width of the page in points
- * @param pageheight height of the page in points
- *
- * @return the created /Page object
- */
- public PDFPage makePage(PDFResources resources, PDFStream contents,
- int pagewidth, int pageheight, Page currentPage) {
-
- /*
- * create a PDFPage with the next object number, the given
- * resources, contents and dimensions
- */
- PDFPage page = new PDFPage(++this.objectcount, resources, contents,
- pagewidth, pageheight);
-
- if (currentPage != null) {
- Enumeration enum = currentPage.getIDList().elements();
- while (enum.hasMoreElements()) {
- String id = enum.nextElement().toString();
- idReferences.setInternalGoToPageReference(id,
- page.referencePDF());
- }
- }
-
- /* add it to the list of objects */
- this.objects.addElement(page);
-
- /* add the page to the Root */
- this.root.addPage(page);
-
- return page;
- }
-
- /**
- * make a link object
- *
- * @param rect the clickable rectangle
- * @param destination the destination file
- * @param linkType the link type
- * @return the PDFLink object created
- */
- public PDFLink makeLink(Rectangle rect, String destination,
- int linkType) {
-
- PDFLink linkObject;
- PDFAction action;
-
- PDFLink link = new PDFLink(++this.objectcount, rect);
- this.objects.addElement(link);
-
- if (linkType == LinkSet.EXTERNAL) {
- // check destination
- if (destination.endsWith(".pdf")) { // FileSpec
- PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount,
- destination);
- this.objects.addElement(fileSpec);
- action = new PDFGoToRemote(++this.objectcount, fileSpec);
- this.objects.addElement(action);
- link.setAction(action);
- } else { // URI
- PDFUri uri = new PDFUri(destination);
- link.setAction(uri);
- }
- } else { // linkType is internal
- String goToReference = getGoToReference(destination);
- PDFInternalLink internalLink = new PDFInternalLink(goToReference);
- link.setAction(internalLink);
- }
- return link;
- }
-
- private String getGoToReference(String destination) {
- String goToReference;
- if (idReferences.doesIDExist(destination)) {
- if (idReferences.doesGoToReferenceExist(destination)) {
- goToReference =
- idReferences.getInternalLinkGoToReference(destination);
- } else { // assign Internal Link GoTo object
- goToReference =
- idReferences.createInternalLinkGoTo(destination,
- ++this.objectcount);
- addTrailerObject(idReferences.getPDFGoTo(destination));
- }
- } else { // id was not found, so create it
- idReferences.createNewId(destination);
- idReferences.addToIdValidationList(destination);
- goToReference = idReferences.createInternalLinkGoTo(destination,
- ++this.objectcount);
- addTrailerObject(idReferences.getPDFGoTo(destination));
- }
- return goToReference;
- }
-
- public void addTrailerObject(PDFObject object) {
- this.trailerObjects.addElement(object);
- }
-
- /**
- Ensure there is room in the locations xref for the number of
- objects that have been created.
- */
- private void prepareLocations() {
- while(location.size() < objectcount)
- location.addElement(locationPlaceholder);
- }
-
- /**
- * make a stream object
- *
- * @return the stream object created
- */
- public PDFStream makeStream() {
-
- /*
- * create a PDFStream with the next object number and add it
- *
- * to the list of objects
- */
- PDFStream obj = new PDFStream(++this.objectcount);
- obj.addDefaultFilters();
-
- this.objects.addElement(obj);
- return obj;
- }
-
-
- /**
- * make an annotation list object
- *
- * @return the annotation list object created
- */
- public PDFAnnotList makeAnnotList() {
-
- /*
- * create a PDFAnnotList with the next object number and add it
- * to the list of objects
- */
- PDFAnnotList obj = new PDFAnnotList(++this.objectcount);
- this.objects.addElement(obj);
- return obj;
- }
-
- /**
- * Get the root Outlines object. This method does not write
- * the outline to the PDF document, it simply creates a
- * reference for later.
- */
- public PDFOutline getOutlineRoot() {
- if(outlineRoot != null)
- return outlineRoot;
-
- outlineRoot = new PDFOutline(++this.objectcount, null, null);
- addTrailerObject(outlineRoot);
- root.setRootOutline(outlineRoot);
- return outlineRoot;
- }
-
- /**
- * Make an outline object and add it to the given outline
- * @param parent parent PDFOutline object
- * @param label the title for the new outline object
- * @param action the PDFAction to reference
- */
- public PDFOutline makeOutline(PDFOutline parent, String label,
- String destination) {
- String goToRef = getGoToReference(destination);
-
- PDFOutline obj = new PDFOutline(++this.objectcount, label, goToRef);
- System.out.println("created new outline object");
-
- if (parent != null) {
- parent.addOutline(obj);
- }
- this.objects.addElement(obj);
- return obj;
-
- }
-
- /**
- * get the /Resources object for the document
- *
- * @return the /Resources object
- */
- public PDFResources getResources() {
- return this.resources;
- }
-
- /**
- * write the entire document out
- *
- * @param writer the OutputStream to output the document to
- */
- public void output(OutputStream stream) throws IOException {
-
- prepareLocations();
-
- Enumeration en = this.objects.elements();
- while (en.hasMoreElements()) {
- /* retrieve the object with the current number */
- PDFObject object = (PDFObject)en.nextElement();
-
- /*
- * add the position of this object to the list of object
- * locations
- */
- location.setElementAt(
- new Integer(this.position),object.getNumber() - 1);
-
- /*
- * output the object and increment the character position
- * by the object's length
- */
- this.position += object.output(stream);
- }
-
- this.objects.clear();
- }
-
- /**
- * write the PDF header <P>
- *
- * This method must be called prior to formatting
- * and outputting AreaTrees.
- *
- * @param stream the OutputStream to write the header to
- * @return the number of bytes written
- */
- public void outputHeader(OutputStream stream)
- throws IOException {
- this.position=0;
-
- byte[] pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes();
- stream.write(pdf);
- this.position += pdf.length;
-
- // output a binary comment as recommended by the PDF spec (3.4.1)
- byte[] bin = {
- (byte)'%', (byte)0xAA, (byte)0xAB, (byte)0xAC, (byte)0xAD,
- (byte)'\n'
- };
- stream.write(bin);
- this.position += bin.length;
-
- this.resources.setXObjects(xObjects);
- }
-
- /**
- * write the trailer
- *
- * @param stream the OutputStream to write the trailer to
- */
- public void outputTrailer(OutputStream stream)
- throws IOException {
- output(stream);
- Enumeration e = trailerObjects.elements();
- while(e.hasMoreElements()) {
- PDFObject o = (PDFObject) e.nextElement();
- this.location.setElementAt(
- new Integer(this.position), o.getNumber() - 1);
- this.position += o.output(stream);
- }
- /* output the xref table and increment the character position
- by the table's length */
- this.position += outputXref(stream);
-
- /* construct the trailer */
- String pdf =
- "trailer\n" +
- "<<\n" +
- "/Size " + (this.objectcount + 1) + "\n" +
- "/Root " + this.root.number + " " + this.root.generation + " R\n" +
- "/Info " + this.info.number + " " + this.info.generation + " R\n" +
- ">>\n" +
- "startxref\n" +
- this.xref + "\n" +
- "%%EOF\n";
-
- /* write the trailer */
- stream.write(pdf.getBytes());
- }
-
- /**
- * write the xref table
- *
- * @param stream the OutputStream to write the xref table to
- * @return the number of characters written
- */
- private int outputXref(OutputStream stream) throws IOException {
-
- /* remember position of xref table */
- this.xref = this.position;
-
- /* construct initial part of xref */
- StringBuffer pdf = new StringBuffer("xref\n0 "
- + (this.objectcount + 1)
- + "\n0000000000 65535 f \n");
-
- Enumeration en = this.location.elements();
- while (en.hasMoreElements()) {
- String x = en.nextElement().toString();
-
- /* contruct xref entry for object */
- String padding = "0000000000";
- String loc = padding.substring(x.length()) + x;
-
- /* append to xref table */
- pdf = pdf.append(loc + " 00000 n \n");
- }
-
- /* write the xref table and return the character length */
- byte[] pdfBytes = pdf.toString().getBytes();
- stream.write(pdfBytes);
- return pdfBytes.length;
- }
-
- public void setIDReferences(IDReferences idReferences) {
- this.idReferences = idReferences;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * class representing an /Encoding object.
- *
- * A small object expressing the base encoding name and
- * the differences from the base encoding.
- *
- * The three base encodings are given by their name.
- *
- * Encodings are specified on page 213 and onwards of the PDF 1.3 spec.
- */
-public class PDFEncoding extends PDFObject {
-
- /**
- * the name for the standard encoding scheme
- */
- public static final String MacRomanEncoding = "MacRomanEncoding";
-
- /**
- * the name for the standard encoding scheme
- */
- public static final String MacExpertEncoding = "MacExpertEncoding";
-
- /**
- * the name for the standard encoding scheme
- */
- public static final String WinAnsiEncoding = "WinAnsiEncoding";
-
- /**
- * the name for the base encoding.
- * One of the three base encoding scheme names or
- * the default font's base encoding if null.
- */
- protected String basename;
-
- /**
- * the differences from the base encoding
- */
- protected Hashtable differences;
-
- /**
- * create the /Encoding object
- *
- * @param number the object's number
- * @param basename the name of the character encoding schema
- */
- public PDFEncoding(int number, String basename) {
-
- /* generic creation of PDF object */
- super(number);
-
- /* set fields using paramaters */
- this.basename = basename;
- this.differences = new Hashtable();
- }
-
- /**
- * add differences to the encoding
- *
- * @param code the first index of the sequence to be changed
- * @param sequence the sequence of glyph names (as String)
- */
- public void addDifferences(int code, Vector sequence) {
- differences.put(new Integer(code), sequence);
- }
-
- /**
- * produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation
- + " obj\n<< /Type /Encoding");
- if ((basename != null) && (!basename.equals(""))) {
- p.append("\n/BaseEncoding /" + this.basename);
- }
- if (!differences.isEmpty()) {
- p.append("\n/Differences [ ");
- Object code;
- Enumeration codes = differences.keys();
- while (codes.hasMoreElements()) {
- code = codes.nextElement();
- p.append(" ");
- p.append(code);
- Vector sequence = (Vector)differences.get(code);
- for (int i = 0; i < sequence.size(); i++) {
- p.append(" /");
- p.append((String)sequence.elementAt(i));
- }
- }
- p.append(" ]");
- }
- p.append(" >>\nendobj\n");
- return p.toString().getBytes();
- }
-
- /*
- * example (p. 214)
- * 25 0 obj
- * <<
- * /Type /Encoding
- * /Differences [39 /quotesingle 96 /grave 128
- * /Adieresis /Aring /Ccedilla /Eacute /Ntilde
- * /Odieresis /Udieresis /aacute /agrave]
- * >>
- * endobj
- */
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a /FileSpec object.
- *
- */
-public class PDFFileSpec extends PDFObject {
-
- /**
- * the filename
- */
- protected String filename;
-
- /**
- * create a /FileSpec object.
- *
- * @param number the object's number
- * @param filename the filename represented by this object
- */
- public PDFFileSpec(int number, String filename) {
-
- /* generic creation of object */
- super(number);
-
- this.filename = filename;
- }
-
- /**
- * represent the object in PDF
- *
- * @return the PDF string
- */
- public byte[] toPDF() {
- String p = new String(this.number + " " + this.generation
- + " obj\n<<\n/Type /FileSpec\n" + "/F ("
- + this.filename + ")\n" + ">>\nendobj\n");
- return p.getBytes();
- }
-
- /*
- * example
- * 29 0 obj
- * <<
- * /Type /FileSpec
- * /F (table1.pdf)
- * >>
- * endobj
- */
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-
-// Author: Eric SCHAEFFER, Kelly A. Campbell
-// Description: represent a PDF filter object
-
-package org.apache.fop.pdf;
-
-public abstract class PDFFilter {
- /*
- * These are no longer needed, but are here as a reminder about what
- * filters pdf supports.
- * public static final int ASCII_HEX_DECODE = 1;
- * public static final int ASCII_85_DECODE = 2;
- * public static final int LZW_DECODE = 3;
- * public static final int RUN_LENGTH_DECODE = 4;
- * public static final int CCITT_FAX_DECODE = 5;
- * public static final int DCT_DECODE = 6;
- * public static final int FLATE_DECODE = 7;
- */
-
- /**
- * Marker to know if this filter has already been applied to the data
- */
- private boolean _applied = false;
-
- public boolean isApplied() {
- return _applied;
- }
-
- /**
- * Set the applied attribute to the given value. This attribute is
- * used to determine if this filter is just a placeholder for the
- * decodeparms and dictionary entries, or if the filter needs to
- * actually encode the data. For example if the raw data is copied
- * out of an image file in it's compressed format, then this
- * should be set to true and the filter options should be set to
- * those which the raw data was encoded with.
- */
- public void setApplied(boolean b) {
- _applied = b;
- }
-
-
- /**
- * return a PDF string representation of the filter, e.g. /FlateDecode
- */
- public abstract String getName();
-
- /**
- * return a parameter dictionary for this filter, or null
- */
- public abstract String getDecodeParms();
-
- /**
- * encode the given data with the filter
- */
- public abstract byte[] encode(byte[] data);
-
-
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-// Author: Eric SCHAEFFER
-// Description: Filter Exception
-
-package org.apache.fop.pdf;
-
-public class PDFFilterException extends Exception {
-
- public PDFFilterException() {
- super();
- }
-
- public PDFFilterException(String message) {
- super(message);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a /Font object.
- *
- * A more complete object expressing the base font name and encoding of a
- * font along with an internal name for the font used within
- * streams of content.
- *
- * Fonts are specified on page 198 and onwards of the PDF 1.3 spec.
- */
-public class PDFFont extends PDFObject {
-
- /**
- * font subtype to be used as parameter to createFont()
- */
- public static final byte TYPE0 = 0;
-
- /**
- * font subtype to be used as parameter to createFont()
- */
- public static final byte TYPE1 = 1;
-
- /**
- * font subtype to be used as parameter to createFont()
- */
- public static final byte MMTYPE1 = 2;
-
- /**
- * font subtype to be used as parameter to createFont()
- */
- public static final byte TYPE3 = 3;
-
- /**
- * font subtype to be used as parameter to createFont()
- */
- public static final byte TRUETYPE = 4;
-
- /**
- * font subtype names as output in the PDF
- */
- protected static final String[] TYPE_NAMES =
- new String[] // take care of the order
- {
- "Type0", "Type1", "MMType1", "Type3", "TrueType"
- };
-
- /**
- * the internal name for the font (eg "F1")
- */
- protected String fontname;
-
- /**
- * the font's subtype
- * (as defined by the constants TYPE0, TYPE1, MMTYPE1, TYPE3, TRUETYPE)
- */
- protected byte subtype;
-
- /**
- * the base font name (eg "Helvetica")
- */
- protected String basefont;
-
- /**
- * the character encoding scheme used by the font.
- * It can be a String for standard encodings, or
- * a PDFEncoding for a more complex scheme, or
- * a PDFStream containing a CMap in a Type0 font.
- * If <code>null</code> then not written out in the PDF.
- */
- protected Object encoding;
-
- /**
- * the Unicode mapping mechanism
- */
- // protected PDFToUnicode mapping;
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- */
- public PDFFont(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */) {
-
- /* generic creation of PDF object */
- super(number);
-
- /* set fields using paramaters */
- this.fontname = fontname;
- this.subtype = subtype;
- this.basefont = basefont;
- this.encoding = encoding;
- // this.mapping = mapping;
- }
-
- /**
- * factory method with the basic parameters
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- */
- public static PDFFont createFont(int number, String fontname,
- byte subtype, String basefont,
- Object encoding) {
- switch (subtype) {
- case TYPE0:
- return new PDFFontType0(number, fontname, subtype, basefont,
- encoding);
- case TYPE1:
- case MMTYPE1:
- return new PDFFontType1(number, fontname, subtype, basefont,
- encoding);
- /*
- * case TYPE3 :
- * return new PDFFontType3(number, fontname, subtype, basefont, encoding);
- */
- case TRUETYPE:
- return new PDFFontTrueType(number, fontname, subtype, basefont,
- encoding);
- }
- return null; // should not happend
- }
-
- /**
- * factory method with the extended parameters
- * for Type1, MMType1 and TrueType
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param firstChar the first character code in the font
- * @param lastChar the last character code in the font
- * @param widths an array of size (lastChar - firstChar +1)
- * @param descriptor the descriptor for other font's metrics
- */
- public static PDFFont createFont(int number, String fontname,
- byte subtype, String basefont,
- Object encoding, int firstChar,
- int lastChar, PDFArray widths,
- PDFFontDescriptor descriptor) {
-
- PDFFontNonBase14 font;
- switch (subtype) {
- case TYPE0:
- font = new PDFFontType0(number, fontname, subtype, basefont,
- encoding);
- font.setDescriptor(descriptor);
- return font;
- case TYPE1:
- case MMTYPE1:
- font = new PDFFontType1(number, fontname, subtype, basefont,
- encoding);
- font.setWidthMetrics(firstChar, lastChar, widths);
- font.setDescriptor(descriptor);
- return font;
- case TYPE3:
- return null; // should not happend
-
- case TRUETYPE:
- font = new PDFFontTrueType(number, fontname, subtype, basefont,
- encoding);
- font.setWidthMetrics(firstChar, lastChar, widths);
- font.setDescriptor(descriptor);
- return font;
-
- }
- return null; // should not happend
- }
-
- /**
- * get the internal name used for this font
- *
- * @return the internal name
- */
- public String getName() {
- return this.fontname;
- }
-
- /**
- * produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation
- + " obj\n<< /Type /Font\n/Subtype /"
- + TYPE_NAMES[this.subtype] + "\n/Name /" + this.fontname
- + "\n/BaseFont /" + this.basefont);
- if (encoding != null) {
- p.append("\n/Encoding ");
- if (encoding instanceof PDFEncoding) {
- p.append(((PDFEncoding)this.encoding).referencePDF());
- } else if (encoding instanceof PDFStream) {
- p.append(((PDFStream)this.encoding).referencePDF());
- } else {
- p.append("/").append((String)encoding);
- }
- }
- fillInPDF(p);
- p.append(" >>\nendobj\n");
- return p.toString().getBytes();
- }
-
- /**
- * fill in the specifics for the font's subtype.
- *
- * the given buffer already contains the fields common to all font types.
- *
- * @param begin the buffer to be completed with the type specific fields
- */
- protected void fillInPDF(StringBuffer begin) {}
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a font descriptor.
- *
- * Font descriptors are specified on page 222 and onwards of the PDF 1.3 spec.
- */
-public class PDFFontDescriptor extends PDFObject {
-
- // Required fields
- protected int ascent;
- protected int capHeight;
- protected int descent;
- protected int flags;
- protected PDFRectangle fontBBox;
- protected String basefont; // PDF-spec: FontName
- protected int italicAngle;
- protected int stemV;
- // Optional fields
- protected int stemH = 0;
- protected int xHeight = 0;
- protected int leading = 0;
- protected int avgWidth = 0;
- protected int maxWidth = 0;
- protected int missingWidth = 0;
- protected PDFStream fontfile;
- // protected String charSet = null;
-
- protected byte subtype;
-
- /**
- * create the /FontDescriptor object
- *
- * @param number the object's number
- * @param ascent the maximum height above the baseline
- * @param descent the maximum depth below the baseline
- * @param capHeight height of the capital letters
- * @param flags various characteristics of the font
- * @param fontBBox the bounding box for the described font
- * @param basefont the base font name
- * @param italicAngle the angle of the vertical dominant strokes
- * @param stemV the width of the dominant vertical stems of glyphs
- */
- public PDFFontDescriptor(int number, String basefont, int ascent,
- int descent, int capHeight, int flags,
- PDFRectangle fontBBox, int italicAngle,
- int stemV) {
-
- /* generic creation of PDF object */
- super(number);
-
- /* set fields using paramaters */
- this.basefont = basefont;
- this.ascent = ascent;
- this.descent = descent;
- this.capHeight = capHeight;
- this.flags = flags;
- this.fontBBox = fontBBox;
- this.italicAngle = italicAngle;
- this.stemV = stemV;
- }
-
- /**
- * set the optional metrics
- */
- public void setMetrics(int avgWidth, int maxWidth, int missingWidth,
- int leading, int stemH, int xHeight) {
- this.avgWidth = avgWidth;
- this.maxWidth = maxWidth;
- this.missingWidth = missingWidth;
- this.leading = leading;
- this.stemH = stemH;
- this.xHeight = xHeight;
- }
-
- /**
- * set the optional font file stream
- *
- * @param subtype the font type defined in the font stream
- * @param fontfile the stream containing an embedded font
- */
- public void setFontFile(byte subtype, PDFStream fontfile) {
- this.subtype = subtype;
- this.fontfile = fontfile;
- }
-
- // public void setCharSet(){}//for subset fonts
-
- /**
- * produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer(this.number + " " + this.generation
- + " obj\n<< /Type /FontDescriptor"
- + "\n/FontName /" + this.basefont);
-
- p.append("\n/FontBBox ");
- p.append(fontBBox.toPDFString());
- p.append("\n/Flags ");
- p.append(flags);
- p.append("\n/CapHeight ");
- p.append(capHeight);
- p.append("\n/Ascent ");
- p.append(ascent);
- p.append("\n/Descent ");
- p.append(descent);
- p.append("\n/ItalicAngle ");
- p.append(italicAngle);
- p.append("\n/StemV ");
- p.append(stemV);
- // optional fields
- if (stemH != 0) {
- p.append("\n/StemH ");
- p.append(stemH);
- }
- if (xHeight != 0) {
- p.append("\n/XHeight ");
- p.append(xHeight);
- }
- if (avgWidth != 0) {
- p.append("\n/AvgWidth ");
- p.append(avgWidth);
- }
- if (maxWidth != 0) {
- p.append("\n/MaxWidth ");
- p.append(maxWidth);
- }
- if (missingWidth != 0) {
- p.append("\n/MissingWidth ");
- p.append(missingWidth);
- }
- if (leading != 0) {
- p.append("\n/Leading ");
- p.append(leading);
- }
- if (fontfile != null) {
- switch (subtype) {
- case PDFFont.TYPE1:
- p.append("\n/FontFile ");
- break;
- case PDFFont.TRUETYPE:
- p.append("\n/FontFile2 ");
- break;
- case PDFFont.TYPE0:
- p.append("\n/FontFile2 ");
- break;
- default:
- p.append("\n/FontFile2 ");
- }
- p.append(fontfile.referencePDF());
- }
- // charSet for subset fonts // not yet implemented
- // CID optional field
- fillInPDF(p);
- p.append("\n >>\nendobj\n");
- return p.toString().getBytes();
- }
-
- /**
- * fill in the specifics for the font's descriptor.
- *
- * the given buffer already contains the fields common to all descriptors.
- *
- * @param begin the buffer to be completed with the specific fields
- */
- protected void fillInPDF(StringBuffer begin) {}
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-
-/**
- * A common ancestor for Type1, TrueType, MMType1 and Type3 fonts
- * (all except base 14 fonts).
- */
-public abstract class PDFFontNonBase14 extends PDFFont {
-
- /**
- * first character code in the font
- */
- protected int firstChar;
-
- /**
- * last character code in the font
- */
- protected int lastChar;
-
- /**
- * widths of characters from firstChar to lastChar
- */
- protected PDFArray widths;
-
- /**
- * descriptor of font metrics
- */
- protected PDFFontDescriptor descriptor;
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- */
- public PDFFontNonBase14(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding);
-
- this.descriptor = null;
- }
-
- /**
- * set the width metrics for the font
- *
- * @param firstChar the first character code in the font
- * @param lastChar the last character code in the font
- * @param widths an array of size (lastChar - firstChar +1)
- */
- public void setWidthMetrics(int firstChar, int lastChar,
- PDFArray widths) {
- /* set fields using paramaters */
- this.firstChar = firstChar;
- this.lastChar = lastChar;
- this.widths = widths;
- }
-
- /**
- * set the font descriptor (unused for the Type3 fonts)
- *
- * @param descriptor the descriptor for other font's metrics
- */
- public void setDescriptor(PDFFontDescriptor descriptor) {
- this.descriptor = descriptor;
- }
-
- /**
- * fill in the specifics for the font's subtype
- */
- protected void fillInPDF(StringBuffer p) {
- p.append("\n/FirstChar ");
- p.append(firstChar);
- p.append("\n/LastChar ");
- p.append(lastChar);
- p.append("\n/Widths ");
- p.append(this.widths.referencePDF());
- if (descriptor != null) {
- p.append("\n/FontDescriptor ");
- p.append(this.descriptor.referencePDF());
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a TrueType font.
- *
- * In fact everything already done in the superclass.
- * Must only define the not default constructor.
- */
-public class PDFFontTrueType extends PDFFontNonBase14 {
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype (PDFFont.TRUETYPE)
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- */
- public PDFFontTrueType(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding /* , mapping */);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a Type0 font.
- *
- * Type0 fonts are specified on page 208 and onwards of the PDF 1.3 spec.
- */
-public class PDFFontType0 extends PDFFontNonBase14 {
-
- /**
- * this should be an array of CIDFont but only the first one is used
- */
- protected PDFCIDFont descendantFonts;
-
- protected PDFCMap cmap;
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype (PDFFont.TYPE0)
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- */
- public PDFFontType0(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding /* , mapping */);
-
- /* set fields using paramaters */
- this.descendantFonts = null;
- cmap = null;
- }
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype (PDFFont.TYPE0)
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- * @param descendantFonts the CIDFont upon which this font is based
- */
- public PDFFontType0(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */,
- PDFCIDFont descendantFonts) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding /* , mapping */);
-
- /* set fields using paramaters */
- this.descendantFonts = descendantFonts;
- }
-
- /**
- * set the descendant font
- *
- * @param descendantFonts the CIDFont upon which this font is based
- */
- public void setDescendantFonts(PDFCIDFont descendantFonts) {
- this.descendantFonts = descendantFonts;
- }
-
- public void setCMAP(PDFCMap cmap) {
- this.cmap = cmap;
- }
-
- /**
- * fill in the specifics for the font's subtype
- */
- protected void fillInPDF(StringBuffer p) {
- if (descendantFonts != null) {
- p.append("\n/DescendantFonts [ "
- + this.descendantFonts.referencePDF() + " ] ");
- }
- if (cmap != null) {
- p.append("\n/ToUnicode " + cmap.referencePDF());
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a Type1 or MMType1 font (not necessary for the base 14).
- *
- * Type1 fonts are specified on page 201 and onwards of the PDF 1.3 spec.
- * MMType1 fonts are specified on page 205 and onwards of the PDF 1.3 spec.
- *
- * In fact everything already done in the superclass.
- * Must only define the not default constructor.
- */
-public class PDFFontType1 extends PDFFontNonBase14 {
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype (PDFFont.TYPE1 or PDFFont.MMTYPE1)
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- */
- public PDFFontType1(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a Type3 font.
- *
- * <p><b>CAUTION: this is not yet fully implemented!!!!!!!</b>
- * the /CharProcs is still missing its <code>toPDF()</code> method.
- * </p>
- *
- * Type3 fonts are specified on page 206 and onwards of the PDF 1.3 spec.
- */
-public class PDFFontType3 extends PDFFontNonBase14 {
-
- /**
- * font's required /FontBBox bounding box
- */
- protected PDFRectangle fontBBox;
-
- /**
- * font's required /FontMatrix array
- */
- protected PDFArray fontMatrix;
-
- /**
- * font's required /CharProcs dictionary
- */
- protected PDFCharProcs charProcs;
-
- /**
- * font's optional /Resources object
- */
- protected PDFResources resources;
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype (PDFFont.TYPE3)
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- */
- public PDFFontType3(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding /* , mapping */);
-
- this.fontBBox = null;
- this.fontMatrix = null;
- this.charProcs = null;
- }
-
- /**
- * create the /Font object
- *
- * @param number the object's number
- * @param fontname the internal name for the font
- * @param subtype the font's subtype (PDFFont.TYPE3)
- * @param basefont the base font name
- * @param encoding the character encoding schema used by the font
- * @param mapping the Unicode mapping mechanism
- * @param fontBBox the font's bounding box
- * @param fontMatrix the font's transformation matrix
- * @param charProcs the glyphs' definitions
- */
- public PDFFontType3(int number, String fontname, byte subtype,
- String basefont,
- Object encoding /* , PDFToUnicode mapping */,
- PDFRectangle fontBBox, PDFArray fontMatrix,
- PDFCharProcs charProcs) {
-
- /* generic creation of PDF object */
- super(number, fontname, subtype, basefont, encoding /* , mapping */);
-
- this.fontBBox = fontBBox;
- this.fontMatrix = fontMatrix;
- this.charProcs = charProcs;
- }
-
- /**
- * set the font's bounding box
- *
- * @param bbox bounding box for the font
- */
- public void setFontBBox(PDFRectangle bbox) {
- this.fontBBox = bbox;
- }
-
- /**
- * set the font's transformation matrix
- *
- * @param matrix the transformation matrix for the font
- */
- public void setFontMatrix(PDFArray matrix) {
- this.fontMatrix = matrix;
- }
-
- /**
- * set the glyphs' definitions.
- * The /CharProcs object needs to be registered in the document's resources.
- *
- * @param chars the glyphs' dictionary
- */
- public void setCharProcs(PDFCharProcs chars) {
- this.charProcs = chars;
- }
-
- /**
- * fill in the specifics for the font's subtype.
- *
- * the given buffer already contains the fields common to all font types.
- *
- * @param p the buffer to be completed with the type specific fields
- */
- protected void fillInPDF(StringBuffer p) {
- if (fontBBox != null) {
- p.append("\n/FontBBox ");
- p.append(fontBBox.toPDF());
- }
- if (fontMatrix != null) {
- p.append("\n/FontMatrix ");
- p.append(fontMatrix.toPDF());
- }
- if (charProcs != null) {
- p.append("\n/CharProcs ");
- p.append(charProcs.referencePDF());
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java...
-import java.util.Vector;
-
-/**
- * class representing a PDF Function.
- *
- * PDF Functions represent parameterized mathematical formulas and sampled representations with
- * arbitrary resolution. Functions are used in two areas: device-dependent
- * rasterization information for halftoning and transfer
- * functions, and color specification for smooth shading (a PDF 1.3 feature).
- *
- * All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
- */
-public class PDFFunction extends PDFObject {
- // Guts common to all function types
-
- /**
- * Required: The Type of function (0,2,3,4) default is 0.
- */
- protected int functionType = 0; // Default
-
- /**
- * Required: 2 * m Array of Double numbers which are possible inputs to the function
- */
- protected Vector domain = null;
-
- /**
- * Required: 2 * n Array of Double numbers which are possible outputs to the function
- */
- protected Vector range = null;
-
- /* ********************TYPE 0***************************** */
- // FunctionType 0 specific function guts
-
- /**
- * Required: Array containing the Integer size of the Domain and Range, respectively.
- * Note: This is really more like two seperate integers, sizeDomain, and sizeRange,
- * but since they're expressed as an array in PDF, my implementation reflects that.
- */
- protected Vector size = null;
-
- /**
- * Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32
- */
- protected int bitsPerSample = 1;
-
- /**
- * Optional for Type 0: order of interpolation between samples. Limited to linear (1) or cubic (3). Default is 1
- */
- protected int order = 1;
-
- /**
- * Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain.
- *
- * Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.
- * Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions.
- */
- protected Vector encode = null;
-
- /**
- * Optinoal for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range. Defaults to Range.
- */
- protected Vector decode = null;
-
- /**
- * Optional For Type 0: A stream of sample values
- */
-
- /**
- * Required For Type 4: Postscript Calculator function composed of arithmetic, boolean, and stack operators + boolean constants
- */
- protected StringBuffer functionDataStream = null;
-
- /**
- * Required (?) For Type 0: A vector of Strings for the various filters to be used to decode the stream.
- * These are how the string is compressed. Flate, LZW, etc.
- */
- protected Vector filter = null;
- /* *************************TYPE 2************************** */
-
- /**
- * Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0].
- */
- protected Vector cZero = null;
-
- /**
- * Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1].
- */
- protected Vector cOne = null;
-
- /**
- * Required for Type 2: The interpolation exponent.
- * Each value x will return n results.
- * Must be greater than 0.
- */
- protected double interpolationExponentN = 1;
-
- /* *************************TYPE 3************************** */
-
- /**
- * Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function.
- */
- protected Vector functions = null;
-
- /**
- * Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain.
- * k is the number of functions.
- * If you pass null, it will output (1/k) in an array of k-1 elements.
- * This makes each function responsible for an equal amount of the stitching function.
- * It makes the gradient even.
- */
- protected Vector bounds = null;
- // See encode above, as it's also part of Type 3 Functions.
-
- /* *************************TYPE 4************************** */
- // See 'data' above.
-
- /**
- * create an complete Function object of Type 0, A Sampled function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theDomain Vector objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theSize A Vector object of Integer objects.
- * This is the number of samples in each input dimension.
- * I can't imagine there being more or less than two input dimensions,
- * so maybe this should be an array of length 2.
- *
- * See page 265 of the PDF 1.3 Spec.
- * @param theBitsPerSample An int specifying the number of bits user to represent each sample value.
- * Limited to 1,2,4,8,12,16,24 or 32.
- * See page 265 of the 1.3 PDF Spec.
- * @param theOrder The order of interpolation between samples. Default is 1 (one). Limited
- * to 1 (one) or 3, which means linear or cubic-spline interpolation.
- *
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theEncode Vector objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is optional.
- *
- * See page 265 in the PDF 1.3 spec.
- * @param theDecode Vector objects of Double objects.
- * This is a linear mapping of sample values into the range.
- * The default is just the range.
- *
- * This attribute is optional.
- * Read about it on page 265 of the PDF 1.3 spec.
- * @param theFunctionDataStream The sample values that specify the function are provided in a stream.
- *
- * This is optional, but is almost always used.
- *
- * Page 265 of the PDF 1.3 spec has more.
- * @param theFilter This is a vector of String objects which are the various filters that
- * have are to be applied to the stream to make sense of it. Order matters,
- * so watch out.
- *
- * This is not documented in the Function section of the PDF 1.3 spec,
- * it was deduced from samples that this is sometimes used, even if we may never
- * use it in FOP. It is added for completeness sake.
- * @param theNumber The object number of this PDF object.
- * @param theFunctionType This is the type of function (0,2,3, or 4).
- * It should be 0 as this is the constructor for sampled functions.
- */
- public PDFFunction(int theNumber, int theFunctionType, Vector theDomain,
- Vector theRange, Vector theSize, int theBitsPerSample,
- int theOrder, Vector theEncode, Vector theDecode,
- StringBuffer theFunctionDataStream, Vector theFilter) {
- super(theNumber);
-
- this.functionType = 0; // dang well better be 0;
- this.size = theSize;
- this.bitsPerSample = theBitsPerSample;
- this.order = theOrder; // int
- this.encode = theEncode; // vector of int
- this.decode = theDecode; // vector of int
- this.functionDataStream = theFunctionDataStream;
- this.filter = theFilter; // vector of Strings
-
- // the domain and range are actually two dimensional arrays.
- // so if there's not an even number of items, bad stuff
- // happens.
- this.domain = theDomain;
- this.range = theRange;
- }
-
- /**
- * create an complete Function object of Type 2, an Exponential Interpolation function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theNumber the object's number
- * @param theDomain Vector objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector of Doubles that is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theCZero This is a vector of Double objects which defines the function result
- * when x=0.
- *
- * This attribute is optional.
- * It's described on page 268 of the PDF 1.3 spec.
- * @param theCOne This is a vector of Double objects which defines the function result
- * when x=1.
- *
- * This attribute is optional.
- * It's described on page 268 of the PDF 1.3 spec.
- * @param theInterpolationExponentN This is the inerpolation exponent.
- *
- * This attribute is required.
- * PDF Spec page 268
- * @param theFunctionType The type of the function, which should be 2.
- */
- public PDFFunction(int theNumber, int theFunctionType, Vector theDomain,
- Vector theRange, Vector theCZero, Vector theCOne,
- double theInterpolationExponentN) {
- super(theNumber);
-
- this.functionType = 2; // dang well better be 2;
-
- this.cZero = theCZero;
- this.cOne = theCOne;
- this.interpolationExponentN = theInterpolationExponentN;
-
-
- this.domain = theDomain;
- this.range = theRange;
-
- }
-
- /**
- * create an complete Function object of Type 3, a Stitching function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theNumber the object's number
- * @param theDomain Vector objects of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector objects of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theFunctions A Vector of the PDFFunction objects that the stitching function stitches.
- *
- * This attributed is required.
- * It is described on page 269 of the PDF spec.
- * @param theBounds This is a vector of Doubles representing the numbers that,
- * in conjunction with Domain define the intervals to which each function from
- * the 'functions' object applies. It must be in order of increasing magnitude,
- * and each must be within Domain.
- *
- * It basically sets how much of the gradient each function handles.
- *
- * This attributed is required.
- * It's described on page 269 of the PDF 1.3 spec.
- * @param theEncode Vector objects of Double objects.
- * This is the linear mapping of input values intop the domain
- * of the function's sample table. Default is hard to represent in
- * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
- * This attribute is required.
- *
- * See page 270 in the PDF 1.3 spec.
- * @param theFunctionType This is the function type. It should be 3,
- * for a stitching function.
- */
- public PDFFunction(int theNumber, int theFunctionType, Vector theDomain,
- Vector theRange, Vector theFunctions,
- Vector theBounds, Vector theEncode) {
- super(theNumber);
-
- this.functionType = 3; // dang well better be 3;
-
- this.functions = theFunctions;
- this.bounds = theBounds;
- this.encode = theEncode;
- this.domain = theDomain;
- this.range = theRange;
-
- }
-
- /**
- * create an complete Function object of Type 4, a postscript calculator function.
- *
- * Use null for an optional object parameter if you choose not to use it.
- * For optional int parameters, pass the default.
- *
- * @param theDomain Vector object of Double objects.
- * This is the domain of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theRange Vector object of Double objects.
- * This is the Range of the function.
- * See page 264 of the PDF 1.3 Spec.
- * @param theFunctionDataStream This is a stream of arithmetic, boolean, and stack operators and boolean constants.
- * I end up enclosing it in the '{' and '}' braces for you, so don't do it
- * yourself.
- *
- * This attribute is required.
- * It's described on page 269 of the PDF 1.3 spec.
- * @param theNumber The object number of this PDF object.
- * @param theFunctionType The type of function which should be 4, as this is
- * a Postscript calculator function
- */
- public PDFFunction(int theNumber, int theFunctionType, Vector theDomain,
- Vector theRange, StringBuffer theFunctionDataStream) {
- super(theNumber);
-
- this.functionType = 4; // dang well better be 4;
- this.functionDataStream = theFunctionDataStream;
-
- this.domain = theDomain;
-
- this.range = theRange;
-
- }
-
-
- /**
- * represent as PDF. Whatever the FunctionType is, the correct
- * representation spits out. The sets of required and optional
- * attributes are different for each type, but if a required
- * attribute's object was constructed as null, then no error
- * is raised. Instead, the malformed PDF that was requested
- * by the construction is dutifully output.
- * This policy should be reviewed.
- *
- * @return the PDF string.
- */
- public byte[] toPDF() {
- int vectorSize = 0;
- int numberOfFunctions = 0;
- int tempInt = 0;
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation
- + " obj\n<< \n/FunctionType " + this.functionType + " \n");
-
- // FunctionType 0
- if (this.functionType == 0) {
- if (this.domain != null) {
- // DOMAIN
- p.append("/Domain [ ");
- vectorSize = this.domain.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- // SIZE
- if (this.size != null) {
- p.append("/Size [ ");
- vectorSize = this.size.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.size.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
- // ENCODE
- if (this.encode != null) {
- p.append("/Encode [ ");
- vectorSize = this.encode.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.encode.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- } else {
- p.append("/Encode [ ");
- vectorSize = this.functions.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append("0 1 ");
- }
- p.append("] \n");
-
- }
-
- // BITSPERSAMPLE
- p.append("/BitsPerSample " + this.bitsPerSample);
-
- // ORDER (optional)
- if (this.order == 1 || this.order == 3) {
- p.append(" \n/Order " + this.order + " \n");
- }
-
- // RANGE
- if (this.range != null) {
- p.append("/Range [ ");
- vectorSize = this.range.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- }
-
- // DECODE
- if (this.decode != null) {
- p.append("/Decode [ ");
- vectorSize = this.decode.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.decode.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- }
-
- // LENGTH
- if (this.functionDataStream != null) {
- p.append("/Length " + (this.functionDataStream.length() + 1)
- + " \n");
- }
-
- // FILTER?
- if (this.filter != null) { // if there's a filter
- vectorSize = this.filter.size();
- p.append("/Filter ");
- if (vectorSize == 1) {
- p.append("/" + ((String)this.filter.elementAt(0))
- + " \n");
- } else {
- p.append("[ ");
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append("/" + ((String)this.filter.elementAt(0))
- + " ");
- }
- p.append("] \n");
- }
- }
- p.append(">> \n");
-
- // stream representing the function
- if (this.functionDataStream != null) {
- p.append("stream\n" + this.functionDataStream
- + "\nendstream\n");
- }
-
- p.append("endobj\n");
-
- } // end of if FunctionType 0
- else if (this.functionType == 2) {
- // DOMAIN
- if (this.domain != null) {
- p.append("/Domain [ ");
- vectorSize = this.domain.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
-
- // RANGE
- if (this.range != null) {
- p.append("/Range [ ");
- vectorSize = this.range.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- }
-
- // FunctionType, C0, C1, N are required in PDF
-
- // C0
- if (this.cZero != null) {
- p.append("/C0 [ ");
- vectorSize = this.cZero.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.cZero.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
-
- // C1
- if (this.cOne != null) {
- p.append("/C1 [ ");
- vectorSize = this.cOne.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.cOne.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
-
- // N: The interpolation Exponent
- p.append("/N "
- + PDFNumber.doubleOut(new Double(this.interpolationExponentN))
- + " \n");
-
- p.append(">> \nendobj\n");
-
- } else if (this.functionType
- == 3) { // fix this up when my eyes uncross
- // DOMAIN
- if (this.domain != null) {
- p.append("/Domain [ ");
- vectorSize = this.domain.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- // RANGE
- if (this.range != null) {
- p.append("/Range [ ");
- vectorSize = this.range.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- }
-
- // FUNCTIONS
- if (this.functions != null) {
- p.append("/Functions [ ");
- numberOfFunctions = this.functions.size();
- for (tempInt = 0; tempInt < numberOfFunctions; tempInt++) {
- p.append(((PDFFunction)this.functions.elementAt(tempInt)).referencePDF()
- + " ");
-
- }
- p.append("] \n");
- }
-
-
- // ENCODE
- if (this.encode != null) {
- p.append("/Encode [ ");
- vectorSize = this.encode.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.encode.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- } else {
- p.append("/Encode [ ");
- vectorSize = this.functions.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append("0 1 ");
- }
- p.append("] \n");
-
- }
-
-
- // BOUNDS, required, but can be empty
- p.append("/Bounds [ ");
- if (this.bounds != null) {
-
- vectorSize = this.bounds.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.bounds.elementAt(tempInt))
- + " ");
- }
-
- } else {
- if (this.functions != null) {
- // if there are n functions,
- // there must be n-1 bounds.
- // so let each function handle an equal portion
- // of the whole. e.g. if there are 4, then [ 0.25 0.25 0.25 ]
-
- String functionsFraction = PDFNumber.doubleOut(new Double(1.0
- / ((double)numberOfFunctions)));
-
- for (tempInt = 0; tempInt + 1 < numberOfFunctions;
- tempInt++) {
-
- p.append(functionsFraction + " ");
- }
- functionsFraction = null; // clean reference.
-
- }
-
- }
- p.append("] \n");
-
-
- p.append(">> \nendobj\n");
- } else if (this.functionType
- == 4) { // fix this up when my eyes uncross
- // DOMAIN
- if (this.domain != null) {
- p.append("/Domain [ ");
- vectorSize = this.domain.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- // RANGE
- if (this.range != null) {
- p.append("/Range [ ");
- vectorSize = this.range.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.range.elementAt(tempInt))
- + " ");
- }
-
- p.append("] \n");
- }
-
- // LENGTH
- if (this.functionDataStream != null) {
- p.append("/Length " + (this.functionDataStream.length() + 1)
- + " \n");
- }
-
- p.append(">> \n");
-
- // stream representing the function
- if (this.functionDataStream != null) {
- p.append("stream\n{ " + this.functionDataStream
- + " } \nendstream\n");
- }
-
- p.append("endobj\n");
-
- }
-
- return (p.toString().getBytes());
-
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a /GoTo object.
- *
- */
-public class PDFGoTo extends PDFAction {
-
- /**
- * the pageReference
- */
- protected String pageReference;
- protected float xPosition = 0, yPosition = 0;
-
- /**
- * create a /GoTo object.
- *
- * @param number the object's number
- * @param pageReference the pageReference represented by this object
- */
- public PDFGoTo(int number, String pageReference) {
-
- /* generic creation of object */
- super(number);
-
- this.pageReference = pageReference;
- }
-
-
- /**
- * Sets page reference after object has been created
- *
- * @param pageReference
- * the new page reference to use
- */
- public void setPageReference(String pageReference) {
- this.pageReference = pageReference;
- }
-
-
-
- /**
- * Sets the Y position to jump to
- *
- * @param yPosition y position
- */
- public void setYPosition(int yPosition) {
- this.yPosition = (yPosition / 1000f);
- }
-
-
-
- /**
- * Sets the x Position to jump to
- *
- * @param xPosition x position
- */
- public void setXPosition(int xPosition) {
- this.xPosition = (xPosition / 1000f);
- }
-
- public String getAction() {
- return referencePDF();
- }
-
-
- /**
- * represent the object in PDF
- *
- * @return the PDF string
- */
- public byte[] toPDF() {
- String p = new String(this.number + " " + this.generation
- + " obj\n<<\n/S /GoTo\n" + "/D ["
- + this.pageReference + " /XYZ " + xPosition
- + " " + yPosition + " null]\n"
- + ">>\nendobj\n");
- return p.getBytes();
- }
-
- /*
- * example
- * 29 0 obj
- * <<
- * /S /GoTo
- * /D [23 0 R /FitH 600]
- * >>
- * endobj
- */
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a /GoToR object.
- */
-public class PDFGoToRemote extends PDFAction {
-
- /**
- * the file specification
- */
- protected PDFFileSpec pdfFileSpec;
-
- /**
- * create an GoToR object.
- *
- * @param number the object's number
- * @param fileSpec the fileSpec associated with the action
- */
- public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec) {
-
- /* generic creation of object */
- super(number);
-
- this.pdfFileSpec = pdfFileSpec;
- }
-
- /**
- * return the action string which will reference this object
- *
- * @return the action String
- */
- public String getAction() {
- return this.referencePDF();
- }
-
- /**
- * represent the object in PDF
- *
- * @return the PDF string
- */
- public byte[] toPDF() {
- String p = new String(this.number + " " + this.generation + " obj\n"
- + "<<\n/S /GoToR\n" + "/F "
- + pdfFileSpec.referencePDF() + "\n"
- + "/D [ 0 /XYZ null null null ]"
- + " \n>>\nendobj\n");
- return p.getBytes();
- }
-
-
- /*
- * example
- * 28 0 obj
- * <<
- * /S /GoToR
- * /F 29 0 R
- * /D [ 0 /XYZ -6 797 null ]
- * >>
- * endobj
- */
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * class representing an /Info object
- */
-public class PDFInfo extends PDFObject {
-
- /**
- * the application producing the PDF
- */
- protected String producer;
-
- /**
- * create an Info object
- *
- * @param number the object's number
- */
- public PDFInfo(int number) {
- super(number);
- }
-
- /**
- * set the producer string
- *
- * @param producer the producer string
- */
- public void setProducer(String producer) {
- this.producer = producer;
- }
-
- /**
- * produce the PDF representation of the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- String p = this.number + " " + this.generation
- + " obj\n<< /Type /Info\n/Producer (" + this.producer
- + ") >>\nendobj\n";
- return p.getBytes();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class used to create a PDF internal link
- */
-public class PDFInternalLink extends PDFAction {
-
-
- String goToReference;
-
- /**
- * create an internal link instance.
- *
- * @param goToReference the GoTo Reference to which the link should point
- */
- public PDFInternalLink(String goToReference) {
-
- this.goToReference = goToReference;
- }
-
- /**
- * returns the action ncecessary for an internal link
- *
- * @return the action to place next to /A within a Link
- */
- public String getAction() {
- return goToReference;
- }
-
- /**
- * there is nothing to return for the toPDF method, as it should not be called
- *
- * @return an empty string
- */
- public byte[] toPDF() {
- return new byte[0];
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.awt.Rectangle;
-
-/**
- * class representing an /Annot object of /Subtype /Link
- */
-public class PDFLink extends PDFObject {
-
- float ulx;
- float uly;
- float brx;
- float bry;
- String color;
- PDFAction action;
-
- /**
- * create objects associated with a link annotation (GoToR)
- *
- * @param number the object's number
- * @param producer the application producing the PDF
- */
- public PDFLink(int number, Rectangle r) {
- /* generic creation of PDF object */
- super(number);
-
- this.ulx = r.x;
- this.uly = r.y;
- this.brx = r.x + r.width;
- this.bry = r.y - r.height;
- this.color = "0 0 0"; // just for now
-
- }
-
- public void setAction(PDFAction action) {
- this.action = action;
- }
-
- /**
- * produce the PDF representation of the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- String p = this.number + " " + this.generation + " obj\n"
- + "<< /Type /Annot\n" + "/Subtype /Link\n" + "/Rect [ "
- + (ulx / 1000f) + " " + (uly / 1000f) + " "
- + (brx / 1000f) + " " + (bry / 1000f) + " ]\n" + "/C [ "
- + this.color + " ]\n" + "/Border [ 0 0 0 ]\n" + "/A "
- + this.action.getAction() + "\n" + "/H /I\n>>\nendobj\n";
- return p.getBytes();
- }
-
- /*
- * example
- * 19 0 obj
- * <<
- * /Type /Annot
- * /Subtype /Link
- * /Rect [ 176.032 678.48412 228.73579 692.356 ]
- * /C [ 0.86491 0.03421 0.02591 ]
- * /Border [ 0 0 1 ]
- * /A 28 0 R
- * /H /I
- * >>
- * endobj
- */
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-public class PDFNumber {
-
- private PDFNumber() {}
-
- public static String doubleOut(Double doubleDown) {
- StringBuffer p = new StringBuffer();
- if (doubleDown.doubleValue() < 0) {
- doubleDown = new Double(-doubleDown.doubleValue());
- p.append("-");
- }
- double trouble = doubleDown.doubleValue() % 1;
- if (trouble > 0.950) {
- p.append(doubleDown.intValue() + 1);
- } else if (trouble < 0.050) {
- p.append(doubleDown.intValue());
- } else {
- String doubleString = new String(doubleDown + "");
- int decimal = doubleString.indexOf(".");
- if (decimal != -1) {
- p.append(doubleString.substring(0, decimal));
-
- if ((doubleString.length() - decimal) > 6) {
- p.append(doubleString.substring(decimal, decimal + 6));
- } else {
- p.append(doubleString.substring(decimal));
- }
- } else {
- p.append(doubleString);
- }
- }
- return (p.toString());
- }
-
- public static String doubleOut(double doubleDown) {
-
- StringBuffer p = new StringBuffer();
- if (doubleDown < 0) {
- doubleDown = -doubleDown;
- p.append("-");
- }
- double trouble = doubleDown % 1;
-
- if (trouble > 0.950) {
- p.append((int)doubleDown + 1);
- } else if (trouble < 0.050) {
- p.append((int)doubleDown);
- } else {
- String doubleString = new String(doubleDown + "");
- int decimal = doubleString.indexOf(".");
- if (decimal != -1) {
- p.append(doubleString.substring(0, decimal));
-
- if ((doubleString.length() - decimal) > 6) {
- p.append(doubleString.substring(decimal, decimal + 6));
- } else {
- p.append(doubleString.substring(decimal));
- }
- } else {
- p.append(doubleString);
- }
- }
- return (p.toString());
- }
-
- public static String doubleOut(double doubleDown, int dec) {
-
- StringBuffer p = new StringBuffer();
- if (doubleDown < 0) {
- doubleDown = -doubleDown;
- p.append("-");
- }
- double trouble = doubleDown % 1;
-
- if (trouble > (1.0 - (5.0 / (Math.pow(10.0, dec))))) {
- p.append((int)doubleDown + 1);
- } else if (trouble < (5.0 / (Math.pow(10.0, dec)))) {
- p.append((int)doubleDown);
- } else {
- String doubleString = new String(doubleDown + "");
- int decimal = doubleString.indexOf(".");
- if (decimal != -1) {
- p.append(doubleString.substring(0, decimal));
-
- if ((doubleString.length() - decimal) > dec) {
- p.append(doubleString.substring(decimal, decimal + dec));
- } else {
- p.append(doubleString.substring(decimal));
- }
- } else {
- p.append(doubleString);
- }
- }
- return (p.toString());
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * generic PDF object.
- *
- * A PDF Document is essentially a collection of these objects. A PDF
- * Object has a number and a generation (although the generation will always
- * be 0 in new documents).
- */
-public abstract class PDFObject {
-
- /**
- * the object's number
- */
- protected int number;
-
- /**
- * the object's generation (0 in new documents)
- */
- protected int generation = 0;
-
- /**
- * create an empty object
- *
- * @param number the object's number
- */
- public PDFObject(int number) {
- this.number = number;
- }
-
- public PDFObject() {
- // do nothing
- }
-
- /**
- * @return the PDF Object number
- */
- public int getNumber() {
- return this.number;
- }
-
- /**
- * write the PDF represention of this object
- *
- * @param stream the stream to write the PDF to
- * @return the number of bytes written
- */
- protected int output(OutputStream stream) throws IOException {
- byte[] pdf = this.toPDF();
- stream.write(pdf);
- return pdf.length;
- }
-
- /**
- * the PDF representation of a reference to this object
- *
- * @return the reference string
- */
- public String referencePDF() {
- String p = this.number + " " + this.generation + " R";
- return p;
- }
-
- /**
- * represent object as PDF
- *
- * @return PDF string
- */
- abstract byte[] toPDF();
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import java.util.Vector;
-
-
-/**
- * This represents a single Outline object in a PDF, including the root Outlines
- * object. Outlines provide the bookmark bar, usually rendered to the right of
- * a PDF document in user agents such as Acrobat Reader
- *
- * @author Kelly A. Campbell
- *
- */
-
-public class PDFOutline extends PDFObject {
-
- /**
- * list of sub-entries (outline objects)
- */
- private Vector _subentries;
-
- /**
- * parent outline object. Root Outlines parent is null
- */
- private PDFOutline _parent;
-
- private PDFOutline _prev;
- private PDFOutline _next;
-
- private PDFOutline _first;
- private PDFOutline _last;
-
- private int _count;
-
-
- /**
- * title to display for the bookmark entry
- */
- private String _title;
-
- String _actionRef;
-
-
-
- /**
- * @param number the object id number
- * @param title the title of the outline entry (can only be null for root Outlines obj)
- * @param page the page which this outline refers to.
- */
- public PDFOutline(int number, String title, String action) {
- super(number);
- _subentries = new Vector();
- _count = 0;
- _parent = null;
- _prev = null;
- _next = null;
- _first = null;
- _last = null;
- _title = title;
- _actionRef = action;
-
-
- }
-
- public void setTitle(String title) {
- _title = title;
- }
-
- /**
- * Add a sub element to this outline
- */
- public void addOutline(PDFOutline outline) {
- if (_subentries.size() > 0) {
- outline._prev =
- (PDFOutline)_subentries.elementAt(_subentries.size() - 1);
- outline._prev._next = outline;
- } else {
- _first = outline;
- }
-
- _subentries.addElement(outline);
- outline._parent = this;
-
- incrementCount(); // note: count is not just the immediate children
-
- _last = outline;
-
- }
-
- private void incrementCount() {
- // count is a total of our immediate subentries and all descendent subentries
- _count++;
- if (_parent != null) {
- _parent.incrementCount();
- }
- }
-
-
- /**
- * represent the object in PDF
- */
- protected byte[] toPDF() {
- StringBuffer result = new StringBuffer(this.number + " "
- + this.generation
- + " obj\n<<\n");
- if (_parent == null) {
- // root Outlines object
- if (_first != null && _last != null) {
- result.append(" /First " + _first.referencePDF() + "\n");
- result.append(" /Last " + _last.referencePDF() + "\n");
- // no count... we start with the outline completely closed for now
- }
- } else {
- // subentry Outline object
- result.append(" /Title (" + escapeString(_title) + ")\n");
- result.append(" /Parent " + _parent.referencePDF() + "\n");
- if (_first != null && _last != null) {
- result.append(" /First " + _first.referencePDF() + "\n");
- result.append(" /Last " + _last.referencePDF() + "\n");
- }
- if (_prev != null) {
- result.append(" /Prev " + _prev.referencePDF() + "\n");
- }
- if (_next != null) {
- result.append(" /Next " + _next.referencePDF() + "\n");
- }
- if (_count > 0) {
- result.append(" /Count -" + _count + "\n");
- }
-
- if (_actionRef != null) {
- result.append(" /A " + _actionRef + "\n");
- }
-
-
- }
- result.append(">> endobj\n");
- return result.toString().getBytes();
-
- }
-
- /**
- * escape string (see 3.8.1 in PDF reference 2nd edition)
- */
- private String escapeString(String s) {
- StringBuffer result = new StringBuffer();
- if (s != null) {
- int l = s.length();
-
- // byte order marker (0xfeff)
- result.append("\\376\\377");
-
- for (int i = 0; i < l; i++) {
- char ch = s.charAt(i);
- int high = (ch & 0xff00) >>> 8;
- int low = ch & 0xff;
- result.append("\\");
- result.append(Integer.toOctalString(high));
- result.append("\\");
- result.append(Integer.toOctalString(low));
- }
- }
-
- return result.toString();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a /Page object.
- *
- * There is one of these for every page in a PDF document. The object
- * specifies the dimensions of the page and references a /Resources
- * object, a contents stream and the page's parent in the page
- * hierarchy.
- *
- * Modified by Mark Lillywhite, mark-fop@inomial.com. The Parent
- * object was being referred to by reference, but all that we
- * ever used from the Parent was it's PDF object ID, and according
- * to the memory profile this was causing OOM issues. So, we store
- * only the object ID of the parent, rather than the parent itself.
- */
-public class PDFPage extends PDFObject {
-
- /**
- * the page's parent, a PDF reference object
- */
- protected String parent;
-
- /**
- * the page's /Resource object
- */
- protected PDFResources resources;
-
- /**
- * the contents stream
- */
- protected PDFStream contents;
-
- /**
- * the width of the page in points
- */
- protected int pagewidth;
-
- /**
- * the height of the page in points
- */
- protected int pageheight;
-
- /**
- * the list of annotation objects for this page
- */
- protected PDFAnnotList annotList;
-
- /**
- * create a /Page object
- *
- * @param number the object's number
- * @param resources the /Resources object
- * @param contents the content stream
- * @param pagewidth the page's width in points
- * @param pageheight the page's height in points
- */
- public PDFPage(int number, PDFResources resources, PDFStream contents,
- int pagewidth, int pageheight) {
-
- /* generic creation of object */
- super(number);
-
- /* set fields using parameters */
- this.resources = resources;
- this.contents = contents;
- this.pagewidth = pagewidth;
- this.pageheight = pageheight;
-
- this.annotList = null;
- }
-
- /**
- * set this page's parent
- *
- * @param parent the /Pages object that is this page's parent
- */
- public void setParent(PDFPages parent) {
- this.parent = parent.referencePDF();
- }
-
- /**
- * set this page's annotation list
- *
- * @param annotList a PDFAnnotList list of annotations
- */
- public void setAnnotList(PDFAnnotList annotList) {
- this.annotList = annotList;
- }
-
- /**
- * get this page's annotation list
- *
- * @return annotList a PDFAnnotList list of annotations
- */
- public PDFAnnotList getAnnotList() {
- return this.annotList;
- }
-
- public void addShading(PDFShading shading) {
- this.resources.addShading(shading);
- }
-
- /**
- * represent this object as PDF
- *
- * @return the PDF string
- */
- public byte[] toPDF() {
- StringBuffer sb = new StringBuffer();
-
- sb = sb.append(this.number + " " + this.generation + " obj\n"
- + "<< /Type /Page\n" + "/Parent "
- + this.parent + "\n"
- + "/MediaBox [ 0 0 " + this.pagewidth + " "
- + this.pageheight + " ]\n" + "/Resources "
- + this.resources.referencePDF() + "\n" + "/Contents "
- + this.contents.referencePDF() + "\n");
- if (this.annotList != null) {
- sb = sb.append("/Annots " + this.annotList.referencePDF() + "\n");
- }
-
- sb = sb.append(">>\nendobj\n");
-
- return sb.toString().getBytes();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.io.PrintWriter;
-import org.apache.fop.messaging.MessageHandler;
-import java.util.Vector;
-
-/**
- * class representing a /Pages object.
- *
- * A /Pages object is an ordered collection of pages (/Page objects)
- * (Actually, /Pages can contain further /Pages as well but this
- * implementation doesn't allow this)
- */
-public class PDFPages extends PDFObject {
-
- /**
- * the /Page objects
- */
- protected Vector kids = new Vector();
-
- /**
- * the number of /Page objects
- */
- protected int count = 0;
-
- // private PDFPages parent;
-
- /**
- * create a /Pages object. NOTE: The PDFPages
- * object must be created before the PDF document is
- * generated, but it is not written to the stream immediately.
- * It must aslo be allocated an object ID (so that the kids
- * can refer to the parent) so that the XRef table needs to
- * be updated before this object is written.
- *
- * @param number the object's number
- */
- public PDFPages(int number) {
- super(number);
- }
-
- /**
- * add a /Page object.
- *
- * @param page the PDFPage to add.
- */
- public void addPage(PDFPage page) {
- this.kids.addElement(page.referencePDF());
- page.setParent(this);
- this.incrementCount();
- }
-
- /**
- * get the count of /Page objects
- *
- * @return the number of pages
- */
- public int getCount() {
- return this.count;
- }
-
- /**
- * increment the count of /Page objects
- */
- public void incrementCount() {
- this.count++;
- // MessageHandler.logln("Incrementing count to " + this.getCount());
- }
-
- /**
- * represent the object in PDF
- *
- * @return the PDF string
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer(this.number + " " + this.generation
- + " obj\n<< /Type /Pages\n/Count "
- + this.getCount() + "\n/Kids [");
- for (int i = 0; i < kids.size(); i++) {
- p = p.append(kids.elementAt(i) + " ");
- }
- p = p.append("] >>\nendobj\n");
- return p.toString().getBytes();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import org.apache.fop.datatypes.ColorSpace;
-
-public abstract class PDFPathPaint extends PDFObject {
-
- // protected int colorspace = 0; //default is 0:RGB, not 1:CMYK
- protected ColorSpace colorSpace;
-
- public PDFPathPaint(int theNumber) {
- super(theNumber);
-
- }
-
- public PDFPathPaint() {
- // do nothing
- }
-
- public String getColorSpaceOut(boolean fillNotStroke) {
- return ("");
- }
-
- public void setColorSpace(int theColorSpace) {
- this.colorSpace.setColorSpace(theColorSpace);
- }
-
- public int getColorSpace() {
- return (this.colorSpace.getColorSpace());
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java...
-import java.util.Vector;
-
-// FOP...
-import org.apache.fop.datatypes.ColorSpace;
-
-/**
- * class representing a PDF Function.
- *
- * PDF Functions represent parameterized mathematical formulas and sampled representations with
- * arbitrary resolution. Functions are used in two areas: device-dependent
- * rasterization information for halftoning and transfer
- * functions, and color specification for smooth shading (a PDF 1.3 feature).
- *
- * All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
- */
-public class PDFPattern extends PDFPathPaint {
-
- /**
- * The resources associated with this pattern
- */
- // Guts common to all function types
-
- protected PDFResources resources = null;
-
- /**
- * Either one (1) for tiling, or two (2) for shading.
- */
- protected int patternType = 2; // Default
-
- /**
- * The name of the pattern such as "Pa1" or "Pattern1"
- */
- protected String patternName = null;
-
- /**
- * 1 for colored pattern, 2 for uncolored
- */
- protected int paintType = 2;
-
- /**
- * 1 for constant spacing, 2 for no distortion, and 3 for fast rendering
- */
- protected int tilingType = 1;
-
- /**
- * Vector of Doubles representing the Bounding box rectangle
- */
- protected Vector bBox = null;
-
- /**
- * Horizontal spacing
- */
- protected double xStep = -1;
-
- /**
- * Vertical spacing
- */
- protected double yStep = -1;
-
- /**
- * The Shading object comprising the Type 2 pattern
- */
- protected PDFShading shading = null;
-
- /**
- * Vector of Integers represetning the Extended unique Identifier
- */
- protected Vector xUID = null;
-
- /**
- * String representing the extended Graphics state.
- * Probably will never be used like this.
- */
- protected StringBuffer extGState =
- null; // eventually, need a PDFExtGSState object... but not now.
-
- /**
- * Vector of Doubles representing the Transformation matrix.
- */
- protected Vector matrix = null;
-
- /**
- * The stream of a pattern
- */
- protected StringBuffer patternDataStream = null;
-
-
- /**
- * Create a tiling pattern (type 1).
- *
- * @param theNumber The object number of this PDF Object
- * @param thePatternName The name of the pattern such as "Pa1" or "Pattern1"
- * @param theResources the resources associated with this pattern
- * @param thePatternType the type of pattern, which is 1 for tiling.
- * @param thePaintType 1 or 2, colored or uncolored.
- * @param theTilingType 1, 2, or 3, constant spacing, no distortion, or faster tiling
- * @param theBBox Vector of Doubles: The pattern cell bounding box
- * @param theXStep horizontal spacing
- * @param theYStep vertical spacing
- * @param theMatrix Optional Vector of Doubles transformation matrix
- * @param theXUID Optional vector of Integers that uniquely identify the pattern
- * @param thePatternDataStream The stream of pattern data to be tiled.
- */
- public PDFPattern(int theNumber, String thePatternName,
- PDFResources theResources, int thePatternType, // 1
- int thePaintType, int theTilingType, Vector theBBox, double theXStep,
- double theYStep, Vector theMatrix, Vector theXUID,
- StringBuffer thePatternDataStream) {
- super(theNumber);
- this.patternName = thePatternName;
-
- this.resources = theResources;
- // This next parameter is implicit to all constructors, and is
- // not directly passed.
-
- this.patternType = 1; // thePatternType;
- this.paintType = thePaintType;
- this.tilingType = theTilingType;
- this.bBox = theBBox;
- this.xStep = theXStep;
- this.yStep = theYStep;
- this.matrix = theMatrix;
- this.xUID = theXUID;
- this.patternDataStream = thePatternDataStream;
- }
-
- /**
- * Create a type 2 pattern (smooth shading)
- *
- * @param theNumber the object number of this PDF object
- * @param thePatternName the name of the pattern
- * @param thePatternType the type of the pattern, which is 2, smooth shading
- * @param theShading the PDF Shading object that comprises this pattern
- * @param theXUID optional:the extended unique Identifier if used.
- * @param theExtGState optional: the extended graphics state, if used.
- * @param theMatrix Optional:Vector of Doubles that specify the matrix.
- */
- public PDFPattern(int theNumber, String thePatternName,
- int thePatternType, PDFShading theShading,
- Vector theXUID, StringBuffer theExtGState,
- Vector theMatrix) {
- super(theNumber);
-
- this.patternName = thePatternName;
-
- this.patternType = 2; // thePatternType;
- this.shading = theShading;
- this.xUID = theXUID;
- // this isn't really implemented, so it should always be null.
- // I just don't want to have to add a new parameter once it is implemented.
- this.extGState = theExtGState; // always null
- this.matrix = theMatrix;
- }
-
- /**
- * Get the name of the pattern
- *
- * @return String representing the name of the pattern.
- */
- public String getName() {
- return (this.patternName);
- }
-
- public String getColorSpaceOut(boolean fillNotStroke) {
- if (fillNotStroke) { // fill but no stroke
- return ("/Pattern cs /" + this.getName() + " scn \n");
- } else { // stroke (or border)
- return ("/Pattern CS /" + this.getName() + " SCN \n");
- }
- }
-
-
- /**
- * represent as PDF. Whatever the FunctionType is, the correct
- * representation spits out. The sets of required and optional
- * attributes are different for each type, but if a required
- * attribute's object was constructed as null, then no error
- * is raised. Instead, the malformed PDF that was requested
- * by the construction is dutifully output.
- * This policy should be reviewed.
- *
- * @return the PDF string.
- */
- public byte[] toPDF() {
-
-
- int vectorSize = 0;
- int tempInt = 0;
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation
- + " obj\n<< \n/Type /Pattern \n");
-
- if (this.resources != null) {
- p.append("/Resources " + this.resources.referencePDF() + " \n");
- }
-
- p.append("/PatternType " + this.patternType + " \n");
-
- if (this.patternType == 1) {
- p.append("/PaintType " + this.paintType + " \n");
- p.append("/TilingType " + this.tilingType + " \n");
-
- if (this.bBox != null) {
- vectorSize = this.bBox.size();
- p.append("/BBox [ ");
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.bBox.elementAt(tempInt)));
- p.append(" ");
- }
- p.append("] \n");
- }
- p.append("/XStep " + PDFNumber.doubleOut(new Double(this.xStep))
- + " \n");
- p.append("/YStep " + PDFNumber.doubleOut(new Double(this.yStep))
- + " \n");
-
- if (this.matrix != null) {
- vectorSize = this.matrix.size();
- p.append("/Matrix [ ");
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.matrix.elementAt(tempInt)));
- p.append(" ");
- }
- p.append("] \n");
- }
-
- if (this.xUID != null) {
- vectorSize = this.xUID.size();
- p.append("/XUID [ ");
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(((Integer)this.xUID.elementAt(tempInt)) + " ");
- }
- p.append("] \n");
- }
- // don't forget the length of the stream.
- if (this.patternDataStream != null) {
- p.append("/Length " + (this.patternDataStream.length() + 1)
- + " \n");
- }
-
- } else // if (this.patternType ==2)
- { // Smooth Shading...
- if (this.shading != null) {
- p.append("/Shading " + this.shading.referencePDF() + " \n");
- }
-
- if (this.xUID != null) {
- vectorSize = this.xUID.size();
- p.append("/XUID [ ");
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(((Integer)this.xUID.elementAt(tempInt)) + " ");
- }
- p.append("] \n");
- }
-
- if (this.extGState
- != null) { // will probably have to change this if it's used.
- p.append("/ExtGState " + this.extGState + " \n");
- }
-
- if (this.matrix != null) {
- vectorSize = this.matrix.size();
- p.append("/Matrix [ ");
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.matrix.elementAt(tempInt)));
- p.append(" ");
- }
- p.append("] \n");
- }
- } // end of if patterntype =1...else 2.
-
- p.append(">> \n");
-
- // stream representing the function
- if (this.patternDataStream != null) {
- p.append("stream\n" + this.patternDataStream + "\nendstream\n");
- }
-
- p.append("endobj\n");
-
-
-
- return (p.toString().getBytes());
-
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class representing a rectangle
- *
- * Rectangles are specified on page 183 of the PDF 1.3 spec.
- */
-public class PDFRectangle {
-
- /**
- * lower left x coordinate
- */
- protected int llx;
-
- /**
- * lower left y coordinate
- */
- protected int lly;
-
- /**
- * upper right x coordinate
- */
- protected int urx;
-
- /**
- * upper right y coordinate
- */
- protected int ury;
-
- /**
- * create a rectangle giving the four separate values
- *
- * @param llx lower left x coordinate
- * @param lly lower left y coordinate
- * @param urx upper right x coordinate
- * @param ury upper right y coordinate
- */
- public PDFRectangle(int llx, int lly, int urx, int ury) {
- this.llx = llx;
- this.lly = lly;
- this.urx = urx;
- this.ury = ury;
- }
-
- /**
- * create a rectangle giving an array of four values
- *
- * @param array values in the order llx, lly, urx, ury
- */
- public PDFRectangle(int[] array) {
- this.llx = array[0];
- this.lly = array[1];
- this.urx = array[2];
- this.ury = array[3];
- }
-
- /**
- * produce the PDF representation for the object
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- return toPDFString().getBytes();
- }
-
- public String toPDFString() {
- return new String(" [" + llx + " " + lly + " " + urx + " " + ury
- + "] ");
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.io.PrintWriter;
-import java.util.Enumeration;
-import java.util.Vector;
-import java.util.Hashtable;
-
-/**
- * class representing a /Resources object.
- *
- * /Resources object contain a list of references to the fonts for the
- * document
- */
-public class PDFResources extends PDFObject {
-
- /**
- * /Font objects keyed by their internal name
- */
- protected Hashtable fonts = new Hashtable();
-
- protected Vector xObjects = null;
- protected Vector patterns = new Vector();
- protected Vector shadings = new Vector();
-
- /**
- * create a /Resources object.
- *
- * @param number the object's number
- */
- public PDFResources(int number) {
-
- /* generic creation of object */
- super(number);
-
- }
-
- /**
- * add font object to resources list.
- *
- * @param font the PDFFont to add
- */
- public void addFont(PDFFont font) {
- this.fonts.put(font.getName(), font);
- }
-
- public void addShading(PDFShading theShading) {
- this.shadings.addElement(theShading);
- }
-
- public void addPattern(PDFPattern thePattern) {
- this.patterns.addElement(thePattern);
- }
-
- public void setXObjects(Vector xObjects) {
- this.xObjects = xObjects;
- }
-
- /**
- * represent the object in PDF
- *
- * @return the PDF
- */
- public byte[] toPDF() {
- StringBuffer p = new StringBuffer(this.number + " " + this.generation
- + " obj\n<< \n");
- if (!this.fonts.isEmpty()) {
- p.append("/Font << ");
-
- /* construct PDF dictionary of font object references */
- Enumeration fontEnumeration = this.fonts.keys();
- while (fontEnumeration.hasMoreElements()) {
- String fontName = (String)fontEnumeration.nextElement();
- p.append("/" + fontName + " "
- + ((PDFFont)this.fonts.get(fontName)).referencePDF()
- + " ");
- }
-
- p.append(">> \n");
- }
-
- PDFShading currentShading = null;
- if (!this.shadings.isEmpty()) {
- p.append("/Shading << ");
-
- for (int currentShadingNumber = 0;
- currentShadingNumber < this.shadings.size();
- currentShadingNumber++) {
- currentShading =
- ((PDFShading)this.shadings.elementAt(currentShadingNumber));
-
- p.append("/" + currentShading.getName() + " "
- + currentShading.referencePDF() + " "); // \n ??????
- }
-
- p.append(">> \n");
- }
- // "free" the memory. Sorta.
- currentShading = null;
-
- PDFPattern currentPattern = null;
- if (!this.patterns.isEmpty()) {
- p.append("/Pattern << ");
-
- for (int currentPatternNumber = 0;
- currentPatternNumber < this.patterns.size();
- currentPatternNumber++) {
- currentPattern =
- ((PDFPattern)this.patterns.elementAt(currentPatternNumber));
-
- p.append("/" + currentPattern.getName() + " "
- + currentPattern.referencePDF() + " ");
- }
-
- p.append(">> \n");
- }
- // "free" the memory. Sorta.
- currentPattern = null;
-
- p.append("/ProcSet [ /PDF /ImageC /Text ] ");
-
- if (!this.xObjects.isEmpty()) {
- p = p.append("/XObject <<");
- for (int i = 1; i <= this.xObjects.size(); i++) {
- p = p.append("/Im" + i + " "
- + ((PDFXObject)this.xObjects.elementAt(i - 1)).referencePDF()
- + " \n");
- }
- p = p.append(" >>\n");
- }
-
- p = p.append(">> \nendobj\n");
-
- return p.toString().getBytes();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.io.IOException;
-import java.io.PrintWriter;
-
-/**
- * class representing a Root (/Catalog) object
- */
-public class PDFRoot extends PDFObject {
-
- /**
- * the /Pages object that is root of the Pages hierarchy
- */
- protected PDFPages rootPages;
-
- /**
- * Root outline object
- */
- private PDFOutline _outline;
-
- /**
- * create a Root (/Catalog) object. NOTE: The PDFRoot
- * object must be created before the PDF document is
- * generated, but it is not assigned an object ID until
- * it is about to be written (immediately before the xref
- * table as part of the trsailer). (mark-fop@inomial.com)
- *
- * @param number the object's number
- */
- public PDFRoot(int number, PDFPages pages) {
- super(number);
- setRootPages(pages);
- }
-
- /**
- * Before the root is written to the document stream,
- * make sure it's object number is set. Package-private access
- * only; outsiders should not be fiddling with this stuff.
- */
- void setNumber(int number) {
- this.number = number;
- }
-
- /**
- * add a /Page object to the root /Pages object
- *
- * @param page the /Page object to add
- */
- public void addPage(PDFPage page) {
- this.rootPages.addPage(page);
- }
-
- /**
- * set the root /Pages object
- *
- * @param pages the /Pages object to set as root
- */
- public void setRootPages(PDFPages pages) {
- this.rootPages = pages;
- }
-
- public void setRootOutline(PDFOutline outline) {
- _outline = outline;
- }
-
- public PDFOutline getRootOutline() {
- return _outline;
- }
-
-
- /**
- * represent the object as PDF.
- *
- * @throws IllegalStateException if the setNumber() method has
- * not been called.
- *
- * @return the PDF string
- */
- public byte[] toPDF()
- throws IllegalStateException {
- StringBuffer p = new StringBuffer(this.number + " " + this.generation
- + " obj\n<< /Type /Catalog\n/Pages "
- + this.rootPages.referencePDF()
- + "\n");
- if (_outline != null) {
- p.append(" /Outlines " + _outline.referencePDF() + "\n");
- p.append(" /PageMode /UseOutlines\n");
-
- }
- p.append(" >>\nendobj\n");
- return p.toString().getBytes();
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-// Java...
-import java.util.Vector;
-
-// FOP
-import org.apache.fop.datatypes.ColorSpace;
-
-/**
- * class representing a PDF Smooth Shading object.
- *
- * PDF Functions represent parameterized mathematical formulas and sampled representations with
- * arbitrary resolution. Functions are used in two areas: device-dependent
- * rasterization information for halftoning and transfer
- * functions, and color specification for smooth shading (a PDF 1.3 feature).
- *
- * All PDF Functions have a shadingType (0,2,3, or 4), a Domain, and a Range.
- */
-public class PDFShading extends PDFObject {
- // Guts common to all function types
-
- /**
- * The name of the Shading e.g. "Shading1"
- */
- protected String shadingName = null;
-
- /**
- * Required: The Type of shading (1,2,3,4,5,6,7)
- */
- protected int shadingType = 3; // Default
-
- /**
- * A ColorSpace representing the colorspace. "DeviceRGB" is an example.
- */
- // protected StringBuffer colorSpace = null;
- protected ColorSpace colorSpace = null;
-
- /**
- * The background color. Since shading is opaque,
- * this is very rarely used.
- */
- protected Vector background = null;
-
- /**
- * Optional: A Vector specifying the clipping rectangle
- */
- protected Vector bBox = null;
-
- /**
- * Optional: A flag whether or not to filter the shading function
- * to prevent aliasing artifacts. Default is false.
- */
- protected boolean antiAlias = false;
-
- /**
- * Optional for Type 1: Array of four numbers, xmin, xmax, ymin, ymax. Default is [0 1 0 1]
- * Optional for Type 2: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
- * Optional for Type 3: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
- */
-
- protected Vector domain = null;
-
- /**
- * Optional for Type 1: A transformation matrix
- */
- protected Vector matrix = null;
-
- /**
- * Required for Type 1, 2, and 3:
- * The object of the color mapping function (usually type 2 or 3).
- * Optional for Type 4,5,6, and 7: When it's nearly the same thing.
- */
- protected PDFFunction function = null;
-
- /**
- * Required for Type 2: An Array of four numbers specifying the starting and ending coordinate pairs
- * Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1] specifying the centers and radii of
- * the starting and ending circles.
- */
- protected Vector coords = null;
-
- /**
- * Required for Type 2+3: An Array of two boolean values specifying whether to extend the
- * start and end colors past the start and end points,
- * respectively. Default is false, false.
- */
- protected Vector extend = null;
-
- /**
- * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate.
- * Allowed to be 1,2,4,8,12,16,24, or 32.
- */
- protected int bitsPerCoordinate = 0;
-
- /**
- * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent the edge flag for each vertex.
- * Allowed to be 2,4,or 8, while the Edge flag itself is allowed to be 0,1 or 2.
- */
- protected int bitsPerFlag = 0;
-
- /**
- * Required for Type 4,5,6, and 7: Array of Doubles which specifies how to decode coordinate and color component values.
- * Each type has a differing number of decode array members, so check the spec.
- * Page 303 in PDF Spec 1.3
- */
- protected Vector decode = null;
-
- /**
- * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate.
- * Allowed to be 1,2,4,8,12, or 16
- */
- protected int bitsPerComponent = 0;
-
- /**
- * Required for Type 5:The number of vertices in each "row" of the lattice; it must be greater than or equal to 2.
- */
- protected int verticesPerRow = 0;
-
- /**
- * Constructor for type function based shading
- *
- * @param theNumber The object number of this PDF object
- * @param theShadingName The name of the shading pattern. Can be anything
- * without spaces. "Shading1" or "Sh1" are good examples.
- * @param theShadingType The type of shading object, which should be 1 for function
- * based shading.
- * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
- * @param theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Whether or not to anti-alias.
- * @param theDomain Optional vector of Doubles specifying the domain.
- * @param theMatrix Vector of Doubles specifying the matrix.
- * If it's a pattern, then the matrix maps it to pattern space.
- * If it's a shading, then it maps it to current user space.
- * It's optional, the default is the identity matrix
- * @param theFunction The PDF Function that maps an (x,y) location to a color
- */
- public PDFShading(int theNumber, String theShadingName,
- int theShadingType, ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias, Vector theDomain,
- Vector theMatrix, PDFFunction theFunction) {
- super(theNumber);
- this.shadingName = theShadingName;
- this.shadingType = theShadingType; // 1
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.domain = theDomain;
- this.matrix = theMatrix;
- this.function = theFunction;
-
- }
-
- /**
- * Constructor for Type 2 and 3
- *
- * @param theNumber The object number of this PDF object.
- * @param theShadingName The name of the shading pattern. Can be anything
- * without spaces. "Shading1" or "Sh1" are good examples.
- * @param theShadingType 2 or 3 for axial or radial shading
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theCoords Vector of four (type 2) or 6 (type 3) Double
- * @param theDomain Vector of Doubles specifying the domain
- * @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function
- * @param theExtend Vector of Booleans of whether to extend teh start and end colors past the start and end points
- * The default is [false, false]
- */
- public PDFShading(int theNumber, String theShadingName,
- int theShadingType, ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias, Vector theCoords,
- Vector theDomain, PDFFunction theFunction,
- Vector theExtend) {
- super(theNumber);
- this.shadingName = theShadingName;
- this.shadingType = theShadingType; // 2 or 3
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.coords = theCoords;
- this.domain = theDomain;
- this.function = theFunction;
- this.extend = theExtend;
-
- }
-
- /**
- * Constructor for Type 4,6, or 7
- *
- * @param theNumber The object number of this PDF object.
- * @param theShadingType 4, 6, or 7 depending on whether it's
- * Free-form gouraud-shaded triangle meshes, coons patch meshes,
- * or tensor product patch meshes, respectively.
- * @param theShadingName The name of the shading pattern. Can be anything
- * without spaces. "Shading1" or "Sh1" are good examples.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32.
- * @param theBitsPerComponent 1,2,4,8,12, and 16
- * @param theBitsPerFlag 2,4,8.
- * @param theDecode Vector of Doubles see PDF 1.3 spec pages 303 to 312.
- * @param theFunction the PDFFunction
- */
- public PDFShading(int theNumber, String theShadingName,
- int theShadingType, ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, int theBitsPerFlag,
- Vector theDecode, PDFFunction theFunction) {
- super(theNumber);
-
- this.shadingType = theShadingType; // 4,6 or 7
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.bitsPerCoordinate = theBitsPerCoordinate;
- this.bitsPerComponent = theBitsPerComponent;
- this.bitsPerFlag = theBitsPerFlag;
- this.decode = theDecode;
- this.function = theFunction;
- }
-
- /**
- * Constructor for type 5
- *
- * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
- * @param theShadingName The name of the shading pattern. Can be anything
- * without spaces. "Shading1" or "Sh1" are good examples.
- * @param theColorSpace "DeviceRGB" or similar.
- * @param theBackground theBackground An array of color components appropriate to the
- * colorspace key specifying a single color value.
- * This key is used by the f operator buy ignored by the sh operator.
- * @param theBBox Vector of double's representing a rectangle
- * in the coordinate space that is current at the
- * time of shading is imaged. Temporary clipping
- * boundary.
- * @param theAntiAlias Default is false
- * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32
- * @param theBitsPerComponent 1,2,4,8,12,24,32
- * @param theDecode Vector of Doubles. See page 305 in PDF 1.3 spec.
- * @param theVerticesPerRow number of vertices in each "row" of the lattice.
- * @param theFunction The PDFFunction that's mapped on to this shape
- * @param theNumber the object number of this PDF object.
- */
- public PDFShading(int theNumber, String theShadingName,
- int theShadingType, ColorSpace theColorSpace,
- Vector theBackground, Vector theBBox,
- boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, Vector theDecode,
- int theVerticesPerRow, PDFFunction theFunction) {
- super(theNumber);
- this.shadingName = theShadingName;
- this.shadingType = theShadingType; // 5
- this.colorSpace = theColorSpace;
- this.background = theBackground;
- this.bBox = theBBox;
- this.antiAlias = theAntiAlias;
-
- this.bitsPerCoordinate = theBitsPerCoordinate;
- this.bitsPerComponent = theBitsPerComponent;
- this.decode = theDecode;
- this.verticesPerRow = theVerticesPerRow;
- this.function = theFunction;
-
- }
-
- public String getName() {
- return (this.shadingName);
- }
-
- /**
- * represent as PDF. Whatever the shadingType is, the correct
- * representation spits out. The sets of required and optional
- * attributes are different for each type, but if a required
- * attribute's object was constructed as null, then no error
- * is raised. Instead, the malformed PDF that was requested
- * by the construction is dutifully output.
- * This policy should be reviewed.
- *
- * @return the PDF string.
- */
- public byte[] toPDF() {
- int vectorSize;
- int tempInt;
- StringBuffer p = new StringBuffer();
- p.append(this.number + " " + this.generation
- + " obj\n<< \n/ShadingType " + this.shadingType + " \n");
- if (this.colorSpace != null) {
- p.append("/ColorSpace /"
- + this.colorSpace.getColorSpacePDFString() + " \n");
- }
-
- if (this.background != null) {
- p.append("/Background [ ");
- vectorSize = this.background.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.background.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
-
- if (this.bBox
- != null) { // I've never seen an example, so I guess this is right.
- p.append("/BBox [ ");
- vectorSize = this.bBox.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.bBox.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
-
- if (this.antiAlias) {
- p.append("/AntiAlias " + this.antiAlias + " \n");
- }
-
- // Here's where we differentiate based on what type it is.
- if (this.shadingType == 1) { // function based shading
- if (this.domain != null) {
- p.append("/Domain [ ");
- vectorSize = this.domain.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- if (this.matrix != null) {
- p.append("/Matrix [ ");
- vectorSize = this.matrix.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.matrix.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
- } else if ((this.shadingType == 2)
- || (this.shadingType
- == 3)) { // 2 is axial shading (linear gradient)
- // 3 is radial shading (circular gradient)
- if (this.coords != null) {
- p.append("/Coords [ ");
- vectorSize = this.coords.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.coords.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- }
-
- // DOMAIN
- if (this.domain != null) {
- p.append("/Domain [ ");
- vectorSize = this.domain.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(PDFNumber.doubleOut((Double)this.domain.elementAt(tempInt))
- + " ");
- }
- p.append("] \n");
- } else {
- p.append("/Domain [ 0 1 ] \n");
- }
-
- if (this.extend != null) {
- p.append("/Extend [ ");
- vectorSize = this.extend.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(((Boolean)this.extend.elementAt(tempInt)) + " ");
- }
-
- p.append("] \n");
- } else {
- p.append("/Extend [ true true ] \n");
- }
-
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
-
-
- } else if ((this.shadingType == 4) || (this.shadingType == 6)
- || (this.shadingType
- == 7)) { // 4:Free-form Gouraud-shaded triangle meshes
- // 6:coons patch meshes
- // 7://tensor product patch meshes (which no one ever uses)
- if (this.bitsPerCoordinate > 0) {
- p.append("/BitsPerCoordinate " + this.bitsPerCoordinate
- + " \n");
- } else {
- p.append("/BitsPerCoordinate 1 \n");
- }
-
- if (this.bitsPerComponent > 0) {
- p.append("/BitsPerComponent " + this.bitsPerComponent
- + " \n");
- } else {
- p.append("/BitsPerComponent 1 \n");
- }
-
- if (this.bitsPerFlag > 0) {
- p.append("/BitsPerFlag " + this.bitsPerFlag + " \n");
- } else {
- p.append("/BitsPerFlag 2 \n");
- }
-
- if (this.decode != null) {
- p.append("/Decode [ ");
- vectorSize = this.decode.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(((Boolean)this.decode.elementAt(tempInt)) + " ");
- }
-
- p.append("] \n");
- }
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
-
- } else if (this.shadingType
- == 5) { // Lattice Free form gouraud-shaded triangle mesh
-
- if (this.bitsPerCoordinate > 0) {
- p.append("/BitsPerCoordinate " + this.bitsPerCoordinate
- + " \n");
- } else {
- p.append("/BitsPerCoordinate 1 \n");
- }
-
- if (this.bitsPerComponent > 0) {
- p.append("/BitsPerComponent " + this.bitsPerComponent
- + " \n");
- } else {
- p.append("/BitsPerComponent 1 \n");
- }
-
- if (this.decode != null) {
- p.append("/Decode [ ");
- vectorSize = this.decode.size();
- for (tempInt = 0; tempInt < vectorSize; tempInt++) {
- p.append(((Boolean)this.decode.elementAt(tempInt)) + " ");
- }
-
- p.append("] \n");
- }
-
- if (this.function != null) {
- p.append("/Function ");
- p.append(this.function.referencePDF() + " \n");
- }
-
- if (this.verticesPerRow > 0) {
- p.append("/VerticesPerRow " + this.verticesPerRow + " \n");
- } else {
- p.append("/VerticesPerRow 2 \n");
- }
-
- }
-
- p.append(">> \nendobj\n");
-
- return (p.toString().getBytes());
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.util.Vector;
-import java.util.Enumeration;
-import org.apache.fop.configuration.Configuration;
-import org.apache.fop.messaging.MessageHandler;
-
-/**
- * class representing a PDF stream.
- *
- * A derivative of the PDF Object, a PDF Stream has not only a dictionary
- * but a stream of PDF commands. The stream of commands is where the real
- * work is done, the dictionary just provides information like the stream
- * length.
- */
-public class PDFStream extends PDFObject {
-
- /**
- * the stream of PDF commands
- */
- protected ByteArrayOutputStream _data;
-
- /**
- * the filters that should be applied
- */
- private Vector _filters;
-
- /**
- * create an empty stream object
- *
- * @param number the object's number
- */
- public PDFStream(int number) {
- super(number);
- _data = new ByteArrayOutputStream();
- _filters = new Vector();
- }
-
- /**
- * append data to the stream
- *
- * @param s the string of PDF to add
- */
- public void add(String s) {
- try {
- _data.write(s.getBytes());
- } catch (IOException ex) {
- ex.printStackTrace();
- }
-
- }
-
- /**
- * Add a filter for compression of the stream. Filters are
- * applied in the order they are added. This should always be a
- * new instance of the particular filter of choice. The applied
- * flag in the filter is marked true after it has been applied to the
- * data.
- */
- public void addFilter(PDFFilter filter) {
- if (filter != null) {
- _filters.addElement(filter);
- }
-
- }
-
- public void addFilter(String filterType) {
- if (filterType == null) {
- return;
- }
- if (filterType.equals("flate")) {
- addFilter(new FlateFilter());
- } else if (filterType.equals("ascii-85")) {
- addFilter(new ASCII85Filter());
- } else if (filterType.equals("ascii-hex")) {
- addFilter(new ASCIIHexFilter());
- } else if (filterType.equals("")) {
- return;
- } else {
- MessageHandler.errorln("Unsupported filter type in stream-filter-list: "
- + filterType);
- }
- }
-
-
- protected void addDefaultFilters() {
- Vector filters = Configuration.getListValue("stream-filter-list",
- Configuration.PDF);
- if (filters == null) {
- // try getting it as a String
- String filter = Configuration.getStringValue("stream-filter-list",
- Configuration.PDF);
- if (filter == null) {
- // built-in default to flate
- addFilter(new FlateFilter());
- } else {
- addFilter(filter);
- }
- } else {
- for (int i = 0; i < filters.size(); i++) {
- String v = (String)filters.elementAt(i);
- addFilter(v);
- }
- }
- }
-
-
- /**
- * append an array of xRGB pixels, ASCII Hex Encoding it first
- *
- * @param pixels the area of pixels
- * @param width the width of the image in pixels
- * @param height the height of the image in pixels
- */
- public void addImageArray(int[] pixels, int width, int height) {
- try {
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int p = pixels[i * width + j];
- int r = (p >> 16) & 0xFF;
- int g = (p >> 8) & 0xFF;
- int b = (p) & 0xFF;
- if (r < 16) {
- _data.write('0');
- }
- _data.write(Integer.toHexString(r).getBytes());
- if (g < 16) {
- _data.write('0');
- }
- _data.write(Integer.toHexString(g).getBytes());
- if (b < 16) {
- _data.write('0');
- }
- _data.write(Integer.toHexString(b).getBytes());
- _data.write(' ');
- }
- }
- _data.write(">\n".getBytes());
- } catch (IOException ex) {
- ex.printStackTrace();
- }
-
- }
-
- public void setData(byte[] data) throws IOException {
- _data.reset();
- _data.write(data);
- }
-
- public byte[] getData() {
- return _data.toByteArray();
- }
-
- public int getDataLength() {
- return _data.size();
- }
-
-
-
- /**
- * represent as PDF.
- *
- * @return the PDF string.
- */
- /*
- * public byte[] toPDF() {
- * byte[] d = _data.toByteArray();
- * ByteArrayOutputStream s = new ByteArrayOutputStream();
- * String p = this.number + " " + this.generation
- * + " obj\n<< /Length " + (d.length+1)
- * + " >>\nstream\n";
- * s.write(p.getBytes());
- * s.write(d);
- * s.write("\nendstream\nendobj\n".getBytes());
- * return s.toByteArray();
- * }
- */
- public byte[] toPDF() {
- throw new RuntimeException();
- }
-
-
- // overload the base object method so we don't have to copy
- // byte arrays around so much
- protected int output(OutputStream stream) throws IOException {
- int length = 0;
- String filterEntry = applyFilters();
- byte[] p = (this.number + " " + this.generation + " obj\n<< /Length "
- + (_data.size() + 1) + " " + filterEntry
- + " >>\n").getBytes();
-
- stream.write(p);
- length += p.length;
- length += outputStreamData(stream);
- p = "endobj\n".getBytes();
- stream.write(p);
- length += p.length;
- return length;
-
- }
-
- /**
- * Output just the stream data enclosed by stream/endstream markers
- */
- protected int outputStreamData(OutputStream stream) throws IOException {
- int length = 0;
- byte[] p = "stream\n".getBytes();
- stream.write(p);
- length += p.length;
- _data.writeTo(stream);
- length += _data.size();
- p = "\nendstream\n".getBytes();
- stream.write(p);
- length += p.length;
- return length;
-
- }
-
-
- /**
- * Apply the filters to the data
- * in the order given and return the /Filter and /DecodeParms
- * entries for the stream dictionary. If the filters have already
- * been applied to the data (either externally, or internally)
- * then the dictionary entries are built and returned.
- */
- protected String applyFilters() throws IOException {
- if (_filters.size() > 0) {
- Vector names = new Vector();
- Vector parms = new Vector();
-
- // run the filters
- Enumeration e = _filters.elements();
- while (e.hasMoreElements()) {
- PDFFilter filter = (PDFFilter)e.nextElement();
- // apply the filter encoding if neccessary
- if (!filter.isApplied()) {
- byte[] tmp = filter.encode(_data.toByteArray());
- _data.reset();
- _data.write(tmp);
- filter.setApplied(true);
- }
- // place the names in our local vector in reverse order
- names.insertElementAt(filter.getName(), 0);
- parms.insertElementAt(filter.getDecodeParms(), 0);
- }
-
- // now build up the filter entries for the dictionary
- return buildFilterEntries(names) + buildDecodeParms(parms);
- }
- return "";
-
- }
-
- private String buildFilterEntries(Vector names) {
- StringBuffer sb = new StringBuffer();
- sb.append("/Filter ");
- if (names.size() > 1) {
- sb.append("[ ");
- }
- Enumeration e = names.elements();
- while (e.hasMoreElements()) {
- sb.append((String)e.nextElement());
- sb.append(" ");
- }
- if (names.size() > 1) {
- sb.append("]");
- }
- sb.append("\n");
- return sb.toString();
- }
-
- private String buildDecodeParms(Vector parms) {
- StringBuffer sb = new StringBuffer();
- boolean needParmsEntry = false;
- sb.append("/DecodeParms ");
-
- if (parms.size() > 1) {
- sb.append("[ ");
- }
- Enumeration e = parms.elements();
- while (e.hasMoreElements()) {
- String s = (String)e.nextElement();
- if (s != null) {
- sb.append(s);
- needParmsEntry = true;
- } else {
- sb.append("null");
- }
- sb.append(" ");
- }
- if (parms.size() > 1) {
- sb.append("]");
- }
- sb.append("\n");
- if (needParmsEntry) {
- return sb.toString();
- } else {
- return "";
- }
- }
-
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-public class PDFT1Stream extends PDFStream {
- private int origLength;
- private int len1, len3;
- private byte[] originalData = null;
-
- public PDFT1Stream(int num, int len) {
- super(num);
- origLength = len;
- }
-
- private final static boolean byteCmp(byte[] src, int offset, byte[] cmp) {
- boolean ret = true;
- for (int i = 0; ret == true && i < cmp.length; i++) {
- // System.out.println("Compare: ");
- // System.out.println(" "+src[offset+i]+" "+cmp[i]);
- if (src[offset + i] != cmp[i])
- ret = false;
- }
- return ret;
- }
-
- /**
- * calculates the Length1 and Length3 PDFStream attributes for type1
- * font embedding
- */
- private void calcLengths(byte[] originalData) {
- // Calculate length 1 and 3
- // System.out.println ("Checking font, size = "+originalData.length);
-
- // Length1 is the size of the initial ascii portion
- // search for "currentfile eexec"
- // Get the first binary number and search backwards for "eexec"
- len1 = 30;
-
- byte[] eexec = (new String("currentfile eexec")).getBytes();
- // System.out.println("Length1="+len1);
- while (!byteCmp(originalData, len1 - eexec.length, eexec))
- len1++;
- // Skip newline
- len1++;
-
- // Length3 is length of the last portion of the file
- len3 = 0;
- byte[] cltom = (new String("cleartomark")).getBytes();
- len3 -= cltom.length;
- while (!byteCmp(originalData, origLength + len3, cltom)) {
- len3--;
- // System.out.println("Len3="+len3);
- }
- len3 = -len3;
- len3++;
- // Eat 512 zeroes
- int numZeroes = 0;
- byte[] ws1 = "\n".getBytes();
- byte[] ws2 = "\r".getBytes();
- byte[] ws3 = "0".getBytes();
- while ((originalData[origLength - len3] == ws1[0] || originalData[origLength - len3] == ws2[0] || originalData[origLength - len3] == ws3[0])
- && numZeroes < 512) {
- len3++;
- if (originalData[origLength - len3] == ws3[0])
- numZeroes++;
- }
- // System.out.println("Length3="+len3);
- }
-
- // overload the base object method so we don't have to copy
- // byte arrays around so much
- protected int output(java.io.OutputStream stream)
- throws java.io.IOException {
- int length = 0;
- String filterEntry = applyFilters();
- String preData = new String(this.number + " " + this.generation
- + " obj\n<< /Length "
- + (_data.size() + 1) + " " + filterEntry
- + " " + "/Length1 " + len1 + " /Length2 "
- + (origLength - len3 - len1)
- + " /Length3 " + len3 + " >>\n");
-
- byte[] p = preData.getBytes();
- stream.write(p);
- length += p.length;
-
- length += outputStreamData(stream);
- p = "endobj\n".getBytes();
- stream.write(p);
- length += p.length;
- System.out.println("Embedded Type1 font");
- return length;
- }
-
- public void setData(byte[] data, int size) throws java.io.IOException {
- calcLengths(data);
- _data.reset();
- // System.out.println("Writing " + size + " bytes of font data");
- _data.write(data, 0, size);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-public class PDFTTFStream extends PDFStream {
- private int origLength;
-
- public PDFTTFStream(int num, int len) {
- super(num);
- origLength = len;
- }
-
- // overload the base object method so we don't have to copy
- // byte arrays around so much
- protected int output(java.io.OutputStream stream)
- throws java.io.IOException {
- int length = 0;
- String filterEntry = applyFilters();
- String preData = new String(this.number + " " + this.generation
- + " obj\n<< /Length "
- + (_data.size() + 1) + " " + filterEntry
- + " " + "/Length1 " + origLength
- + " >>\n");
-
- byte[] p = preData.getBytes();
- stream.write(p);
- length += p.length;
-
- length += outputStreamData(stream);
- p = "endobj\n".getBytes();
- stream.write(p);
- length += p.length;
- return length;
- }
-
- public void setData(byte[] data, int size) throws java.io.IOException {
- _data.reset();
- System.out.println("Writing " + size + " bytes of font data");
- _data.write(data, 0, size);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-/**
- * class used to create a PDF Uri link
- */
-public class PDFUri extends PDFAction {
-
-
- String uri;
-
- /**
- * create a Uri instance.
- *
- * @param uri the uri to which the link should point
- */
- public PDFUri(String uri) {
-
- this.uri = uri;
- }
-
- /**
- * returns the action ncecessary for a uri
- *
- * @return the action to place next to /A within a Link
- */
- public String getAction() {
- return "<< /URI (" + uri + ")\n/S /URI >>";
- }
-
- /**
- * there is nothing to return for the toPDF method, as it should not be called
- *
- * @return an empty string
- */
- public byte[] toPDF() {
- return new byte[0];
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.pdf;
-
-import java.util.Vector;
-
-/**
- * class representing a <b>W</b> array for CID fonts.
- */
-public class PDFWArray {
-
- /**
- * the metrics
- */
- private Vector entries;
-
- public PDFWArray() {
- entries = new Vector();
- }
-
- /**
- * add an entry for single starting CID.
- * i.e. in the form "c [w ...]"
- *
- * @param start the starting CID value.
- * @param metrics the metrics array.
- */
- public void addEntry(int start, int[] metrics) {
- entries.addElement(new Entry(start, metrics));
- }
-
- /**
- * add an entry for a range of CIDs (/W element on p 213)
- *
- * @param first the first CID in the range
- * @param last the last CID in the range
- * @param width the width for all CIDs in the range
- */
- public void addEntry(int first, int last, int width) {
- entries.addElement(new int[] {
- first, last, width
- });
- }
-
- /**
- * add an entry for a range of CIDs (/W2 element on p 210)
- *
- * @param first the first CID in the range
- * @param last the last CID in the range
- * @param width the width for all CIDs in the range
- * @param posX the x component for the vertical position vector
- * @param posY the y component for the vertical position vector
- */
- public void addEntry(int first, int last, int width, int posX, int posY) {
- entries.addElement(new int[] {
- first, last, width, posX, posY
- });
- }
-
- public byte[] toPDF() {
- return toPDFString().getBytes();
- }
-
- public String toPDFString() {
- StringBuffer p = new StringBuffer();
- p.append("[ ");
- int len = entries.size();
- for (int i = 0; i < len; i++) {
- Object entry = entries.elementAt(i);
- if (entry instanceof int[]) {
- int[] line = (int[])entry;
- for (int j = 0; j < line.length; j++) {
- p.append(line[j]);
- p.append(" ");
- }
- } else {
- ((Entry)entry).fillInPDF(p);
- }
- }
- p.append("]");
- return p.toString();
- }
-
- /**
- * inner class for entries in the form "c [w ...]"
- */
- private static class Entry {
- private static final StringBuffer p = new StringBuffer();
- private int start;
- private int[] metrics;
- public Entry(int s, int[] m) {
- start = s;
- metrics = m;
- }
-
- public void fillInPDF(StringBuffer p) {
- // p.setLength(0);
- p.append(start);
- p.append(" [");
- for (int i = 0; i < metrics.length; i++) {
- p.append(this.metrics[i]);
- p.append(" ");
- }
- p.append("] ");
- }
-
- }
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-/* modified by JKT to integrate with 0.12.0 */
-/* modified by Eric SCHAEFFER to integrate with 0.13.0 */
-
-package org.apache.fop.pdf;
-
-// Java
-import java.io.IOException;
-import org.apache.fop.messaging.MessageHandler;
-import java.io.OutputStream;
-
-// FOP
-import org.apache.fop.datatypes.ColorSpace;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.image.FopImageException;
-
-/**
- * PDF XObject
- *
- * A derivative of the PDF Object, is a PDF Stream that has not only a
- * dictionary but a stream of image data.
- * the dictionary just provides information like the stream length
- */
-public class PDFXObject extends PDFObject {
-
- FopImage fopimage;
- int Xnum;
-
-
- /**
- * create an Xobject with the given number and name and load the
- * image in the object
- */
- public PDFXObject(int number, int Xnumber, FopImage img) {
- super(number);
- this.Xnum = Xnumber;
- if (img == null)
- MessageHandler.errorln("FISH");
- fopimage = img;
- }
-
- /**
- * @return the PDF XObject number
- */
- public int getXNumber() {
- return this.Xnum;
- }
-
- /**
- * represent as PDF
- */
- protected int output(OutputStream stream) throws IOException {
- int length = 0;
- int i = 0;
- int x, y;
-
- try {
- // delegate the stream work to PDFStream
- PDFStream imgStream = new PDFStream(0);
-
- imgStream.setData(fopimage.getBitmaps());
- // imgStream.addFilter(new FlateFilter());
- imgStream.addDefaultFilters();
-
- String dictEntries = imgStream.applyFilters();
-
- String p = this.number + " " + this.generation + " obj\n";
- p = p + "<</Type /XObject\n";
- p = p + "/Subtype /Image\n";
- p = p + "/Name /Im" + Xnum + "\n";
- p = p + "/Length " + imgStream.getDataLength();
- p = p + "/Width " + fopimage.getWidth() + "\n";
- p = p + "/Height " + fopimage.getHeight() + "\n";
- p = p + "/BitsPerComponent " + fopimage.getBitsPerPixel() + "\n";
- ColorSpace cs = fopimage.getColorSpace();
- p = p + "/ColorSpace /" + cs.getColorSpacePDFString() + "\n";
- if (fopimage.isTransparent()) {
- PDFColor transp = fopimage.getTransparentColor();
- p = p + "/Mask [" + transp.red255() + " " + transp.red255()
- + " " + transp.green255() + " " + transp.green255() + " "
- + transp.blue255() + " " + transp.blue255() + "]\n";
- }
- p = p + dictEntries;
- p = p + ">>\n";
-
- // don't know if it's the good place (other objects can have references to it)
- fopimage.close();
-
- // push the pdf dictionary on the writer
- byte[] pdfBytes = p.getBytes();
- stream.write(pdfBytes);
- length += pdfBytes.length;
- // push all the image data on the writer and takes care of length for trailer
- length += imgStream.outputStreamData(stream);
-
- pdfBytes = ("endobj\n").getBytes();
- stream.write(pdfBytes);
- length += pdfBytes.length;
- } catch (FopImageException imgex) {
- MessageHandler.errorln("Error in XObject : "
- + imgex.getMessage());
- }
-
- return length;
- }
-
- byte[] toPDF() {
- /*
- * Not used any more
- * String p = this.number + " " + this.generation + " obj\n";
- * p = p + "<</Type /XObject\n";
- * p = p + "/Subtype /Image\n";
- * p = p + "/Name /Im"+Xnum+"\n";
- * p = p + "/Width "+fopimage.getpixelwidth()+"\n";
- * p = p + "/Height "+fopimage.getpixelheight()+"\n";
- * p = p + "/BitsPerComponent 8\n";
- * if (fopimage.getcolor())
- * p = p + "/ColorSpace /DeviceRGB\n";
- * else
- * p = p + "/ColorSpace /DeviceGray\n";
- * p = p + "/Filter /ASCIIHexDecode\n";
- * p = p + "/Length ";
- * return p;
- */
- return null;
- }
-
-}
+++ /dev/null
-/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
-
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources."
- */
-
-// PrintRenderer is an abstract base class for renderers that produce printed type output.
-// Subclasses would be PDFRenderer, PCLRenderer and similar renderers.
-
-package org.apache.fop.render;
-
-// FOP
-import org.apache.fop.pdf.PDFPathPaint;
-import org.apache.fop.pdf.PDFColor;
-// import org.apache.fop.render.Renderer;
-// import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.image.ImageArea;
-// import org.apache.fop.image.FopImage;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.layout.*;
-import org.apache.fop.layout.inline.*;
-import org.apache.fop.datatypes.*;
-// import org.apache.fop.configuration.Configuration;
-// import org.apache.fop.extensions.*;
-// import org.apache.fop.datatypes.IDReferences;
-import org.apache.fop.render.pdf.FontSetup;
-
-import org.apache.fop.svg.SVGArea;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Enumeration;
-
-/**
- * Abstract base class of "Print" type renderers.
- *
- * Modified by Mark Lillywhite mark-fop@inomial.com. Removed
- * the render(AreaTree, OutputStream) method, and added
- * no-op concrete implementation of startRenderer() and
- * stopRenderer(). The method render(Page, OutputStream)
- * is not mentioned in this class but it is inherited from
- * the Renderer interface.
- */
-public abstract class PrintRenderer implements Renderer {
- // vvv These are not currently referenced by the PrintRenderer, but are common to PCL and PDF renderers - so declare here.
-
- /**
- * the current (internal) font name
- */
- protected String currentFontName;
-
- /**
- * the current font size in millipoints
- */
- protected int currentFontSize;
-
- /**
- * the current color/gradient for borders, letters, etc.
- */
- protected PDFPathPaint currentStroke = null;
-
- /**
- * the current color/gradient to fill shapes with
- */
- protected PDFPathPaint currentFill = null;
-
- /**
- * the current colour's red component
- */
- // protected float currentRed = 0;
-
- /**
- * the current colour's green component
- */
- // protected float currentGreen = 0;
-
- /**
- * the current colour's blue component
- */
- // protected float currentBlue = 0;
- // ^^^
-
- /**
- * the current vertical position in millipoints from bottom
- */
- protected int currentYPosition = 0;
-
- /**
- * the current horizontal position in millipoints from left
- */
- protected int currentXPosition = 0;
-
- /**
- * the horizontal position of the current area container
- */
- protected int currentAreaContainerXPosition = 0;
-
- // previous values used for text-decoration drawing
- protected int prevUnderlineXEndPos;
- protected int prevUnderlineYEndPos;
- protected int prevUnderlineSize;
- protected PDFColor prevUnderlineColor;
- protected int prevOverlineXEndPos;
- protected int prevOverlineYEndPos;
- protected int prevOverlineSize;
- protected PDFColor prevOverlineColor;
- protected int prevLineThroughXEndPos;
- protected int prevLineThroughYEndPos;
- protected int prevLineThroughSize;
- protected PDFColor prevLineThroughColor;
-
- protected FontInfo fontInfo;
-
- /**
- * the IDReferences for this document
- */
- protected IDReferences idReferences;
-
- /**
- * set the document's producer
- *
- * @param producer string indicating application producing PDF
- */
- public abstract void setProducer(String producer);
-
- /**
- * add a line to the current stream
- *
- * @param x1 the start x location in millipoints
- * @param y1 the start y location in millipoints
- * @param x2 the end x location in millipoints
- * @param y2 the end y location in millipoints
- * @param th the thickness in millipoints
- * @param r the red component
- * @param g the green component
- * @param b the blue component
- */
- protected abstract void addLine(int x1, int y1, int x2, int y2, int th,
- PDFPathPaint stroke);
-
- /**
- * add a line to the current stream
- *
- * @param x1 the start x location in millipoints
- * @param y1 the start y location in millipoints
- * @param x2 the end x location in millipoints
- * @param y2 the end y location in millipoints
- * @param th the thickness in millipoints
- * @param rs the rule style
- * @param r the red component
- * @param g the green component
- * @param b the blue component
- */
- protected abstract void addLine(int x1, int y1, int x2, int y2, int th,
- int rs, PDFPathPaint stroke);
-
- /**
- * add a rectangle to the current stream
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param stroke the stroke color/gradient
- */
- protected abstract void addRect(int x, int y, int w, int h,
- PDFPathPaint stroke);
-
- /**
- * add a filled and stroked rectangle to the current stream
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param fill the fill color/gradient
- * @param stroke the stroke color/gradient
- */
- protected abstract void addRect(int x, int y, int w, int h,
- PDFPathPaint stroke, PDFPathPaint fill);
-
- /**
- * Add a filled rectangle to the current stream
- * This default implementation calls addRect
- * using the same color for fill and border.
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param fill the fill color/gradient
- */
- protected void addFilledRect(int x, int y, int w, int h,
- PDFPathPaint fill) {
- addRect(x, y, w, h, fill, fill);
- }
-
- /**
- * render area container
- *
- * @param area the area container to render
- */
- public void renderAreaContainer(AreaContainer area) {
-
- int saveY = this.currentYPosition;
- int saveX = this.currentAreaContainerXPosition;
-
- if (area.getPosition() == Position.ABSOLUTE) {
- // XPosition and YPosition give the content rectangle position
- this.currentYPosition = area.getYPosition();
- this.currentAreaContainerXPosition = area.getXPosition();
- } else if (area.getPosition() == Position.RELATIVE) {
- this.currentYPosition -= area.getYPosition();
- this.currentAreaContainerXPosition += area.getXPosition();
- } else if (area.getPosition() == Position.STATIC) {
- this.currentYPosition -= area.getPaddingTop()
- + area.getBorderTopWidth();
- /*
- * this.currentAreaContainerXPosition +=
- * area.getPaddingLeft() + area.getBorderLeftWidth();
- */
- }
-
- this.currentXPosition = this.currentAreaContainerXPosition;
- doFrame(area);
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this);
- }
- // Restore previous origin
- this.currentYPosition = saveY;
- this.currentAreaContainerXPosition = saveX;
- if (area.getPosition() == Position.STATIC) {
- this.currentYPosition -= area.getHeight();
- }
-
- /**
- * **
- * if (area.getPosition() != Position.STATIC) {
- * this.currentYPosition = saveY;
- * this.currentAreaContainerXPosition = saveX;
- * } else
- * this.currentYPosition -= area.getHeight();
- * **
- */
- }
-
- public void renderBodyAreaContainer(BodyAreaContainer area) {
- int saveY = this.currentYPosition;
- int saveX = this.currentAreaContainerXPosition;
-
- if (area.getPosition() == Position.ABSOLUTE) {
- // Y position is computed assuming positive Y axis, adjust for negative postscript one
- this.currentYPosition = area.getYPosition();
- this.currentAreaContainerXPosition = area.getXPosition();
- } else if (area.getPosition() == Position.RELATIVE) {
- this.currentYPosition -= area.getYPosition();
- this.currentAreaContainerXPosition += area.getXPosition();
- }
-
- this.currentXPosition = this.currentAreaContainerXPosition;
- int w, h;
- int rx = this.currentAreaContainerXPosition;
- w = area.getContentWidth();
- h = area.getContentHeight();
- int ry = this.currentYPosition;
- ColorType bg = area.getBackgroundColor();
-
- // I'm not sure I should have to check for bg being null
- // but I do
- if ((bg != null) && (bg.alpha() == 0)) {
- this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg));
- }
-
- // floats & footnotes stuff
- renderAreaContainer(area.getBeforeFloatReferenceArea());
- renderAreaContainer(area.getFootnoteReferenceArea());
-
- // main reference area
- Enumeration e = area.getMainReferenceArea().getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this); // span areas
- }
-
-
- if (area.getPosition() != Position.STATIC) {
- this.currentYPosition = saveY;
- this.currentAreaContainerXPosition = saveX;
- } else
- this.currentYPosition -= area.getHeight();
-
- }
-
- public void renderSpanArea(SpanArea area) {
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this); // column areas
- }
-
- }
-
- private void doFrame(Area area) {
- int w, h;
- int rx = this.currentAreaContainerXPosition;
- w = area.getContentWidth();
- if (area instanceof BlockArea)
- rx += ((BlockArea)area).getStartIndent();
- h = area.getContentHeight();
- int ry = this.currentYPosition;
- ColorType bg = area.getBackgroundColor();
-
- rx = rx - area.getPaddingLeft();
- ry = ry + area.getPaddingTop();
- w = w + area.getPaddingLeft() + area.getPaddingRight();
- h = h + area.getPaddingTop() + area.getPaddingBottom();
-
- // I'm not sure I should have to check for bg being null
- // but I do
- if ((bg != null) && (bg.alpha() == 0)) {
- this.addFilledRect(rx, ry, w, -h, new PDFColor(bg));
- }
-
- // rx = rx - area.getBorderLeftWidth();
- // ry = ry + area.getBorderTopWidth();
- // w = w + area.getBorderLeftWidth() + area.getBorderRightWidth();
- // h = h + area.getBorderTopWidth() + area.getBorderBottomWidth();
-
- // Handle line style
- // Offset for haft the line width!
- BorderAndPadding bp = area.getBorderAndPadding();
- // int left = rx - area.getBorderLeftWidth() / 2;
- // int right = rx + w + area.getBorderRightWidth() / 2;
- // int top = ry + area.getBorderTopWidth() / 2;
- // int bottom = ry - h - area.getBorderBottomWidth() / 2;
- // if (area.getBorderTopWidth() != 0)
- // addLine(left, top, right, top, area.getBorderTopWidth(),
- // new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
- // if (area.getBorderLeftWidth() != 0)
- // addLine(left, ry + area.getBorderTopWidth(), left, bottom, area.getBorderLeftWidth(),
- // new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
- // if (area.getBorderRightWidth() != 0)
- // addLine(right, ry + area.getBorderTopWidth(), right, bottom, area.getBorderRightWidth(),
- // new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
- // if (area.getBorderBottomWidth() != 0)
- // addLine(rx - area.getBorderLeftWidth(), bottom, rx + w + area.getBorderRightWidth(), bottom, area.getBorderBottomWidth(),
- // new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
- // Try using rectangles instead of lines. Line style will be a
- // problem though?
- int left = area.getBorderLeftWidth();
- int right = area.getBorderRightWidth();
- int top = area.getBorderTopWidth();
- int bottom = area.getBorderBottomWidth();
- // If style is solid, use filled rectangles
- if (top != 0)
- addFilledRect(rx, ry, w, top,
- new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
- if (left != 0)
- addFilledRect(rx - left, ry - h - bottom, left, h + top + bottom,
- new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
- if (right != 0)
- addFilledRect(rx + w, ry - h - bottom, right, h + top + bottom,
- new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
- if (bottom != 0)
- addFilledRect(rx, ry - h - bottom, w, bottom,
- new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
- }
-
-
- /**
- * render block area
- *
- * @param area the block area to render
- */
- public void renderBlockArea(BlockArea area) {
- // KLease: Temporary test to fix block positioning
- // Offset ypos by padding and border widths
- this.currentYPosition -= (area.getPaddingTop()
- + area.getBorderTopWidth());
- doFrame(area);
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this);
- }
- this.currentYPosition -= (area.getPaddingBottom()
- + area.getBorderBottomWidth());
- }
-
- /**
- * render display space
- *
- * @param space the display space to render
- */
- public void renderDisplaySpace(DisplaySpace space) {
- int d = space.getSize();
- this.currentYPosition -= d;
- }
-
- /**
- * render image area
- *
- * @param area the image area to render
- */
- public abstract void renderImageArea(ImageArea area);
-
- /**
- * render a foreign object area
- */
- public abstract void renderForeignObjectArea(ForeignObjectArea area);
-
- /**
- * render SVG area
- *
- * @param area the SVG area to render
- */
- public abstract void renderSVGArea(SVGArea area);
-
- /**
- * render inline area
- *
- * @param area inline area to render
- */
- public abstract void renderWordArea(WordArea area);
-
- protected void addWordLines(WordArea area, int rx, int bl, int size,
- PDFColor theAreaColor) {
- if (area.getUnderlined()) {
- int yPos = bl - size / 10;
- addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
- theAreaColor);
- // save position for underlining a following InlineSpace
- prevUnderlineXEndPos = rx + area.getContentWidth();
- prevUnderlineYEndPos = yPos;
- prevUnderlineSize = size / 14;
- prevUnderlineColor = theAreaColor;
- }
-
- if (area.getOverlined()) {
- int yPos = bl + area.getFontState().getAscender() + size / 10;
- addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
- theAreaColor);
- prevOverlineXEndPos = rx + area.getContentWidth();
- prevOverlineYEndPos = yPos;
- prevOverlineSize = size / 14;
- prevOverlineColor = theAreaColor;
- }
-
- if (area.getLineThrough()) {
- int yPos = bl + area.getFontState().getAscender() * 3 / 8;
- addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
- theAreaColor);
- prevLineThroughXEndPos = rx + area.getContentWidth();
- prevLineThroughYEndPos = yPos;
- prevLineThroughSize = size / 14;
- prevLineThroughColor = theAreaColor;
- }
- }
-
- /**
- * render inline space
- *
- * @param space space to render
- */
- public void renderInlineSpace(InlineSpace space) {
- this.currentXPosition += space.getSize();
- if (space.getUnderlined()) {
- if (prevUnderlineColor != null) {
- addLine(prevUnderlineXEndPos, prevUnderlineYEndPos,
- prevUnderlineXEndPos + space.getSize(),
- prevUnderlineYEndPos, prevUnderlineSize,
- prevUnderlineColor);
- }
- }
- if (space.getOverlined()) {
- if (prevOverlineColor != null) {
- addLine(prevOverlineXEndPos, prevOverlineYEndPos,
- prevOverlineXEndPos + space.getSize(),
- prevOverlineYEndPos, prevOverlineSize,
- prevOverlineColor);
- }
- }
- if (space.getLineThrough()) {
- if (prevLineThroughColor != null) {
- addLine(prevLineThroughXEndPos, prevLineThroughYEndPos,
- prevLineThroughXEndPos + space.getSize(),
- prevLineThroughYEndPos, prevLineThroughSize,
- prevLineThroughColor);
- }
- }
- }
-
- /**
- * render line area
- *
- * @param area area to render
- */
- public void renderLineArea(LineArea area) {
- int rx = this.currentAreaContainerXPosition + area.getStartIndent();
- int ry = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= area.getPlacementOffset();
- this.currentXPosition = rx;
-
- int bl = this.currentYPosition;
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- if (b instanceof InlineArea) {
- InlineArea ia = (InlineArea)b;
- this.currentYPosition = ry - ia.getYOffset();
- } else {
- this.currentYPosition = ry - area.getPlacementOffset();
- }
- b.render(this);
- }
-
- this.currentYPosition = ry - h;
- this.currentXPosition = rx;
- }
-
- /**
- * render page
- *
- * @param page page to render
- */
- public abstract void renderPage(Page page);
-
- /**
- * render leader area
- *
- * @param area area to render
- */
- public void renderLeaderArea(LeaderArea area) {
- int rx = this.currentXPosition;
- int ry = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
- int th = area.getRuleThickness();
- int st = area.getRuleStyle();
-
- // checks whether thickness is = 0, because of bug in pdf (or where?),
- // a line with thickness 0 is still displayed
- if (th != 0) {
- switch (st) {
- case org.apache.fop.fo.properties.RuleStyle.DOUBLE:
- addLine(rx, ry, rx + w, ry, th / 3, st,
- new PDFColor(area.getRed(), area.getGreen(),
- area.getBlue()));
- addLine(rx, ry + (2 * th / 3), rx + w, ry + (2 * th / 3),
- th / 3, st,
- new PDFColor(area.getRed(), area.getGreen(),
- area.getBlue()));
- break;
- case org.apache.fop.fo.properties.RuleStyle.GROOVE:
- addLine(rx, ry, rx + w, ry, th / 2, st,
- new PDFColor(area.getRed(), area.getGreen(),
- area.getBlue()));
- addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
- new PDFColor(255, 255, 255));
- break;
- case org.apache.fop.fo.properties.RuleStyle.RIDGE:
- addLine(rx, ry, rx + w, ry, th / 2, st,
- new PDFColor(255, 255, 255));
- addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
- new PDFColor(area.getRed(), area.getGreen(),
- area.getBlue()));
- break;
- default:
- addLine(rx, ry, rx + w, ry, th, st,
- new PDFColor(area.getRed(), area.getGreen(),
- area.getBlue()));
- }
- this.currentXPosition += area.getContentWidth();
- this.currentYPosition += th;
- }
- }
-
- /**
- * set up the font info
- *
- * @param fontInfo font info to set up
- */
- public void setupFontInfo(FontInfo fontInfo) {
- this.fontInfo = fontInfo;
- FontSetup.setup(fontInfo);
- }
-
- /**
- Default start renderer method. This would
- normally be overridden. (mark-fop@inomial.com).
- */
- public void startRenderer(OutputStream outputStream)
- throws IOException {}
- /**
- Default stop renderer method. This would
- normally be overridden. (mark-fop@inomial.com).
- */
- {
- }
-
-}
+++ /dev/null
-/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
-
-/*
- * -- $Id$ --
- * ============================================================================
- * The Apache Software License, Version 1.1
- * ============================================================================
- *
- * Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modifica-
- * tion, 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. The end-user documentation included with the redistribution, if any, must
- * include the following acknowledgment: "This product includes software
- * developed by the Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself, if
- * and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Fop" and "Apache Software Foundation" must not be used to
- * endorse or promote products derived from this software without prior
- * written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache", nor may
- * "Apache" appear in their name, without prior written permission of the
- * Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 THE
- * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- * DING, 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.
- *
- * This software consists of voluntary contributions made by many individuals
- * on behalf of the Apache Software Foundation and was originally created by
- * James Tauber <jtauber@jtauber.com>. For more information on the Apache
- * Software Foundation, please see <http://www.apache.org/>.
- *
- */
-package org.apache.fop.render;
-
-// FOP
-import org.apache.fop.svg.SVGArea;
-import org.apache.fop.image.ImageArea;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.layout.*;
-import org.apache.fop.layout.inline.*;
-
-// Java
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * interface implement by all renderers.
- *
- * a Renderer implementation takes areas/spaces and produces output in
- * some format.
- */
-public interface Renderer {
-
- /**
- * set up the given FontInfo
- */
- public void setupFontInfo(FontInfo fontInfo);
-
- /**
- * set up renderer options
- */
- public void setOptions(java.util.Hashtable options);
-
- /**
- * set the producer of the rendering
- */
- public void setProducer(String producer);
-
- /**
- * render the given area tree to the given stream
- */
- //public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException;
- public void render(Page page, OutputStream stream)
- throws IOException, FOPException;
-
- /**
- * render the given area container
- */
- public void renderAreaContainer(AreaContainer area);
-
- /**
- * render the given area container
- */
- public void renderBodyAreaContainer(BodyAreaContainer area);
-
- /**
- * render the given span area
- */
- public void renderSpanArea(SpanArea area);
-
- /**
- * render the given block area
- */
- public void renderBlockArea(BlockArea area);
-
- /**
- * render the given display space
- */
- public void renderDisplaySpace(DisplaySpace space);
-
- /**
- * render the given SVG area
- */
- public void renderSVGArea(SVGArea area);
-
- /**
- * render a foreign object area
- */
- public void renderForeignObjectArea(ForeignObjectArea area);
-
- /**
- * render the given image area
- */
- public void renderImageArea(ImageArea area);
-
- /**
- * render the given inline area
- */
- public void renderWordArea(WordArea area);
-
- /**
- * render the given inline space
- */
- public void renderInlineSpace(InlineSpace space);
-
- /**
- * render the given line area
- */
- public void renderLineArea(LineArea area);
-
- /**
- * render the given page
- */
- public void renderPage(Page page);
-
- /**
- * render the given leader area
- */
- public void renderLeaderArea(LeaderArea area);
-
- public void startRenderer(OutputStream outputStream)
- throws IOException;
-
- public void stopRenderer(OutputStream outputStream)
- throws IOException;
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.awt;
-
-// FOP
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.layout.FontInfo;
-import org.apache.fop.layout.FontDescriptor;
-import org.apache.fop.layout.FontState;
-
-// Java
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.FontMetrics;
-import java.awt.font.FontRenderContext;
-import java.awt.font.TextLayout;
-
-/**
- * This is a FontMetrics to be used for AWT rendering.
- * It instanciates a font, depening on famil and style
- * values. The java.awt.FontMetrics for this font is then
- * created to be used for the actual measurement.
- * Since layout is word by word and since it is expected that
- * two subsequent words often share the same style, the
- * Font and FontMetrics is buffered and only changed if needed.
- * <p>
- * Since FontState and FontInfo multiply all factors by
- * size, we assume a "standard" font of FONT_SIZE.
- */
-
-public class AWTFontMetrics {
-
- /**
- * Font size standard used for metric measurements
- */
- public static final int FONT_SIZE = 1;
-
- /**
- * This factor multiplies the calculated values to scale
- * to FOP internal measurements
- */
- public static final int FONT_FACTOR = (1000 * 1000) / FONT_SIZE;
-
- /**
- * The width of all 256 character, if requested
- */
- private int width[] = null;
-
- /**
- * The typical height of a small cap latter
- */
- private int xHeight = 0;
-
- /**
- * Buffered font.
- * f1 is bufferd for metric measurements during layout.
- * fSized is buffered for display purposes
- */
- private Font f1 = null; // , fSized = null;
-
- /**
- * The family type of the font last used
- */
- private String family = "";
-
- /**
- * The style of the font last used
- */
- private int style = 0;
-
- /**
- * The size of the font last used
- */
- private float size = 0;
-
- /**
- * The FontMetrics object used to calculate character width etc.
- */
- private FontMetrics fmt = null;
-
- /**
- * Temp graphics object needed to get the font metrics
- */
- Graphics2D graphics;
-
- /**
- * Constructs a new Font-metrics.
- * @param parent an temp graphics object - this is needed so
- * that we can get an instance of
- * java.awt.FontMetrics
- */
- public AWTFontMetrics(Graphics2D graphics) {
- this.graphics = graphics;
- }
-
- /**
- * Determines the font ascent of the Font described by this
- * FontMetrics object
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- * @return ascent in milliponts
- */
- public int getAscender(String family, int style, int size) {
- setFont(family, style, size);
- // return (int)(FONT_FACTOR * fmt.getAscent());
-
- // workaround for sun bug on FontMetric.getAscent()
- // http://developer.java.sun.com/developer/bugParade/bugs/4399887.html
- int realAscent = fmt.getAscent()
- - (fmt.getDescent() + fmt.getLeading());
- return FONT_FACTOR * realAscent;
- }
-
-
- /**
- * The size of a capital letter measured from the font's baseline
- */
- public int getCapHeight(String family, int style, int size) {
- // currently just gets Ascent value but maybe should use
- // getMaxAcent() at some stage
- return getAscender(family, style, size);
- }
-
- /**
- * Determines the font descent of the Font described by this
- * FontMetrics object
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- * @return descent in milliponts
- */
- public int getDescender(String family, int style, int size) {
- setFont(family, style, size);
- return (-1 * FONT_FACTOR * fmt.getDescent());
- }
-
- /**
- * Determines the typical font height of a small cap letter
- * FontMetrics object
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- * @return font height in milliponts
- */
- public int getXHeight(String family, int style, int size) {
- setFont(family, style, size);
- return (int)(FONT_FACTOR * xHeight);
- }
-
- /**
- * Returns width (in 1/1000ths of point size) of character at
- * code point i
- * @param i the character for which to get the width
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- * @param size the of the font
- */
- public int width(int i, String family, int style, int size) {
- int w;
- setFont(family, style, size);
- // the output seems to look a little better if the
- // space is rendered larger than given by
- // the FontMetrics object
- if (i <= 32)
- w = (int)(1.4 * fmt.charWidth(i) * FONT_FACTOR);
- else
- w = (int)(fmt.charWidth(i) * FONT_FACTOR);
- return w;
- }
-
- /**
- * Return widths (in 1/1000ths of point size) of all
- * characters
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- */
- public int[] getWidths(String family, int style, int size) {
- int i;
-
- if (width == null) {
- width = new int[256];
- }
- setFont(family, style, size);
- for (i = 0; i < 256; i++) {
- width[i] = FONT_FACTOR * fmt.charWidth(i);
- }
- return width;
- }
-
- /**
- * Checks whether the font for which values are
- * requested is the one used immediately before or
- * whether it is a new one
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- * @return true if the font was changed, false otherwise
- */
- private boolean setFont(String family, int style, int size) {
- boolean changed = false;
- Rectangle2D rect;
- TextLayout layout;
- int s = (int)(size / 1000f);
-
- if (f1 == null) {
- f1 = new Font(family, style, s);
- fmt = graphics.getFontMetrics(f1);
- changed = true;
- } else {
- if ((this.style != style) ||!this.family.equals(family)
- || this.size != s) {
- if (family.equals(this.family)) {
- f1 = f1.deriveFont(style, (float)s);
- } else
- f1 = new Font(family, style, s);
- fmt = graphics.getFontMetrics(f1);
- changed = true;
- }
- // else the font is unchanged from last time
- }
- if (changed) {
- layout = new TextLayout("m", f1, graphics.getFontRenderContext());
- rect = layout.getBounds();
- xHeight = (int)rect.getHeight();
- }
- // save the family and style for later comparison
- this.family = family;
- this.style = style;
- this.size = s;
- return changed;
- }
-
-
- /**
- * Returns a java.awt.Font instance for the desired
- * family, style and size type.
- * This is here, so that the font-mapping
- * of FOP-defined fonts to java-fonts can be done
- * in one place and does not need to occur in
- * AWTFontRenderer.
- * @param family font family (jave name) to use
- * @param style font style (jave def.) to use
- * @param size font size
- * @return font with the desired characeristics.
- */
- public java.awt.Font getFont(String family, int style, int size) {
- Font f;
-
- setFont(family, style, size);
- return f1;
- /*
- * if( setFont(family,style, size) ) fSized = null;
- * if( fSized == null || this.size != size ) {
- * fSized = f1.deriveFont( size / 1000f );
- * }
- * this.size = size;
- * return fSized;
- */
- }
-
-}
-
-
-
-
-
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.awt;
-
-/*
- * originally contributed by
- * Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
- * Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
- * Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
- */
-
-import org.apache.fop.layout.*;
-import org.apache.fop.layout.inline.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.datatypes.*;
-import org.apache.fop.image.*;
-import org.apache.fop.svg.*;
-import org.apache.fop.render.pdf.*;
-import org.apache.fop.viewer.*;
-import org.apache.fop.apps.*;
-
-import org.w3c.dom.svg.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.batik.bridge.*;
-import org.apache.batik.swing.svg.*;
-import org.apache.batik.swing.gvt.*;
-import org.apache.batik.gvt.*;
-import org.apache.batik.gvt.renderer.*;
-import org.apache.batik.gvt.filter.*;
-import org.apache.batik.gvt.event.*;
-
-import java.awt.*;
-import java.awt.Image;
-import java.awt.image.*;
-import java.awt.geom.*;
-import java.awt.font.*;
-import java.util.*;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.io.*;
-import java.beans.*;
-import javax.swing.*;
-import java.awt.print.*;
-import java.awt.image.BufferedImage;
-import java.text.*;
-
-import org.apache.fop.render.Renderer;
-
-/**
- Modified by Mark Lillywhite mark-fop@inomial.com. Did lots of
- cleaning up and made the class implement the new Renderer
- interface. This class could also do with a general audit,
- and I suspect it's not swing-thread-safe either.
-*/
-
-public class AWTRenderer implements Renderer, Printable, Pageable {
-
- protected int pageWidth = 0;
- protected int pageHeight = 0;
- protected double scaleFactor = 100.0;
- protected int pageNumber = 0;
- protected Vector pageList = new Vector();
- protected ProgressListener progressListener = null;
- protected Translator res = null;
-
- protected Hashtable fontNames = new Hashtable();
- protected Hashtable fontStyles = new Hashtable();
- protected Color saveColor = null;
-
- protected IDReferences idReferences = null;
-
- /**
- * Image Object and Graphics Object. The Graphics Object is the Graphics
- * object that is contained withing the Image Object.
- */
- private BufferedImage pageImage = null;
- private Graphics2D graphics = null;
-
- /**
- * The current (internal) font name
- */
- protected String currentFontName;
-
- /**
- * The current font size in millipoints
- */
- protected int currentFontSize;
-
- /**
- * The current colour's red, green and blue component
- */
- protected float currentRed = 0;
- protected float currentGreen = 0;
- protected float currentBlue = 0;
-
- /**
- * The parent component, used to set up the font.
- * This is needed as FontSetup needs a live AWT component
- * in order to generate valid font measures.
- */
- protected Component parent;
-
- /**
- * The current vertical position in millipoints from bottom
- */
- protected int currentYPosition = 0;
-
- /**
- * The current horizontal position in millipoints from left
- */
- protected int currentXPosition = 0;
-
- /**
- * The horizontal position of the current area container
- */
- private int currentAreaContainerXPosition = 0;
-
- /**
- * options
- */
- protected Hashtable options;
-
- /**
- * set up renderer options
- */
- public void setOptions(Hashtable options) {
- this.options = options;
- }
-
- public AWTRenderer(Translator aRes) {
- res = aRes;
- }
-
- /**
- * Sets parent component which is used to set up the font.
- * This is needed as FontSetup needs a live AWT component
- * in order to generate valid font measures.
- * @param parent the live AWT component reference
- */
- public void setComponent(Component parent) {
- this.parent = parent;
- }
-
- public int getPageNumber() {
- return pageNumber;
- }
-
- public void setPageNumber(int aValue) {
- pageNumber = aValue;
- }
-
- public void setScaleFactor(double newScaleFactor) {
- scaleFactor = newScaleFactor;
- }
-
- public double getScaleFactor() {
- return scaleFactor;
- }
-
- public BufferedImage getLastRenderedPage() {
- return pageImage;
- }
-
- /**
- * add a line to the current stream
- *
- * @param x1 the start x location in millipoints
- * @param y1 the start y location in millipoints
- * @param x2 the end x location in millipoints
- * @param y2 the end y location in millipoints
- * @param th the thickness in millipoints
- * @param r the red component
- * @param g the green component
- * @param b the blue component
- */
-
- // corrected 7/13/01 aml,rlc to properly handle thickness
- //
- protected void addLine(int x1, int y1, int x2, int y2, int th, float r,
- float g, float b) {
- graphics.setColor(new Color(r, g, b));
- int x = x1;
- int y = y1;
- int height, width;
- if (x1 == x2) // vertical line
- {
- height = y2 - y1;
- if (height > 0) // y coordinates are reversed between fo and AWT
- {
- height = -height;
- y = y2;
- }
- width = th;
- if (width < 0) {
- width = -width;
- x -= width;
- }
- } else // horizontal line
- {
- width = x2 - x1;
- if (width < 0) {
- width = -width;
- x = x2;
- }
- height = th;
- if (height > 0) // y coordinates are reversed between fo and AWT
- {
- height = -height;
- y -= height;
- }
- }
- addRect(x, y, width, height, false);
-
- // // graphics.setColor(Color.red);
- // graphics.drawLine((int)(x1 / 1000f),
- // pageHeight - (int)(y1 / 1000f), (int)(x2 / 1000f),
- // pageHeight - (int)(y2 / 1000f));
- }
-
-
- /**
- * draw a rectangle
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param r the red component
- * @param g the green component
- * @param b the blue component
- */
-
- // changed by aml/rlc to use helper function that
- // corrects for integer roundoff, and to remove 3D effect
-
-
- protected void addRect(int x, int y, int w, int h, float r, float g,
- float b) {
- graphics.setColor(new Color(r, g, b));
- // graphics.setColor(Color.green);
- addRect(x, y, w, h, true);
- }
-
- /**
- * draw a filled rectangle
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param r the red component of edges
- * @param g the green component of edges
- * @param b the blue component of edges
- * @param fr the red component of the fill
- * @param fg the green component of the fill
- * @param fb the blue component of the fill
- */
-
- // changed by aml/rlc to use helper function that
- // corrects for integer roundoff
- protected void addRect(int x, int y, int w, int h, float r, float g,
- float b, float fr, float fg, float fb) {
- graphics.setColor(new Color(r, g, b));
- addRect(x, y, w, h, true);
- graphics.setColor(new Color(fr, fg, fb));
- addRect(x, y, w, h, false);
- }
-
- /**
- * draw a filled rectangle in the current color
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param drawAsOutline true for draw, false for fill
- */
-
- // helper function by aml/rlc to correct integer roundoff problems
- //
- protected void addRect(int x, int y, int w, int h,
- boolean drawAsOutline) {
- int startx = (x + 500) / 1000;
- int starty = pageHeight - ((y + 500) / 1000);
- int endx = (x + w + 500) / 1000;
- int endy = pageHeight - ((y + h + 500) / 1000);
- if (drawAsOutline)
- graphics.drawRect(startx, starty, endx - startx, endy - starty);
- else
- graphics.fillRect(startx, starty, endx - startx, endy - starty);
- }
-
- /**
- * To configure before print.
- *
- * Choose pages
- * Zoom factor
- * Page format / Landscape or Portrait
- */
- public void transform(Graphics2D g2d, double zoomPercent, double angle) {
- AffineTransform at = g2d.getTransform();
- at.rotate(angle);
- at.scale(zoomPercent / 100.0, zoomPercent / 100.0);
- g2d.setTransform(at);
- }
-
- protected void drawFrame() {
-
- int width = pageWidth;
- int height = pageHeight;
-
- graphics.setColor(Color.white);
- graphics.fillRect(0, 0, width, height);
- graphics.setColor(Color.black);
- graphics.drawRect(-1, -1, width + 2, height + 2);
- graphics.drawLine(width + 2, 0, width + 2, height + 2);
- graphics.drawLine(width + 3, 1, width + 3, height + 3);
-
- graphics.drawLine(0, height + 2, width + 2, height + 2);
- graphics.drawLine(1, height + 3, width + 3, height + 3);
- }
-
- /**
- * Retrieve the number of pages in this document.
- *
- * @return the number of pages
- */
- public int getPageCount() {
- return pageList.size();
- }
-
- public void removePage(int page) {
- pageList.removeElementAt(page);
- }
-
- public void render(int aPageNumber) {
- if(aPageNumber >= pageList.size())
- return;
-
- try {
- render((Page) pageList.elementAt(aPageNumber));
- } catch(IOException e) {
- e.printStackTrace();
- // This exception can't occur because we are not dealing with
- // any files
- }
-
- }
-
- public void render(Page page, OutputStream stream)
- throws IOException {
- pageList.addElement(page);
- }
-
- public void render(Page page)
- throws IOException {
- idReferences = page.getIDReferences();
-
- pageWidth = (int)((float)page.getWidth() / 1000f + .5);
- pageHeight = (int)((float)page.getHeight() / 1000f + .5);
-
-
- pageImage =
- new BufferedImage((int)((pageWidth * (int)scaleFactor) / 100),
- (int)((pageHeight * (int)scaleFactor) / 100),
- BufferedImage.TYPE_INT_RGB);
-
- graphics = pageImage.createGraphics();
-
- transform(graphics, scaleFactor, 0);
- drawFrame();
-
- renderPage(page);
- }
-
- public void renderPage(Page page) {
- BodyAreaContainer body;
- AreaContainer before, after;
-
- body = page.getBody();
- before = page.getBefore();
- after = page.getAfter();
-
- this.currentFontName = "";
- this.currentFontSize = 0;
-
- renderBodyAreaContainer(body);
-
- if (before != null) {
- renderAreaContainer(before);
- }
-
- if (after != null) {
- renderAreaContainer(after);
- }
-
- // SG: Wollen wir Links abbilden?
- /*
- * if (page.hasLinks()) {
- * ....
- * }
- */
- }
-
- public void renderAreaContainer(AreaContainer area) {
-
- int saveY = this.currentYPosition;
- int saveX = this.currentAreaContainerXPosition;
-
- if (area.getPosition()
- == org.apache.fop.fo.properties.Position.ABSOLUTE) {
- // Y position is computed assuming positive Y axis, adjust
- // for negative postscript one
- this.currentYPosition = area.getYPosition()
- - 2 * area.getPaddingTop()
- - 2 * area.getBorderTopWidth();
- this.currentAreaContainerXPosition = area.getXPosition();
- } else if (area.getPosition()
- == org.apache.fop.fo.properties.Position.RELATIVE) {
- this.currentYPosition -= area.getYPosition();
- this.currentAreaContainerXPosition += area.getXPosition();
- } else if (area.getPosition()
- == org.apache.fop.fo.properties.Position.STATIC) {
- this.currentYPosition -= area.getPaddingTop()
- + area.getBorderTopWidth();
- this.currentAreaContainerXPosition += area.getPaddingLeft()
- + area.getBorderLeftWidth();
- }
-
- doFrame(area);
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- b.render(this);
- }
-
- if (area.getPosition()
- != org.apache.fop.fo.properties.Position.STATIC) {
- this.currentYPosition = saveY;
- this.currentAreaContainerXPosition = saveX;
- } else {
- this.currentYPosition -= area.getHeight();
- }
- }
-
- // empty for now
- public void renderBodyAreaContainer(BodyAreaContainer area) {
- renderAreaContainer(area.getBeforeFloatReferenceArea());
- renderAreaContainer(area.getFootnoteReferenceArea());
-
- // main reference area
- Enumeration e = area.getMainReferenceArea().getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- b.render(this); // span areas
- }
-
- }
-
- // empty for now
- public void renderSpanArea(SpanArea area) {
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- b.render(this); // column areas
- }
-
- }
-
- private void doFrame(org.apache.fop.layout.Area area) {
- int w, h;
- int rx = this.currentAreaContainerXPosition;
- w = area.getContentWidth();
-
- if (area instanceof BlockArea) {
- rx += ((BlockArea)area).getStartIndent();
- }
-
- h = area.getContentHeight();
- int ry = this.currentYPosition;
- ColorType bg = area.getBackgroundColor();
-
- rx = rx - area.getPaddingLeft();
- ry = ry + area.getPaddingTop();
- w = w + area.getPaddingLeft() + area.getPaddingRight();
- h = h + area.getPaddingTop() + area.getPaddingBottom();
-
- // I'm not sure I should have to check for bg being null
- // but I do
- if ((bg != null) && (bg.alpha() == 0)) {
- this.addRect(rx, ry, w, -h, bg.red(), bg.green(), bg.blue(),
- bg.red(), bg.green(), bg.blue());
- }
-
- rx = rx - area.getBorderLeftWidth();
- ry = ry + area.getBorderTopWidth();
- w = w + area.getBorderLeftWidth() + area.getBorderRightWidth();
- h = h + area.getBorderTopWidth() + area.getBorderBottomWidth();
-
- BorderAndPadding bp = area.getBorderAndPadding();
- ColorType borderColor;
-
- if (area.getBorderTopWidth() != 0) {
- borderColor = bp.getBorderColor(BorderAndPadding.TOP);
- // addLine(rx, ry, rx + w, ry, area.getBorderTopWidth(), // corrected aml/rlc
- addLine(rx, ry, rx + w, ry, -area.getBorderTopWidth(),
- borderColor.red(), borderColor.green(),
- borderColor.blue());
- }
-
- if (area.getBorderLeftWidth() != 0) {
- borderColor = bp.getBorderColor(BorderAndPadding.LEFT);
- addLine(rx, ry, rx, ry - h, area.getBorderLeftWidth(),
- borderColor.red(), borderColor.green(),
- borderColor.blue());
- }
-
- if (area.getBorderRightWidth() != 0) {
- borderColor = bp.getBorderColor(BorderAndPadding.RIGHT);
- addLine(rx + w, ry, rx + w, ry - h,
- // area.getBorderRightWidth(), borderColor.red(), // corrected aml/rlc
- -area.getBorderRightWidth(), borderColor.red(),
- borderColor.green(),
- borderColor.blue());
- }
-
- if (area.getBorderBottomWidth() != 0) {
- borderColor = bp.getBorderColor(BorderAndPadding.BOTTOM);
- addLine(rx, ry - h, rx + w, ry - h, area.getBorderBottomWidth(),
- borderColor.red(), borderColor.green(),
- borderColor.blue());
- }
- }
-
-
-
- protected Rectangle2D getBounds(org.apache.fop.layout.Area a) {
- return new Rectangle2D.Double(currentAreaContainerXPosition,
- currentYPosition,
- a.getAllocationWidth(), a.getHeight());
- }
-
- /*
- * public void renderBlockArea(BlockArea area) {
- * doFrame(area);
- * Enumeration e = area.getChildren().elements();
- * while (e.hasMoreElements()) {
- * org.apache.fop.layout.Box b =
- * (org.apache.fop.layout.Box) e.nextElement();
- * b.render(this);
- * }
- * }
- */
- public void renderBlockArea(BlockArea area) {
- this.currentYPosition -= (area.getPaddingTop()
- + area.getBorderTopWidth());
- doFrame(area);
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- b.render(this);
- }
- this.currentYPosition -= (area.getPaddingBottom()
- + area.getBorderBottomWidth());
- }
-
-
- public void setupFontInfo(FontInfo fontInfo) {
- // create a temp Image to test font metrics on
- BufferedImage fontImage =
- new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
- FontSetup.setup(fontInfo, fontImage.createGraphics());
- }
-
- public void renderDisplaySpace(DisplaySpace space) {
- int d = space.getSize();
- this.currentYPosition -= d;
- }
-
-
- // correct integer roundoff (aml/rlc)
-
- public void renderImageArea(ImageArea area) {
-
- int x = currentAreaContainerXPosition + area.getXOffset();
-
- int y = currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- FopImage img = area.getImage();
-
- if (img == null) {
- MessageHandler.logln("Error while loading image : area.getImage() is null");
-
- // correct integer roundoff
- // graphics.drawRect(x / 1000, pageHeight - y / 1000,
- // w / 1000, h / 1000);
- addRect(x, y, w, h, true); // use helper function
-
-
- java.awt.Font f = graphics.getFont();
- java.awt.Font smallFont = new java.awt.Font(f.getFontName(),
- f.getStyle(), 8);
-
- graphics.setFont(smallFont);
-
- // correct integer roundoff // aml/rlc
- // graphics.drawString("area.getImage() is null", x / 1000,
- // pageHeight - y / 1000);
-
- graphics.drawString("area.getImage() is null", (x + 500) / 1000,
- pageHeight - (y + 500) / 1000);
-
-
- graphics.setFont(f);
- } else {
- if (img instanceof SVGImage) {
- try {
- SVGDocument svg = ((SVGImage)img).getSVGDocument();
- renderSVGDocument(svg, (int)x, (int)y);
- } catch (FopImageException e) {}
-
- } else {
-
- String urlString = img.getURL();
- try {
- URL url = new URL(urlString);
-
- ImageIcon icon = new ImageIcon(url);
- Image image = icon.getImage();
-
- // correct integer roundoff aml/rlc
- // graphics.drawImage(image, x / 1000,
- // pageHeight - y / 1000, w / 1000, h / 1000,
- // null);
-
- int startx = (x + 500) / 1000;
- int starty = pageHeight - ((y + 500) / 1000);
- int endx = (x + w + 500) / 1000;
- int endy = pageHeight - ((y + h + 500) / 1000);
-
- // reverse start and end y because h is positive
- graphics.drawImage(image, startx, starty, endx - startx,
- starty - endy, null);
-
- } catch (MalformedURLException mue) {
- // cannot normally occur because, if URL is wrong, constructing FopImage
- // will already have failed earlier on
- }
-
- }
- }
-
- currentYPosition -= h;
- }
-
- public void renderWordArea(WordArea area) {
- char ch;
- StringBuffer pdf = new StringBuffer();
-
- String name = area.getFontState().getFontName();
- int size = area.getFontState().getFontSize();
- boolean underlined = area.getUnderlined();
-
- float red = area.getRed();
- float green = area.getGreen();
- float blue = area.getBlue();
-
- FontMetricsMapper mapper;
- try {
- mapper =
- (FontMetricsMapper)area.getFontState().getFontInfo().getMetricsFor(name);
- } catch (FOPException iox) {
- mapper = new FontMetricsMapper("MonoSpaced", java.awt.Font.PLAIN,
- graphics);
- }
-
- if ((!name.equals(this.currentFontName))
- || (size != this.currentFontSize)) {
- this.currentFontName = name;
- this.currentFontSize = size;
- }
-
- if ((red != this.currentRed) || (green != this.currentGreen)
- || (blue != this.currentBlue)) {
- this.currentRed = red;
- this.currentGreen = green;
- this.currentBlue = blue;
- }
-
- int rx = this.currentXPosition;
- int bl = this.currentYPosition;
-
-
- String s; // = area.getText();
- if (area.getPageNumberID()
- != null) { // this text is a page number, so resolve it
- s = idReferences.getPageNumber(area.getPageNumberID());
- if (s == null) {
- s = "";
- }
- } else {
- s = area.getText();
- }
-
- Color oldColor = graphics.getColor();
- java.awt.Font oldFont = graphics.getFont();
- java.awt.Font f = mapper.getFont(size);
-
- if (saveColor != null) {
- if (saveColor.getRed() != red || saveColor.getGreen() != green
- || saveColor.getBlue() != blue) {
- saveColor = new Color(red, green, blue);
- }
- } else {
- saveColor = new Color(red, green, blue);
- }
- graphics.setColor(saveColor);
-
- AttributedString ats = new AttributedString(s);
- ats.addAttribute(TextAttribute.FONT, f);
- if (underlined) {
- ats.addAttribute(TextAttribute.UNDERLINE,
- TextAttribute.UNDERLINE_ON);
- }
- AttributedCharacterIterator iter = ats.getIterator();
-
- // correct integer roundoff
- // graphics.drawString(iter, rx / 1000f,
- // (int)(pageHeight - bl / 1000f));
-
- graphics.drawString(iter, (rx + 500) / 1000,
- (int)(pageHeight - (bl + 500) / 1000));
-
- graphics.setColor(oldColor);
- this.currentXPosition += area.getContentWidth();
- }
-
- public void renderInlineSpace(InlineSpace space) {
- this.currentXPosition += space.getSize();
- }
-
- public void renderLineArea(LineArea area) {
-
- int rx = this.currentAreaContainerXPosition + area.getStartIndent();
- int ry = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= area.getPlacementOffset();
- this.currentXPosition = rx;
-
- int bl = this.currentYPosition;
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- org.apache.fop.layout.Box b =
- (org.apache.fop.layout.Box)e.nextElement();
- if (b instanceof InlineArea) {
- InlineArea ia = (InlineArea)b;
- this.currentYPosition = ry - ia.getYOffset();
- } else {
- this.currentYPosition = ry - area.getPlacementOffset();
- }
- b.render(this);
- }
-
- this.currentYPosition = ry - h;
- }
-
- /**
- * render leader area into AWT
- *
- * @param area area to render
- */
-
- // call to addRect corrected by aml/rlc
-
- public void renderLeaderArea(LeaderArea area) {
-
- int rx = this.currentXPosition;
- int ry = this.currentYPosition;
- int w = area.getLeaderLength();
- int h = area.getHeight();
- int th = area.getRuleThickness();
- int st = area.getRuleStyle(); // not used at the moment
- float r = area.getRed();
- float g = area.getGreen();
- float b = area.getBlue();
- Color oldColor = graphics.getColor();
-
- graphics.setColor(new Color(r, g, b));
-
- // use helper function to correct integer roundoff - aml/rlc
- // graphics.fillRect((int)(rx / 1000f),
- // (int)(pageHeight - ry / 1000f), (int)(w / 1000f),
- // (int)(th / 1000f));
-
- addRect(rx, ry, w, -th, false); // NB addRect expects negative height
-
- graphics.setColor(oldColor);
- this.currentXPosition += area.getContentWidth();
- }
-
- public void renderSVGArea(SVGArea area) {
-
- int x = this.currentXPosition;
- int y = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- Document doc = area.getSVGDocument();
- renderSVGDocument(doc, x, y);
- this.currentXPosition += area.getContentWidth();
- }
-
- protected void renderSVGDocument(Document doc, int x, int y) {
- UserAgent userAgent = new MUserAgent(new AffineTransform());
-
- GVTBuilder builder = new GVTBuilder();
- GraphicsNodeRenderContext rc = getRenderContext();
- BridgeContext ctx = new BridgeContext(userAgent, rc);
- GraphicsNode root;
-
- // correct integer roundoff aml/rlc
- // graphics.translate(x / 1000f, pageHeight - y / 1000f);
- graphics.translate((x + 500) / 1000, pageHeight - (y + 500) / 1000);
-
- graphics.setRenderingHints(rc.getRenderingHints());
- try {
- root = builder.build(ctx, doc);
- root.paint(graphics, rc);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- // correct integer roundoff aml/rlc
- // graphics.translate(-x / 1000f, y / 1000f - pageHeight);
- graphics.translate(-(x + 500) / 1000, (y + 500) / 1000 - pageHeight);
-
- }
-
- public GraphicsNodeRenderContext getRenderContext() {
- GraphicsNodeRenderContext nodeRenderContext = null;
- if (nodeRenderContext == null) {
- RenderingHints hints = new RenderingHints(null);
- hints.put(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
- hints.put(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR);
-
- FontRenderContext fontRenderContext =
- new FontRenderContext(new AffineTransform(), true, true);
-
- TextPainter textPainter = new StrokingTextPainter();
-
- GraphicsNodeRableFactory gnrFactory =
- new ConcreteGraphicsNodeRableFactory();
-
- nodeRenderContext =
- new GraphicsNodeRenderContext(new AffineTransform(), null,
- hints, fontRenderContext,
- textPainter, gnrFactory);
- }
-
- return nodeRenderContext;
- }
-
-
- public void setProducer(String producer) {
- // defined in Renderer Interface
- }
-
-
- public int print(Graphics g, PageFormat pageFormat,
- int pageIndex) throws PrinterException {
- if (pageIndex >= pageList.size())
- return NO_SUCH_PAGE;
-
- Graphics2D oldGraphics = graphics;
- int oldPageNumber = pageNumber;
-
- graphics = (Graphics2D)g;
- Page aPage = (Page)pageList.elementAt(pageIndex);
- renderPage(aPage);
- graphics = oldGraphics;
-
- return PAGE_EXISTS;
- }
-
- public int getNumberOfPages() {
- return pageList.size();
- }
-
- public PageFormat getPageFormat(int pageIndex)
- throws IndexOutOfBoundsException {
- if (pageIndex >= pageList.size())
- return null;
-
- Page page = (Page)pageList.elementAt(pageIndex);
- PageFormat pageFormat = new PageFormat();
- Paper paper = new Paper();
-
- double width = page.getWidth();
- double height = page.getHeight();
-
- // if the width is greater than the height assume lanscape mode
- // and swap the width and height values in the paper format
- if (width > height) {
- paper.setImageableArea(0, 0, height / 1000d, width / 1000d);
- paper.setSize(height / 1000d, width / 1000d);
- pageFormat.setOrientation(PageFormat.LANDSCAPE);
- } else {
- paper.setImageableArea(0, 0, width / 1000d, height / 1000d);
- paper.setSize(width / 1000d, height / 1000d);
- pageFormat.setOrientation(PageFormat.PORTRAIT);
- }
- pageFormat.setPaper(paper);
- return pageFormat;
- }
-
- public Printable getPrintable(int pageIndex)
- throws IndexOutOfBoundsException {
- return this;
- }
-
- public void setProgressListener(ProgressListener l) {
- progressListener = l;
- }
-
- public static Color colorType2Color(ColorType ct) {
- if (ct == null) {
- return null;
- }
- return new Color(ct.red(), ct.green(), ct.blue());
- }
-
-
-
- /**
- * Draws an image.
- * TODO: protect other image formats (JIMI)
- */
- /*
- * public void renderImage(String href, float x, float y, float width,
- * float height, Vector transform) {
- * // What is with transformations?
- * try {
- * URL url = new URL(href);
- * ImageIcon imageIcon = new ImageIcon(url);
- * AffineTransform fullTransform = new AffineTransform();
- * AffineTransform aTransform;
- * transform = (transform == null) ? new Vector() : transform;
- * for (int i = 0; i < transform.size(); i++) {
- * org.w3c.dom.svg.SVGTransform t =
- * (org.w3c.dom.svg.SVGTransform)
- * transform.elementAt(i);
- * SVGMatrix matrix = t.getMatrix();
- * aTransform = new AffineTransform(matrix.getA(),
- * matrix.getB(), matrix.getC(), matrix.getD(),
- * matrix.getE(), matrix.getF());
- * fullTransform.concatenate(aTransform);
- * }
- * BufferedImage bi = new BufferedImage((int) width, (int) height,
- * BufferedImage.TYPE_INT_RGB);
- * Graphics2D g2d = bi.createGraphics();
- * BufferedImageOp bop = new AffineTransformOp(fullTransform,
- * AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
- * g2d.drawImage(imageIcon.getImage(), 0, 0, (int) width,
- * (int) height, imageIcon.getImageObserver());
- * graphics.drawImage(bi, bop, (int) x, (int) y);
- * } catch (Exception ex) {
- * MessageHandler.errorln("AWTRenderer: renderImage(): " +
- * ex.getMessage());
- * }
- * }
- */
-
- public void renderForeignObjectArea(ForeignObjectArea area) {
- area.getObject().render(this);
- }
-
-
- protected class MUserAgent implements UserAgent {
- AffineTransform currentTransform = null;
-
- /**
- * Creates a new SVGUserAgent.
- */
- protected MUserAgent(AffineTransform at) {
- currentTransform = at;
- }
-
- /**
- * Displays an error message.
- */
- public void displayError(String message) {
- System.err.println(message);
- }
-
- /**
- * Displays an error resulting from the specified Exception.
- */
- public void displayError(Exception ex) {
- ex.printStackTrace(System.err);
- }
-
- /**
- * Displays a message in the User Agent interface.
- * The given message is typically displayed in a status bar.
- */
- public void displayMessage(String message) {
- System.out.println(message);
- }
-
- /**
- * Returns a customized the pixel to mm factor.
- */
- public float getPixelToMM() {
- // this is set to 72dpi as the values in fo are 72dpi
- return 0.35277777777777777778f; // 72 dpi
- // return 0.26458333333333333333333333333333f; // 96dpi
- }
-
- /**
- * Returns the language settings.
- */
- public String getLanguages() {
- return "en"; // userLanguages;
- }
-
- /**
- * Returns the user stylesheet uri.
- * @return null if no user style sheet was specified.
- */
- public String getUserStyleSheetURI() {
- return null; // userStyleSheetURI;
- }
-
- /**
- * Returns the class name of the XML parser.
- */
- public String getXMLParserClassName() {
- return Driver.getParserClassName();
- }
-
- /**
- * Opens a link in a new component.
- * @param doc The current document.
- * @param uri The document URI.
- */
- public void openLink(SVGAElement elt) {
- // application.openLink(uri);
- }
-
-
- public Point getClientAreaLocationOnScreen() {
- return new Point(0, 0);
- }
-
- public void setSVGCursor(java.awt.Cursor cursor) {}
-
-
- public AffineTransform getTransform() {
- return currentTransform;
- }
-
- public Dimension2D getViewportSize() {
- return new Dimension(100, 100);
- }
-
- public EventDispatcher getEventDispatcher() {
- return null;
- }
-
- public boolean supportExtension(String str) {
- return false;
- }
-
- public boolean hasFeature(String str) {
- return false;
- }
-
- public void registerExtension(BridgeExtension be) {}
-
- public void handleElement(Element elt, Object data) {}
-
- }
-
- public void startRenderer(OutputStream outputStream)
- throws IOException {}
-
-
- public void stopRenderer(OutputStream outputStream)
- throws IOException {
- render(0);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.awt;
-
-// FOP
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.layout.FontInfo;
-import org.apache.fop.layout.FontDescriptor;
-import org.apache.fop.layout.FontState;
-
-// Java
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.awt.Graphics2D;
-import java.awt.Font;
-
-
-/**
- * This class implements org.apache.fop.layout.FontMetric and
- * is added to the hash table in FontInfo. It deferes the
- * actual calculation of the metrics to
- * AWTFontMetrics. It only keeps the java name and
- * style as member varibles
- */
-
-public class FontMetricsMapper implements org.apache.fop.layout.FontMetric {
-
- /**
- * The first and last non space-character
- */
- private final static int FIRST_CHAR = 32;
- private final static int LAST_CHAR = 255;
-
- /**
- * This is a AWTFontMetrics that does the real calculation.
- * It is only one class that dynamically determines the font-size.
- */
- private static AWTFontMetrics metric = null;
-
- /**
- * The java name of the font.
- * # Make the family name immutable.
- */
- private final String family;
-
- /**
- * The java style of the font.
- * # Make the style immutable.
- */
- private final int style;
-
- /**
- * Constructs a new Font-metrics.
- * @param family the family name of the font (java value)
- * @param style the java type style value of the font
- * @param parent an AWT component - this is needed so
- * that we can get an instance of
- * java.awt.FontMetrics
- */
- public FontMetricsMapper(String family, int style, Graphics2D graphics) {
- this.family = family;
- this.style = style;
- if (metric == null)
- metric = new AWTFontMetrics(graphics);
- }
-
- /**
- * Determines the font ascent of the Font described by this
- * FontMetrics object
- * @return ascent in milliponts
- */
- public int getAscender(int size) {
- return metric.getAscender(family, style, size);
- }
-
-
- /**
- * The size of a capital letter measured from the font's baseline
- */
- public int getCapHeight(int size) {
- return metric.getCapHeight(family, style, size);
- }
-
- /**
- * Determines the font descent of the Font described by this
- * FontMetrics object
- * @return descent in milliponts
- */
- public int getDescender(int size) {
- return metric.getDescender(family, style, size);
- }
-
- /**
- * Determines the typical font height of this
- * FontMetrics object
- * @return font height in milliponts
- */
- public int getXHeight(int size) {
- return metric.getXHeight(family, style, size);
- }
-
-
- public int getFirstChar() {
- return FIRST_CHAR;
- }
-
- public int getLastChar() {
- return LAST_CHAR;
- }
-
- /**
- * return width (in 1/1000ths of point size) of character at
- * code point i.
- */
- public int width(int i, int size) {
- return metric.width(i, family, style, size);
- }
-
-
- /**
- * return width (in 1/1000ths of point size) of all character
- */
- public int[] getWidths(int size) {
- return metric.getWidths(family, style, size);
- }
-
- /**
- * Gets a Font instance of the Font that this
- * FontMetrics describes in the desired size.
- * @return font with the desired characeristics.
- */
- public Font getFont(int size) {
- return metric.getFont(family, style, size);
- }
-
-}
-
-
-
-
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.awt;
-
-// FOP
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.layout.FontInfo;
-import org.apache.fop.layout.FontDescriptor;
-
-// Java
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.awt.Font;
-import java.awt.Graphics2D;
-
-/**
- * sets up the AWT fonts. It is similar to
- * org.apache.fop.render.pdf.FontSetup.
- * Assigns the font (with metrics) to internal names like "F1" and
- * assigns family-style-weight triplets to the fonts
- */
-public class FontSetup {
-
-
- /**
- * sets up the font info object.
- *
- * adds metrics for basic fonts and useful family-style-weight
- * triplets for lookup
- *
- * @param fontInfo the font info object to set up
- * @param parent needed, since a live AWT component is needed
- * to get a valid java.awt.FontMetrics object
- */
- public static void setup(FontInfo fontInfo, Graphics2D graphics) {
- FontMetricsMapper metric;
- int normal, bold, bolditalic, italic;
-
- MessageHandler.logln("setting up fonts");
-
- /*
- * available java fonts are:
- * Serif - bold, normal, italic, bold-italic
- * SansSerif - bold, normal, italic, bold-italic
- * MonoSpaced - bold, normal, italic, bold-italic
- */
- normal = java.awt.Font.PLAIN;
- bold = java.awt.Font.BOLD;
- italic = java.awt.Font.ITALIC;
- bolditalic = java.awt.Font.BOLD + java.awt.Font.ITALIC;
-
- metric = new FontMetricsMapper("SansSerif", normal, graphics);
- // --> goes to F1
- fontInfo.addMetrics("F1", metric);
- metric = new FontMetricsMapper("SansSerif", italic, graphics);
- // --> goes to F2
- fontInfo.addMetrics("F2", metric);
- metric = new FontMetricsMapper("SansSerif", bold, graphics);
- // --> goes to F3
- fontInfo.addMetrics("F3", metric);
- metric = new FontMetricsMapper("SansSerif", bolditalic, graphics);
- // --> goes to F4
- fontInfo.addMetrics("F4", metric);
-
-
- metric = new FontMetricsMapper("Serif", normal, graphics);
- // --> goes to F5
- fontInfo.addMetrics("F5", metric);
- metric = new FontMetricsMapper("Serif", italic, graphics);
- // --> goes to F6
- fontInfo.addMetrics("F6", metric);
- metric = new FontMetricsMapper("Serif", bold, graphics);
- // --> goes to F7
- fontInfo.addMetrics("F7", metric);
- metric = new FontMetricsMapper("Serif", bolditalic, graphics);
- // --> goes to F8
- fontInfo.addMetrics("F8", metric);
-
- metric = new FontMetricsMapper("MonoSpaced", normal, graphics);
- // --> goes to F9
- fontInfo.addMetrics("F9", metric);
- metric = new FontMetricsMapper("MonoSpaced", italic, graphics);
- // --> goes to F10
- fontInfo.addMetrics("F10", metric);
- metric = new FontMetricsMapper("MonoSpaced", bold, graphics);
- // --> goes to F11
- fontInfo.addMetrics("F11", metric);
- metric = new FontMetricsMapper("MonoSpaced", bolditalic, graphics);
- // --> goes to F12
- fontInfo.addMetrics("F12", metric);
-
- metric = new FontMetricsMapper("Symbol", bolditalic, graphics);
- // --> goes to F13 and F14
- fontInfo.addMetrics("F13", metric);
- fontInfo.addMetrics("F14", metric);
-
- // Custom type 1 fonts step 1/2
- // fontInfo.addMetrics("F15", new OMEP());
- // fontInfo.addMetrics("F16", new GaramondLightCondensed());
- // fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
-
- /* any is treated as serif */
- fontInfo.addFontProperties("F5", "any", "normal", "normal");
- fontInfo.addFontProperties("F6", "any", "italic", "normal");
- fontInfo.addFontProperties("F6", "any", "oblique", "normal");
- fontInfo.addFontProperties("F7", "any", "normal", "bold");
- fontInfo.addFontProperties("F8", "any", "italic", "bold");
- fontInfo.addFontProperties("F8", "any", "oblique", "bold");
-
- fontInfo.addFontProperties("F1", "sans-serif", "normal", "normal");
- fontInfo.addFontProperties("F2", "sans-serif", "oblique", "normal");
- fontInfo.addFontProperties("F2", "sans-serif", "italic", "normal");
- fontInfo.addFontProperties("F3", "sans-serif", "normal", "bold");
- fontInfo.addFontProperties("F4", "sans-serif", "oblique", "bold");
- fontInfo.addFontProperties("F4", "sans-serif", "italic", "bold");
- fontInfo.addFontProperties("F5", "serif", "normal", "normal");
- fontInfo.addFontProperties("F6", "serif", "oblique", "normal");
- fontInfo.addFontProperties("F6", "serif", "italic", "normal");
- fontInfo.addFontProperties("F7", "serif", "normal", "bold");
- fontInfo.addFontProperties("F8", "serif", "oblique", "bold");
- fontInfo.addFontProperties("F8", "serif", "italic", "bold");
- fontInfo.addFontProperties("F9", "monospace", "normal", "normal");
- fontInfo.addFontProperties("F10", "monospace", "oblique", "normal");
- fontInfo.addFontProperties("F10", "monospace", "italic", "normal");
- fontInfo.addFontProperties("F11", "monospace", "normal", "bold");
- fontInfo.addFontProperties("F12", "monospace", "oblique", "bold");
- fontInfo.addFontProperties("F12", "monospace", "italic", "bold");
-
- fontInfo.addFontProperties("F1", "Helvetica", "normal", "normal");
- fontInfo.addFontProperties("F2", "Helvetica", "oblique", "normal");
- fontInfo.addFontProperties("F2", "Helvetica", "italic", "normal");
- fontInfo.addFontProperties("F3", "Helvetica", "normal", "bold");
- fontInfo.addFontProperties("F4", "Helvetica", "oblique", "bold");
- fontInfo.addFontProperties("F4", "Helvetica", "italic", "bold");
- fontInfo.addFontProperties("F5", "Times", "normal", "normal");
- fontInfo.addFontProperties("F6", "Times", "oblique", "normal");
- fontInfo.addFontProperties("F6", "Times", "italic", "normal");
- fontInfo.addFontProperties("F7", "Times", "normal", "bold");
- fontInfo.addFontProperties("F8", "Times", "oblique", "bold");
- fontInfo.addFontProperties("F8", "Times", "italic", "bold");
- fontInfo.addFontProperties("F9", "Courier", "normal", "normal");
- fontInfo.addFontProperties("F10", "Courier", "oblique", "normal");
- fontInfo.addFontProperties("F10", "Courier", "italic", "normal");
- fontInfo.addFontProperties("F11", "Courier", "normal", "bold");
- fontInfo.addFontProperties("F12", "Courier", "oblique", "bold");
- fontInfo.addFontProperties("F12", "Courier", "italic", "bold");
- fontInfo.addFontProperties("F13", "Symbol", "normal", "normal");
- fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", "normal");
-
- // Custom type 1 fonts step 2/2
- // fontInfo.addFontProperties("F15", "OMEP", "normal", "normal");
- // fontInfo.addFontProperties("F16", "Garamond-LightCondensed", "normal", "normal");
- // fontInfo.addFontProperties("F17", "BauerBodoni", "italic", "bold");
-
- /* for compatibility with PassiveTex */
- fontInfo.addFontProperties("F5", "Times-Roman", "normal", "normal");
- fontInfo.addFontProperties("F6", "Times-Roman", "oblique", "normal");
- fontInfo.addFontProperties("F6", "Times-Roman", "italic", "normal");
- fontInfo.addFontProperties("F7", "Times-Roman", "normal", "bold");
- fontInfo.addFontProperties("F8", "Times-Roman", "oblique", "bold");
- fontInfo.addFontProperties("F8", "Times-Roman", "italic", "bold");
- fontInfo.addFontProperties("F5", "Times Roman", "normal", "normal");
- fontInfo.addFontProperties("F6", "Times Roman", "oblique", "normal");
- fontInfo.addFontProperties("F6", "Times Roman", "italic", "normal");
- fontInfo.addFontProperties("F7", "Times Roman", "normal", "bold");
- fontInfo.addFontProperties("F8", "Times Roman", "oblique", "bold");
- fontInfo.addFontProperties("F8", "Times Roman", "italic", "bold");
- fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
- "normal", "normal");
- }
-
-}
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif;
-
-// FOP
-import org.apache.fop.layout.FontMetric;
-
-/**
- * base class for PDF font classes
- */
-public abstract class Font implements FontMetric {
-
- /**
- * get the encoding of the font
- */
- public abstract String encoding();
-
- /**
- * get the base font name
- */
- public abstract String fontName();
-}
-
-
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif;
-
-// FOP
-import org.apache.fop.render.mif.fonts.*;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.layout.FontInfo;
-import org.apache.fop.layout.FontDescriptor;
-import org.apache.fop.mif.MIFDocument;
-// import org.apache.fop.pdf.PDFResources;
-
-// Java
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-/**
- * sets up the PDF fonts.
- *
- * Assigns the font (with metrics) to internal names like "F1" and
- * assigns family-style-weight triplets to the fonts
- */
-public class FontSetup {
-
- /**
- * sets up the font info object.
- *
- * adds metrics for basic fonts and useful family-style-weight
- * triplets for lookup
- *
- * @param fontInfo the font info object to set up
- */
- public static void setup(FontInfo fontInfo) {
- MessageHandler.logln("setting up fonts");
-
- fontInfo.addMetrics("F1", new Helvetica());
- fontInfo.addMetrics("F2", new HelveticaOblique());
- fontInfo.addMetrics("F3", new HelveticaBold());
- fontInfo.addMetrics("F4", new HelveticaBoldOblique());
- fontInfo.addMetrics("F5", new TimesRoman());
- fontInfo.addMetrics("F6", new TimesItalic());
- fontInfo.addMetrics("F7", new TimesBold());
- fontInfo.addMetrics("F8", new TimesBoldItalic());
- fontInfo.addMetrics("F9", new Courier());
- fontInfo.addMetrics("F10", new CourierOblique());
- fontInfo.addMetrics("F11", new CourierBold());
- fontInfo.addMetrics("F12", new CourierBoldOblique());
- fontInfo.addMetrics("F13", new Symbol());
- fontInfo.addMetrics("F14", new ZapfDingbats());
-
- // Custom type 1 fonts step 1/2
- // fontInfo.addMetrics("F15", new OMEP());
- // fontInfo.addMetrics("F16", new GaramondLightCondensed());
- // fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
-
- /* any is treated as serif */
- fontInfo.addFontProperties("F5", "any", "normal", "normal");
- fontInfo.addFontProperties("F6", "any", "italic", "normal");
- fontInfo.addFontProperties("F6", "any", "oblique", "normal");
- fontInfo.addFontProperties("F7", "any", "normal", "bold");
- fontInfo.addFontProperties("F8", "any", "italic", "bold");
- fontInfo.addFontProperties("F8", "any", "oblique", "bold");
-
- fontInfo.addFontProperties("F1", "sans-serif", "normal", "normal");
- fontInfo.addFontProperties("F2", "sans-serif", "oblique", "normal");
- fontInfo.addFontProperties("F2", "sans-serif", "italic", "normal");
- fontInfo.addFontProperties("F3", "sans-serif", "normal", "bold");
- fontInfo.addFontProperties("F4", "sans-serif", "oblique", "bold");
- fontInfo.addFontProperties("F4", "sans-serif", "italic", "bold");
- fontInfo.addFontProperties("F5", "serif", "normal", "normal");
- fontInfo.addFontProperties("F6", "serif", "oblique", "normal");
- fontInfo.addFontProperties("F6", "serif", "italic", "normal");
- fontInfo.addFontProperties("F7", "serif", "normal", "bold");
- fontInfo.addFontProperties("F8", "serif", "oblique", "bold");
- fontInfo.addFontProperties("F8", "serif", "italic", "bold");
- fontInfo.addFontProperties("F9", "monospace", "normal", "normal");
- fontInfo.addFontProperties("F10", "monospace", "oblique", "normal");
- fontInfo.addFontProperties("F10", "monospace", "italic", "normal");
- fontInfo.addFontProperties("F11", "monospace", "normal", "bold");
- fontInfo.addFontProperties("F12", "monospace", "oblique", "bold");
- fontInfo.addFontProperties("F12", "monospace", "italic", "bold");
-
- fontInfo.addFontProperties("F1", "Helvetica", "normal", "normal");
- fontInfo.addFontProperties("F2", "Helvetica", "oblique", "normal");
- fontInfo.addFontProperties("F2", "Helvetica", "italic", "normal");
- fontInfo.addFontProperties("F3", "Helvetica", "normal", "bold");
- fontInfo.addFontProperties("F4", "Helvetica", "oblique", "bold");
- fontInfo.addFontProperties("F4", "Helvetica", "italic", "bold");
- fontInfo.addFontProperties("F5", "Times", "normal", "normal");
- fontInfo.addFontProperties("F6", "Times", "oblique", "normal");
- fontInfo.addFontProperties("F6", "Times", "italic", "normal");
- fontInfo.addFontProperties("F7", "Times", "normal", "bold");
- fontInfo.addFontProperties("F8", "Times", "oblique", "bold");
- fontInfo.addFontProperties("F8", "Times", "italic", "bold");
- fontInfo.addFontProperties("F9", "Courier", "normal", "normal");
- fontInfo.addFontProperties("F10", "Courier", "oblique", "normal");
- fontInfo.addFontProperties("F10", "Courier", "italic", "normal");
- fontInfo.addFontProperties("F11", "Courier", "normal", "bold");
- fontInfo.addFontProperties("F12", "Courier", "oblique", "bold");
- fontInfo.addFontProperties("F12", "Courier", "italic", "bold");
- fontInfo.addFontProperties("F13", "Symbol", "normal", "normal");
- fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", "normal");
-
- // Custom type 1 fonts step 2/2
- // fontInfo.addFontProperties("F15", "OMEP", "normal", "normal");
- // fontInfo.addFontProperties("F16", "Garamond-LightCondensed", "normal", "normal");
- // fontInfo.addFontProperties("F17", "BauerBodoni", "italic", "bold");
-
- /* for compatibility with PassiveTex */
- fontInfo.addFontProperties("F5", "Times-Roman", "normal", "normal");
- fontInfo.addFontProperties("F6", "Times-Roman", "oblique", "normal");
- fontInfo.addFontProperties("F6", "Times-Roman", "italic", "normal");
- fontInfo.addFontProperties("F7", "Times-Roman", "normal", "bold");
- fontInfo.addFontProperties("F8", "Times-Roman", "oblique", "bold");
- fontInfo.addFontProperties("F8", "Times-Roman", "italic", "bold");
- fontInfo.addFontProperties("F5", "Times Roman", "normal", "normal");
- fontInfo.addFontProperties("F6", "Times Roman", "oblique", "normal");
- fontInfo.addFontProperties("F6", "Times Roman", "italic", "normal");
- fontInfo.addFontProperties("F7", "Times Roman", "normal", "bold");
- fontInfo.addFontProperties("F8", "Times Roman", "oblique", "bold");
- fontInfo.addFontProperties("F8", "Times Roman", "italic", "bold");
- fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
- "normal", "normal");
- }
-
- /**
- * add the fonts in the font info to the PDF document
- *
- * @param doc PDF document to add fonts to
- * @param fontInfo font info object to get font information from
- */
- public static void addToFontFormat(MIFDocument mifDoc,
- FontInfo fontInfo) {
-
- Hashtable fonts = fontInfo.getFonts();
- Enumeration e = fonts.keys();
- while (e.hasMoreElements()) {
- String f = (String)e.nextElement();
- Font font = (Font)fonts.get(f);
- FontDescriptor desc = null;
- if (font instanceof FontDescriptor) {
- desc = (FontDescriptor)font;
- }
- /*
- * mifDoc.makeFont(f,font.fontName(),
- * font.encoding(),
- * font,
- * desc
- * );
- */
-
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-// Author : Seshadri G
-
-package org.apache.fop.render.mif;
-
-// FOP
-import org.apache.fop.render.Renderer;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.image.ImageArea;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.fo.*;
-import org.apache.fop.layout.*;
-import org.apache.fop.layout.inline.*;
-import org.apache.fop.datatypes.*;
-import org.apache.fop.svg.*;
-import org.apache.fop.mif.*;
-import org.apache.fop.layout.*;
-import org.apache.fop.image.*;
-
-import org.w3c.dom.*;
-import org.w3c.dom.svg.*;
-import org.w3c.dom.css.*;
-import org.w3c.dom.svg.SVGLength;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import java.awt.Rectangle;
-import java.util.Vector;
-import java.util.Hashtable;
-
-/**
- * Renderer that renders areas to MIF
- *
- * Modified by Mark Lillywhite mark-fop@inomial.com. Updated to
- * collect all the Pages and print them out at the end. This means
- * that the MIF renderer does not stream, but on the other hand
- * it should still work. I don't have an MIF view to test it with,
- * you see.
- */
-public class MIFRenderer implements Renderer {
-
- private String currentFontName;
- private String currentFontSize;
- private int pageHeight;
- private int pageWidth;
-
- /**
- * the current vertical position in millipoints from bottom
- */
- protected int currentYPosition = 0;
-
- /**
- * the current horizontal position in millipoints from left
- */
- protected int currentXPosition = 0;
-
- /**
- * the horizontal position of the current area container
- */
- private int currentAreaContainerXPosition = 0;
-
-
- /**
- * the MIF Document being created
- */
- protected MIFDocument mifDoc;
-
-
- /* is a table currently open? */
- private boolean inTable = false;
-
- /**
- * options
- */
- protected Hashtable options;
-
- /**
- * create the MIF renderer
- */
- public MIFRenderer() {
- this.mifDoc = new MIFDocument();
- }
-
- /**
- * set up renderer options
- */
- public void setOptions(Hashtable options) {
- this.options = options;
- }
-
- /**
- * set up the given FontInfo
- */
- public void setupFontInfo(FontInfo fontInfo) {
-
- FontSetup.setup(fontInfo);
- // FontSetup.addToFontFormat(this.mifDoc, fontInfo);
-
- }
-
- /**
- * set the producer of the rendering
- */
- public void setProducer(String producer) {}
-
-
- public void renderAreaContainer(AreaContainer area) {
-
- if (area.foCreator != null
- && area.foCreator.getName() == "fo:table") {
-
- this.mifDoc.createTable();
- this.inTable = true;
- } else if (area.foCreator != null
- && area.foCreator.getName() == "fo:table-body") {
-
- this.mifDoc.setCurrent("fo:table-body");
- } else if (area.foCreator != null
- && area.foCreator.getName() == "fo:table-column") {
-
- int colWidth =
- ((org.apache.fop.fo.flow.TableColumn)area.foCreator).getColumnWidth();
- this.mifDoc.setColumnProp(colWidth);
- } else if (area.foCreator != null
- && area.foCreator.getName() == "fo:table-row") {
-
- this.mifDoc.startRow();
- } else if (area.foCreator != null
- && area.foCreator.getName() == "fo:table-cell") {
-
- int rowSpan =
- ((org.apache.fop.fo.flow.TableCell)area.foCreator).getNumRowsSpanned();
- int colSpan =
- ((org.apache.fop.fo.flow.TableCell)area.foCreator).getNumColumnsSpanned();
- this.mifDoc.startCell(rowSpan, colSpan);
- } else if (inTable) {
-
- inTable = false;
- this.mifDoc.endTable();
-
- }
- int saveY = this.currentYPosition;
- int saveX = this.currentAreaContainerXPosition;
-
- if (area.getPosition() == Position.ABSOLUTE) {
- // Y position is computed assuming positive Y axis, adjust for negative postscript one
- this.currentYPosition = area.getYPosition()
- - 2 * area.getPaddingTop()
- - 2 * area.getBorderTopWidth();
-
- this.currentAreaContainerXPosition = area.getXPosition();
- } else if (area.getPosition() == Position.RELATIVE) {
-
- this.currentYPosition -= area.getYPosition();
- this.currentAreaContainerXPosition += area.getXPosition();
-
- } else if (area.getPosition() == Position.STATIC) {
-
- this.currentYPosition -= area.getPaddingTop()
- + area.getBorderTopWidth();
- this.currentAreaContainerXPosition += area.getPaddingLeft()
- + area.getBorderLeftWidth();
- }
-
- this.currentXPosition = this.currentAreaContainerXPosition;
- doFrame(area);
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this);
- }
- if (area.getPosition() != Position.STATIC) {
- this.currentYPosition = saveY;
- this.currentAreaContainerXPosition = saveX;
- } else
- this.currentYPosition -= area.getHeight();
- }
-
- public void renderBodyAreaContainer(BodyAreaContainer area) {
-
-
- int saveY = this.currentYPosition;
- int saveX = this.currentAreaContainerXPosition;
-
- if (area.getPosition() == Position.ABSOLUTE) {
- // Y position is computed assuming positive Y axis, adjust for negative postscript one
- this.currentYPosition = area.getYPosition();
- this.currentAreaContainerXPosition = area.getXPosition();
- } else if (area.getPosition() == Position.RELATIVE) {
- this.currentYPosition -= area.getYPosition();
- this.currentAreaContainerXPosition += area.getXPosition();
- }
-
- this.currentXPosition = this.currentAreaContainerXPosition;
- int w, h;
- int rx = this.currentAreaContainerXPosition;
- w = area.getContentWidth();
- h = area.getContentHeight();
- int ry = this.currentYPosition;
- ColorType bg = area.getBackgroundColor();
-
- /*
- * // I'm not sure I should have to check for bg being null
- * // but I do
- * if ((bg != null) && (bg.alpha() == 0)) {
- * this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg));
- * }
- */
- /*
- * // floats & footnotes stuff
- * renderAreaContainer(area.getBeforeFloatReferenceArea());
- * renderAreaContainer(area.getFootnoteReferenceArea());
- */
- // main reference area
- Enumeration e = area.getMainReferenceArea().getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this); // span areas
- }
-
-
- if (area.getPosition() != Position.STATIC) {
- this.currentYPosition = saveY;
- this.currentAreaContainerXPosition = saveX;
- } else
- this.currentYPosition -= area.getHeight();
-
- }
-
- private void doFrame(Area area) {
- int w, h;
- int rx = this.currentAreaContainerXPosition;
- w = area.getContentWidth();
-
- if (area instanceof BlockArea)
- rx += ((BlockArea)area).getStartIndent();
-
- h = area.getContentHeight();
- int ry = this.currentYPosition;
- ColorType bg = area.getBackgroundColor();
-
- rx = rx - area.getPaddingLeft();
- ry = ry + area.getPaddingTop();
- w = w + area.getPaddingLeft() + area.getPaddingRight();
- h = h + area.getPaddingTop() + area.getPaddingBottom();
-
- /*
- * // I'm not sure I should have to check for bg being null
- * // but I do
- * if ((bg != null) && (bg.alpha() == 0)) {
- * this.addRect(rx, ry, w, -h,
- * new PDFColor(bg),
- * new PDFColor(bg));
- * }
- */
-
- rx = rx - area.getBorderLeftWidth();
- ry = ry + area.getBorderTopWidth();
- w = w + area.getBorderLeftWidth() + area.getBorderRightWidth();
- h = h + area.getBorderTopWidth() + area.getBorderBottomWidth();
-
- // Create a textrect with these dimensions.
- // The y co-ordinate is measured +ve downwards so subtract page-height
-
- this.mifDoc.setTextRectProp(rx, pageHeight - ry, w, h);
-
- /*
- * BorderAndPadding bp = area.getBorderAndPadding();
- * if (area.getBorderTopWidth() != 0)
- * addLine(rx, ry, rx + w, ry, area.getBorderTopWidth(),
- * new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
- * if (area.getBorderLeftWidth() != 0)
- * addLine(rx, ry, rx, ry - h, area.getBorderLeftWidth(),
- * new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
- * if (area.getBorderRightWidth() != 0)
- * addLine(rx + w, ry, rx + w, ry - h, area.getBorderRightWidth(),
- * new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
- * if (area.getBorderBottomWidth() != 0)
- * addLine(rx, ry - h, rx + w, ry - h, area.getBorderBottomWidth(),
- * new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
- */
- }
-
- public void renderSpanArea(SpanArea area) {
-
- // A span maps to a textframe
-
-
- this.mifDoc.createTextRect(area.getColumnCount());
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this); // column areas
- }
-
- }
-
- /**
- * render the given block area
- */
- public void renderBlockArea(BlockArea area) {
-
- this.mifDoc.setBlockProp(area.getStartIndent(), area.getEndIndent());
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this);
- }
-
- }
-
- /**
- * render the given display space
- */
- public void renderDisplaySpace(DisplaySpace space) {
-
- int d = space.getSize();
- this.currentYPosition -= d;
-
- }
-
- /**
- * render the given SVG area
- */
- public void renderSVGArea(SVGArea area) {}
-
- /**
- * render a foreign object area
- */
- public void renderForeignObjectArea(ForeignObjectArea area) {}
-
-
- public void renderWordArea(WordArea area) {
- String s;
- s = area.getText();
- this.mifDoc.addToStream(s);
-
- this.currentXPosition += area.getContentWidth();
- }
-
- /**
- * render the given image area
- */
- public void renderImageArea(ImageArea area) {
-
- int x = this.currentAreaContainerXPosition + area.getXOffset();
- int y = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= h;
-
- FopImage img = area.getImage();
- if (img instanceof SVGImage) {
- /*
- * try {
- * SVGSVGElement svg =
- * ((SVGImage) img).getSVGDocument().getRootElement();
- * currentStream.add("ET\nq\n" + (((float) w) / 1000f) +
- * " 0 0 " + (((float) h) / 1000f) + " " +
- * (((float) x) / 1000f) + " " +
- * (((float)(y - h)) / 1000f) + " cm\n");
- * // renderSVG(svg, (int) x, (int) y);
- * currentStream.add("Q\nBT\n");
- * } catch (FopImageException e) {
- * }
- */
-
- MessageHandler.logln("Warning: SVG images not supported in this version");
- } else {
- String url = img.getURL();
- this.mifDoc.addImage(url, x, pageHeight - y, w, h);
-
- }
- }
-
- /**
- * render the given inline area
- */
- public void renderInlineArea(InlineArea area) {}
-
- /**
- * render the given inline space
- */
- public void renderInlineSpace(InlineSpace space) {
-
- // I dont need the size of space! I just need to
- // leave a blank space each time
- String s = " ";
- this.mifDoc.addToStream(s); // cool!
- this.currentXPosition += space.getSize();
- }
-
- /**
- * render the given line area
- */
- public void renderLineArea(LineArea area) {
-
- int rx = this.currentAreaContainerXPosition + area.getStartIndent();
- int ry = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= area.getPlacementOffset();
- this.currentXPosition = rx;
-
- int bl = this.currentYPosition;
-
- // The start of a new linearea corresponds to a new para in FM
-
- this.mifDoc.startLine();
-
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
-
- Box b = (Box)e.nextElement();
- this.currentYPosition = ry - area.getPlacementOffset();
- b.render(this);
-
- }
- this.currentYPosition = ry - h;
- this.currentXPosition = rx;
-
- }
-
- /**
- * render the given page
- */
- public void renderPage(Page page) {
-
- AreaContainer before, after;
- BodyAreaContainer body;
- body = page.getBody();
- before = page.getBefore();
- after = page.getAfter();
-
- this.currentFontName = "";
- this.currentFontSize = "0";
-
- pageHeight = page.getHeight();
- pageWidth = page.getWidth();
- this.mifDoc.setDocumentHeightWidth(pageHeight, pageWidth);
-
- this.mifDoc.createPage();
-
- renderBodyAreaContainer(body);
-
-
- // If the area is an instance of anything other than body, it goes into the
- // corresponding master page.
-
-
- if (before != null) {
-
- this.mifDoc.createTextRect(1); // Create a rect with one col
- renderAreaContainer(before);
- }
-
- if (after != null) {
-
- this.mifDoc.createTextRect(1); // Create a rect with one col
- renderAreaContainer(after);
- }
-
- }
-
- /**
- * render the given leader area
- */
- public void renderLeaderArea(LeaderArea area) {}
-
- /**
- Default start renderer method. This would
- normally be overridden. (mark-fop@inomial.com).
- */
- public void startRenderer(OutputStream outputStream)
- throws IOException {
- MessageHandler.logln("rendering areas to MIF");
- }
-
- /**
- Default stop renderer method. This would
- normally be overridden. (mark-fop@inomial.com)
- */
- public void stopRenderer(OutputStream outputStream)
- throws IOException {
- MessageHandler.logln("writing out MIF");
- this.mifDoc.output(outputStream);
- outputStream.flush();
- }
-
- public void render(Page page, OutputStream outputStream) {
- this.renderPage(page);
- }
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class Courier extends Font {
- private final static String fontName = "Courier";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 562;
- private final static int xHeight = 426;
- private final static int ascender = 629;
- private final static int descender = -157;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 600;
- width[0x00C6] = 600;
- width[0x00C1] = 600;
- width[0x00C2] = 600;
- width[0x00C4] = 600;
- width[0x00C0] = 600;
- width[0x00C5] = 600;
- width[0x00C3] = 600;
- width[0x0042] = 600;
- width[0x0043] = 600;
- width[0x00C7] = 600;
- width[0x0044] = 600;
- width[0x0045] = 600;
- width[0x00C9] = 600;
- width[0x00CA] = 600;
- width[0x00CB] = 600;
- width[0x00C8] = 600;
- width[0x00D0] = 600;
- width[0x0046] = 600;
- width[0x0047] = 600;
- width[0x0048] = 600;
- width[0x0049] = 600;
- width[0x00CD] = 600;
- width[0x00CE] = 600;
- width[0x00CF] = 600;
- width[0x00CC] = 600;
- width[0x004A] = 600;
- width[0x004B] = 600;
- width[0x004C] = 600;
- width[0x004D] = 600;
- width[0x004E] = 600;
- width[0x00D1] = 600;
- width[0x004F] = 600;
- width[0x008C] = 600;
- width[0x00D3] = 600;
- width[0x00D4] = 600;
- width[0x00D6] = 600;
- width[0x00D2] = 600;
- width[0x00D8] = 600;
- width[0x00D5] = 600;
- width[0x0050] = 600;
- width[0x0051] = 600;
- width[0x0052] = 600;
- width[0x0053] = 600;
- width[0x008A] = 600;
- width[0x0054] = 600;
- width[0x00DE] = 600;
- width[0x0055] = 600;
- width[0x00DA] = 600;
- width[0x00DB] = 600;
- width[0x00DC] = 600;
- width[0x00D9] = 600;
- width[0x0056] = 600;
- width[0x0057] = 600;
- width[0x0058] = 600;
- width[0x0059] = 600;
- width[0x00DD] = 600;
- width[0x009F] = 600;
- width[0x005A] = 600;
- width[0x0061] = 600;
- width[0x00E1] = 600;
- width[0x00E2] = 600;
- width[0x00B4] = 600;
- width[0x00E4] = 600;
- width[0x00E6] = 600;
- width[0x00E0] = 600;
- width[0x0026] = 600;
- width[0x00E5] = 600;
- width[0xAB] = 600;
- width[0xAF] = 600;
- width[0xAC] = 600;
- width[0xAE] = 600;
- width[0xAD] = 600;
- width[0x005E] = 600;
- width[0x007E] = 600;
- width[0x002A] = 600;
- width[0x0040] = 600;
- width[0x00E3] = 600;
- width[0x0062] = 600;
- width[0x005C] = 600;
- width[0x007C] = 600;
- width[0x007B] = 600;
- width[0x007D] = 600;
- width[0x005B] = 600;
- width[0x005D] = 600;
- width[0x00A6] = 600;
- width[0x0095] = 600;
- width[0x0063] = 600;
- width[0x00E7] = 600;
- width[0x00B8] = 600;
- width[0x00A2] = 600;
- width[0x0088] = 600;
- width[0x003A] = 600;
- width[0x002C] = 600;
- width[0x00A9] = 600;
- width[0x00A4] = 600;
- width[0x0064] = 600;
- width[0x0086] = 600;
- width[0x0087] = 600;
- width[0x00B0] = 600;
- width[0x00A8] = 600;
- width[0x00F7] = 600;
- width[0x0024] = 600;
- width[0x0065] = 600;
- width[0x00E9] = 600;
- width[0x00EA] = 600;
- width[0x00EB] = 600;
- width[0x00E8] = 600;
- width[0x0038] = 600;
- width[0x0085] = 600;
- width[0x0097] = 600;
- width[0x0096] = 600;
- width[0x003D] = 600;
- width[0x00F0] = 600;
- width[0x0021] = 600;
- width[0x00A1] = 600;
- width[0x0066] = 600;
- width[0x0035] = 600;
- width[0x0083] = 600;
- width[0x0034] = 600;
- width[0xA4] = 600;
- width[0x0067] = 600;
- width[0x00DF] = 600;
- width[0x0060] = 600;
- width[0x003E] = 600;
- width[0x00AB] = 600;
- width[0x00BB] = 600;
- width[0x008B] = 600;
- width[0x009B] = 600;
- width[0x0068] = 600;
- width[0x002D] = 600;
- width[0x0069] = 600;
- width[0x00ED] = 600;
- width[0x00EE] = 600;
- width[0x00EF] = 600;
- width[0x00EC] = 600;
- width[0x006A] = 600;
- width[0x006B] = 600;
- width[0x006C] = 600;
- width[0x003C] = 600;
- width[0x00AC] = 600;
- width[0x006D] = 600;
- width[0x00AF] = 600;
- width[0x2D] = 600;
- width[0x00B5] = 600;
- width[0x00D7] = 600;
- width[0x006E] = 600;
- width[0x0039] = 600;
- width[0x00F1] = 600;
- width[0x0023] = 600;
- width[0x006F] = 600;
- width[0x00F3] = 600;
- width[0x00F4] = 600;
- width[0x00F6] = 600;
- width[0x009C] = 600;
- width[0x00F2] = 600;
- width[0x0031] = 600;
- width[0x00BD] = 600;
- width[0x00BC] = 600;
- width[0x00B9] = 600;
- width[0x00AA] = 600;
- width[0x00BA] = 600;
- width[0x00F8] = 600;
- width[0x00F5] = 600;
- width[0x0070] = 600;
- width[0x00B6] = 600;
- width[0x0028] = 600;
- width[0x0029] = 600;
- width[0x0025] = 600;
- width[0x002E] = 600;
- width[0x00B7] = 600;
- width[0x0089] = 600;
- width[0x002B] = 600;
- width[0x00B1] = 600;
- width[0x0071] = 600;
- width[0x003F] = 600;
- width[0x00BF] = 600;
- width[0x0022] = 600;
- width[0x0084] = 600;
- width[0x0093] = 600;
- width[0x0094] = 600;
- width[0x0091] = 600;
- width[0x0092] = 600;
- width[0x0082] = 600;
- width[0x0027] = 600;
- width[0x0072] = 600;
- width[0x00AE] = 600;
- width[0x00B0] = 600;
- width[0x0073] = 600;
- width[0x009A] = 600;
- width[0x00A7] = 600;
- width[0x003B] = 600;
- width[0x0037] = 600;
- width[0x0036] = 600;
- width[0x002F] = 600;
- width[0x0020] = 600;
- width[0x00A0] = 600;
- width[0x00A3] = 600;
- width[0x0074] = 600;
- width[0x00FE] = 600;
- width[0x0033] = 600;
- width[0x00BE] = 600;
- width[0x00B3] = 600;
- width[0x0098] = 600;
- width[0x0099] = 600;
- width[0x0032] = 600;
- width[0x00B2] = 600;
- width[0x0075] = 600;
- width[0x00FA] = 600;
- width[0x00FB] = 600;
- width[0x00FC] = 600;
- width[0x00F9] = 600;
- width[0x005F] = 600;
- width[0x0076] = 600;
- width[0x0077] = 600;
- width[0x0078] = 600;
- width[0x0079] = 600;
- width[0x00FD] = 600;
- width[0x00FF] = 600;
- width[0x00A5] = 600;
- width[0x007A] = 600;
- width[0x0030] = 600;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class CourierBold extends Font {
- private final static String fontName = "Courier-Bold";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 562;
- private final static int xHeight = 439;
- private final static int ascender = 626;
- private final static int descender = -142;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 600;
- width[0x00C6] = 600;
- width[0x00C1] = 600;
- width[0x00C2] = 600;
- width[0x00C4] = 600;
- width[0x00C0] = 600;
- width[0x00C5] = 600;
- width[0x00C3] = 600;
- width[0x0042] = 600;
- width[0x0043] = 600;
- width[0x00C7] = 600;
- width[0x0044] = 600;
- width[0x0045] = 600;
- width[0x00C9] = 600;
- width[0x00CA] = 600;
- width[0x00CB] = 600;
- width[0x00C8] = 600;
- width[0x00D0] = 600;
- width[0x0046] = 600;
- width[0x0047] = 600;
- width[0x0048] = 600;
- width[0x0049] = 600;
- width[0x00CD] = 600;
- width[0x00CE] = 600;
- width[0x00CF] = 600;
- width[0x00CC] = 600;
- width[0x004A] = 600;
- width[0x004B] = 600;
- width[0x004C] = 600;
- width[0x004D] = 600;
- width[0x004E] = 600;
- width[0x00D1] = 600;
- width[0x004F] = 600;
- width[0x008C] = 600;
- width[0x00D3] = 600;
- width[0x00D4] = 600;
- width[0x00D6] = 600;
- width[0x00D2] = 600;
- width[0x00D8] = 600;
- width[0x00D5] = 600;
- width[0x0050] = 600;
- width[0x0051] = 600;
- width[0x0052] = 600;
- width[0x0053] = 600;
- width[0x008A] = 600;
- width[0x0054] = 600;
- width[0x00DE] = 600;
- width[0x0055] = 600;
- width[0x00DA] = 600;
- width[0x00DB] = 600;
- width[0x00DC] = 600;
- width[0x00D9] = 600;
- width[0x0056] = 600;
- width[0x0057] = 600;
- width[0x0058] = 600;
- width[0x0059] = 600;
- width[0x00DD] = 600;
- width[0x009F] = 600;
- width[0x005A] = 600;
- width[0x0061] = 600;
- width[0x00E1] = 600;
- width[0x00E2] = 600;
- width[0x00B4] = 600;
- width[0x00E4] = 600;
- width[0x00E6] = 600;
- width[0x00E0] = 600;
- width[0x0026] = 600;
- width[0x00E5] = 600;
- width[0xAB] = 600;
- width[0xAF] = 600;
- width[0xAC] = 600;
- width[0xAE] = 600;
- width[0xAD] = 600;
- width[0x005E] = 600;
- width[0x007E] = 600;
- width[0x002A] = 600;
- width[0x0040] = 600;
- width[0x00E3] = 600;
- width[0x0062] = 600;
- width[0x005C] = 600;
- width[0x007C] = 600;
- width[0x007B] = 600;
- width[0x007D] = 600;
- width[0x005B] = 600;
- width[0x005D] = 600;
- width[0x00A6] = 600;
- width[0x0095] = 600;
- width[0x0063] = 600;
- width[0x00E7] = 600;
- width[0x00B8] = 600;
- width[0x00A2] = 600;
- width[0x0088] = 600;
- width[0x003A] = 600;
- width[0x002C] = 600;
- width[0x00A9] = 600;
- width[0x00A4] = 600;
- width[0x0064] = 600;
- width[0x0086] = 600;
- width[0x0087] = 600;
- width[0x00B0] = 600;
- width[0x00A8] = 600;
- width[0x00F7] = 600;
- width[0x0024] = 600;
- width[0x0065] = 600;
- width[0x00E9] = 600;
- width[0x00EA] = 600;
- width[0x00EB] = 600;
- width[0x00E8] = 600;
- width[0x0038] = 600;
- width[0x0085] = 600;
- width[0x0097] = 600;
- width[0x0096] = 600;
- width[0x003D] = 600;
- width[0x00F0] = 600;
- width[0x0021] = 600;
- width[0x00A1] = 600;
- width[0x0066] = 600;
- width[0x0035] = 600;
- width[0x0083] = 600;
- width[0x0034] = 600;
- width[0xA4] = 600;
- width[0x0067] = 600;
- width[0x00DF] = 600;
- width[0x0060] = 600;
- width[0x003E] = 600;
- width[0x00AB] = 600;
- width[0x00BB] = 600;
- width[0x008B] = 600;
- width[0x009B] = 600;
- width[0x0068] = 600;
- width[0x002D] = 600;
- width[0x0069] = 600;
- width[0x00ED] = 600;
- width[0x00EE] = 600;
- width[0x00EF] = 600;
- width[0x00EC] = 600;
- width[0x006A] = 600;
- width[0x006B] = 600;
- width[0x006C] = 600;
- width[0x003C] = 600;
- width[0x00AC] = 600;
- width[0x006D] = 600;
- width[0x00AF] = 600;
- width[0x2D] = 600;
- width[0x00B5] = 600;
- width[0x00D7] = 600;
- width[0x006E] = 600;
- width[0x0039] = 600;
- width[0x00F1] = 600;
- width[0x0023] = 600;
- width[0x006F] = 600;
- width[0x00F3] = 600;
- width[0x00F4] = 600;
- width[0x00F6] = 600;
- width[0x009C] = 600;
- width[0x00F2] = 600;
- width[0x0031] = 600;
- width[0x00BD] = 600;
- width[0x00BC] = 600;
- width[0x00B9] = 600;
- width[0x00AA] = 600;
- width[0x00BA] = 600;
- width[0x00F8] = 600;
- width[0x00F5] = 600;
- width[0x0070] = 600;
- width[0x00B6] = 600;
- width[0x0028] = 600;
- width[0x0029] = 600;
- width[0x0025] = 600;
- width[0x002E] = 600;
- width[0x00B7] = 600;
- width[0x0089] = 600;
- width[0x002B] = 600;
- width[0x00B1] = 600;
- width[0x0071] = 600;
- width[0x003F] = 600;
- width[0x00BF] = 600;
- width[0x0022] = 600;
- width[0x0084] = 600;
- width[0x0093] = 600;
- width[0x0094] = 600;
- width[0x0091] = 600;
- width[0x0092] = 600;
- width[0x0082] = 600;
- width[0x0027] = 600;
- width[0x0072] = 600;
- width[0x00AE] = 600;
- width[0x00B0] = 600;
- width[0x0073] = 600;
- width[0x009A] = 600;
- width[0x00A7] = 600;
- width[0x003B] = 600;
- width[0x0037] = 600;
- width[0x0036] = 600;
- width[0x002F] = 600;
- width[0x0020] = 600;
- width[0x00A0] = 600;
- width[0x00A3] = 600;
- width[0x0074] = 600;
- width[0x00FE] = 600;
- width[0x0033] = 600;
- width[0x00BE] = 600;
- width[0x00B3] = 600;
- width[0x0098] = 600;
- width[0x0099] = 600;
- width[0x0032] = 600;
- width[0x00B2] = 600;
- width[0x0075] = 600;
- width[0x00FA] = 600;
- width[0x00FB] = 600;
- width[0x00FC] = 600;
- width[0x00F9] = 600;
- width[0x005F] = 600;
- width[0x0076] = 600;
- width[0x0077] = 600;
- width[0x0078] = 600;
- width[0x0079] = 600;
- width[0x00FD] = 600;
- width[0x00FF] = 600;
- width[0x00A5] = 600;
- width[0x007A] = 600;
- width[0x0030] = 600;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class CourierBoldOblique extends Font {
- private final static String fontName = "Courier-BoldOblique";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 562;
- private final static int xHeight = 439;
- private final static int ascender = 626;
- private final static int descender = -142;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 600;
- width[0x00C6] = 600;
- width[0x00C1] = 600;
- width[0x00C2] = 600;
- width[0x00C4] = 600;
- width[0x00C0] = 600;
- width[0x00C5] = 600;
- width[0x00C3] = 600;
- width[0x0042] = 600;
- width[0x0043] = 600;
- width[0x00C7] = 600;
- width[0x0044] = 600;
- width[0x0045] = 600;
- width[0x00C9] = 600;
- width[0x00CA] = 600;
- width[0x00CB] = 600;
- width[0x00C8] = 600;
- width[0x00D0] = 600;
- width[0x0046] = 600;
- width[0x0047] = 600;
- width[0x0048] = 600;
- width[0x0049] = 600;
- width[0x00CD] = 600;
- width[0x00CE] = 600;
- width[0x00CF] = 600;
- width[0x00CC] = 600;
- width[0x004A] = 600;
- width[0x004B] = 600;
- width[0x004C] = 600;
- width[0x004D] = 600;
- width[0x004E] = 600;
- width[0x00D1] = 600;
- width[0x004F] = 600;
- width[0x008C] = 600;
- width[0x00D3] = 600;
- width[0x00D4] = 600;
- width[0x00D6] = 600;
- width[0x00D2] = 600;
- width[0x00D8] = 600;
- width[0x00D5] = 600;
- width[0x0050] = 600;
- width[0x0051] = 600;
- width[0x0052] = 600;
- width[0x0053] = 600;
- width[0x008A] = 600;
- width[0x0054] = 600;
- width[0x00DE] = 600;
- width[0x0055] = 600;
- width[0x00DA] = 600;
- width[0x00DB] = 600;
- width[0x00DC] = 600;
- width[0x00D9] = 600;
- width[0x0056] = 600;
- width[0x0057] = 600;
- width[0x0058] = 600;
- width[0x0059] = 600;
- width[0x00DD] = 600;
- width[0x009F] = 600;
- width[0x005A] = 600;
- width[0x0061] = 600;
- width[0x00E1] = 600;
- width[0x00E2] = 600;
- width[0x00B4] = 600;
- width[0x00E4] = 600;
- width[0x00E6] = 600;
- width[0x00E0] = 600;
- width[0x0026] = 600;
- width[0x00E5] = 600;
- width[0xAB] = 600;
- width[0xAF] = 600;
- width[0xAC] = 600;
- width[0xAE] = 600;
- width[0xAD] = 600;
- width[0x005E] = 600;
- width[0x007E] = 600;
- width[0x002A] = 600;
- width[0x0040] = 600;
- width[0x00E3] = 600;
- width[0x0062] = 600;
- width[0x005C] = 600;
- width[0x007C] = 600;
- width[0x007B] = 600;
- width[0x007D] = 600;
- width[0x005B] = 600;
- width[0x005D] = 600;
- width[0x00A6] = 600;
- width[0x0095] = 600;
- width[0x0063] = 600;
- width[0x00E7] = 600;
- width[0x00B8] = 600;
- width[0x00A2] = 600;
- width[0x0088] = 600;
- width[0x003A] = 600;
- width[0x002C] = 600;
- width[0x00A9] = 600;
- width[0x00A4] = 600;
- width[0x0064] = 600;
- width[0x0086] = 600;
- width[0x0087] = 600;
- width[0x00B0] = 600;
- width[0x00A8] = 600;
- width[0x00F7] = 600;
- width[0x0024] = 600;
- width[0x0065] = 600;
- width[0x00E9] = 600;
- width[0x00EA] = 600;
- width[0x00EB] = 600;
- width[0x00E8] = 600;
- width[0x0038] = 600;
- width[0x0085] = 600;
- width[0x0097] = 600;
- width[0x0096] = 600;
- width[0x003D] = 600;
- width[0x00F0] = 600;
- width[0x0021] = 600;
- width[0x00A1] = 600;
- width[0x0066] = 600;
- width[0x0035] = 600;
- width[0x0083] = 600;
- width[0x0034] = 600;
- width[0xA4] = 600;
- width[0x0067] = 600;
- width[0x00DF] = 600;
- width[0x0060] = 600;
- width[0x003E] = 600;
- width[0x00AB] = 600;
- width[0x00BB] = 600;
- width[0x008B] = 600;
- width[0x009B] = 600;
- width[0x0068] = 600;
- width[0x002D] = 600;
- width[0x0069] = 600;
- width[0x00ED] = 600;
- width[0x00EE] = 600;
- width[0x00EF] = 600;
- width[0x00EC] = 600;
- width[0x006A] = 600;
- width[0x006B] = 600;
- width[0x006C] = 600;
- width[0x003C] = 600;
- width[0x00AC] = 600;
- width[0x006D] = 600;
- width[0x00AF] = 600;
- width[0x2D] = 600;
- width[0x00B5] = 600;
- width[0x00D7] = 600;
- width[0x006E] = 600;
- width[0x0039] = 600;
- width[0x00F1] = 600;
- width[0x0023] = 600;
- width[0x006F] = 600;
- width[0x00F3] = 600;
- width[0x00F4] = 600;
- width[0x00F6] = 600;
- width[0x009C] = 600;
- width[0x00F2] = 600;
- width[0x0031] = 600;
- width[0x00BD] = 600;
- width[0x00BC] = 600;
- width[0x00B9] = 600;
- width[0x00AA] = 600;
- width[0x00BA] = 600;
- width[0x00F8] = 600;
- width[0x00F5] = 600;
- width[0x0070] = 600;
- width[0x00B6] = 600;
- width[0x0028] = 600;
- width[0x0029] = 600;
- width[0x0025] = 600;
- width[0x002E] = 600;
- width[0x00B7] = 600;
- width[0x0089] = 600;
- width[0x002B] = 600;
- width[0x00B1] = 600;
- width[0x0071] = 600;
- width[0x003F] = 600;
- width[0x00BF] = 600;
- width[0x0022] = 600;
- width[0x0084] = 600;
- width[0x0093] = 600;
- width[0x0094] = 600;
- width[0x0091] = 600;
- width[0x0092] = 600;
- width[0x0082] = 600;
- width[0x0027] = 600;
- width[0x0072] = 600;
- width[0x00AE] = 600;
- width[0x00B0] = 600;
- width[0x0073] = 600;
- width[0x009A] = 600;
- width[0x00A7] = 600;
- width[0x003B] = 600;
- width[0x0037] = 600;
- width[0x0036] = 600;
- width[0x002F] = 600;
- width[0x0020] = 600;
- width[0x00A0] = 600;
- width[0x00A3] = 600;
- width[0x0074] = 600;
- width[0x00FE] = 600;
- width[0x0033] = 600;
- width[0x00BE] = 600;
- width[0x00B3] = 600;
- width[0x0098] = 600;
- width[0x0099] = 600;
- width[0x0032] = 600;
- width[0x00B2] = 600;
- width[0x0075] = 600;
- width[0x00FA] = 600;
- width[0x00FB] = 600;
- width[0x00FC] = 600;
- width[0x00F9] = 600;
- width[0x005F] = 600;
- width[0x0076] = 600;
- width[0x0077] = 600;
- width[0x0078] = 600;
- width[0x0079] = 600;
- width[0x00FD] = 600;
- width[0x00FF] = 600;
- width[0x00A5] = 600;
- width[0x007A] = 600;
- width[0x0030] = 600;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class CourierOblique extends Font {
- private final static String fontName = "Courier-Oblique";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 562;
- private final static int xHeight = 426;
- private final static int ascender = 629;
- private final static int descender = -157;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 600;
- width[0x00C6] = 600;
- width[0x00C1] = 600;
- width[0x00C2] = 600;
- width[0x00C4] = 600;
- width[0x00C0] = 600;
- width[0x00C5] = 600;
- width[0x00C3] = 600;
- width[0x0042] = 600;
- width[0x0043] = 600;
- width[0x00C7] = 600;
- width[0x0044] = 600;
- width[0x0045] = 600;
- width[0x00C9] = 600;
- width[0x00CA] = 600;
- width[0x00CB] = 600;
- width[0x00C8] = 600;
- width[0x00D0] = 600;
- width[0x0046] = 600;
- width[0x0047] = 600;
- width[0x0048] = 600;
- width[0x0049] = 600;
- width[0x00CD] = 600;
- width[0x00CE] = 600;
- width[0x00CF] = 600;
- width[0x00CC] = 600;
- width[0x004A] = 600;
- width[0x004B] = 600;
- width[0x004C] = 600;
- width[0x004D] = 600;
- width[0x004E] = 600;
- width[0x00D1] = 600;
- width[0x004F] = 600;
- width[0x008C] = 600;
- width[0x00D3] = 600;
- width[0x00D4] = 600;
- width[0x00D6] = 600;
- width[0x00D2] = 600;
- width[0x00D8] = 600;
- width[0x00D5] = 600;
- width[0x0050] = 600;
- width[0x0051] = 600;
- width[0x0052] = 600;
- width[0x0053] = 600;
- width[0x008A] = 600;
- width[0x0054] = 600;
- width[0x00DE] = 600;
- width[0x0055] = 600;
- width[0x00DA] = 600;
- width[0x00DB] = 600;
- width[0x00DC] = 600;
- width[0x00D9] = 600;
- width[0x0056] = 600;
- width[0x0057] = 600;
- width[0x0058] = 600;
- width[0x0059] = 600;
- width[0x00DD] = 600;
- width[0x009F] = 600;
- width[0x005A] = 600;
- width[0x0061] = 600;
- width[0x00E1] = 600;
- width[0x00E2] = 600;
- width[0x00B4] = 600;
- width[0x00E4] = 600;
- width[0x00E6] = 600;
- width[0x00E0] = 600;
- width[0x0026] = 600;
- width[0x00E5] = 600;
- width[0xAB] = 600;
- width[0xAF] = 600;
- width[0xAC] = 600;
- width[0xAE] = 600;
- width[0xAD] = 600;
- width[0x005E] = 600;
- width[0x007E] = 600;
- width[0x002A] = 600;
- width[0x0040] = 600;
- width[0x00E3] = 600;
- width[0x0062] = 600;
- width[0x005C] = 600;
- width[0x007C] = 600;
- width[0x007B] = 600;
- width[0x007D] = 600;
- width[0x005B] = 600;
- width[0x005D] = 600;
- width[0x00A6] = 600;
- width[0x0095] = 600;
- width[0x0063] = 600;
- width[0x00E7] = 600;
- width[0x00B8] = 600;
- width[0x00A2] = 600;
- width[0x0088] = 600;
- width[0x003A] = 600;
- width[0x002C] = 600;
- width[0x00A9] = 600;
- width[0x00A4] = 600;
- width[0x0064] = 600;
- width[0x0086] = 600;
- width[0x0087] = 600;
- width[0x00B0] = 600;
- width[0x00A8] = 600;
- width[0x00F7] = 600;
- width[0x0024] = 600;
- width[0x0065] = 600;
- width[0x00E9] = 600;
- width[0x00EA] = 600;
- width[0x00EB] = 600;
- width[0x00E8] = 600;
- width[0x0038] = 600;
- width[0x0085] = 600;
- width[0x0097] = 600;
- width[0x0096] = 600;
- width[0x003D] = 600;
- width[0x00F0] = 600;
- width[0x0021] = 600;
- width[0x00A1] = 600;
- width[0x0066] = 600;
- width[0x0035] = 600;
- width[0x0083] = 600;
- width[0x0034] = 600;
- width[0xA4] = 600;
- width[0x0067] = 600;
- width[0x00DF] = 600;
- width[0x0060] = 600;
- width[0x003E] = 600;
- width[0x00AB] = 600;
- width[0x00BB] = 600;
- width[0x008B] = 600;
- width[0x009B] = 600;
- width[0x0068] = 600;
- width[0x002D] = 600;
- width[0x0069] = 600;
- width[0x00ED] = 600;
- width[0x00EE] = 600;
- width[0x00EF] = 600;
- width[0x00EC] = 600;
- width[0x006A] = 600;
- width[0x006B] = 600;
- width[0x006C] = 600;
- width[0x003C] = 600;
- width[0x00AC] = 600;
- width[0x006D] = 600;
- width[0x00AF] = 600;
- width[0x2D] = 600;
- width[0x00B5] = 600;
- width[0x00D7] = 600;
- width[0x006E] = 600;
- width[0x0039] = 600;
- width[0x00F1] = 600;
- width[0x0023] = 600;
- width[0x006F] = 600;
- width[0x00F3] = 600;
- width[0x00F4] = 600;
- width[0x00F6] = 600;
- width[0x009C] = 600;
- width[0x00F2] = 600;
- width[0x0031] = 600;
- width[0x00BD] = 600;
- width[0x00BC] = 600;
- width[0x00B9] = 600;
- width[0x00AA] = 600;
- width[0x00BA] = 600;
- width[0x00F8] = 600;
- width[0x00F5] = 600;
- width[0x0070] = 600;
- width[0x00B6] = 600;
- width[0x0028] = 600;
- width[0x0029] = 600;
- width[0x0025] = 600;
- width[0x002E] = 600;
- width[0x00B7] = 600;
- width[0x0089] = 600;
- width[0x002B] = 600;
- width[0x00B1] = 600;
- width[0x0071] = 600;
- width[0x003F] = 600;
- width[0x00BF] = 600;
- width[0x0022] = 600;
- width[0x0084] = 600;
- width[0x0093] = 600;
- width[0x0094] = 600;
- width[0x0091] = 600;
- width[0x0092] = 600;
- width[0x0082] = 600;
- width[0x0027] = 600;
- width[0x0072] = 600;
- width[0x00AE] = 600;
- width[0x00B0] = 600;
- width[0x0073] = 600;
- width[0x009A] = 600;
- width[0x00A7] = 600;
- width[0x003B] = 600;
- width[0x0037] = 600;
- width[0x0036] = 600;
- width[0x002F] = 600;
- width[0x0020] = 600;
- width[0x00A0] = 600;
- width[0x00A3] = 600;
- width[0x0074] = 600;
- width[0x00FE] = 600;
- width[0x0033] = 600;
- width[0x00BE] = 600;
- width[0x00B3] = 600;
- width[0x0098] = 600;
- width[0x0099] = 600;
- width[0x0032] = 600;
- width[0x00B2] = 600;
- width[0x0075] = 600;
- width[0x00FA] = 600;
- width[0x00FB] = 600;
- width[0x00FC] = 600;
- width[0x00F9] = 600;
- width[0x005F] = 600;
- width[0x0076] = 600;
- width[0x0077] = 600;
- width[0x0078] = 600;
- width[0x0079] = 600;
- width[0x00FD] = 600;
- width[0x00FF] = 600;
- width[0x00A5] = 600;
- width[0x007A] = 600;
- width[0x0030] = 600;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class Helvetica extends Font {
- private final static String fontName = "Helvetica";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 718;
- private final static int xHeight = 523;
- private final static int ascender = 718;
- private final static int descender = -207;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 667;
- width[0x00C6] = 1000;
- width[0x00C1] = 667;
- width[0x00C2] = 667;
- width[0x00C4] = 667;
- width[0x00C0] = 667;
- width[0x00C5] = 667;
- width[0x00C3] = 667;
- width[0x0042] = 667;
- width[0x0043] = 722;
- width[0x00C7] = 722;
- width[0x0044] = 722;
- width[0x0045] = 667;
- width[0x00C9] = 667;
- width[0x00CA] = 667;
- width[0x00CB] = 667;
- width[0x00C8] = 667;
- width[0x00D0] = 722;
- width[0x0046] = 611;
- width[0x0047] = 778;
- width[0x0048] = 722;
- width[0x0049] = 278;
- width[0x00CD] = 278;
- width[0x00CE] = 278;
- width[0x00CF] = 278;
- width[0x00CC] = 278;
- width[0x004A] = 500;
- width[0x004B] = 667;
- width[0x004C] = 556;
- width[0x004D] = 833;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 778;
- width[0x008C] = 1000;
- width[0x00D3] = 778;
- width[0x00D4] = 778;
- width[0x00D6] = 778;
- width[0x00D2] = 778;
- width[0x00D8] = 778;
- width[0x00D5] = 778;
- width[0x0050] = 667;
- width[0x0051] = 778;
- width[0x0052] = 722;
- width[0x0053] = 667;
- width[0x008A] = 667;
- width[0x0054] = 611;
- width[0x00DE] = 667;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 667;
- width[0x0057] = 944;
- width[0x0058] = 667;
- width[0x0059] = 667;
- width[0x00DD] = 667;
- width[0x009F] = 667;
- width[0x005A] = 611;
- width[0x0061] = 556;
- width[0x00E1] = 556;
- width[0x00E2] = 556;
- width[0x00B4] = 333;
- width[0x00E4] = 556;
- width[0x00E6] = 889;
- width[0x00E0] = 556;
- width[0x0026] = 667;
- width[0x00E5] = 556;
- width[0x005E] = 469;
- width[0x007E] = 584;
- width[0x002A] = 389;
- width[0x0040] = 1015;
- width[0x00E3] = 556;
- width[0x0062] = 556;
- width[0x005C] = 278;
- width[0x007C] = 260;
- width[0x007B] = 334;
- width[0x007D] = 334;
- width[0x005B] = 278;
- width[0x005D] = 278;
- width[0x00A6] = 260;
- width[0x0095] = 350;
- width[0x0063] = 500;
- width[0x00E7] = 500;
- width[0x00B8] = 333;
- width[0x00A2] = 556;
- width[0x0088] = 333;
- width[0x003A] = 278;
- width[0x002C] = 278;
- width[0x00A9] = 737;
- width[0x00A4] = 556;
- width[0x0064] = 556;
- width[0x0086] = 556;
- width[0x0087] = 556;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 584;
- width[0x0024] = 556;
- width[0x0065] = 556;
- width[0x00E9] = 556;
- width[0x00EA] = 556;
- width[0x00EB] = 556;
- width[0x00E8] = 556;
- width[0x0038] = 556;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 556;
- width[0x003D] = 584;
- width[0x00F0] = 556;
- width[0x0021] = 278;
- width[0x00A1] = 333;
- width[0x0066] = 278;
- width[0x0035] = 556;
- width[0x0083] = 556;
- width[0x0034] = 556;
- width[0xA4] = 167;
- width[0x0067] = 556;
- width[0x00DF] = 611;
- width[0x0060] = 333;
- width[0x003E] = 584;
- width[0x00AB] = 556;
- width[0x00BB] = 556;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 556;
- width[0x002D] = 333;
- width[0x0069] = 222;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 222;
- width[0x006B] = 500;
- width[0x006C] = 222;
- width[0x003C] = 584;
- width[0x00AC] = 584;
- width[0x006D] = 833;
- width[0x00AF] = 333;
- width[0x2D] = 324;
- width[0x00B5] = 556;
- width[0x00D7] = 584;
- width[0x006E] = 556;
- width[0x0039] = 556;
- width[0x00F1] = 556;
- width[0x0023] = 556;
- width[0x006F] = 556;
- width[0x00F3] = 556;
- width[0x00F4] = 556;
- width[0x00F6] = 556;
- width[0x009C] = 944;
- width[0x00F2] = 556;
- width[0x0031] = 556;
- width[0x00BD] = 834;
- width[0x00BC] = 834;
- width[0x00B9] = 333;
- width[0x00AA] = 370;
- width[0x00BA] = 365;
- width[0x00F8] = 611;
- width[0x00F5] = 556;
- width[0x0070] = 556;
- width[0x00B6] = 537;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 889;
- width[0x002E] = 278;
- width[0x00B7] = 278;
- width[0x0089] = 1000;
- width[0x002B] = 584;
- width[0x00B1] = 584;
- width[0x0071] = 556;
- width[0x003F] = 556;
- width[0x00BF] = 611;
- width[0x0022] = 355;
- width[0x0084] = 333;
- width[0x0093] = 333;
- width[0x0094] = 333;
- width[0x0091] = 222;
- width[0x0092] = 222;
- width[0x0082] = 222;
- width[0x0027] = 191;
- width[0x0072] = 333;
- width[0x00AE] = 737;
- width[0x00B0] = 333;
- width[0x0073] = 500;
- width[0x009A] = 500;
- width[0x00A7] = 556;
- width[0x003B] = 278;
- width[0x0037] = 556;
- width[0x0036] = 556;
- width[0x002F] = 278;
- width[0x0020] = 278;
- width[0x00A0] = 278;
- width[0x00A3] = 556;
- width[0x0074] = 278;
- width[0x00FE] = 556;
- width[0x0033] = 556;
- width[0x00BE] = 834;
- width[0x00B3] = 333;
- width[0x0098] = 333;
- width[0x0099] = 1000;
- width[0x0032] = 556;
- width[0x00B2] = 333;
- width[0x0075] = 556;
- width[0x00FA] = 556;
- width[0x00FB] = 556;
- width[0x00FC] = 556;
- width[0x00F9] = 556;
- width[0x005F] = 556;
- width[0x0076] = 500;
- width[0x0077] = 722;
- width[0x0078] = 500;
- width[0x0079] = 500;
- width[0x00FD] = 500;
- width[0x00FF] = 500;
- width[0x00A5] = 556;
- width[0x007A] = 500;
- width[0x0030] = 556;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class HelveticaBold extends Font {
- private final static String fontName = "Helvetica-Bold";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 718;
- private final static int xHeight = 532;
- private final static int ascender = 718;
- private final static int descender = -207;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 722;
- width[0x00C6] = 1000;
- width[0x00C1] = 722;
- width[0x00C2] = 722;
- width[0x00C4] = 722;
- width[0x00C0] = 722;
- width[0x00C5] = 722;
- width[0x00C3] = 722;
- width[0x0042] = 722;
- width[0x0043] = 722;
- width[0x00C7] = 722;
- width[0x0044] = 722;
- width[0x0045] = 667;
- width[0x00C9] = 667;
- width[0x00CA] = 667;
- width[0x00CB] = 667;
- width[0x00C8] = 667;
- width[0x00D0] = 722;
- width[0x0046] = 611;
- width[0x0047] = 778;
- width[0x0048] = 722;
- width[0x0049] = 278;
- width[0x00CD] = 278;
- width[0x00CE] = 278;
- width[0x00CF] = 278;
- width[0x00CC] = 278;
- width[0x004A] = 556;
- width[0x004B] = 722;
- width[0x004C] = 611;
- width[0x004D] = 833;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 778;
- width[0x008C] = 1000;
- width[0x00D3] = 778;
- width[0x00D4] = 778;
- width[0x00D6] = 778;
- width[0x00D2] = 778;
- width[0x00D8] = 778;
- width[0x00D5] = 778;
- width[0x0050] = 667;
- width[0x0051] = 778;
- width[0x0052] = 722;
- width[0x0053] = 667;
- width[0x008A] = 667;
- width[0x0054] = 611;
- width[0x00DE] = 667;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 667;
- width[0x0057] = 944;
- width[0x0058] = 667;
- width[0x0059] = 667;
- width[0x00DD] = 667;
- width[0x009F] = 667;
- width[0x005A] = 611;
- width[0x0061] = 556;
- width[0x00E1] = 556;
- width[0x00E2] = 556;
- width[0x00B4] = 333;
- width[0x00E4] = 556;
- width[0x00E6] = 889;
- width[0x00E0] = 556;
- width[0x0026] = 722;
- width[0x00E5] = 556;
- width[0x005E] = 584;
- width[0x007E] = 584;
- width[0x002A] = 389;
- width[0x0040] = 975;
- width[0x00E3] = 556;
- width[0x0062] = 611;
- width[0x005C] = 278;
- width[0x007C] = 280;
- width[0x007B] = 389;
- width[0x007D] = 389;
- width[0x005B] = 333;
- width[0x005D] = 333;
- width[0x00A6] = 280;
- width[0x0095] = 350;
- width[0x0063] = 556;
- width[0x00E7] = 556;
- width[0x00B8] = 333;
- width[0x00A2] = 556;
- width[0x0088] = 333;
- width[0x003A] = 333;
- width[0x002C] = 278;
- width[0x00A9] = 737;
- width[0x00A4] = 556;
- width[0x0064] = 611;
- width[0x0086] = 556;
- width[0x0087] = 556;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 584;
- width[0x0024] = 556;
- width[0x0065] = 556;
- width[0x00E9] = 556;
- width[0x00EA] = 556;
- width[0x00EB] = 556;
- width[0x00E8] = 556;
- width[0x0038] = 556;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 556;
- width[0x003D] = 584;
- width[0x00F0] = 611;
- width[0x0021] = 333;
- width[0x00A1] = 333;
- width[0x0066] = 333;
- width[0x0035] = 556;
- width[0x0083] = 556;
- width[0x0034] = 556;
- width[0xA4] = 167;
- width[0x0067] = 611;
- width[0x00DF] = 611;
- width[0x0060] = 333;
- width[0x003E] = 584;
- width[0x00AB] = 556;
- width[0x00BB] = 556;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 611;
- width[0x002D] = 333;
- width[0x0069] = 278;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 278;
- width[0x006B] = 556;
- width[0x006C] = 278;
- width[0x003C] = 584;
- width[0x00AC] = 584;
- width[0x006D] = 889;
- width[0x00AF] = 333;
- width[0x2D] = 584;
- width[0x00B5] = 611;
- width[0x00D7] = 584;
- width[0x006E] = 611;
- width[0x0039] = 556;
- width[0x00F1] = 611;
- width[0x0023] = 556;
- width[0x006F] = 611;
- width[0x00F3] = 611;
- width[0x00F4] = 611;
- width[0x00F6] = 611;
- width[0x009C] = 944;
- width[0x00F2] = 611;
- width[0x0031] = 556;
- width[0x00BD] = 834;
- width[0x00BC] = 834;
- width[0x00B9] = 333;
- width[0x00AA] = 370;
- width[0x00BA] = 365;
- width[0x00F8] = 611;
- width[0x00F5] = 611;
- width[0x0070] = 611;
- width[0x00B6] = 556;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 889;
- width[0x002E] = 278;
- width[0x00B7] = 278;
- width[0x0089] = 1000;
- width[0x002B] = 584;
- width[0x00B1] = 584;
- width[0x0071] = 611;
- width[0x003F] = 611;
- width[0x00BF] = 611;
- width[0x0022] = 474;
- width[0x0084] = 500;
- width[0x0093] = 500;
- width[0x0094] = 500;
- width[0x0091] = 278;
- width[0x0092] = 278;
- width[0x0082] = 278;
- width[0x0027] = 238;
- width[0x0072] = 389;
- width[0x00AE] = 737;
- width[0x00B0] = 333;
- width[0x0073] = 556;
- width[0x009A] = 556;
- width[0x00A7] = 556;
- width[0x003B] = 333;
- width[0x0037] = 556;
- width[0x0036] = 556;
- width[0x002F] = 278;
- width[0x0020] = 278;
- width[0x00A0] = 278;
- width[0x00A3] = 556;
- width[0x0074] = 333;
- width[0x00FE] = 611;
- width[0x0033] = 556;
- width[0x00BE] = 834;
- width[0x00B3] = 333;
- width[0x0098] = 333;
- width[0x0099] = 1000;
- width[0x0032] = 556;
- width[0x00B2] = 333;
- width[0x0075] = 611;
- width[0x00FA] = 611;
- width[0x00FB] = 611;
- width[0x00FC] = 611;
- width[0x00F9] = 611;
- width[0x005F] = 556;
- width[0x0076] = 556;
- width[0x0077] = 778;
- width[0x0078] = 556;
- width[0x0079] = 556;
- width[0x00FD] = 556;
- width[0x00FF] = 556;
- width[0x00A5] = 556;
- width[0x007A] = 500;
- width[0x0030] = 556;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class HelveticaBoldOblique extends Font {
- private final static String fontName = "Helvetica-BoldOblique";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 718;
- private final static int xHeight = 532;
- private final static int ascender = 718;
- private final static int descender = -207;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 722;
- width[0x00C6] = 1000;
- width[0x00C1] = 722;
- width[0x00C2] = 722;
- width[0x00C4] = 722;
- width[0x00C0] = 722;
- width[0x00C5] = 722;
- width[0x00C3] = 722;
- width[0x0042] = 722;
- width[0x0043] = 722;
- width[0x00C7] = 722;
- width[0x0044] = 722;
- width[0x0045] = 667;
- width[0x00C9] = 667;
- width[0x00CA] = 667;
- width[0x00CB] = 667;
- width[0x00C8] = 667;
- width[0x00D0] = 722;
- width[0x0046] = 611;
- width[0x0047] = 778;
- width[0x0048] = 722;
- width[0x0049] = 278;
- width[0x00CD] = 278;
- width[0x00CE] = 278;
- width[0x00CF] = 278;
- width[0x00CC] = 278;
- width[0x004A] = 556;
- width[0x004B] = 722;
- width[0x004C] = 611;
- width[0x004D] = 833;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 778;
- width[0x008C] = 1000;
- width[0x00D3] = 778;
- width[0x00D4] = 778;
- width[0x00D6] = 778;
- width[0x00D2] = 778;
- width[0x00D8] = 778;
- width[0x00D5] = 778;
- width[0x0050] = 667;
- width[0x0051] = 778;
- width[0x0052] = 722;
- width[0x0053] = 667;
- width[0x008A] = 667;
- width[0x0054] = 611;
- width[0x00DE] = 667;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 667;
- width[0x0057] = 944;
- width[0x0058] = 667;
- width[0x0059] = 667;
- width[0x00DD] = 667;
- width[0x009F] = 667;
- width[0x005A] = 611;
- width[0x0061] = 556;
- width[0x00E1] = 556;
- width[0x00E2] = 556;
- width[0x00B4] = 333;
- width[0x00E4] = 556;
- width[0x00E6] = 889;
- width[0x00E0] = 556;
- width[0x0026] = 722;
- width[0x00E5] = 556;
- width[0x005E] = 584;
- width[0x007E] = 584;
- width[0x002A] = 389;
- width[0x0040] = 975;
- width[0x00E3] = 556;
- width[0x0062] = 611;
- width[0x005C] = 278;
- width[0x007C] = 280;
- width[0x007B] = 389;
- width[0x007D] = 389;
- width[0x005B] = 333;
- width[0x005D] = 333;
- width[0x00A6] = 280;
- width[0x0095] = 350;
- width[0x0063] = 556;
- width[0x00E7] = 556;
- width[0x00B8] = 333;
- width[0x00A2] = 556;
- width[0x0088] = 333;
- width[0x003A] = 333;
- width[0x002C] = 278;
- width[0x00A9] = 737;
- width[0x00A4] = 556;
- width[0x0064] = 611;
- width[0x0086] = 556;
- width[0x0087] = 556;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 584;
- width[0x0024] = 556;
- width[0x0065] = 556;
- width[0x00E9] = 556;
- width[0x00EA] = 556;
- width[0x00EB] = 556;
- width[0x00E8] = 556;
- width[0x0038] = 556;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 556;
- width[0x003D] = 584;
- width[0x00F0] = 611;
- width[0x0021] = 333;
- width[0x00A1] = 333;
- width[0x0066] = 333;
- width[0x0035] = 556;
- width[0x0083] = 556;
- width[0x0034] = 556;
- width[0xA4] = 167;
- width[0x0067] = 611;
- width[0x00DF] = 611;
- width[0x0060] = 333;
- width[0x003E] = 584;
- width[0x00AB] = 556;
- width[0x00BB] = 556;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 611;
- width[0x002D] = 333;
- width[0x0069] = 278;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 278;
- width[0x006B] = 556;
- width[0x006C] = 278;
- width[0x003C] = 584;
- width[0x00AC] = 584;
- width[0x006D] = 889;
- width[0x00AF] = 333;
- width[0x2D] = 584;
- width[0x00B5] = 611;
- width[0x00D7] = 584;
- width[0x006E] = 611;
- width[0x0039] = 556;
- width[0x00F1] = 611;
- width[0x0023] = 556;
- width[0x006F] = 611;
- width[0x00F3] = 611;
- width[0x00F4] = 611;
- width[0x00F6] = 611;
- width[0x009C] = 944;
- width[0x00F2] = 611;
- width[0x0031] = 556;
- width[0x00BD] = 834;
- width[0x00BC] = 834;
- width[0x00B9] = 333;
- width[0x00AA] = 370;
- width[0x00BA] = 365;
- width[0x00F8] = 611;
- width[0x00F5] = 611;
- width[0x0070] = 611;
- width[0x00B6] = 556;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 889;
- width[0x002E] = 278;
- width[0x00B7] = 278;
- width[0x0089] = 1000;
- width[0x002B] = 584;
- width[0x00B1] = 584;
- width[0x0071] = 611;
- width[0x003F] = 611;
- width[0x00BF] = 611;
- width[0x0022] = 474;
- width[0x0084] = 500;
- width[0x0093] = 500;
- width[0x0094] = 500;
- width[0x0091] = 278;
- width[0x0092] = 278;
- width[0x0082] = 278;
- width[0x0027] = 238;
- width[0x0072] = 389;
- width[0x00AE] = 737;
- width[0x00B0] = 333;
- width[0x0073] = 556;
- width[0x009A] = 556;
- width[0x00A7] = 556;
- width[0x003B] = 333;
- width[0x0037] = 556;
- width[0x0036] = 556;
- width[0x002F] = 278;
- width[0x0020] = 278;
- width[0x00A0] = 278;
- width[0x00A3] = 556;
- width[0x0074] = 333;
- width[0x00FE] = 611;
- width[0x0033] = 556;
- width[0x00BE] = 834;
- width[0x00B3] = 333;
- width[0x0098] = 333;
- width[0x0099] = 1000;
- width[0x0032] = 556;
- width[0x00B2] = 333;
- width[0x0075] = 611;
- width[0x00FA] = 611;
- width[0x00FB] = 611;
- width[0x00FC] = 611;
- width[0x00F9] = 611;
- width[0x005F] = 556;
- width[0x0076] = 556;
- width[0x0077] = 778;
- width[0x0078] = 556;
- width[0x0079] = 556;
- width[0x00FD] = 556;
- width[0x00FF] = 556;
- width[0x00A5] = 556;
- width[0x007A] = 500;
- width[0x0030] = 556;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class HelveticaOblique extends Font {
- private final static String fontName = "Helvetica-Oblique";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 718;
- private final static int xHeight = 523;
- private final static int ascender = 718;
- private final static int descender = -207;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 667;
- width[0x00C6] = 1000;
- width[0x00C1] = 667;
- width[0x00C2] = 667;
- width[0x00C4] = 667;
- width[0x00C0] = 667;
- width[0x00C5] = 667;
- width[0x00C3] = 667;
- width[0x0042] = 667;
- width[0x0043] = 722;
- width[0x00C7] = 722;
- width[0x0044] = 722;
- width[0x0045] = 667;
- width[0x00C9] = 667;
- width[0x00CA] = 667;
- width[0x00CB] = 667;
- width[0x00C8] = 667;
- width[0x00D0] = 722;
- width[0x0046] = 611;
- width[0x0047] = 778;
- width[0x0048] = 722;
- width[0x0049] = 278;
- width[0x00CD] = 278;
- width[0x00CE] = 278;
- width[0x00CF] = 278;
- width[0x00CC] = 278;
- width[0x004A] = 500;
- width[0x004B] = 667;
- width[0x004C] = 556;
- width[0x004D] = 833;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 778;
- width[0x008C] = 1000;
- width[0x00D3] = 778;
- width[0x00D4] = 778;
- width[0x00D6] = 778;
- width[0x00D2] = 778;
- width[0x00D8] = 778;
- width[0x00D5] = 778;
- width[0x0050] = 667;
- width[0x0051] = 778;
- width[0x0052] = 722;
- width[0x0053] = 667;
- width[0x008A] = 667;
- width[0x0054] = 611;
- width[0x00DE] = 667;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 667;
- width[0x0057] = 944;
- width[0x0058] = 667;
- width[0x0059] = 667;
- width[0x00DD] = 667;
- width[0x009F] = 667;
- width[0x005A] = 611;
- width[0x0061] = 556;
- width[0x00E1] = 556;
- width[0x00E2] = 556;
- width[0x00B4] = 333;
- width[0x00E4] = 556;
- width[0x00E6] = 889;
- width[0x00E0] = 556;
- width[0x0026] = 667;
- width[0x00E5] = 556;
- width[0x005E] = 469;
- width[0x007E] = 584;
- width[0x002A] = 389;
- width[0x0040] = 1015;
- width[0x00E3] = 556;
- width[0x0062] = 556;
- width[0x005C] = 278;
- width[0x007C] = 260;
- width[0x007B] = 334;
- width[0x007D] = 334;
- width[0x005B] = 278;
- width[0x005D] = 278;
- width[0x00A6] = 260;
- width[0x0095] = 350;
- width[0x0063] = 500;
- width[0x00E7] = 500;
- width[0x00B8] = 333;
- width[0x00A2] = 556;
- width[0x0088] = 333;
- width[0x003A] = 278;
- width[0x002C] = 278;
- width[0x00A9] = 737;
- width[0x00A4] = 556;
- width[0x0064] = 556;
- width[0x0086] = 556;
- width[0x0087] = 556;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 584;
- width[0x0024] = 556;
- width[0x0065] = 556;
- width[0x00E9] = 556;
- width[0x00EA] = 556;
- width[0x00EB] = 556;
- width[0x00E8] = 556;
- width[0x0038] = 556;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 556;
- width[0x003D] = 584;
- width[0x00F0] = 556;
- width[0x0021] = 278;
- width[0x00A1] = 333;
- width[0x0066] = 278;
- width[0x0035] = 556;
- width[0x0083] = 556;
- width[0x0034] = 556;
- width[0xA4] = 167;
- width[0x0067] = 556;
- width[0x00DF] = 611;
- width[0x0060] = 333;
- width[0x003E] = 584;
- width[0x00AB] = 556;
- width[0x00BB] = 556;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 556;
- width[0x002D] = 333;
- width[0x0069] = 222;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 222;
- width[0x006B] = 500;
- width[0x006C] = 222;
- width[0x003C] = 584;
- width[0x00AC] = 584;
- width[0x006D] = 833;
- width[0x00AF] = 333;
- width[0x2D] = 584;
- width[0x00B5] = 556;
- width[0x00D7] = 584;
- width[0x006E] = 556;
- width[0x0039] = 556;
- width[0x00F1] = 556;
- width[0x0023] = 556;
- width[0x006F] = 556;
- width[0x00F3] = 556;
- width[0x00F4] = 556;
- width[0x00F6] = 556;
- width[0x009C] = 944;
- width[0x00F2] = 556;
- width[0x0031] = 556;
- width[0x00BD] = 834;
- width[0x00BC] = 834;
- width[0x00B9] = 333;
- width[0x00AA] = 370;
- width[0x00BA] = 365;
- width[0x00F8] = 611;
- width[0x00F5] = 556;
- width[0x0070] = 556;
- width[0x00B6] = 537;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 889;
- width[0x002E] = 278;
- width[0x00B7] = 278;
- width[0x0089] = 1000;
- width[0x002B] = 584;
- width[0x00B1] = 584;
- width[0x0071] = 556;
- width[0x003F] = 556;
- width[0x00BF] = 611;
- width[0x0022] = 355;
- width[0x0084] = 333;
- width[0x0093] = 333;
- width[0x0094] = 333;
- width[0x0091] = 222;
- width[0x0092] = 222;
- width[0x0082] = 222;
- width[0x0027] = 191;
- width[0x0072] = 333;
- width[0x00AE] = 737;
- width[0x00B0] = 333;
- width[0x0073] = 500;
- width[0x009A] = 500;
- width[0x00A7] = 556;
- width[0x003B] = 278;
- width[0x0037] = 556;
- width[0x0036] = 556;
- width[0x002F] = 278;
- width[0x0020] = 278;
- width[0x00A0] = 278;
- width[0x00A3] = 556;
- width[0x0074] = 278;
- width[0x00FE] = 556;
- width[0x0033] = 556;
- width[0x00BE] = 834;
- width[0x00B3] = 333;
- width[0x0098] = 333;
- width[0x0099] = 1000;
- width[0x0032] = 556;
- width[0x00B2] = 333;
- width[0x0075] = 556;
- width[0x00FA] = 556;
- width[0x00FB] = 556;
- width[0x00FC] = 556;
- width[0x00F9] = 556;
- width[0x005F] = 556;
- width[0x0076] = 500;
- width[0x0077] = 722;
- width[0x0078] = 500;
- width[0x0079] = 500;
- width[0x00FD] = 500;
- width[0x00FF] = 500;
- width[0x00A5] = 556;
- width[0x007A] = 500;
- width[0x0030] = 556;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class Symbol extends Font {
- private final static String fontName = "Symbol";
- private final static String encoding = "StandardEncoding";
- private final static int capHeight = 1010;
- private final static int xHeight = 520;
- private final static int ascender = 1010;
- private final static int descender = -293;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0020] = 250;
- width[0x0021] = 333;
- width[0x22] = 713;
- width[0x0023] = 500;
- width[0x24] = 549;
- width[0x0025] = 833;
- width[0x0026] = 778;
- width[0x27] = 439;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x2A] = 500;
- width[0x002B] = 549;
- width[0x002C] = 250;
- width[0x2D] = 549;
- width[0x002E] = 250;
- width[0x002F] = 278;
- width[0x0030] = 500;
- width[0x0031] = 500;
- width[0x0032] = 500;
- width[0x0033] = 500;
- width[0x0034] = 500;
- width[0x0035] = 500;
- width[0x0036] = 500;
- width[0x0037] = 500;
- width[0x0038] = 500;
- width[0x0039] = 500;
- width[0x003A] = 278;
- width[0x003B] = 278;
- width[0x003C] = 549;
- width[0x003D] = 549;
- width[0x003E] = 549;
- width[0x003F] = 444;
- width[0x40] = 549;
- width[0x41] = 722;
- width[0x42] = 667;
- width[0x43] = 722;
- width[0x44] = 612;
- width[0x45] = 611;
- width[0x46] = 763;
- width[0x47] = 603;
- width[0x48] = 722;
- width[0x49] = 333;
- width[0x4A] = 631;
- width[0x4B] = 722;
- width[0x4C] = 686;
- width[0x4D] = 889;
- width[0x4E] = 722;
- width[0x4F] = 722;
- width[0x50] = 768;
- width[0x51] = 741;
- width[0x52] = 556;
- width[0x53] = 592;
- width[0x54] = 611;
- width[0x55] = 690;
- width[0x56] = 439;
- width[0x57] = 768;
- width[0x58] = 645;
- width[0x59] = 795;
- width[0x5A] = 611;
- width[0x005B] = 333;
- width[0x5C] = 863;
- width[0x005D] = 333;
- width[0x5E] = 658;
- width[0x005F] = 500;
- width[0x60] = 500;
- width[0x61] = 631;
- width[0x62] = 549;
- width[0x63] = 549;
- width[0x64] = 494;
- width[0x65] = 439;
- width[0x66] = 521;
- width[0x67] = 411;
- width[0x68] = 603;
- width[0x69] = 329;
- width[0x6A] = 603;
- width[0x6B] = 549;
- width[0x6C] = 549;
- width[0x006D] = 576;
- width[0x00B5] = 576;
- width[0x6E] = 521;
- width[0x6F] = 549;
- width[0x70] = 549;
- width[0x71] = 521;
- width[0x72] = 549;
- width[0x73] = 603;
- width[0x74] = 439;
- width[0x75] = 576;
- width[0x76] = 713;
- width[0x77] = 686;
- width[0x78] = 493;
- width[0x79] = 686;
- width[0x7A] = 494;
- width[0x007B] = 480;
- width[0x007C] = 200;
- width[0x007D] = 480;
- width[0x7E] = 549;
- width[0xA1] = 620;
- width[0xA2] = 247;
- width[0xA3] = 549;
- width[0xA4] = 167;
- width[0xA5] = 713;
- width[0x0083] = 500;
- width[0xA7] = 753;
- width[0xA8] = 753;
- width[0xA9] = 753;
- width[0xAA] = 753;
- width[0xAB] = 1042;
- width[0xAC] = 987;
- width[0xAD] = 603;
- width[0xAE] = 987;
- width[0xAF] = 603;
- width[0x00B0] = 400;
- width[0x00B1] = 549;
- width[0xB2] = 411;
- width[0xB3] = 549;
- width[0x00D7] = 549;
- width[0xB5] = 713;
- width[0xB6] = 494;
- width[0x0095] = 460;
- width[0x00F7] = 549;
- width[0xB9] = 549;
- width[0xBA] = 549;
- width[0xBB] = 549;
- width[0x0085] = 1000;
- width[0xBD] = 603;
- width[0xBE] = 1000;
- width[0xBF] = 658;
- width[0xC0] = 823;
- width[0xC1] = 686;
- width[0xC2] = 795;
- width[0xC3] = 987;
- width[0xC4] = 768;
- width[0xC5] = 768;
- width[0xC6] = 823;
- width[0xC7] = 768;
- width[0xC8] = 768;
- width[0xC9] = 713;
- width[0xCA] = 713;
- width[0xCB] = 713;
- width[0xCC] = 713;
- width[0xCD] = 713;
- width[0xCE] = 713;
- width[0xCF] = 713;
- width[0xD0] = 768;
- width[0xD1] = 713;
- width[0xD2] = 790;
- width[0xD3] = 790;
- width[0xD4] = 890;
- width[0xD5] = 823;
- width[0xD6] = 549;
- width[0xD7] = 250;
- width[0x00AC] = 713;
- width[0xD9] = 603;
- width[0xDA] = 603;
- width[0xDB] = 1042;
- width[0xDC] = 987;
- width[0xDD] = 603;
- width[0xDE] = 987;
- width[0xDF] = 603;
- width[0xE0] = 494;
- width[0xE1] = 329;
- width[0xE2] = 790;
- width[0xE3] = 790;
- width[0xE4] = 786;
- width[0xE5] = 713;
- width[0xE6] = 384;
- width[0xE7] = 384;
- width[0xE8] = 384;
- width[0xE9] = 384;
- width[0xEA] = 384;
- width[0xEB] = 384;
- width[0xEC] = 494;
- width[0xED] = 494;
- width[0xEE] = 494;
- width[0xEF] = 494;
- width[0xF1] = 329;
- width[0xF2] = 274;
- width[0xF3] = 686;
- width[0xF4] = 686;
- width[0xF5] = 686;
- width[0xF6] = 384;
- width[0xF7] = 384;
- width[0xF8] = 384;
- width[0xF9] = 384;
- width[0xFA] = 384;
- width[0xFB] = 384;
- width[0xFC] = 494;
- width[0xFD] = 494;
- width[0xFE] = 494;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class TimesBold extends Font {
- private final static String fontName = "Times-Bold";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 676;
- private final static int xHeight = 461;
- private final static int ascender = 676;
- private final static int descender = -205;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 722;
- width[0x00C6] = 1000;
- width[0x00C1] = 722;
- width[0x00C2] = 722;
- width[0x00C4] = 722;
- width[0x00C0] = 722;
- width[0x00C5] = 722;
- width[0x00C3] = 722;
- width[0x0042] = 667;
- width[0x0043] = 722;
- width[0x00C7] = 722;
- width[0x0044] = 722;
- width[0x0045] = 667;
- width[0x00C9] = 667;
- width[0x00CA] = 667;
- width[0x00CB] = 667;
- width[0x00C8] = 667;
- width[0x00D0] = 722;
- width[0x0046] = 611;
- width[0x0047] = 778;
- width[0x0048] = 778;
- width[0x0049] = 389;
- width[0x00CD] = 389;
- width[0x00CE] = 389;
- width[0x00CF] = 389;
- width[0x00CC] = 389;
- width[0x004A] = 500;
- width[0x004B] = 778;
- width[0x004C] = 667;
- width[0x004D] = 944;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 778;
- width[0x008C] = 1000;
- width[0x00D3] = 778;
- width[0x00D4] = 778;
- width[0x00D6] = 778;
- width[0x00D2] = 778;
- width[0x00D8] = 778;
- width[0x00D5] = 778;
- width[0x0050] = 611;
- width[0x0051] = 778;
- width[0x0052] = 722;
- width[0x0053] = 556;
- width[0x008A] = 556;
- width[0x0054] = 667;
- width[0x00DE] = 611;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 722;
- width[0x0057] = 1000;
- width[0x0058] = 722;
- width[0x0059] = 722;
- width[0x00DD] = 722;
- width[0x009F] = 722;
- width[0x005A] = 667;
- width[0x0061] = 500;
- width[0x00E1] = 500;
- width[0x00E2] = 500;
- width[0x00B4] = 333;
- width[0x00E4] = 500;
- width[0x00E6] = 722;
- width[0x00E0] = 500;
- width[0x0026] = 833;
- width[0x00E5] = 500;
- width[0x005E] = 581;
- width[0x007E] = 520;
- width[0x002A] = 500;
- width[0x0040] = 930;
- width[0x00E3] = 500;
- width[0x0062] = 556;
- width[0x005C] = 278;
- width[0x007C] = 220;
- width[0x007B] = 394;
- width[0x007D] = 394;
- width[0x005B] = 333;
- width[0x005D] = 333;
- width[0x00A6] = 220;
- width[0x0095] = 350;
- width[0x0063] = 444;
- width[0x00E7] = 444;
- width[0x00B8] = 333;
- width[0x00A2] = 500;
- width[0x0088] = 333;
- width[0x003A] = 333;
- width[0x002C] = 250;
- width[0x00A9] = 747;
- width[0x00A4] = 500;
- width[0x0064] = 556;
- width[0x0086] = 500;
- width[0x0087] = 500;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 570;
- width[0x0024] = 500;
- width[0x0065] = 444;
- width[0x00E9] = 444;
- width[0x00EA] = 444;
- width[0x00EB] = 444;
- width[0x00E8] = 444;
- width[0x0038] = 500;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 500;
- width[0x003D] = 570;
- width[0x00F0] = 500;
- width[0x0021] = 333;
- width[0x00A1] = 333;
- width[0x0066] = 333;
- width[0x0035] = 500;
- width[0x0083] = 500;
- width[0x0034] = 500;
- width[0xA4] = 167;
- width[0x0067] = 500;
- width[0x00DF] = 556;
- width[0x0060] = 333;
- width[0x003E] = 570;
- width[0x00AB] = 500;
- width[0x00BB] = 500;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 556;
- width[0x002D] = 333;
- width[0x0069] = 278;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 333;
- width[0x006B] = 556;
- width[0x006C] = 278;
- width[0x003C] = 570;
- width[0x00AC] = 570;
- width[0x006D] = 833;
- width[0x00AF] = 333;
- width[0x2D] = 570;
- width[0x00B5] = 556;
- width[0x00D7] = 570;
- width[0x006E] = 556;
- width[0x0039] = 500;
- width[0x00F1] = 556;
- width[0x0023] = 500;
- width[0x006F] = 500;
- width[0x00F3] = 500;
- width[0x00F4] = 500;
- width[0x00F6] = 500;
- width[0x009C] = 722;
- width[0x00F2] = 500;
- width[0x0031] = 500;
- width[0x00BD] = 750;
- width[0x00BC] = 750;
- width[0x00B9] = 300;
- width[0x00AA] = 300;
- width[0x00BA] = 330;
- width[0x00F8] = 500;
- width[0x00F5] = 500;
- width[0x0070] = 556;
- width[0x00B6] = 540;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 1000;
- width[0x002E] = 250;
- width[0x00B7] = 250;
- width[0x0089] = 1000;
- width[0x002B] = 570;
- width[0x00B1] = 570;
- width[0x0071] = 556;
- width[0x003F] = 500;
- width[0x00BF] = 500;
- width[0x0022] = 555;
- width[0x0084] = 500;
- width[0x0093] = 500;
- width[0x0094] = 500;
- width[0x0091] = 333;
- width[0x0092] = 333;
- width[0x0082] = 333;
- width[0x0027] = 278;
- width[0x0072] = 444;
- width[0x00AE] = 747;
- width[0x00B0] = 333;
- width[0x0073] = 389;
- width[0x009A] = 389;
- width[0x00A7] = 500;
- width[0x003B] = 333;
- width[0x0037] = 500;
- width[0x0036] = 500;
- width[0x002F] = 278;
- width[0x0020] = 250;
- width[0x00A0] = 250;
- width[0x00A3] = 500;
- width[0x0074] = 333;
- width[0x00FE] = 556;
- width[0x0033] = 500;
- width[0x00BE] = 750;
- width[0x00B3] = 300;
- width[0x0098] = 333;
- width[0x0099] = 1000;
- width[0x0032] = 500;
- width[0x00B2] = 300;
- width[0x0075] = 556;
- width[0x00FA] = 556;
- width[0x00FB] = 556;
- width[0x00FC] = 556;
- width[0x00F9] = 556;
- width[0x005F] = 500;
- width[0x0076] = 500;
- width[0x0077] = 722;
- width[0x0078] = 500;
- width[0x0079] = 500;
- width[0x00FD] = 500;
- width[0x00FF] = 500;
- width[0x00A5] = 500;
- width[0x007A] = 444;
- width[0x0030] = 500;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class TimesBoldItalic extends Font {
- private final static String fontName = "Times-BoldItalic";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 669;
- private final static int xHeight = 462;
- private final static int ascender = 699;
- private final static int descender = -205;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 667;
- width[0x00C6] = 944;
- width[0x00C1] = 667;
- width[0x00C2] = 667;
- width[0x00C4] = 667;
- width[0x00C0] = 667;
- width[0x00C5] = 667;
- width[0x00C3] = 667;
- width[0x0042] = 667;
- width[0x0043] = 667;
- width[0x00C7] = 667;
- width[0x0044] = 722;
- width[0x0045] = 667;
- width[0x00C9] = 667;
- width[0x00CA] = 667;
- width[0x00CB] = 667;
- width[0x00C8] = 667;
- width[0x00D0] = 722;
- width[0x0046] = 667;
- width[0x0047] = 722;
- width[0x0048] = 778;
- width[0x0049] = 389;
- width[0x00CD] = 389;
- width[0x00CE] = 389;
- width[0x00CF] = 389;
- width[0x00CC] = 389;
- width[0x004A] = 500;
- width[0x004B] = 667;
- width[0x004C] = 611;
- width[0x004D] = 889;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 722;
- width[0x008C] = 944;
- width[0x00D3] = 722;
- width[0x00D4] = 722;
- width[0x00D6] = 722;
- width[0x00D2] = 722;
- width[0x00D8] = 722;
- width[0x00D5] = 722;
- width[0x0050] = 611;
- width[0x0051] = 722;
- width[0x0052] = 667;
- width[0x0053] = 556;
- width[0x008A] = 556;
- width[0x0054] = 611;
- width[0x00DE] = 611;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 667;
- width[0x0057] = 889;
- width[0x0058] = 667;
- width[0x0059] = 611;
- width[0x00DD] = 611;
- width[0x009F] = 611;
- width[0x005A] = 611;
- width[0x0061] = 500;
- width[0x00E1] = 500;
- width[0x00E2] = 500;
- width[0x00B4] = 333;
- width[0x00E4] = 500;
- width[0x00E6] = 722;
- width[0x00E0] = 500;
- width[0x0026] = 778;
- width[0x00E5] = 500;
- width[0x005E] = 570;
- width[0x007E] = 570;
- width[0x002A] = 500;
- width[0x0040] = 832;
- width[0x00E3] = 500;
- width[0x0062] = 500;
- width[0x005C] = 278;
- width[0x007C] = 220;
- width[0x007B] = 348;
- width[0x007D] = 348;
- width[0x005B] = 333;
- width[0x005D] = 333;
- width[0x00A6] = 220;
- width[0x0095] = 350;
- width[0x0063] = 444;
- width[0x00E7] = 444;
- width[0x00B8] = 333;
- width[0x00A2] = 500;
- width[0x0088] = 333;
- width[0x003A] = 333;
- width[0x002C] = 250;
- width[0x00A9] = 747;
- width[0x00A4] = 500;
- width[0x0064] = 500;
- width[0x0086] = 500;
- width[0x0087] = 500;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 570;
- width[0x0024] = 500;
- width[0x0065] = 444;
- width[0x00E9] = 444;
- width[0x00EA] = 444;
- width[0x00EB] = 444;
- width[0x00E8] = 444;
- width[0x0038] = 500;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 500;
- width[0x003D] = 570;
- width[0x00F0] = 500;
- width[0x0021] = 389;
- width[0x00A1] = 389;
- width[0x0066] = 333;
- width[0x0035] = 500;
- width[0x0083] = 500;
- width[0x0034] = 500;
- width[0xA4] = 167;
- width[0x0067] = 500;
- width[0x00DF] = 500;
- width[0x0060] = 333;
- width[0x003E] = 570;
- width[0x00AB] = 500;
- width[0x00BB] = 500;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 556;
- width[0x002D] = 333;
- width[0x0069] = 278;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 278;
- width[0x006B] = 500;
- width[0x006C] = 278;
- width[0x003C] = 570;
- width[0x00AC] = 606;
- width[0x006D] = 778;
- width[0x00AF] = 333;
- width[0x2D] = 606;
- width[0x00B5] = 576;
- width[0x00D7] = 570;
- width[0x006E] = 556;
- width[0x0039] = 500;
- width[0x00F1] = 556;
- width[0x0023] = 500;
- width[0x006F] = 500;
- width[0x00F3] = 500;
- width[0x00F4] = 500;
- width[0x00F6] = 500;
- width[0x009C] = 722;
- width[0x00F2] = 500;
- width[0x0031] = 500;
- width[0x00BD] = 750;
- width[0x00BC] = 750;
- width[0x00B9] = 300;
- width[0x00AA] = 266;
- width[0x00BA] = 300;
- width[0x00F8] = 500;
- width[0x00F5] = 500;
- width[0x0070] = 500;
- width[0x00B6] = 500;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 833;
- width[0x002E] = 250;
- width[0x00B7] = 250;
- width[0x0089] = 1000;
- width[0x002B] = 570;
- width[0x00B1] = 570;
- width[0x0071] = 500;
- width[0x003F] = 500;
- width[0x00BF] = 500;
- width[0x0022] = 555;
- width[0x0084] = 500;
- width[0x0093] = 500;
- width[0x0094] = 500;
- width[0x0091] = 333;
- width[0x0092] = 333;
- width[0x0082] = 333;
- width[0x0027] = 278;
- width[0x0072] = 389;
- width[0x00AE] = 747;
- width[0x00B0] = 333;
- width[0x0073] = 389;
- width[0x009A] = 389;
- width[0x00A7] = 500;
- width[0x003B] = 333;
- width[0x0037] = 500;
- width[0x0036] = 500;
- width[0x002F] = 278;
- width[0x0020] = 250;
- width[0x00A0] = 250;
- width[0x00A3] = 500;
- width[0x0074] = 278;
- width[0x00FE] = 500;
- width[0x0033] = 500;
- width[0x00BE] = 750;
- width[0x00B3] = 300;
- width[0x0098] = 333;
- width[0x0099] = 1000;
- width[0x0032] = 500;
- width[0x00B2] = 300;
- width[0x0075] = 556;
- width[0x00FA] = 556;
- width[0x00FB] = 556;
- width[0x00FC] = 556;
- width[0x00F9] = 556;
- width[0x005F] = 500;
- width[0x0076] = 444;
- width[0x0077] = 667;
- width[0x0078] = 500;
- width[0x0079] = 444;
- width[0x00FD] = 444;
- width[0x00FF] = 444;
- width[0x00A5] = 500;
- width[0x007A] = 389;
- width[0x0030] = 500;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class TimesItalic extends Font {
- private final static String fontName = "Times-Italic";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 653;
- private final static int xHeight = 441;
- private final static int ascender = 683;
- private final static int descender = -205;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 611;
- width[0x00C6] = 889;
- width[0x00C1] = 611;
- width[0x00C2] = 611;
- width[0x00C4] = 611;
- width[0x00C0] = 611;
- width[0x00C5] = 611;
- width[0x00C3] = 611;
- width[0x0042] = 611;
- width[0x0043] = 667;
- width[0x00C7] = 667;
- width[0x0044] = 722;
- width[0x0045] = 611;
- width[0x00C9] = 611;
- width[0x00CA] = 611;
- width[0x00CB] = 611;
- width[0x00C8] = 611;
- width[0x00D0] = 722;
- width[0x0046] = 611;
- width[0x0047] = 722;
- width[0x0048] = 722;
- width[0x0049] = 333;
- width[0x00CD] = 333;
- width[0x00CE] = 333;
- width[0x00CF] = 333;
- width[0x00CC] = 333;
- width[0x004A] = 444;
- width[0x004B] = 667;
- width[0x004C] = 556;
- width[0x004D] = 833;
- width[0x004E] = 667;
- width[0x00D1] = 667;
- width[0x004F] = 722;
- width[0x008C] = 944;
- width[0x00D3] = 722;
- width[0x00D4] = 722;
- width[0x00D6] = 722;
- width[0x00D2] = 722;
- width[0x00D8] = 722;
- width[0x00D5] = 722;
- width[0x0050] = 611;
- width[0x0051] = 722;
- width[0x0052] = 611;
- width[0x0053] = 500;
- width[0x008A] = 500;
- width[0x0054] = 556;
- width[0x00DE] = 611;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 611;
- width[0x0057] = 833;
- width[0x0058] = 611;
- width[0x0059] = 556;
- width[0x00DD] = 556;
- width[0x009F] = 556;
- width[0x005A] = 556;
- width[0x0061] = 500;
- width[0x00E1] = 500;
- width[0x00E2] = 500;
- width[0x00B4] = 333;
- width[0x00E4] = 500;
- width[0x00E6] = 667;
- width[0x00E0] = 500;
- width[0x0026] = 778;
- width[0x00E5] = 500;
- width[0x005E] = 422;
- width[0x007E] = 541;
- width[0x002A] = 500;
- width[0x0040] = 920;
- width[0x00E3] = 500;
- width[0x0062] = 500;
- width[0x005C] = 278;
- width[0x007C] = 275;
- width[0x007B] = 400;
- width[0x007D] = 400;
- width[0x005B] = 389;
- width[0x005D] = 389;
- width[0x00A6] = 275;
- width[0x0095] = 350;
- width[0x0063] = 444;
- width[0x00E7] = 444;
- width[0x00B8] = 333;
- width[0x00A2] = 500;
- width[0x0088] = 333;
- width[0x003A] = 333;
- width[0x002C] = 250;
- width[0x00A9] = 760;
- width[0x00A4] = 500;
- width[0x0064] = 500;
- width[0x0086] = 500;
- width[0x0087] = 500;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 675;
- width[0x0024] = 500;
- width[0x0065] = 444;
- width[0x00E9] = 444;
- width[0x00EA] = 444;
- width[0x00EB] = 444;
- width[0x00E8] = 444;
- width[0x0038] = 500;
- width[0x0085] = 889;
- width[0x0097] = 889;
- width[0x0096] = 500;
- width[0x003D] = 675;
- width[0x00F0] = 500;
- width[0x0021] = 333;
- width[0x00A1] = 389;
- width[0x0066] = 278;
- width[0x0035] = 500;
- width[0x0083] = 500;
- width[0x0034] = 500;
- width[0xA4] = 167;
- width[0x0067] = 500;
- width[0x00DF] = 500;
- width[0x0060] = 333;
- width[0x003E] = 675;
- width[0x00AB] = 500;
- width[0x00BB] = 500;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 500;
- width[0x002D] = 333;
- width[0x0069] = 278;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 278;
- width[0x006B] = 444;
- width[0x006C] = 278;
- width[0x003C] = 675;
- width[0x00AC] = 675;
- width[0x006D] = 722;
- width[0x00AF] = 333;
- width[0x2D] = 675;
- width[0x00B5] = 500;
- width[0x00D7] = 675;
- width[0x006E] = 500;
- width[0x0039] = 500;
- width[0x00F1] = 500;
- width[0x0023] = 500;
- width[0x006F] = 500;
- width[0x00F3] = 500;
- width[0x00F4] = 500;
- width[0x00F6] = 500;
- width[0x009C] = 667;
- width[0x00F2] = 500;
- width[0x0031] = 500;
- width[0x00BD] = 750;
- width[0x00BC] = 750;
- width[0x00B9] = 300;
- width[0x00AA] = 276;
- width[0x00BA] = 310;
- width[0x00F8] = 500;
- width[0x00F5] = 500;
- width[0x0070] = 500;
- width[0x00B6] = 523;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 833;
- width[0x002E] = 250;
- width[0x00B7] = 250;
- width[0x0089] = 1000;
- width[0x002B] = 675;
- width[0x00B1] = 675;
- width[0x0071] = 500;
- width[0x003F] = 500;
- width[0x00BF] = 500;
- width[0x0022] = 420;
- width[0x0084] = 556;
- width[0x0093] = 556;
- width[0x0094] = 556;
- width[0x0091] = 333;
- width[0x0092] = 333;
- width[0x0082] = 333;
- width[0x0027] = 214;
- width[0x0072] = 389;
- width[0x00AE] = 760;
- width[0x00B0] = 333;
- width[0x0073] = 389;
- width[0x009A] = 389;
- width[0x00A7] = 500;
- width[0x003B] = 333;
- width[0x0037] = 500;
- width[0x0036] = 500;
- width[0x002F] = 278;
- width[0x0020] = 250;
- width[0x00A0] = 250;
- width[0x00A3] = 500;
- width[0x0074] = 278;
- width[0x00FE] = 500;
- width[0x0033] = 500;
- width[0x00BE] = 750;
- width[0x00B3] = 300;
- width[0x0098] = 333;
- width[0x0099] = 980;
- width[0x0032] = 500;
- width[0x00B2] = 300;
- width[0x0075] = 500;
- width[0x00FA] = 500;
- width[0x00FB] = 500;
- width[0x00FC] = 500;
- width[0x00F9] = 500;
- width[0x005F] = 500;
- width[0x0076] = 444;
- width[0x0077] = 667;
- width[0x0078] = 444;
- width[0x0079] = 444;
- width[0x00FD] = 444;
- width[0x00FF] = 444;
- width[0x00A5] = 500;
- width[0x007A] = 389;
- width[0x0030] = 500;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class TimesRoman extends Font {
- private final static String fontName = "Times-Roman";
- private final static String encoding = "WinAnsiEncoding";
- private final static int capHeight = 662;
- private final static int xHeight = 450;
- private final static int ascender = 683;
- private final static int descender = -217;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0041] = 722;
- width[0x00C6] = 889;
- width[0x00C1] = 722;
- width[0x00C2] = 722;
- width[0x00C4] = 722;
- width[0x00C0] = 722;
- width[0x00C5] = 722;
- width[0x00C3] = 722;
- width[0x0042] = 667;
- width[0x0043] = 667;
- width[0x00C7] = 667;
- width[0x0044] = 722;
- width[0x0045] = 611;
- width[0x00C9] = 611;
- width[0x00CA] = 611;
- width[0x00CB] = 611;
- width[0x00C8] = 611;
- width[0x00D0] = 722;
- width[0x0046] = 556;
- width[0x0047] = 722;
- width[0x0048] = 722;
- width[0x0049] = 333;
- width[0x00CD] = 333;
- width[0x00CE] = 333;
- width[0x00CF] = 333;
- width[0x00CC] = 333;
- width[0x004A] = 389;
- width[0x004B] = 722;
- width[0x004C] = 611;
- width[0x004D] = 889;
- width[0x004E] = 722;
- width[0x00D1] = 722;
- width[0x004F] = 722;
- width[0x008C] = 889;
- width[0x00D3] = 722;
- width[0x00D4] = 722;
- width[0x00D6] = 722;
- width[0x00D2] = 722;
- width[0x00D8] = 722;
- width[0x00D5] = 722;
- width[0x0050] = 556;
- width[0x0051] = 722;
- width[0x0052] = 667;
- width[0x0053] = 556;
- width[0x008A] = 556;
- width[0x0054] = 611;
- width[0x00DE] = 556;
- width[0x0055] = 722;
- width[0x00DA] = 722;
- width[0x00DB] = 722;
- width[0x00DC] = 722;
- width[0x00D9] = 722;
- width[0x0056] = 722;
- width[0x0057] = 944;
- width[0x0058] = 722;
- width[0x0059] = 722;
- width[0x00DD] = 722;
- width[0x009F] = 722;
- width[0x005A] = 611;
- width[0x0061] = 444;
- width[0x00E1] = 444;
- width[0x00E2] = 444;
- width[0x00B4] = 333;
- width[0x00E4] = 444;
- width[0x00E6] = 667;
- width[0x00E0] = 444;
- width[0x0026] = 778;
- width[0x00E5] = 444;
- width[0x005E] = 469;
- width[0x007E] = 541;
- width[0x002A] = 500;
- width[0x0040] = 921;
- width[0x00E3] = 444;
- width[0x0062] = 500;
- width[0x005C] = 278;
- width[0x007C] = 200;
- width[0x007B] = 480;
- width[0x007D] = 480;
- width[0x005B] = 333;
- width[0x005D] = 333;
- width[0x00A6] = 200;
- width[0x0095] = 350;
- width[0x0063] = 444;
- width[0x00E7] = 444;
- width[0x00B8] = 333;
- width[0x00A2] = 500;
- width[0x0088] = 333;
- width[0x003A] = 278;
- width[0x002C] = 250;
- width[0x00A9] = 760;
- width[0x00A4] = 500;
- width[0x0064] = 500;
- width[0x0086] = 500;
- width[0x0087] = 500;
- width[0x00B0] = 400;
- width[0x00A8] = 333;
- width[0x00F7] = 564;
- width[0x0024] = 500;
- width[0x0065] = 444;
- width[0x00E9] = 444;
- width[0x00EA] = 444;
- width[0x00EB] = 444;
- width[0x00E8] = 444;
- width[0x0038] = 500;
- width[0x0085] = 1000;
- width[0x0097] = 1000;
- width[0x0096] = 500;
- width[0x003D] = 564;
- width[0x00F0] = 500;
- width[0x0021] = 333;
- width[0x00A1] = 333;
- width[0x0066] = 333;
- width[0x0035] = 500;
- width[0x0083] = 500;
- width[0x0034] = 500;
- width[0xA4] = 167;
- width[0x0067] = 500;
- width[0x00DF] = 500;
- width[0x0060] = 333;
- width[0x003E] = 564;
- width[0x00AB] = 500;
- width[0x00BB] = 500;
- width[0x008B] = 333;
- width[0x009B] = 333;
- width[0x0068] = 500;
- width[0x002D] = 333;
- width[0x0069] = 278;
- width[0x00ED] = 278;
- width[0x00EE] = 278;
- width[0x00EF] = 278;
- width[0x00EC] = 278;
- width[0x006A] = 278;
- width[0x006B] = 500;
- width[0x006C] = 278;
- width[0x003C] = 564;
- width[0x00AC] = 564;
- width[0x006D] = 778;
- width[0x00AF] = 333;
- width[0x2D] = 324;
- width[0x00B5] = 500;
- width[0x00D7] = 564;
- width[0x006E] = 500;
- width[0x0039] = 500;
- width[0x00F1] = 500;
- width[0x0023] = 500;
- width[0x006F] = 500;
- width[0x00F3] = 500;
- width[0x00F4] = 500;
- width[0x00F6] = 500;
- width[0x009C] = 722;
- width[0x00F2] = 500;
- width[0x0031] = 500;
- width[0x00BD] = 750;
- width[0x00BC] = 750;
- width[0x00B9] = 300;
- width[0x00AA] = 276;
- width[0x00BA] = 310;
- width[0x00F8] = 500;
- width[0x00F5] = 500;
- width[0x0070] = 500;
- width[0x00B6] = 453;
- width[0x0028] = 333;
- width[0x0029] = 333;
- width[0x0025] = 833;
- width[0x002E] = 250;
- width[0x00B7] = 250;
- width[0x0089] = 1000;
- width[0x002B] = 564;
- width[0x00B1] = 564;
- width[0x0071] = 500;
- width[0x003F] = 444;
- width[0x00BF] = 444;
- width[0x0022] = 408;
- width[0x0084] = 444;
- width[0x0093] = 444;
- width[0x0094] = 444;
- width[0x0091] = 333;
- width[0x0092] = 333;
- width[0x0082] = 333;
- width[0x0027] = 180;
- width[0x0072] = 333;
- width[0x00AE] = 760;
- width[0x00B0] = 333;
- width[0x0073] = 389;
- width[0x009A] = 389;
- width[0x00A7] = 500;
- width[0x003B] = 278;
- width[0x0037] = 500;
- width[0x0036] = 500;
- width[0x002F] = 278;
- width[0x0020] = 250;
- width[0x00A0] = 250;
- width[0x00A3] = 500;
- width[0x0074] = 278;
- width[0x00FE] = 500;
- width[0x0033] = 500;
- width[0x00BE] = 750;
- width[0x00B3] = 300;
- width[0x0098] = 333;
- width[0x0099] = 980;
- width[0x0032] = 500;
- width[0x00B2] = 300;
- width[0x0075] = 500;
- width[0x00FA] = 500;
- width[0x00FB] = 500;
- width[0x00FC] = 500;
- width[0x00F9] = 500;
- width[0x005F] = 500;
- width[0x0076] = 500;
- width[0x0077] = 722;
- width[0x0078] = 500;
- width[0x0079] = 500;
- width[0x00FD] = 500;
- width[0x00FF] = 500;
- width[0x00A5] = 500;
- width[0x007A] = 444;
- width[0x0030] = 500;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.mif.fonts;
-
-import org.apache.fop.render.mif.Font;
-
-public class ZapfDingbats extends Font {
- private final static String fontName = "ZapfDingbats";
- private final static String encoding = "StandardEncoding";
- private final static int capHeight = 820;
- private final static int xHeight = 426;
- private final static int ascender = 820;
- private final static int descender = -143;
- private final static int firstChar = 32;
- private final static int lastChar = 255;
- private final static int[] width;
-
- static {
- width = new int[256];
- width[0x0020] = 278;
- width[0x0021] = 974;
- width[0x0022] = 961;
- width[0x0023] = 974;
- width[0x0024] = 980;
- width[0x0025] = 719;
- width[0x0026] = 789;
- width[0x0027] = 790;
- width[0x0028] = 791;
- width[0x0029] = 690;
- width[0x002A] = 960;
- width[0x002B] = 939;
- width[0x002C] = 549;
- width[0x002D] = 855;
- width[0x002E] = 911;
- width[0x002F] = 933;
- width[0x0030] = 911;
- width[0x0031] = 945;
- width[0x0032] = 974;
- width[0x0033] = 755;
- width[0x0034] = 846;
- width[0x0035] = 762;
- width[0x0036] = 761;
- width[0x0037] = 571;
- width[0x0038] = 677;
- width[0x0039] = 763;
- width[0x003A] = 760;
- width[0x003B] = 759;
- width[0x003C] = 754;
- width[0x003D] = 494;
- width[0x003E] = 552;
- width[0x003F] = 537;
- width[0x0040] = 577;
- width[0x0041] = 692;
- width[0x0042] = 786;
- width[0x0043] = 788;
- width[0x0044] = 788;
- width[0x0045] = 790;
- width[0x0046] = 793;
- width[0x0047] = 794;
- width[0x0048] = 816;
- width[0x0049] = 823;
- width[0x004A] = 789;
- width[0x004B] = 841;
- width[0x004C] = 823;
- width[0x004D] = 833;
- width[0x004E] = 816;
- width[0x004F] = 831;
- width[0x0050] = 923;
- width[0x0051] = 744;
- width[0x0052] = 723;
- width[0x0053] = 749;
- width[0x0054] = 790;
- width[0x0055] = 792;
- width[0x0056] = 695;
- width[0x0057] = 776;
- width[0x0058] = 768;
- width[0x0059] = 792;
- width[0x005A] = 759;
- width[0x005B] = 707;
- width[0x005C] = 708;
- width[0x005D] = 682;
- width[0x005E] = 701;
- width[0x005F] = 826;
- width[0x0060] = 815;
- width[0x0061] = 789;
- width[0x0062] = 789;
- width[0x0063] = 707;
- width[0x0064] = 687;
- width[0x0065] = 696;
- width[0x0066] = 689;
- width[0x0067] = 786;
- width[0x0068] = 787;
- width[0x0069] = 713;
- width[0x006A] = 791;
- width[0x006B] = 785;
- width[0x006C] = 791;
- width[0x006D] = 873;
- width[0x006E] = 761;
- width[0x006F] = 762;
- width[0x0070] = 762;
- width[0x0071] = 759;
- width[0x0072] = 759;
- width[0x0073] = 892;
- width[0x0074] = 892;
- width[0x0075] = 788;
- width[0x0076] = 784;
- width[0x0077] = 438;
- width[0x0078] = 138;
- width[0x0079] = 277;
- width[0x007A] = 415;
- width[0x007B] = 392;
- width[0x007C] = 392;
- width[0x007D] = 668;
- width[0x007E] = 668;
- width[0x00A1] = 732;
- width[0x00A2] = 544;
- width[0x00A3] = 544;
- width[0x00A4] = 910;
- width[0x00A5] = 667;
- width[0x00A6] = 760;
- width[0x00A7] = 760;
- width[0x00A8] = 776;
- width[0x00A9] = 595;
- width[0x00AA] = 694;
- width[0x00AB] = 626;
- width[0x00AC] = 788;
- width[0x00AD] = 788;
- width[0x00AE] = 788;
- width[0x00AF] = 788;
- width[0x00B0] = 788;
- width[0x00B1] = 788;
- width[0x00B2] = 788;
- width[0x00B3] = 788;
- width[0x00B4] = 788;
- width[0x00B5] = 788;
- width[0x00B6] = 788;
- width[0x00B7] = 788;
- width[0x00B8] = 788;
- width[0x00B9] = 788;
- width[0x00BA] = 788;
- width[0x00BB] = 788;
- width[0x00BC] = 788;
- width[0x00BD] = 788;
- width[0x00BE] = 788;
- width[0x00BF] = 788;
- width[0x00C0] = 788;
- width[0x00C1] = 788;
- width[0x00C2] = 788;
- width[0x00C3] = 788;
- width[0x00C4] = 788;
- width[0x00C5] = 788;
- width[0x00C6] = 788;
- width[0x00C7] = 788;
- width[0x00C8] = 788;
- width[0x00C9] = 788;
- width[0x00CA] = 788;
- width[0x00CB] = 788;
- width[0x00CC] = 788;
- width[0x00CD] = 788;
- width[0x00CE] = 788;
- width[0x00CF] = 788;
- width[0x00D0] = 788;
- width[0x00D1] = 788;
- width[0x00D2] = 788;
- width[0x00D3] = 788;
- width[0x00D4] = 894;
- width[0x00D5] = 838;
- width[0x00D6] = 1016;
- width[0x00D7] = 458;
- width[0x00D8] = 748;
- width[0x00D9] = 924;
- width[0x00DA] = 748;
- width[0x00DB] = 918;
- width[0x00DC] = 927;
- width[0x00DD] = 928;
- width[0x00DE] = 928;
- width[0x00DF] = 834;
- width[0x00E0] = 873;
- width[0x00E1] = 828;
- width[0x00E2] = 924;
- width[0x00E3] = 924;
- width[0x00E4] = 917;
- width[0x00E5] = 930;
- width[0x00E6] = 931;
- width[0x00E7] = 463;
- width[0x00E8] = 883;
- width[0x00E9] = 836;
- width[0x00EA] = 836;
- width[0x00EB] = 867;
- width[0x00EC] = 867;
- width[0x00ED] = 696;
- width[0x00EE] = 696;
- width[0x00EF] = 874;
- width[0x00F1] = 874;
- width[0x00F2] = 760;
- width[0x00F3] = 946;
- width[0x00F4] = 771;
- width[0x00F5] = 865;
- width[0x00F6] = 771;
- width[0x00F7] = 888;
- width[0x00F8] = 967;
- width[0x00F9] = 888;
- width[0x00FA] = 831;
- width[0x00FB] = 873;
- width[0x00FC] = 927;
- width[0x00FD] = 970;
- width[0x00FE] = 918;
- width[0x0089] = 410;
- width[0x0087] = 509;
- width[0x008C] = 334;
- width[0x0086] = 509;
- width[0x0080] = 390;
- width[0x008A] = 234;
- width[0x0084] = 276;
- width[0x0081] = 390;
- width[0x0088] = 410;
- width[0x0083] = 317;
- width[0x0082] = 317;
- width[0x0085] = 276;
- width[0x008D] = 334;
- width[0x008B] = 234;
-
- }
-
- public String encoding() {
- return encoding;
- }
-
- public String fontName() {
- return fontName;
- }
-
- public int getAscender(int size) {
- return size * ascender;
- }
-
- public int getCapHeight(int size) {
- return size * capHeight;
- }
-
- public int getDescender(int size) {
- return size * descender;
- }
-
- public int getXHeight(int size) {
- return size * xHeight;
- }
-
- public int getFirstChar() {
- return firstChar;
- }
-
- public int getLastChar() {
- return lastChar;
- }
-
- public int width(int i, int size) {
- return size * width[i];
- }
-
- public int[] getWidths(int size) {
- int[] arr = new int[getLastChar() - getFirstChar() + 1];
- System.arraycopy(width, getFirstChar(), arr, 0,
- getLastChar() - getFirstChar() + 1);
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- return arr;
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.pcl;
-
-// FOP
-import org.apache.fop.render.PrintRenderer;
-import org.apache.fop.messaging.MessageHandler;
-import org.apache.fop.image.ImageArea;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.properties.*;
-import org.apache.fop.datatypes.*;
-import org.apache.fop.pdf.PDFPathPaint;
-import org.apache.fop.pdf.PDFColor;
-import org.apache.fop.layout.*;
-import org.apache.fop.layout.inline.*;
-import org.apache.fop.image.*;
-
-import org.apache.fop.svg.SVGArea;
-import org.w3c.dom.svg.SVGSVGElement;
-import org.w3c.dom.svg.SVGDocument;
-
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Enumeration;
-
-/**
- * Renderer that renders areas to PCL
- * Created by Arthur E Welch III while at M&I EastPoint Technology
- * Donated by EastPoint to the Apache FOP project March 2, 2001.
- * Modified by Mark Lillywhite mark-fop@inomial.com to use the
- * new Renderer interface.
- */
-public class PCLRenderer extends PrintRenderer {
-
- /**
- * the current stream to add PCL commands to
- */
- public PCLStream currentStream;
-
- private int pageHeight = 7920;
-
- // These variables control the virtual paggination functionality.
- public int curdiv = 0;
- private int divisions = -1;
- public int paperheight = -1; // Paper height in decipoints?
- public int orientation =
- -1; // -1=default/unknown, 0=portrait, 1=landscape.
- public int topmargin = -1; // Top margin in decipoints?
- public int leftmargin = -1; // Left margin in decipoints?
- private int fullmargin = 0;
- private final boolean debug = false;
-
- private int xoffset =
- -180; // X Offset to allow for PCL implicit 1/4" left margin.
-
- private java.util.Hashtable options;
-
- /**
- * Create the PCL renderer
- */
- public PCLRenderer() {}
-
- /**
- * set up renderer options
- */
- public void setOptions(java.util.Hashtable options) {
- this.options = options;
- }
-
- /**
- * set the PCL document's producer
- *
- * @param producer string indicating application producing PCL
- */
- public void setProducer(String producer) {}
-
- /**
- * add a line to the current stream
- *
- * @param x1 the start x location in millipoints
- * @param y1 the start y location in millipoints
- * @param x2 the end x location in millipoints
- * @param y2 the end y location in millipoints
- * @param th the thickness in millipoints
- * @param stroke the line color
- */
- protected void addLine(int x1, int y1, int x2, int y2, int th,
- PDFPathPaint stroke) {
- if (x1 == x2)
- addRect(x1 - (th / 2), y1, th, y2 - y1 + 1, stroke, stroke);
- else if (y1 == y2)
- addRect(x1, y1 + (th / 2), x2 - x1 + 1, th, stroke, stroke);
- }
-
- /**
- * add a line to the current stream
- *
- * @param x1 the start x location in millipoints
- * @param y1 the start y location in millipoints
- * @param x2 the end x location in millipoints
- * @param y2 the end y location in millipoints
- * @param th the thickness in millipoints
- * @param rs the rule style
- * @param stroke the line color
- */
- protected void addLine(int x1, int y1, int x2, int y2, int th, int rs,
- PDFPathPaint stroke) {
- int dashon = 0;
- int dashoff = 0;
- // if ( rs != null && rs.length() > 5 && rs.charAt(0) == '[' && rs.charAt(1) != ']' && rs.charAt(4) == ']' )
- // {
- // dashon = rs.charAt(1) - '0';
- // dashoff = rs.charAt(3) - '0';
- // }
- switch (rs) {
- case org.apache.fop.fo.properties.RuleStyle.DASHED:
- dashon = 3;
- dashoff = 3;
- break;
- case org.apache.fop.fo.properties.RuleStyle.DOTTED:
- dashon = 1;
- dashoff = 3;
- break;
- }
- if (x1 == x2) {
- if (dashon > 0 && dashoff > 0) {
- int start = y1;
- int len = th * dashon;
- while (start < y2) {
- if (start + len > y2)
- len = y2 - start;
- addRect(x1 - (th / 2), start, th, len, stroke, stroke);
- start += (len + dashoff * th);
- }
- } else
- addRect(x1 - (th / 2), y1, th, y2 - y1 + 1, stroke, stroke);
- } else if (y1 == y2) {
- if (dashon > 0 && dashoff > 0) {
- int start = x1;
- int len = th * dashon;
- while (start < x2) {
- if (start + len > x2)
- len = x2 - start;
- addRect(start, y1 + (th / 2), len, th, stroke, stroke);
- start += (len + dashoff * th);
- }
- } else
- addRect(x1, y1 + (th / 2), x2 - x1 + 1, th, stroke, stroke);
- }
- }
-
- /**
- * add a rectangle to the current stream
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param stroke the stroke color/gradient
- */
- protected void addRect(int x, int y, int w, int h, PDFPathPaint stroke) {
- if (h < 0)
- h *= -1;
-
- if (h < 720 || w < 720) {
- if (w < 720)
- w = 720;
- if (h < 720)
- h = 720;
- addRect(x, y, w, h, stroke, stroke);
- } else {
- addRect(x, y, w, 720, stroke, stroke);
- addRect(x, y, 720, h, stroke, stroke);
- addRect(x + w - 720, y, 720, h, stroke, stroke);
- addRect(x, y - h + 720, w, 720, stroke, stroke);
- }
- }
-
- /**
- * add a filled rectangle to the current stream
- *
- * @param x the x position of left edge in millipoints
- * @param y the y position of top edge in millipoints
- * @param w the width in millipoints
- * @param h the height in millipoints
- * @param fill the fill color/gradient
- * @param stroke the stroke color/gradient
- */
- protected void addRect(int x, int y, int w, int h, PDFPathPaint stroke,
- PDFPathPaint fill) {
- if ((w == 0) || (h == 0))
- return;
- if (h < 0)
- h *= -1;
-
- PDFColor sc = (PDFColor)stroke;
- PDFColor fc = (PDFColor)fill;
-
- sc.setColorSpace(ColorSpace.DEVICE_RGB);
- fc.setColorSpace(ColorSpace.DEVICE_RGB);
-
- int lineshade =
- (int)(100
- - ((0.3f * sc.red() + 0.59f * sc.green() + 0.11f * sc.blue())
- * 100f));
- int fillshade =
- (int)(100
- - ((0.3f * fc.red() + 0.59f * fc.green() + 0.11f * fc.blue())
- * 100f));
-
- int xpos = xoffset + (x / 100);
- if (xpos < 0) {
- xpos = 0;
- MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds.");
- }
-
- currentStream.add("\033*v1O\033&a" + xpos + "h"
- + (pageHeight - (y / 100)) + "V" + "\033*c"
- + (w / 100) + "h" + (h / 100) + "V" + "\033*c"
- + lineshade + "G" + "\033*c2P");
- if (fillshade != lineshade && (w >= 720 || h >= 720)) {
- xpos = xoffset + ((x + 240) / 100);
- if (xpos < 0) {
- xpos = 0;
- MessageHandler.errorln("PCLRenderer.addRect() WARNING: Horizontal position out of bounds.");
- }
- currentStream.add("\033&a" + xpos + "h"
- + (pageHeight - ((y + 240)) / 100) + "V"
- + "\033*c" + ((w - 480) / 100) + "h"
- + ((h - 480) / 100) + "V" + "\033*c"
- + fillshade + "G" + "\033*c2P");
- }
- // Reset pattern transparency mode.
- currentStream.add("\033*v0O");
- }
-
- boolean printBMP(FopImage img, int x, int y, int w,
- int h) throws FopImageException {
- // Print the passed image file in PCL.
- byte imgmap[] = img.getBitmaps();
-
- int ix = 0;
- int iy = 0;
- int indx = 0;
- int iw = img.getWidth();
- int ih = img.getHeight();
- int bytewidth = (iw / 8);
- if ((iw % 8) != 0)
- bytewidth++;
- byte ib;
- char ic[] = new char[bytewidth * 2];
- char icu[] = new char[bytewidth];
- int lastcount = -1;
- byte lastbyte = 0;
- int icwidth = 0;
- int cr = 0;
- int cg = 0;
- int cb = 0;
- int grey = 0;
- boolean iscolor = img.getColorSpace().getColorSpace()
- != ColorSpace.DEVICE_GRAY;
- int dcount = 0;
- int xres = (iw * 72000) / w;
- int yres = (ih * 72000) / h;
- int resolution = xres;
- if (yres > xres)
- resolution = yres;
-
- if (resolution > 300)
- resolution = 600;
- else if (resolution > 150)
- resolution = 300;
- else if (resolution > 100)
- resolution = 150;
- else if (resolution > 75)
- resolution = 100;
- else
- resolution = 75;
- if (debug)
- System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor);
- // Setup for graphics
- currentStream.add("\033*t" + resolution + "R\033*r0F\033*r1A");
-
- // Transfer graphics data
- for (iy = 0; iy < ih; iy++) {
- ib = 0;
- // int padding = iw % 8;
- // if ( padding != 0 )
- // padding = 8 - padding;
- // padding = 0;
- // indx = (ih - iy - 1 + padding) * iw;
- indx = iy * iw;
- if (iscolor)
- indx *= 3;
- // currentStream.add("\033*b" + bytewidth + "W");
- for (ix = 0; ix < iw; ix++) {
- if (iscolor) {
- cr = imgmap[indx++] & 0xFF;
- cg = imgmap[indx++] & 0xFF;
- cb = imgmap[indx++] & 0xFF;
- grey = (cr * 30 + cg * 59 + cb * 11) / 100;
- } else
- grey = imgmap[indx++] & 0xFF;
- if (grey < 128)
- ib |= (1 << (7 - (ix % 8)));
- if ((ix % 8) == 7 || ((ix + 1) == iw)) {
- if (icwidth < bytewidth) {
- if (lastcount >= 0) {
- if (ib == lastbyte)
- lastcount++;
- else {
- ic[icwidth++] = (char)(lastcount & 0xFF);
- ic[icwidth++] = (char)lastbyte;
- lastbyte = ib;
- lastcount = 0;
- }
- } else {
- lastbyte = ib;
- lastcount = 0;
- }
- if (lastcount == 255 || ((ix + 1) == iw)) {
- ic[icwidth++] = (char)(lastcount & 0xFF);
- ic[icwidth++] = (char)lastbyte;
- lastbyte = 0;
- lastcount = -1;
- }
- }
- icu[ix / 8] = (char)ib;
- ib = 0;
- }
- }
- if (icwidth < bytewidth) {
- currentStream.add("\033*b1m" + icwidth + "W");
- currentStream.add(new String(ic, 0, icwidth));
- } else {
- currentStream.add("\033*b0m" + bytewidth + "W");
- currentStream.add(new String(icu));
- }
- lastcount = -1;
- icwidth = 0;
- }
-
- // End graphics
- currentStream.add("\033*rB");
-
-
- return (true);
- }
-
- /**
- * render image area to PCL
- *
- * @param area the image area to render
- */
- public void renderImageArea(ImageArea area) {
- int x = this.currentAreaContainerXPosition + area.getXOffset();
- int y = this.currentYPosition;
- int w = area.getContentWidth();
- int h = area.getHeight();
-
- this.currentYPosition -= h;
-
- FopImage img = area.getImage();
-
- int xpos = xoffset + (x / 100);
- if (xpos < 0) {
- xpos = 0;
- MessageHandler.errorln("PCLRenderer.renderImageArea() WARNING: Horizontal position out of bounds.");
- }
-
- currentStream.add("\033&a" + xpos + "h" + (pageHeight - (y / 100))
- + "V");
-
- try {
- printBMP(img, x, y, w, h);
- } catch (FopImageException e) {
- // e.printStackTrace(System.out);
- MessageHandler.errorln("PCLRenderer.renderImageArea() Error printing BMP ("
- + e.toString() + ")");
- }
- }
-
- /**
- * render a foreign object area
- */
- public void renderForeignObjectArea(ForeignObjectArea area) {
- // if necessary need to scale and align the content
- this.currentXPosition = this.currentXPosition + area.getXOffset();
- this.currentYPosition = this.currentYPosition;
- switch (area.getAlign()) {
- case TextAlign.START:
- break;
- case TextAlign.END:
- break;
- case TextAlign.CENTER:
- case TextAlign.JUSTIFY:
- break;
- }
- switch (area.getVerticalAlign()) {
- case VerticalAlign.BASELINE:
- break;
- case VerticalAlign.MIDDLE:
- break;
- case VerticalAlign.SUB:
- break;
- case VerticalAlign.SUPER:
- break;
- case VerticalAlign.TEXT_TOP:
- break;
- case VerticalAlign.TEXT_BOTTOM:
- break;
- case VerticalAlign.TOP:
- break;
- case VerticalAlign.BOTTOM:
- break;
- }
- // in general the content will not be text
-
- // align and scale
-
- switch (area.scalingMethod()) {
- case Scaling.UNIFORM:
- break;
- case Scaling.NON_UNIFORM:
- break;
- }
- // if the overflow is auto (default), scroll or visible
- // then the contents should not be clipped, since this
- // is considered a printing medium.
- switch (area.getOverflow()) {
- case Overflow.VISIBLE:
- case Overflow.SCROLL:
- case Overflow.AUTO:
- break;
- case Overflow.HIDDEN:
- break;
- }
- area.getObject().render(this);
-
- this.currentXPosition += area.getEffectiveWidth();
- // this.currentYPosition -= area.getEffectiveHeight();
- }
-
- /**
- * render SVG area to PCL
- *
- * @param area the SVG area to render
- */
- public void renderSVGArea(SVGArea area) {
- if (debug)
- System.out.println("PCLRenderer.renderSVGArea(" + area + ")");
- int x = this.currentXPosition;
- int y = this.currentYPosition;
- SVGSVGElement svg =
- ((SVGDocument)area.getSVGDocument()).getRootElement();
- int w = (int)(svg.getWidth().getBaseVal().getValue() * 1000);
- int h = (int)(svg.getHeight().getBaseVal().getValue() * 1000);
-
- /*
- * Clip to the svg area.
- * Note: To have the svg overlay (under) a text area then use
- * an fo:block-container
- */
-
- // TODO - translate and clip to viewbox
-
- // currentStream.add(svgRenderer.getString());
-
- // currentStream.add("Q\n");
- }
-
-
- public void setFont(String name, float size) {
- int fontcode = 0;
- if (name.length() > 1 && name.charAt(0) == 'F') {
- try {
- fontcode = Integer.parseInt(name.substring(1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- switch (fontcode) {
- case 1: // F1 = Helvetica
- // currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b24580T");
- // Arial is more common among PCL5 printers than Helvetica - so use Arial
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v0s0b16602T");
- break;
- case 2: // F2 = Helvetica Oblique
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v1s0b16602T");
- break;
- case 3: // F3 = Helvetica Bold
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v0s3b16602T");
- break;
- case 4: // F4 = Helvetica Bold Oblique
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v1s3b16602T");
- break;
- case 5: // F5 = Times Roman
- // currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b25093T");
- // Times New is more common among PCL5 printers than Times - so use Times New
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v0s0b16901T");
- break;
- case 6: // F6 = Times Italic
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v1s0b16901T");
- break;
- case 7: // F7 = Times Bold
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v0s3b16901T");
- break;
- case 8: // F8 = Times Bold Italic
-
- currentStream.add("\033(0N\033(s1p" + (size / 1000)
- + "v1s3b16901T");
- break;
- case 9: // F9 = Courier
-
- currentStream.add("\033(0N\033(s0p"
- + (120.01f / (size / 1000.00f)) + "h0s0b4099T");
- break;
- case 10: // F10 = Courier Oblique
-
- currentStream.add("\033(0N\033(s0p"
- + (120.01f / (size / 1000.00f)) + "h1s0b4099T");
- break;
- case 11: // F11 = Courier Bold
-
- currentStream.add("\033(0N\033(s0p"
- + (120.01f / (size / 1000.00f)) + "h0s3b4099T");
- break;
- case 12: // F12 = Courier Bold Oblique
-
- currentStream.add("\033(0N\033(s0p"
- + (120.01f / (size / 1000.00f)) + "h1s3b4099T");
- break;
- case 13: // F13 = Symbol
-
- currentStream.add("\033(19M\033(s1p" + (size / 1000)
- + "v0s0b16686T");
- // currentStream.add("\033(9U\033(s1p" + (size / 1000) + "v0s0b25093T"); // ECMA Latin 1 Symbol Set in Times Roman???
- break;
- case 14: // F14 = Zapf Dingbats
-
- currentStream.add("\033(14L\033(s1p" + (size / 1000)
- + "v0s0b45101T");
- break;
- default:
- currentStream.add("\033(0N\033(s" + (size / 1000) + "V");
- break;
- }
- }
-
- /**
- * render inline area to PCL
- *
- * @param area inline area to render
- */
- public void renderWordArea(WordArea area) {
- String name = area.getFontState().getFontName();
- int size = area.getFontState().getFontSize();
-
- float red = area.getRed();
- float green = area.getGreen();
- float blue = area.getBlue();
- PDFColor theAreaColor = new PDFColor((double)area.getRed(),
- (double)area.getGreen(),
- (double)area.getBlue());
-
- // currentStream.add("\033*c" + (int)(100 - ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f)) + "G\033*v2T");
- currentStream.add("\033*v1O\033*c"
- + (int)(100 - ((0.3f * red + 0.59f * green + 0.11f * blue) * 100f))
- + "G\033*v2T");
-
- if ((!name.equals(this.currentFontName))
- || (size != this.currentFontSize)) {
- this.currentFontName = name;
- this.currentFontSize = size;
- setFont(name, size);
- }
-
- this.currentFill = theAreaColor;
-
- int rx = this.currentXPosition;
- int bl = this.currentYPosition;
-
- String s;
- if (area.getPageNumberID() != null) {
- // this text is a page number, so resolve it
- s = idReferences.getPageNumber(area.getPageNumberID());
- if (s == null)
- s = "";
- } else {
- s = area.getText();
- }
-
- addWordLines(area, rx, bl, size, theAreaColor);
-
- int xpos = xoffset + (rx / 100);
- if (xpos < 0) {
- xpos = 0;
- MessageHandler.errorln("PCLRenderer.renderWordArea() WARNING: Horizontal position out of bounds.");
- }
- currentStream.add("\033&a" + xpos + "h" + (pageHeight - (bl / 100))
- + "V" + s);
-
- this.currentXPosition += area.getContentWidth();
- }
-
- /**
- * render page into PCL
- *
- * @param page page to render
- */
- public void renderPage(Page page) {
- if (debug)
- System.out.println("PCLRenderer.renderPage() page.Height() = "
- + page.getHeight());
- BodyAreaContainer body;
- AreaContainer before, after, start, end;
-
- if (paperheight > 0 && divisions == -1)
- divisions = paperheight / (page.getHeight() / 100);
-
- if (debug)
- System.out.println("PCLRenderer.renderPage() paperheight="
- + paperheight + " divisions=" + divisions);
-
- // Set top margin.
- // float fullmargin = 0;
- if (divisions > 0)
- fullmargin = paperheight * curdiv / divisions;
- if (topmargin > 0)
- fullmargin += topmargin;
- if (debug)
- System.out.println("PCLRenderer.renderPage() curdiv=" + curdiv
- + " fullmargin=" + fullmargin);
- // if ( fullmargin > 0 )
- // currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C");
- // this.currentYPosition = fullmargin * 100;
-
- if (paperheight > 0)
- pageHeight = (paperheight / divisions) + fullmargin;
- else
- pageHeight = page.getHeight() / 100;
- if (debug)
- System.out.println("PCLRenderer.renderPage() Set currentYPosition="
- + this.currentYPosition);
- if (leftmargin > 0 && curdiv == 0)
- currentStream.add("\033&k" + (leftmargin / 6f)
- + "H\033&a1L\033&k12H");
-
- body = page.getBody();
- before = page.getBefore();
- after = page.getAfter();
- start = page.getStart();
- end = page.getEnd();
-
- this.currentFontName = "";
- this.currentFontSize = 0;
-
- renderBodyAreaContainer(body);
-
- if (before != null)
- renderAreaContainer(before);
-
- if (after != null)
- renderAreaContainer(after);
-
- if (start != null)
- renderAreaContainer(start);
-
- if (end != null)
- renderAreaContainer(end);
-
- // End page.
- if (++curdiv == divisions || divisions == -1) {
- curdiv = 0;
- currentStream.add("\f");
- }
-
- // Links, etc not implemented...
- /*
- * currentPage = this.pdfDoc.makePage(this.pdfResources, currentStream,
- * page.getWidth()/1000, page.getHeight()/1000, page);
- * if (page.hasLinks()) {
- * currentAnnotList = this.pdfDoc.makeAnnotList();
- * currentPage.setAnnotList(currentAnnotList);
- * Enumeration e = page.getLinkSets().elements();
- * while (e.hasMoreElements()) {
- * LinkSet linkSet = (LinkSet) e.nextElement();
- * linkSet.align();
- * String dest = linkSet.getDest();
- * int linkType = linkSet.getLinkType();
- * Enumeration f = linkSet.getRects().elements();
- * while (f.hasMoreElements()) {
- * LinkedRectangle lrect = (LinkedRectangle) f.nextElement();
- * currentAnnotList.addLink(
- * this.pdfDoc.makeLink(lrect.getRectangle(), dest, linkType));
- * }
- * }
- * } else {
- * // just to be on the safe side
- * currentAnnotList = null;
- * }
- */
- }
- public void startRenderer(OutputStream outputStream)
- throws IOException {
- MessageHandler.logln("rendering areas to PCL");
- currentStream = new PCLStream(outputStream);
-
- // Set orientation.
- if (orientation > -1)
- currentStream.add("\033&l" + orientation + "O");
- else
- currentStream.add("\033&l0O");
- if (orientation == 1 || orientation == 3)
- xoffset = -144;
- else
- xoffset = -180;
-
- // Reset the margins.
- currentStream.add("\033" + "9\033&l0E");
- }
-
- public void stopRenderer(OutputStream outputStream)
- throws IOException {
- MessageHandler.logln("writing out PCL");
- outputStream.flush();
- }
-
- public void render(Page page, OutputStream outputStream)
- throws IOException {
- idReferences = page.getIDReferences();
- this.renderPage(page);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.render.pcl;
-
-import java.io.*;
-
-public class PCLStream {
- OutputStream out = null;
- boolean doOutput = true;
-
- public PCLStream(OutputStream os) {
- out = os;
- }
-
- public void add(String str) {
- if (!doOutput)
- return;
-
- byte buff[] = new byte[str.length()];
- int countr;
- int len = str.length();
- for (countr = 0; countr < len; countr++)
- buff[countr] = (byte)str.charAt(countr);
- try {
- out.write(buff);
- } catch (IOException e) {
- // e.printStackTrace();
- // e.printStackTrace(System.out);
- throw new RuntimeException(e.toString());
- }
- }
-
- public void setDoOutput(boolean doout) {
- doOutput = doout;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-
-import java.util.*;
-import java.io.*;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import java.text.DateFormat;
-
-/**
- * This class is an extension of Ant, a script utility from
- * jakarta.apache.org.
- * It provides methods to compare two files
- */
-
-public class Compare {
- private String referenceDirectory, testDirectory;
- private String[] filenameList;
- private String filenames;
- private static boolean IDENTICAL_FILES = true;
- private static boolean NOTIDENTICAL_FILES = false;
- private BufferedInputStream oldfileInput;
- private BufferedInputStream newfileInput;
-
- // sets directory for test files
- public void setTestDirectory(String testDirectory) {
- if (!(testDirectory.endsWith("/") | testDirectory.endsWith("\\"))) {
- testDirectory += File.separator;
- }
- this.testDirectory = testDirectory;
- }
-
- // sets directory for reference files
- public void setReferenceDirectory(String referenceDirectory) {
- if (!(referenceDirectory.endsWith("/")
- | referenceDirectory.endsWith("\\"))) {
- referenceDirectory += File.separator;
- }
- this.referenceDirectory = referenceDirectory;
- }
-
- public void setFilenames(String filenames) {
- StringTokenizer tokens = new StringTokenizer(filenames, ",");
- Vector filenameListTmp = new Vector(20);
- while (tokens.hasMoreTokens()) {
- filenameListTmp.addElement(tokens.nextToken());
- }
- filenameList = new String[filenameListTmp.size()];
- filenameListTmp.copyInto((String[])filenameList);
- }
-
- private boolean compareBytes(File oldFile, File newFile) {
- try {
- oldfileInput =
- new BufferedInputStream(new FileInputStream(oldFile));
- newfileInput =
- new BufferedInputStream(new FileInputStream(newFile));
- int charactO = 0;
- int charactN = 0;
- boolean identical = true;
-
- while (identical & (charactO != -1)) {
- if (charactO == charactN) {
- charactO = oldfileInput.read();
- charactN = newfileInput.read();
- } else {
- return NOTIDENTICAL_FILES;
- }
- }
- return IDENTICAL_FILES;
- } catch (IOException io) {
- System.err.println("Task Compare - Error: \n" + io.toString());
- }
- return NOTIDENTICAL_FILES;
- }
-
- private boolean compareFileSize(File oldFile, File newFile) {
- if (oldFile.length() != newFile.length()) {
- return NOTIDENTICAL_FILES;
- } else {
- return IDENTICAL_FILES;
- }
- } // end: compareBytes
-
- private boolean filesExist(File oldFile, File newFile) {
- if (!oldFile.exists()) {
- System.err.println("Task Compare - ERROR: File "
- + referenceDirectory + oldFile.getName()
- + " doesn't exist!");
- return false;
- } else if (!newFile.exists()) {
- System.err.println("Task Compare - ERROR: File " + testDirectory
- + newFile.getName() + " doesn't exist!");
- return false;
- } else {
- return true;
- }
- }
-
- public void writeHeader(PrintWriter results) {
- String dateTime = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
- DateFormat.MEDIUM).format(new Date());
- results.println("<html><head><title>Test Results</title></head><body>\n");
- results.println("<h2>Compare Results<br>");
- results.println("<font size='1'>created " + dateTime
- + "</font></h2>");
- results.println("<table cellpadding='10' border='2'><thead><th align='center'>reference file</th><th align='center'>test file</th>"
- + "<th align='center'>identical?</th></thead>");
-
-
- }
-
- // main method of task compare
- public void execute() throws BuildException {
- boolean identical = false;
- File oldFile;
- File newFile;
- try {
- PrintWriter results =
- new PrintWriter(new FileWriter("results.html"), true);
- this.writeHeader(results);
- for (int i = 0; i < filenameList.length; i++) {
- oldFile = new File(referenceDirectory + filenameList[i]);
- newFile = new File(testDirectory + filenameList[i]);
- if (filesExist(oldFile, newFile)) {
- identical = compareFileSize(oldFile, newFile);
- if (identical) {
- identical = compareBytes(oldFile, newFile);
- }
- if (!identical) {
- System.out.println("Task Compare: \nFiles "
- + referenceDirectory
- + oldFile.getName() + " - "
- + testDirectory
- + newFile.getName()
- + " are *not* identical.");
- results.println("<tr><td><a href='"
- + referenceDirectory
- + oldFile.getName() + "'>"
- + oldFile.getName()
- + "</a> </td><td> <a href='"
- + testDirectory + newFile.getName()
- + "'>" + newFile.getName() + "</a>"
- + " </td><td><font color='red'>No</font></td></tr>");
- } else {
- results.println("<tr><td><a href='"
- + referenceDirectory
- + oldFile.getName() + "'>"
- + oldFile.getName()
- + "</a> </td><td> <a href='"
- + testDirectory + newFile.getName()
- + "'>" + newFile.getName() + "</a>"
- + " </td><td>Yes</td></tr>");
- }
- }
- }
- results.println("</table></html>");
- } catch (IOException ioe) {
- System.err.println("ERROR: " + ioe);
- }
- } // end: execute()
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-/**
- * This class is an extension of Ant, a script utility from
- * jakarta.apache.org.
- * It takes a couple of xml files conforming to the xml-site dtd and
- * writes them all into one xml file, deleting any reference to
- * the proprietary protocol sbk. The configFile determines what files
- * are read in what sequence.
- */
-// Ant
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-
-
-// SAX
-import org.xml.sax.Parser;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.Locator;
-import org.xml.sax.AttributeList;
-
-// Java
-import java.io.*;
-import java.util.*;
-import java.net.URL;
-
-public class CompileXMLFiles extends Task
- implements org.xml.sax.EntityResolver, org.xml.sax.DTDHandler,
- org.xml.sax.DocumentHandler, org.xml.sax.ErrorHandler {
- private String configFile, outFile;
- private String[] filenameList;
- private String filenames;
- private Vector files = new Vector();
-
- // sets name of configuration file, which must
- // be an xml file conforming to the book.dtd used by xml-site
- public void setConfigFile(String configFile) {
- this.configFile = configFile;
- }
-
- public void setOutFile(String outFile) {
- this.outFile = outFile;
- }
-
-
- // main method of this task
- public void execute() throws BuildException {
- boolean errors = false;
-
- if (!(new File(configFile).exists())) {
- errors = true;
- System.err.println("Task CompileXMLFiles - ERROR: config file "
- + configFile + " is missing.");
- }
-
- Parser parser = createParser();
-
- if (parser == null) {
- System.err.println("Task CompileXMLFiles - ERROR: Unable to create SAX parser");
- errors = true;
- }
- parser.setDocumentHandler(this);
- try {
- parser.parse(CompileXMLFiles.fileInputSource(configFile));
- } catch (SAXException e) {
- System.out.println(e);
- } catch (IOException ioe) {
- System.out.println(ioe);
- }
- } // end: execute()
-
-
- /* the following methods belong to the sax parser and implement the Document Handler */
- public InputSource resolveEntity(String publicId,
- String systemId) throws SAXException {
- return null;
- }
-
- public void notationDecl(String name, String publicId, String systemId) {
- // no op
- }
-
- public void unparsedEntityDecl(String name, String publicId,
- String systemId, String notationName) {
- // no op
- }
-
- public void setDocumentLocator(Locator locator) {
- // no op
- }
-
- public void startDocument() throws SAXException {
- // no op
- }
-
- /*
- * After the cnfiguration file has been parsed all files which
- * have been collected in the ArrayList files are concatinated
- * and written to a new (temporary) file
- */
- public void endDocument() throws SAXException {
- String line, filename;
- BufferedReader in;
- Enumeration iterator = files.elements();
- try {
- BufferedWriter out =
- new BufferedWriter(new FileWriter("compileXMLFiles-tmp.xml"));
- out.write("<?xml version=\"1.0\"?>\n"
- + "<!DOCTYPE documentation [\n"
- + "<!ENTITY nbsp \" \">\n" + "]>\n<documentation>");
- while (iterator.hasMoreElements()) {
- filename = (String)iterator.nextElement();
- in = new BufferedReader(new FileReader(filename));
- while ((line = in.readLine()) != null) {
- // kill the lines pointing to the sbk protocol and the xml declaration
- if (line.indexOf("<!DOCTYPE ") != -1
- || line.indexOf("<?xml ") != -1) {
- line = "";
- }
- out.write(line + "\n");
- }
- out.flush();
- }
- out.write("\n</documentation>");
- out.close();
- } catch (Exception e) {
- System.out.println(e);
- }
-
- }
-
- public void startElement(String name,
- AttributeList atts) throws SAXException {
- String id, label, source;
- if (name.equals("document") || name.equals("entry")) {
- source = atts.getValue("source");
- files.addElement(source);
- }
- }
-
- public void endElement(String name) throws SAXException {
- // no op
- }
-
- public void characters(char ch[], int start,
- int length) throws SAXException {
- // no op
- }
-
- public void ignorableWhitespace(char ch[], int start,
- int length) throws SAXException {
- // no op
- }
-
- public void processingInstruction(String target,
- String data) throws SAXException {
- // no op
- }
-
- public void warning(SAXParseException e) throws SAXException {
- // no op
- }
-
- public void error(SAXParseException e) throws SAXException {
- // no op
- }
-
- public void fatalError(SAXParseException e) throws SAXException {
- throw e;
- }
-
- /* ------------------------ */
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- static Parser createParser() {
- String parserClassName = System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- System.err.println("using SAX parser " + parserClassName);
-
- try {
- return (Parser)Class.forName(parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- System.err.println("Could not find " + parserClassName);
- } catch (InstantiationException e) {
- System.err.println("Could not instantiate " + parserClassName);
- } catch (IllegalAccessException e) {
- System.err.println("Could not access " + parserClassName);
- } catch (ClassCastException e) {
- System.err.println(parserClassName + " is not a SAX driver");
- }
- return null;
- }
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- protected static InputSource fileInputSource(String filename) {
-
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null, path).toString());
- } catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
-}
-
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-// Ant
-import org.apache.tools.ant.*;
-
-
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-// Java
-import java.io.*;
-import java.util.*;
-
-// FOP
-import org.apache.fop.messaging.*;
-import org.apache.fop.apps.Starter;
-import org.apache.fop.apps.InputHandler;
-import org.apache.fop.apps.FOInputHandler;
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.configuration.Configuration;
-
-
-/**
- * Wrapper for Fop which allows it to be accessed from within an Ant task.
- * Accepts the inputs:
- * <ul>
- * <li>fofile -> formatting objects file to be transformed</li>
- * <li>pdffile -> output filename</li>
- * <li>baseDir -> directory to work from</li>
- * <li>messagelevel -> (info | verbose | debug) level to output non-error messages</li>
- * </ul>
- */
-public class Fop extends Task {
- File foFile;
- File pdfFile;
- File baseDir;
- int messageType = Project.MSG_VERBOSE;
-
- /**
- * Sets the input file
- * @param File to input from
- */
- public void setFofile(File foFile) {
- this.foFile = foFile;
- }
-
- /**
- * Gets the input file
- */
- public File getFofile() {
- if (foFile == null) {
- log("fofile attribute is not set", Project.MSG_ERR);
- throw new BuildException("fofile attribute is not set");
- }
- return foFile;
- }
-
- /**
- * Sets the output file
- * @param File to output to
- */
- public void setPdffile(File pdfFile) {
- this.pdfFile = pdfFile;
- }
-
- /**
- * Sets the output file
- */
- public File getPdffile() {
- if (pdfFile == null) {
- log("pdffile attribute is not set", Project.MSG_ERR);
- throw new BuildException("pdffile attribute is not set");
- }
- return pdfFile;
- }
-
- /**
- * Sets the message level to be used while processing.
- * @param String (info | verbose | debug)
- */
- public void setMessagelevel(String messageLevel) {
- if (messageLevel.equalsIgnoreCase("info")) {
- messageType = Project.MSG_INFO;
- } else if (messageLevel.equalsIgnoreCase("verbose")) {
- messageType = Project.MSG_VERBOSE;
- } else if (messageLevel.equalsIgnoreCase("debug")) {
- messageType = Project.MSG_DEBUG;
- } else {
- log("messagelevel set to unknown value \"" + messageLevel + "\"",
- Project.MSG_ERR);
- throw new BuildException("unknown messagelevel");
- }
- }
-
- /**
- * Returns the message type corresponding to Property.MSG_(INFO | VERBOSE | DEBUG)
- * representing the current message level.
- */
- public int getMessageType() {
- return messageType;
- }
-
- /**
- * Sets the base directory; currently ignored
- * @param File to use as a working directory
- */
- public void setBasedir(File baseDir) {
- this.baseDir = baseDir;
- }
-
- /**
- * Gets the base directory
- */
- public File getBasedir() {
- return (baseDir != null) ? baseDir : project.resolveFile(".");
- }
-
- /**
- * Starts execution of this task
- */
- public void execute() throws BuildException {
- try {
- Starter starter = new FOPTaskStarter(this);
- starter.run();
- } catch (FOPException ex) {
- throw new BuildException(ex);
- }
-
- }
-
-}
-
-class FOPTaskStarter extends Starter {
- Fop task;
- MessageLogger logger;
-
- FOPTaskStarter(Fop task) throws FOPException {
- this.task = task;
- MessageHandler.setOutputMethod(MessageHandler.EVENT);
- logger = new MessageLogger(new MessageHandler(), task);
- logger.setMessageLevel(task.getMessageType());
- }
-
- public void run() throws FOPException {
- try {
- // Configuration.put("baseDir", task.getBasedir().toURL().toExternalForm());
- Configuration.put("baseDir",
- task.getFofile().getParentFile().toURL().toExternalForm());
- } catch (Exception e) {
- task.log("Error setting base directory", Project.MSG_DEBUG);
- }
-
- InputHandler inputHandler = new FOInputHandler(task.getFofile());
- XMLReader parser = inputHandler.getParser();
- setParserFeatures(parser);
-
- FileOutputStream pdfOut = null;
- try {
- pdfOut = new FileOutputStream(task.getPdffile());
- } catch (Exception ex) {
- MessageHandler.errorln("Failed to open " + task.getPdffile());
- throw new BuildException(ex);
- }
-
- task.log("Using base directory: "
- + Configuration.getValue("baseDir"), Project.MSG_DEBUG);
- task.log(task.getFofile().getName() + " -> "
- + task.getPdffile().getName(), Project.MSG_INFO);
-
- try {
- Driver driver = new Driver(inputHandler.getInputSource(), pdfOut);
- driver.setRenderer(Driver.RENDER_PDF);
- driver.setXMLReader(parser);
- driver.run();
- } catch (Exception ex) {
- MessageHandler.logln("Error: " + ex.getMessage());
- throw new BuildException(ex);
- }
- logger.die();
- }
-
-}
-
-class MessageLogger implements MessageListener {
- MessageHandler handler;
- Task task;
- int messageLevel = Project.MSG_VERBOSE;
- int lastMessageLevel = Integer.MIN_VALUE;
- StringBuffer cache = new StringBuffer();
- String breakChars = "\n";
- boolean performCaching = true;
-
- MessageLogger(MessageHandler handler, Task task) {
- this(handler, task, Project.MSG_VERBOSE);
- }
-
- MessageLogger(MessageHandler handler, Task task, int messageLevel) {
- this.handler = handler;
- this.task = task;
- setMessageLevel(messageLevel);
- handler.addListener(this);
- }
-
- public void setMessageLevel(int messageLevel) {
- this.messageLevel = messageLevel;
- }
-
- public int getMessageLevel() {
- return messageLevel;
- }
-
- public void processMessage(MessageEvent event) {
- task.log("Logger got message: \"" + event.getMessage() + "\"",
- Project.MSG_DEBUG);
-
- boolean flushed = false;
-
- if (!flushed) {
- int messageLevel;
- if (event.getMessageType() == MessageEvent.ERROR) {
- messageLevel = Project.MSG_ERR;
- } else {
- messageLevel = this.messageLevel;
- }
- if (messageLevel != lastMessageLevel) {
- flush();
- flushed = true;
- }
- lastMessageLevel = messageLevel;
- }
-
- cache.append(event.getMessage());
-
- if (!performCaching) {
- flush();
- flushed = true;
- }
-
- for (int i = 0; !flushed && i < breakChars.length(); i++) {
- if (event.getMessage().lastIndexOf(breakChars.charAt(i)) != -1) {
- flush();
- flushed = true;
- }
- }
- }
-
- public void flush() {
- StringTokenizer output = new StringTokenizer(cache.toString(), "\n",
- false);
- while (output.hasMoreElements()) {
- task.log(output.nextElement().toString(), lastMessageLevel);
- }
- cache.setLength(0);
- }
-
- public void die() {
- flush();
- // because MessageHandler is static this has to be done
- // or you can get duplicate messages if there are
- // multiple <fop> tags in a buildfile
- handler.removeListener(this);
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-
-import java.io.*;
-import java.text.SimpleDateFormat;
-import java.net.InetAddress;
-import java.util.Date;
-import java.util.Properties;
-
-
-
-/**
- * Creates a manifest file for packing into a jar.
- * <P>
- * Attributes are as follows:
- * <dl>
- * <dt>file</dt> <dd>the manifest file to write out to (required)</dd>
- * <dt>overwrite</dt> <dd>if set to yes or true, overwrite the given
- * manifest file. Default is no</dd>
- * <dt>version</dt> <dd>manifest version. Defaults to "1.0"</dd>
- * <dt>spectitle</dt> <dd>the specification title</dd>
- * <dt>specversion</dt> <dd>the specification version</dd>
- * <dt>specvendor</dt> <dd>the specification vendor</dd>
- * <dt>impltitle</dt> <dd>the implementation title</dd>
- * <dt>implversion</dt> <dd>the implementation version.</dd>
- * <dt>implvendor</dt> <dd>the implementation vendor</dd>
- * <dt>mainclass</dt> <dd>the class to run when java -jar is invoked</dd>
- * <dt>classpath</dt> <dd>the classpath to use when java -jar is invoked</dd>
- * <dt>createdby</dt> <dd>the string to set the Created-By field to</dd>
- * <dt>buildid</dt> <dd>A build identifier. Defaults to a build identifier
- * containing <tt>date + " ("+username+"@"+hostname+" ["+os+" "+version+" "+arch+"]</tt> </dd>
- * </dl>
- *
- * @author Kelly A. Campbell
- */
-
-public class Manifest extends Task {
- public static final String MANIFEST_VERSION = "Manifest-Version: ";
- public static final String CREATED_BY = "Created-By: ";
- public static final String REQUIRED_VERSION = "Required-Version: ";
-
- public static final String SPECIFICATION_TITLE = "Specification-Title: ";
- public static final String SPECIFICATION_VERSION =
- "Specification-Version: ";
- public static final String SPECIFICATION_VENDOR =
- "Specification-Vendor: ";
- public static final String IMPL_TITLE = "Implementation-Title: ";
- public static final String IMPL_VERSION = "Implementation-Version: ";
- public static final String IMPL_VENDOR = "Implementation-Vendor: ";
- public static final String BUILD_ID = "Build-ID: ";
- public static final String MAIN_CLASS = "Main-Class: ";
- public static final String CLASS_PATH = "Class-Path: ";
-
-
- private String _manifestVersion = "1.0";
- private String _spectitle;
- private String _specvers;
- private String _specvend;
- private String _impltitle;
- private String _implvers;
- private String _implvend;
- private String _mainclass;
- private String _classpath;
- private String _createdby;
- private String _buildid;
-
- private String _manifestFilename;
- private Boolean _overwrite = Boolean.FALSE;
-
- public void setFile(String s) {
- _manifestFilename = s;
- }
-
- public void setOverwrite(Boolean b) {
- _overwrite = b;
- }
-
- public void setSpectitle(String s) {
- _spectitle = s;
- }
-
- public void setSpecversion(String s) {
- _specvers = s;
- }
-
- public void setSpecvendor(String s) {
- _specvend = s;
- }
-
- public void setImpltitle(String s) {
- _impltitle = s;
- }
-
- public void setImplversion(String s) {
- _implvers = s;
- }
-
- public void setImplvendor(String s) {
- _implvend = s;
- }
-
- public void setMainclass(String s) {
- _mainclass = s;
- }
-
- public void setClasspath(String s) {
- _classpath = s;
- }
-
- public void setCreatedby(String s) {
- _createdby = s;
- }
-
- public void setBuildid(String s) {
- _buildid = s;
- }
-
- /**
- * Main task method which runs this task and creates the manifest file.
- * @exception BuildException if one of the required attributes isn't set
- */
- public void execute() throws BuildException {
- // System.out.println("Executing manifest task");
-
- PrintWriter out;
- try {
- if (_manifestFilename != null) {
- // open the file for writing
- File f = new File(_manifestFilename);
- if (f.exists()) {
- if (_overwrite.booleanValue()) {
- f.delete();
- } else {
- throw new BuildException("Will not overwrite existing file: "
- + _manifestFilename
- + ". Use overwrite='yes' if you wish to overwrite the file.");
- }
- }
- System.out.println("creating " + f);
-
- // jdk1.2 -- f.createNewFile();
- out = new PrintWriter(new FileOutputStream(f));
-
- } else {
- throw new BuildException("Manifest task requires a 'file' attribute");
- }
- } catch (IOException ex) {
- throw new BuildException(ex);
- }
-
- // setup the implementation versionn (buildID)
- if (_buildid == null || _buildid.trim().equals("")) {
- _buildid = createBuildID();
- }
- if (_createdby == null || _createdby.trim().equals("")) {
- _createdby = getCreator();
- }
-
- print(out, MANIFEST_VERSION, _manifestVersion);
- print(out, CREATED_BY, _createdby);
-
- print(out, SPECIFICATION_TITLE, _spectitle);
- print(out, SPECIFICATION_VERSION, _specvers);
- print(out, SPECIFICATION_VENDOR, _specvend);
- print(out, IMPL_TITLE, _impltitle);
- print(out, IMPL_VERSION, _implvers);
- print(out, IMPL_VENDOR, _implvend);
- print(out, BUILD_ID, _buildid);
- print(out, MAIN_CLASS, _mainclass);
- print(out, CLASS_PATH, _classpath);
-
- out.flush();
- out.close();
-
- }
-
- protected void print(PrintWriter out, String header, String value) {
- if (value != null &&!value.trim().equals("")) {
- out.println(header + value);
- // System.out.println("manifest: "+header+value);
- }
- }
-
- private static String createBuildID() {
- Date d = new Date();
- SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd-HHmmss-z");
- String date = f.format(d);
- String hostname, username, os, version, arch;
- try {
- hostname = InetAddress.getLocalHost().getHostName();
- } catch (Exception ex) {
- hostname = "unknown";
- }
- username = System.getProperty("user.name");
- os = System.getProperty("os.name");
- version = System.getProperty("os.version");
- arch = System.getProperty("os.arch");
- String buildid = date + " (" + username + "@" + hostname + " [" + os
- + " " + version + " " + arch + "])";
- return buildid;
-
- }
-
- private static String getCreator() {
- try {
- Properties props = new Properties();
- InputStream in =
- org.apache.tools.ant.Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt");
- if (in != null) {
- props.load(in);
- in.close();
-
- return "Ant " + props.getProperty("VERSION");
- } else {
- return null;
- }
- } catch (IOException ex) {
- return null;
- }
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-// Ant
-import org.apache.tools.ant.*;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.net.URLClassLoader;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.util.*;
-
-import javax.xml.parsers.*;
-
-import org.w3c.dom.*;
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Testing ant task.
- * This task is used to test FOP as a build target.
- * This uses the TestConverter (with weak code dependancy) to run the tests
- * and check the results.
- */
-public class RunTest extends Task {
- String basedir;
- String testsuite = "";
- String referenceJar = "";
- String refVersion = "";
-
- public RunTest() {}
-
- public void setTestSuite(String str) {
- testsuite = str;
- }
-
- public void setBasedir(String str) {
- basedir = str;
- }
-
- public void setReference(String str) {
- referenceJar = str;
- }
-
- public void setRefVersion(String str) {
- refVersion = str;
- }
-
- /**
- * Execute this ant task.
- * This creates the reference output, if required, then tests
- * the current build.
- */
- public void execute() throws BuildException {
- runReference();
- testNewBuild();
- }
-
- /**
- * Test the current build.
- * This uses the current jar file (in build/fop.jar) to run the
- * tests with.
- * The output is then compared with the reference output.
- */
- protected void testNewBuild() {
- try {
- ClassLoader loader = new URLClassLoader(new URL[] {
- new URL("file:build/fop.jar")
- });
- Hashtable diff = runConverter(loader, "areatree",
- "reference/output/");
- if (diff != null &&!diff.isEmpty()) {
- System.out.println("====================================");
- System.out.println("The following files differ:");
- boolean broke = false;
- for (Enumeration keys = diff.keys();
- keys.hasMoreElements(); ) {
- Object fname = keys.nextElement();
- Boolean pass = (Boolean)diff.get(fname);
- System.out.println("file: " + fname
- + " - reference success: " + pass);
- if (pass.booleanValue()) {
- broke = true;
- }
- }
- if (broke) {
- throw new BuildException("Working tests have been changed.");
- }
- }
- } catch (MalformedURLException mue) {
- mue.printStackTrace();
- }
- }
-
- /**
- * Run the tests for the reference jar file.
- * This checks that the reference output has not already been
- * run and then checks the version of the reference jar against
- * the version required.
- * The reference output is then created.
- */
- protected void runReference() throws BuildException {
- // check not already done
- File f = new File(basedir + "/reference/output/");
- // if(f.exists()) {
- // need to check that files have actually been created.
- // return;
- // } else {
- try {
- ClassLoader loader = new URLClassLoader(new URL[] {
- new URL("file:" + referenceJar)
- });
- boolean failed = false;
-
- try {
- Class cla = Class.forName("org.apache.fop.apps.Options",
- true, loader);
- Object opts = cla.newInstance();
- cla = Class.forName("org.apache.fop.apps.Version", true,
- loader);
- Method get = cla.getMethod("getVersion", new Class[]{});
- if (!get.invoke(null, new Object[]{}).equals(refVersion)) {
- throw new BuildException("Reference jar is not correct version it must be: "
- + refVersion);
- }
- } catch (IllegalAccessException iae) {
- failed = true;
- } catch (IllegalArgumentException are) {
- failed = true;
- } catch (InvocationTargetException are) {
- failed = true;
- } catch (ClassNotFoundException are) {
- failed = true;
- } catch (InstantiationException are) {
- failed = true;
- } catch (NoSuchMethodException are) {
- failed = true;
- }
- if (failed) {
- throw new BuildException("Reference jar could not be found in: "
- + basedir + "/reference/");
- }
- f.mkdirs();
- runConverter(loader, "reference/output/", null);
- } catch (MalformedURLException mue) {
- mue.printStackTrace();
- }
- // }
- }
-
- /**
- * Run the Converter.
- * Runs the test converter using the specified class loader.
- * This loads the TestConverter using the class loader and
- * then runs the test suite for the current test suite
- * file in the base directory.
- * @param loader the class loader to use to run the tests with
- */
- protected Hashtable runConverter(ClassLoader loader, String dest,
- String compDir) {
- String converter = "org.apache.fop.tools.TestConverter";
-
- Hashtable diff = null;
- try {
- Class cla = Class.forName(converter, true, loader);
- Object tc = cla.newInstance();
- Method meth;
-
- meth = cla.getMethod("setBaseDir", new Class[] {
- String.class
- });
- meth.invoke(tc, new Object[] {
- basedir
- });
-
- meth = cla.getMethod("runTests", new Class[] {
- String.class, String.class, String.class
- });
- diff = (Hashtable)meth.invoke(tc, new Object[] {
- testsuite, dest, compDir
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- return diff;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-// package org.apache.tools.ant.taskdefs;
-
-import org.apache.tools.ant.taskdefs.MatchingTask;
-import org.apache.tools.ant.DirectoryScanner;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import org.xml.sax.SAXException;
-
-// fop
-import org.apache.fop.layout.hyphenation.HyphenationTree;
-import org.apache.fop.layout.hyphenation.HyphenationException;
-
-/**
- * SerializeHyphPattern
- */
-
-
-public class SerializeHyphPattern extends MatchingTask {
- private File sourceDir, targetDir;
- private boolean errorDump = false;
-
- /**
- * Main method, which is called by ant.
- */
- public void execute() throws org.apache.tools.ant.BuildException {
- DirectoryScanner ds = this.getDirectoryScanner(sourceDir);
- String[] files = ds.getIncludedFiles();
- for (int i = 0; i < files.length; i++) {
- processFile(files[i].substring(0, files[i].length() - 4));
- }
- } // end execute
-
-
- /**
- * Sets the source directory
- *
- */
- public void setSourceDir(String sourceDir) {
- File dir = new File(sourceDir);
- if (!dir.exists()) {
- System.err.println("Fatal Error: source directory " + sourceDir
- + " for hyphenation files doesn't exist.");
- System.exit(1);
- }
- this.sourceDir = dir;
- }
-
- /**
- * Sets the target directory
- *
- */
- public void setTargetDir(String targetDir) {
- File dir = new File(targetDir);
- this.targetDir = dir;
- }
-
- /**
- * more error information
- *
- */
- public void setErrorDump(boolean errorDump) {
- this.errorDump = errorDump;
- }
-
-
- /*
- * checks whether input or output files exists or the latter is older than input file
- * and start build if necessary
- */
- private void processFile(String filename) {
- File infile = new File(sourceDir, filename + ".xml");
- File outfile = new File(targetDir, filename + ".hyp");
- long outfileLastModified = outfile.lastModified();
- boolean startProcess = true;
-
- startProcess = rebuild(infile, outfile);
- if (startProcess) {
- buildPatternFile(infile, outfile);
- }
- }
-
- /*
- * serializes pattern files
- */
- private void buildPatternFile(File infile, File outfile) {
- System.out.println("Processing " + infile);
- HyphenationTree hTree = new HyphenationTree();
- try {
- hTree.loadPatterns(infile.toString());
- if (errorDump) {
- System.out.println("Stats: ");
- hTree.printStats();
- }
- } catch (HyphenationException ex) {
- System.err.println("Can't load patterns from xml file " + infile
- + " - Maybe hyphenation.dtd is missing?");
- if (errorDump) {
- System.err.println(ex.toString());
- }
- }
- // serialize class
- try {
- ObjectOutputStream out =
- new ObjectOutputStream(new FileOutputStream(outfile));
- out.writeObject(hTree);
- out.close();
- } catch (IOException ioe) {
- System.err.println("Can't write compiled pattern file: "
- + outfile);
- System.err.println(ioe);
- }
- }
-
- /**
- * Checks for existence of output file and compares
- * dates with input and stylesheet file
- */
- private boolean rebuild(File infile, File outfile) {
- if (outfile.exists()) {
- // checks whether output file is older than input file
- if (outfile.lastModified() < infile.lastModified()) {
- return true;
- }
- } else {
- // if output file does not exist, start process
- return true;
- }
- return false;
- } // end rebuild
-
- /*
- * //quick access for debugging
- * public static void main (String args[]) {
- * SerializeHyphPattern ser = new SerializeHyphPattern();
- * ser.setIncludes("*.xml");
- * ser.setSourceDir("\\xml-fop\\hyph\\");
- * ser.setTargetDir("\\xml-fop\\hyph\\");
- * ser.execute();
- * }
- */
-
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-import org.apache.tools.ant.Task;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
-
-
-
-/**
- * Task to call the XSLT processor Xalan (part of xml.apache.org), which converts xml files
- * from a source to an output using a stylesheet file
- *
- * <p>
- * This task can take the following arguments:
- * <ul>
- * <li>infile
- * <li>xsltfile
- * <li>outfile
- * <li>mergefile
- * <li>smart
- * <li>dependent
- * </ul>
- * <p>
- * Of these arguments, <b>infile, outfile</b> and <b>xsltfile</b> are required.
- * <p>smart defaults to 'no'. The other allowed value is 'yes'. If smart is set to 'yes'
- * <P>
- * xalan is only called if either the outfile is older than the infile or the stylesheet
- * or the outfile doesn't exist.
- * <P>
- * <p>dependent defaults to 'none'. Other possible values: a comma delimited list of file names
- * which date is checked against the output file. This way you can name files which, if
- * they have been modified, initiate a restart of the xslt process, like external entities etc.
- * <p>
- * The mergefile parameter causes this task to merge the contents of the specified file into the infile at the end. This is used for the font character mapping generation because the keys() xslt function doesn't work on an external document.
- *
- * @author Fotis Jannidis <a href="mailto:fotis@jannidis.de">fotis@jannidis.de</a>
- * @author Kelly A. Campbell <a href="mailto:camk@camk.net">camk@camk.net</a>
- */
-
-
-public class Xslt extends Task {
- private String infile, outfile, xsltfile, mergefile;
- private String smart =
- "no"; // defaults to do conversion everytime task is called
- private String dependent = "none"; // defaults to no dependencies
- private boolean startXslt = false;
-
- /**
- * When true, we use the trax api's from xalan2, otherwise
- * just the xalan1 native interfaces
- */
- private boolean useTrax = false;
-
-
- /**
- * Sets the input file
- *
- */
- public void setInfile(String infile) {
- this.infile = infile;
- }
-
- public void setMergefile(String mergefile) {
- this.mergefile = mergefile;
- }
-
- /**
- * Sets the stylesheet file
- *
- */
- public void setXsltfile(String xsltfile) {
- this.xsltfile = xsltfile;
- }
-
- /**
- * Sets the output file
- *
- */
- public void setOutfile(String outfile) {
- this.outfile = outfile;
- }
-
- /**
- * Sets the value for smart
- *
- * @param option valid values:
- * <ul>
- * <li>yes: check whether output file is older than input or stylesheet
- * <li>no: (default) do conversion everytime task is called
- * </ul>
- */
- public void setSmart(String smart) {
- this.smart = smart;
- }
-
- /**
- * Sets the value for dependent
- *
- * @param option valid values:
- * <ul>
- * <li>none: (default)
- * <li>comma delimited list of files whose existence and date is checked
- * against the output file
- * </ul>
- */
- public void setDependent(String dependent) {
- this.dependent = dependent;
- }
-
-
- /**
- * Builds a document from the given file, merging the mergefile onto the end of the root node
- */
- private org.w3c.dom.Document buildDocument(String xmlFile)
- throws IOException, SAXException {
- try {
-
- javax.xml.parsers.DocumentBuilder docBuilder =
- javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = docBuilder.parse(new FileInputStream(xmlFile));
-
- if (mergefile != null &&!mergefile.equals("")) {
-
- File mergefileF = new File(mergefile);
-
- Document mergedoc =
- docBuilder.parse(new FileInputStream(mergefileF));
- Node mergenode = doc.importNode(mergedoc.getDocumentElement(),
- true);
- doc.getDocumentElement().appendChild(mergenode);
- }
-
- return doc;
- } catch (javax.xml.parsers.ParserConfigurationException e) {
- System.out.println("Task xslt - SAX ERROR:\n "
- + e.getMessage());
- }
- return null;
- }
-
-
- /**
- * Calls Xalan and does the transformation
- *
- */
- private void transform() {
- try {
- org.w3c.dom.Document source = buildDocument(infile);
- // Perform the transformation.
- System.out.println("============================");
- System.out.println("xslt \nin: " + infile + "\nstyle: "
- + xsltfile + "\nout: " + outfile);
- System.out.println("============================");
- org.apache.fop.tools.xslt.XSLTransform.transform(source,
- xsltfile, outfile);
-
-
- } catch (org.xml.sax.SAXException saxerror) {
- System.out.println("Task xslt - SAX ERROR:\n " + saxerror);
- } catch (MalformedURLException urlerror) {
- System.out.println("Task xslt - URL ERROR:\n " + urlerror);
- } catch (IOException ioerror) {
- System.out.println("Task xslt - IO ERROR:\n " + ioerror);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- } // end transform
-
-
- /**
- * Checks for existence of output file and compares
- * dates with input and stylesheet file
- */
- private boolean smartCheck(File outfileF, long outfileLastModified,
- File infileF, File xsltfileF) {
-
- if (outfileF.exists()) {
- // checks whether output file is older than input file or xslt stylesheet file
- if ((outfileLastModified < infileF.lastModified())
- | (outfileLastModified < xsltfileF.lastModified())) {
- return true;
- }
- } else {
- // if output file does not exist, start xslt process
- return true;
- }
- return false;
- } // end smartCheck
-
- /**
- * Checks for existence and date of dependent files
- * This could be folded together with smartCheck by using
- * a general routine but it wouldn't be as fast as now
- */
- private boolean dependenciesCheck(File outfileF,
- long outfileLastModified) {
- String dependentFileName;
- File dependentFile;
- StringTokenizer tokens = new StringTokenizer(dependent, ",");
- while (tokens.hasMoreTokens()) {
- dependentFileName = (String)tokens.nextToken();
- dependentFile = new File(dependentFileName);
- // check: does dependent file exist
- if (dependentFile.exists()) {
- // check dates
- if ((outfileLastModified < dependentFile.lastModified())) {
- return true;
- }
- } else {
- System.err.println("Task xslt - ERROR in attribute 'dependent':\n file "
- + dependentFileName + " does not exist.");
- }
- }
- return false;
- } // end dependenciesCheck
-
- /**
- * Main method, which is called by ant.
- * Checks for the value of smart and calls startTransform accordingly
- */
- public void execute() throws org.apache.tools.ant.BuildException {
-
- File outfileF = new File(outfile);
- File infileF = new File(infile);
- File xsltfileF = new File(xsltfile);
- long outfileLastModified = outfileF.lastModified();
- boolean startFileExist = true;
-
- // checks whether input and stylesheet exist.
- // this could be left to the parser, but this solution does make problems if smart is set to yes
- if (!infileF.exists()) {
- System.err.println("Task xslt - ERROR:\n Input file "
- + infile + " does not exist!");
- startFileExist = false;
- } else if (!xsltfileF.exists()) {
- System.err.println("Task xslt - ERROR:\n Stylesheet file "
- + xsltfile + " does not exist!");
- startFileExist = false;
- }
-
- // checks attribute 'smart'
- if (smart.equals("no")) {
- startXslt = true;
- // if attribute smart = 'yes'
- } else if (smart.equals("yes")) {
- startXslt = smartCheck(outfileF, outfileLastModified, infileF,
- xsltfileF);
- // checks dependent files against output file, makes only sense if smartCheck returns false
- if (!dependent.equals("none") & (startXslt == false)) {
- startXslt = dependenciesCheck(outfileF, outfileLastModified);
- }
- // returns error message, if smart has another value as 'yes' or 'no'
- } else {
- System.err.println("Task xslt - ERROR: Allowed values for the attribute smart are 'yes' or 'no'");
- }
- if (startFileExist & startXslt) {
- transform();
- }
- } // end execute
-
- // quick access for debugging
- // usage XSLT infile xsltfile outfile (smart is 'yes')
- /*
- * public static void main (String args[]) {
- * Xslt xslt = new Xslt();
- * xslt.setInfile(args[0]);
- * xslt.setXsltfile(args[1]);
- * xslt.setOutfile(args[2]);
- * xslt.setSmart("yes");
- * xslt.setDependent("test1,test2");
- * xslt.execute();
- * }
- */
-
-
-
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.xslt;
-
-import javax.xml.transform.*;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.Writer;
-
-import java.util.Hashtable;
-import org.w3c.dom.Document;
-
-/**
- * Handles xslt tranformations via Trax (xalan2)
- */
-
-public class TraxTransform {
-
- /**
- * Cache of compiled stylesheets (filename, StylesheetRoot)
- */
- private static Hashtable _stylesheetCache = new Hashtable();
-
- public static Transformer getTransformer(String xsltFilename,
- boolean cache) {
- try {
- if (cache && _stylesheetCache.containsKey(xsltFilename)) {
- Templates cachedStylesheet =
- (Templates)_stylesheetCache.get(xsltFilename);
- return cachedStylesheet.newTransformer();
- }
-
- Source xslSheet =
- new javax.xml.transform.stream.StreamSource(xsltFilename);
-
-
- /*
- * System.out.println("****************************");
- * System.out.println("trax compile \nin: " + xsltFilename);
- * System.out.println("****************************");
- */
- TransformerFactory factory = TransformerFactory.newInstance();
-
- Templates compiledSheet = factory.newTemplates(xslSheet);
- if (cache) {
- _stylesheetCache.put(xsltFilename, compiledSheet);
- }
- return compiledSheet.newTransformer();
- } catch (TransformerConfigurationException ex) {
- ex.printStackTrace();
- }
- return null;
-
- }
-
- public static void transform(String xmlSource, String xslURL,
- String outputFile) {
- transform(new javax.xml.transform.stream.StreamSource(xmlSource),
- new javax.xml.transform.stream.StreamSource(xslURL),
- new javax.xml.transform.stream.StreamResult(outputFile));
- }
-
- public static void transform(Document xmlSource, String xslURL,
- String outputFile) {
-
- transform(new javax.xml.transform.dom.DOMSource(xmlSource),
- new javax.xml.transform.stream.StreamSource(xslURL),
- new javax.xml.transform.stream.StreamResult(outputFile));
-
- }
-
- public static void transform(String xmlSource, String xslURL,
- Writer output) {
- transform(new javax.xml.transform.stream.StreamSource(xmlSource),
- new javax.xml.transform.stream.StreamSource(xslURL),
- new javax.xml.transform.stream.StreamResult(output));
- }
-
- public static void transform(Document xmlSource, InputStream xsl,
- Document outputDoc) {
- transform(new javax.xml.transform.dom.DOMSource(xmlSource),
- new javax.xml.transform.stream.StreamSource(xsl),
- new javax.xml.transform.dom.DOMResult(outputDoc));
- }
-
- public static void transform(Source xmlSource, Source xslSource,
- Result result) {
- try {
- Transformer transformer;
- if (xslSource.getSystemId() == null) {
- TransformerFactory factory = TransformerFactory.newInstance();
- transformer = factory.newTransformer(xslSource);
- } else {
- transformer = getTransformer(xslSource.getSystemId(), true);
- }
- transformer.transform(xmlSource, result);
- } catch (TransformerConfigurationException ex) {
- ex.printStackTrace();
- } catch (TransformerException ex) {
- ex.printStackTrace();
- }
-
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.xslt;
-
-import java.io.*;
-import java.lang.reflect.*;
-
-
-public class XSLTransform {
-
- public static void transform(String xmlSource, String xslURL,
- String outputFile) throws Exception {
- Class[] argTypes = {
- String.class, String.class, String.class
- };
- Object[] params = {
- xmlSource, xslURL, outputFile
- };
- transform(params, argTypes);
- }
-
- public static void transform(org.w3c.dom.Document xmlSource,
- String xslURL,
- String outputFile) throws Exception {
- Class[] argTypes = {
- org.w3c.dom.Document.class, String.class, String.class
- };
-
- Object[] params = {
- xmlSource, xslURL, outputFile
- };
- transform(params, argTypes);
-
- }
-
- public static void transform(String xmlSource, String xslURL,
- Writer outputWriter) throws Exception {
- Class[] argTypes = {
- String.class, String.class, Writer.class
- };
- Object[] params = {
- xmlSource, xslURL, outputWriter
- };
- transform(params, argTypes);
-
- }
-
- public static void transform(org.w3c.dom.Document xmlSource,
- InputStream xsl,
- org.w3c.dom.Document outputDoc) throws Exception {
- Class[] argTypes = {
- org.w3c.dom.Document.class, InputStream.class,
- org.w3c.dom.Document.class
- };
- Object[] params = {
- xmlSource, xsl, outputDoc
- };
- transform(params, argTypes);
-
- }
-
-
- private static void transform(Object[] args,
- Class[] argTypes) throws Exception {
- Class transformer = getTransformClass();
- if (transformer != null) {
- Method transformMethod = getTransformMethod(transformer,
- argTypes);
- if (transformMethod != null) {
- try {
- transformMethod.invoke(null, args);
- } catch (InvocationTargetException ex) {
- ex.printStackTrace();
- }
- } else {
- throw new Exception("transform method not found");
- }
- } else {
- throw new Exception("no transformer class found");
- }
-
- }
-
-
- private static Class getTransformClass() {
- try {
- // try trax first
- Class transformer =
- Class.forName("javax.xml.transform.Transformer");
- // ok, make sure we have a liaison to trax
- transformer =
- Class.forName("org.apache.fop.tools.xslt.TraxTransform");
- return transformer;
-
- } catch (ClassNotFoundException ex) {}
- // otherwise, try regular xalan1
- try {
- Class transformer =
- Class.forName("org.apache.xalan.xslt.XSLTProcessor");
- // get the liaison
- transformer =
- Class.forName("org.apache.fop.tools.xslt.Xalan1Transform");
- return transformer;
- } catch (ClassNotFoundException ex) {}
- return null;
-
- }
-
-
- private static Method getTransformMethod(Class c, Class[] argTypes) {
- // System.out.println("transformer class = "+c);
-
- try {
- // Class[] argTypes = new Class[args.length];
- for (int i = 0; i < argTypes.length; i++) {
- // argTypes[i] = args[i].getClass();
- // System.out.println("arg["+i+"] type = "+argTypes[i]);
-
- }
-
- Method transformer = c.getMethod("transform", argTypes);
- return transformer;
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
-
- }
- return null;
- }
-
-}
+++ /dev/null
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.xslt;
-
-import org.apache.xalan.xslt.*;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Hashtable;
-import org.w3c.dom.Document;
-
-/**
- * Handles xslt tranformations via Xalan1 (non-trax)
- */
-
-public class Xalan1Transform {
-
- /**
- * Cache of compiled stylesheets (filename, StylesheetRoot)
- */
- private static Hashtable _stylesheetCache = new Hashtable();
-
- public static StylesheetRoot getStylesheet(String xsltFilename, boolean cache)
- throws org.xml.sax.SAXException {
- if (cache && _stylesheetCache.containsKey(xsltFilename)) {
- return (StylesheetRoot)_stylesheetCache.get(xsltFilename);
- }
-
- // Use XSLTProcessor to instantiate an XSLTProcessor.
- XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
-
- XSLTInputSource xslSheet = new XSLTInputSource(xsltFilename);
-
- // Perform the transformation.
- StylesheetRoot compiledSheet = processor.processStylesheet(xslSheet);
- if (cache) {
- _stylesheetCache.put(xsltFilename, compiledSheet);
- }
- return compiledSheet;
- }
-
- public static void transform(String xmlSource, String xslURL,
- String outputFile) throws java.io.IOException,
- java.net.MalformedURLException,
- org.xml.sax.SAXException {
- try {
- javax.xml.parsers.DocumentBuilder docBuilder =
- javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = docBuilder.parse(new FileInputStream(xmlSource));
- transform(doc, xslURL, outputFile);
- } catch (javax.xml.parsers.ParserConfigurationException ex) {
- throw new org.xml.sax.SAXException(ex);
- }
-
- }
-
- public static void transform(Document xmlSource, String xslURL,
- String outputFile) throws java.io.IOException,
- java.net.MalformedURLException,
- org.xml.sax.SAXException {
-
- XSLTResultTarget xmlResult = new XSLTResultTarget(outputFile);
-
- StylesheetRoot stylesheet = getStylesheet(xslURL, true);
-
- // Perform the transformation.
- stylesheet.process(XSLTProcessorFactory.getProcessor(), xmlSource,
- xmlResult);
- }
-
- public static void transform(String xmlSource, String xslURL,
- java.io.Writer outputFile) throws java.io.IOException,
- java.net.MalformedURLException,
- org.xml.sax.SAXException {
-
- XSLTInputSource source = new XSLTInputSource(xmlSource);
- XSLTResultTarget xmlResult = new XSLTResultTarget(outputFile);
-
- StylesheetRoot stylesheet = getStylesheet(xslURL, true);
-
- // Perform the transformation.
- stylesheet.process(XSLTProcessorFactory.getProcessor(), source,
- xmlResult);
- }
-
- public static void transform(Document xmlSource, InputStream xsl,
- Document outputDoc) throws java.io.IOException,
- java.net.MalformedURLException,
- org.xml.sax.SAXException {
-
- XSLTInputSource source = new XSLTInputSource(xmlSource);
- XSLTInputSource xslSheet = new XSLTInputSource(xsl);
- XSLTResultTarget xmlResult = new XSLTResultTarget(outputDoc);
-
-
- // Perform the transformation.
- XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
-
- processor.process(source, xslSheet, xmlResult);
- }
-
-}