* A base class which holds information about the current rendering state.
*/
public abstract class AbstractState {
+
+ /** current state data */
private AbstractData currentData = null;
+
+ /** the state stack */
private Stack/*<AbstractData>*/ stateStack = null;
/**
* Instantiates a new state data object
+ *
* @return a new state data object
*/
protected abstract AbstractData instantiateData();
/**
+ * Returns the currently valid state
+ *
* @return the currently valid state
*/
public AbstractData getData() {
/**
* Get the color.
+ *
* @return the color
*/
public Color getColor() {
/**
* Get the background color.
+ *
* @return the background color
*/
public Color getBackColor() {
/**
* Set the current font name
+ *
* @param internalFontName the internal font name
* @return true if the font name has changed
*/
/**
* Gets the current font name
+ *
* @return the current font name
*/
public String getFontName() {
/**
* Gets the current font size
+ *
* @return the current font size
*/
public int getFontSize() {
/**
* Set the current line width.
+ *
* @param width the line width in points
* @return true if the line width has changed
*/
}
/**
- * Gets the current line width
+ * Returns the current line width
+ *
* @return the current line width
*/
public float getLineWidth() {
/**
* Sets the dash array (line type) for the current basic stroke
+ *
* @param dash the line dash array
* @return true if the dash array has changed
*/
/**
* Concatenates the given AffineTransform to the current one.
+ *
* @param tf the transform to concatenate to the current level transform
*/
public void concatenate(AffineTransform tf) {
* Pop the state from the stack and set current values to popped state.
* This should be called when a Q operator is used so
* the state is restored to the correct values.
+ *
* @return the restored state, null if the stack is empty
*/
public AbstractData pop() {
}
/**
+ * Return the state stack
+ *
* @return the state stack
*/
protected Stack/*<AbstractData>*/ getStateStack() {
* A base state data holding object
*/
public abstract class AbstractData implements Cloneable, Serializable {
+
/** The current color */
private Color color = null;
* a new viewport. Note that all concatenation operations are logged
* so they can be replayed if necessary (ex. for block-containers with
* "fixed" positioning.
+ *
* @param at Transformation to perform
*/
public void concatenate(AffineTransform at) {
/**
* Get the current AffineTransform.
+ *
* @return the current transform
*/
public AffineTransform getTransform() {
float[] dstPts = new float[srcPts.length];
int[] coords = mpts2units(srcPts, dstPts);
int x2 = coords[X] + Math.round(mpt2units(width * 1000));
- int thickness = Math.round(mpt2units(height * 1000));
- getAFPDataStream().createLine(
- coords[X],
- coords[Y],
- x2,
- coords[Y],
- thickness,
- currentState.getColor());
+ LineDataInfo lineDataInfo = new LineDataInfo();
+ lineDataInfo.x1 = coords[X];
+ lineDataInfo.y1 = coords[Y];
+ lineDataInfo.x2 = x2;
+ lineDataInfo.y2 = coords[Y];
+ lineDataInfo.thickness = Math.round(mpt2units(height * 1000));
+ lineDataInfo.color = currentState.getColor();
+ getAFPDataStream().createLine(lineDataInfo);
}
/** {@inheritDoc} */
return;
}
+ LineDataInfo lineDataInfo = new LineDataInfo();
+ lineDataInfo.color = col;
+
switch (style) {
+
case Constants.EN_DOUBLE:
+
+ lineDataInfo.x1 = coords[X1];
+ lineDataInfo.y1 = coords[Y1];
+
if (horz) {
float h3 = height / 3;
- float ym2 = dstPts[Y1] + h3 + h3;
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- coords[X2],
- coords[Y1],
- Math.round(h3),
- col);
- afpDataStream.createLine(
- coords[X1],
- Math.round(ym2),
- coords[X2],
- Math.round(ym2),
- Math.round(h3),
- col);
+ lineDataInfo.thickness = Math.round(h3);
+
+ lineDataInfo.x2 = coords[X2];
+ lineDataInfo.y2 = coords[Y1];
+ afpDataStream.createLine(lineDataInfo);
+
+ int ym2 = Math.round(dstPts[Y1] + h3 + h3);
+ lineDataInfo.y1 = ym2;
+ lineDataInfo.y2 = ym2;
+ afpDataStream.createLine(lineDataInfo);
} else {
float w3 = width / 3;
- float xm2 = dstPts[X1] + w3 + w3;
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- coords[X1],
- coords[Y2],
- Math.round(w3),
- col);
- afpDataStream.createLine(
- Math.round(xm2),
- coords[Y1],
- Math.round(xm2),
- coords[Y2],
- Math.round(w3),
- col);
+ lineDataInfo.thickness = Math.round(w3);
+
+ lineDataInfo.x2 = coords[X1];
+ lineDataInfo.y2 = coords[Y2];
+ afpDataStream.createLine(lineDataInfo);
+
+ int xm2 = Math.round(dstPts[X1] + w3 + w3);
+ lineDataInfo.x1 = xm2;
+ lineDataInfo.x2 = xm2;
+ afpDataStream.createLine(lineDataInfo);
}
break;
+
case Constants.EN_DASHED:
+ lineDataInfo.x1 = coords[X1];
+
if (horz) {
float w2 = 2 * height;
- while (coords[X1] + w2 < coords[X2]) {
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- coords[X1] + Math.round(w2),
- coords[Y1],
- Math.round(height),
- col);
- coords[X1] += 2 * w2;
+
+ lineDataInfo.y1 = coords[Y1];
+ lineDataInfo.x2 = coords[X1] + Math.round(w2);
+ lineDataInfo.y2 = coords[Y1];
+ lineDataInfo.thickness = Math.round(height);
+
+ while (lineDataInfo.x1 + w2 < coords[X2]) {
+ afpDataStream.createLine(lineDataInfo);
+ lineDataInfo.x1 += 2 * w2;
}
} else {
float h2 = 2 * width;
- while (coords[Y1] + h2 < coords[Y2]) {
- afpDataStream.createLine(
- coords[X1],
- coords[Y2],
- coords[X1],
- coords[Y1] + Math.round(h2),
- Math.round(width),
- col);
- coords[Y1] += 2 * h2;
+
+ lineDataInfo.y1 = coords[Y2];
+ lineDataInfo.x2 = coords[X1];
+ lineDataInfo.y2 = coords[Y1] + Math.round(h2);
+ lineDataInfo.thickness = Math.round(width);
+
+ while (lineDataInfo.y2 < coords[Y2]) {
+ afpDataStream.createLine(lineDataInfo);
+ lineDataInfo.y2 += 2 * h2;
}
}
break;
+
case Constants.EN_DOTTED:
+
+ lineDataInfo.x1 = coords[X1];
+ lineDataInfo.y1 = coords[Y1];
+
if (horz) {
- while (coords[X1] + height < coords[X2]) {
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- coords[X1] + Math.round(height),
- coords[Y1],
- Math.round(height),
- col
- );
+ lineDataInfo.thickness = Math.round(height);
+ lineDataInfo.x2 = coords[X1] + lineDataInfo.thickness;
+ lineDataInfo.y2 = coords[Y1];
+ while (lineDataInfo.x2 < coords[X2]) {
+ afpDataStream.createLine(lineDataInfo);
coords[X1] += 2 * height;
+ lineDataInfo.x1 = coords[X1];
+ lineDataInfo.x2 = coords[X1] + lineDataInfo.thickness;
}
} else {
- while (coords[Y1] + width < coords[Y2]) {
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- coords[X1],
- coords[Y1] + Math.round(width),
- Math.round(width),
- col);
+ lineDataInfo.thickness = Math.round(width);
+ lineDataInfo.x2 = coords[X1];
+ lineDataInfo.y2 = coords[Y1] + lineDataInfo.thickness;
+
+ while (lineDataInfo.y2 < coords[Y2]) {
+ afpDataStream.createLine(lineDataInfo);
coords[Y1] += 2 * width;
+ lineDataInfo.y1 = coords[Y1];
+ lineDataInfo.y2 = coords[Y1] + lineDataInfo.thickness;
}
}
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE: {
+
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
if (horz) {
- Color uppercol = lightenColor(col, -colFactor);
- Color lowercol = lightenColor(col, colFactor);
+
+ lineDataInfo.x1 = coords[X1];
+ lineDataInfo.x2 = coords[X2];
+
float h3 = height / 3;
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- coords[X2],
- coords[Y1],
- Math.round(h3),
- uppercol);
- afpDataStream.createLine(
- coords[X1],
- Math.round(dstPts[Y1] + h3),
- coords[X2],
- Math.round(dstPts[Y1] + h3),
- Math.round(h3),
- col);
- afpDataStream.createLine(
- coords[X1],
- Math.round(dstPts[Y1] + h3 + h3),
- coords[X2],
- Math.round(dstPts[Y1] + h3 + h3),
- Math.round(h3),
- lowercol);
+
+ lineDataInfo.color = lightenColor(col, -colFactor);
+ lineDataInfo.thickness = Math.round(h3);
+ lineDataInfo.y1 = lineDataInfo.y2 = coords[Y1];
+ afpDataStream.createLine(lineDataInfo);
+
+ lineDataInfo.color = col;
+ lineDataInfo.y1 = lineDataInfo.y2 = Math.round(dstPts[Y1] + h3);
+ afpDataStream.createLine(lineDataInfo);
+
+ lineDataInfo.color = lightenColor(col, colFactor);
+ lineDataInfo.y1 = lineDataInfo.y2 = Math.round(dstPts[Y1] + h3 + h3);
+ afpDataStream.createLine(lineDataInfo);
+
} else {
- Color leftcol = lightenColor(col, -colFactor);
- Color rightcol = lightenColor(col, colFactor);
+
+ lineDataInfo.y1 = coords[Y1];
+ lineDataInfo.y2 = coords[Y2];
+
float w3 = width / 3;
float xm1 = dstPts[X1] + (w3 / 2);
- afpDataStream.createLine(
- Math.round(xm1),
- coords[Y1],
- Math.round(xm1),
- coords[Y2],
- Math.round(w3),
- leftcol);
- afpDataStream.createLine(
- Math.round(xm1 + w3),
- coords[Y1],
- Math.round(xm1 + w3),
- coords[Y2],
- Math.round(w3),
- col);
- afpDataStream.createLine(
- Math.round(xm1 + w3 + w3),
- coords[Y1],
- Math.round(xm1 + w3 + w3),
- coords[Y2],
- Math.round(w3),
- rightcol);
+
+ lineDataInfo.color = lightenColor(col, -colFactor);
+ lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1);
+ afpDataStream.createLine(lineDataInfo);
+
+ lineDataInfo.color = col;
+ lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1 + w3);
+ afpDataStream.createLine(lineDataInfo);
+
+ lineDataInfo.color = lightenColor(col, colFactor);
+ lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1 + w3 + w3);
+ afpDataStream.createLine(lineDataInfo);
}
break;
}
+
case Constants.EN_HIDDEN:
break;
+
case Constants.EN_INSET:
case Constants.EN_OUTSET:
default:
- afpDataStream.createLine(
- coords[X1],
- coords[Y1],
- (horz ? coords[X2] : coords[X1]),
- (horz ? coords[Y1] : coords[Y2]),
- Math.abs(Math.round(horz ? height : width)),
- col);
+ lineDataInfo.x1 = coords[X1];
+ lineDataInfo.y1 = coords[Y1];
+ if (horz) {
+ lineDataInfo.thickness = Math.round(height);
+ lineDataInfo.x2 = coords[X2];
+ lineDataInfo.y2 = coords[Y1];
+ } else {
+ lineDataInfo.thickness = Math.round(width);
+ lineDataInfo.x2 = coords[X1];
+ lineDataInfo.y2 = coords[Y2];
+ }
+ lineDataInfo.x2 = (horz ? coords[X2] : coords[X1]);
+ lineDataInfo.y2 = (horz ? coords[Y1] : coords[Y2]);
+ afpDataStream.createLine(lineDataInfo);
}
}
/** {@inheritDoc} */
public void renderText(TextArea text) {
- log.debug(text.getText());
+// log.debug(text.getText());
renderInlineAreaBackAndBorders(text);
String name = getInternalFontNameForArea(text);
int interCharacterAdjustment = Math.round(mpt2units(text.getTextLetterSpaceAdjust()));
- AFPTextDataInfo textDataInfo = new AFPTextDataInfo();
+ TextDataInfo textDataInfo = new TextDataInfo();
textDataInfo.setFontReference(fontReference);
textDataInfo.setX(coords[X]);
textDataInfo.setY(coords[Y]);
textDataInfo.setVariableSpaceCharacterIncrement(variableSpaceCharacterIncrement);
textDataInfo.setInterCharacterAdjustment(interCharacterAdjustment);
textDataInfo.setData(data);
+ textDataInfo.setOrientation(currentState.getOrientation());
getAFPDataStream().createText(textDataInfo);
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
/** The current page */
private AFPPageState pageState = new AFPPageState();
- /** Whether or not GOCA is used for handling SVG */
- private boolean goca = false; // false by default
-
/**
* Sets the rotation to be used for portrait pages, valid values are 0
* (default), 90, 180, 270.
return this.pageState;
}
- /**
- * Sets if GOCA is to be used for SVG handling
- *
- * @param value is true if GOCA is used for SVG handling
- */
- public void setUseGOCA(boolean value) {
- this.goca = value;
- }
-
- /**
- * Returns true if GOCA is enabled for SVG handling
- *
- * @return true if GOCA is enabled for SVG handling
- */
- public boolean useGOCA() {
- return this.goca;
- }
-
/**
* Sets if the current painted shape is to be filled
*
+ "}";
}
}
+
+ /**
+ * Returns the current text orientation
+ * TODO the current text orientation
+ * @return the current text orientation
+ */
+ public int getOrientation() {
+ return 0;
+ }
+
}
\ No newline at end of file
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.afp;
-
-import java.awt.Color;
-
-/**
- * Contains text data information
- */
-public class AFPTextDataInfo {
- private int fontReference;
- private int x;
- private int y;
- private Color color;
- private int variableSpaceCharacterIncrement;
- private int interCharacterAdjustment;
- private byte[] data;
- private int orientation;
-
- /**
- * @return the font reference
- */
- public int getFontReference() {
- return fontReference;
- }
-
- /**
- * Sets the font reference
- * @param fontReference the font reference
- */
- protected void setFontReference(int fontReference) {
- this.fontReference = fontReference;
- }
-
- /**
- * @return the x coordinate
- */
- public int getX() {
- return x;
- }
-
- /**
- * Sets the X coordinate
- * @param x the X coordinate
- */
- protected void setX(int x) {
- this.x = x;
- }
-
- /**
- * @return the y coordinate
- */
- public int getY() {
- return y;
- }
-
- /**
- * Sets the Y coordinate
- * @param y the Y coordinate
- */
- protected void setY(int y) {
- this.y = y;
- }
-
- /**
- * @return the color
- */
- public Color getColor() {
- return color;
- }
-
- /**
- * Sets the color
- * @param color the color
- */
- protected void setColor(Color color) {
- this.color = color;
- }
-
- /**
- * @return the variable space character increment
- */
- public int getVariableSpaceCharacterIncrement() {
- return variableSpaceCharacterIncrement;
- }
-
- /**
- * Sets the variable space character increment
- * @param variableSpaceCharacterIncrement the variable space character increment
- */
- protected void setVariableSpaceCharacterIncrement(
- int variableSpaceCharacterIncrement) {
- this.variableSpaceCharacterIncrement = variableSpaceCharacterIncrement;
- }
-
- /**
- * @return the inter character adjustment
- */
- public int getInterCharacterAdjustment() {
- return interCharacterAdjustment;
- }
-
- /**
- * Sets the inter character adjustment
- * @param interCharacterAdjustment the inter character adjustment
- */
- protected void setInterCharacterAdjustment(int interCharacterAdjustment) {
- this.interCharacterAdjustment = interCharacterAdjustment;
- }
-
- /**
- * @return the text data
- */
- public byte[] getData() {
- return data;
- }
-
- /**
- * Sets the text data
- * @param data the text orientation
- */
- protected void setData(byte[] data) {
- this.data = data;
- }
-
- /**
- * Sets the text orientation
- * @param orientation the text orientation
- */
- public void setOrientation(int orientation) {
- this.orientation = orientation;
- }
-
- /**
- * @return the text orientation
- */
- public int getOrientation() {
- return this.orientation;
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return "AFPTextDataInfo{fontReference=" + fontReference
- + ", x=" + x
- + ", y=" + y
- + ", color=" + color
- + ", vsci=" + variableSpaceCharacterIncrement
- + ", ica=" + interCharacterAdjustment
- + ", orientation=" + orientation
- + ", data=" + data
- + "}";
- }
-}
\ No newline at end of file
protected Log log = LogFactory.getLog(AFPTextPainter.class);
private AFPTextHandler nativeTextHandler;
- //private FontInfo fontInfo;
/**
* Use the stroking text painter to get the bounds and shape.
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp;
+
+import java.awt.Color;
+
+/**
+ * Text data information
+ */
+public class TextDataInfo {
+
+ private int fontReference;
+
+ private int x;
+
+ private int y;
+
+ private Color color;
+
+ private int variableSpaceCharacterIncrement;
+
+ private int interCharacterAdjustment;
+
+ private byte[] data;
+
+ private int orientation;
+
+ /**
+ * Returns the font reference
+ *
+ * @return the font reference
+ */
+ public int getFontReference() {
+ return fontReference;
+ }
+
+ /**
+ * Sets the font reference
+ *
+ * @param fontReference the font reference
+ */
+ protected void setFontReference(int fontReference) {
+ this.fontReference = fontReference;
+ }
+
+ /**
+ * Returns the x coordinate
+ *
+ * @return the x coordinate
+ */
+ public int getX() {
+ return x;
+ }
+
+ /**
+ * Sets the X coordinate
+ *
+ * @param x the X coordinate
+ */
+ protected void setX(int x) {
+ this.x = x;
+ }
+
+ /**
+ * Returns the y coordinate
+ *
+ * @return the y coordinate
+ */
+ public int getY() {
+ return y;
+ }
+
+ /**
+ * Sets the Y coordinate
+ *
+ * @param y the Y coordinate
+ */
+ protected void setY(int y) {
+ this.y = y;
+ }
+
+ /**
+ * Returns the color
+ *
+ * @return the color
+ */
+ public Color getColor() {
+ return color;
+ }
+
+ /**
+ * Sets the color
+ *
+ * @param color the color
+ */
+ protected void setColor(Color color) {
+ this.color = color;
+ }
+
+ /**
+ * Return the variable space character increment
+ *
+ * @return the variable space character increment
+ */
+ public int getVariableSpaceCharacterIncrement() {
+ return variableSpaceCharacterIncrement;
+ }
+
+ /**
+ * Sets the variable space character increment
+ *
+ * @param variableSpaceCharacterIncrement the variable space character increment
+ */
+ protected void setVariableSpaceCharacterIncrement(
+ int variableSpaceCharacterIncrement) {
+ this.variableSpaceCharacterIncrement = variableSpaceCharacterIncrement;
+ }
+
+ /**
+ * Return the inter character adjustment
+ *
+ * @return the inter character adjustment
+ */
+ public int getInterCharacterAdjustment() {
+ return interCharacterAdjustment;
+ }
+
+ /**
+ * Sets the inter character adjustment
+ *
+ * @param interCharacterAdjustment the inter character adjustment
+ */
+ protected void setInterCharacterAdjustment(int interCharacterAdjustment) {
+ this.interCharacterAdjustment = interCharacterAdjustment;
+ }
+
+ /**
+ * Return the text data
+ *
+ * @return the text data
+ */
+ public byte[] getData() {
+ return data;
+ }
+
+ /**
+ * Sets the text data
+ *
+ * @param data the text orientation
+ */
+ protected void setData(byte[] data) {
+ this.data = data;
+ }
+
+ /**
+ * Sets the text orientation
+ *
+ * @param orientation the text orientation
+ */
+ public void setOrientation(int orientation) {
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the text orientation
+ *
+ * @return the text orientation
+ */
+ public int getOrientation() {
+ return this.orientation;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "TextDataInfo{fontReference=" + fontReference
+ + ", x=" + x
+ + ", y=" + y
+ + ", color=" + color
+ + ", vsci=" + variableSpaceCharacterIncrement
+ + ", ica=" + interCharacterAdjustment
+ + ", orientation=" + orientation
+ + ", data=" + data
+ + "}";
+ }
+}
\ No newline at end of file
* in 99.9% of cases the font metrics will be the same as the 0 degrees
* therefore the implementation currently will always use 0 degrees.
*
- *
* @return characterSetOrentation The current orientation metrics.
*/
private CharacterSetOrientation getCharacterSetOrientation() {
import org.apache.commons.logging.LogFactory;
import org.apache.fop.render.afp.AFPFontAttributes;
-import org.apache.fop.render.afp.AFPTextDataInfo;
+import org.apache.fop.render.afp.LineDataInfo;
+import org.apache.fop.render.afp.TextDataInfo;
import org.apache.fop.render.afp.DataObjectInfo;
import org.apache.fop.render.afp.ExternalResourceGroupManager;
import org.apache.fop.render.afp.ObjectAreaInfo;
* @param textDataInfo
* the afp text data
*/
- public void createText(AFPTextDataInfo textDataInfo) {
+ public void createText(TextDataInfo textDataInfo) {
textDataInfo.setOrientation(orientation);
getCurrentPage().createText(textDataInfo);
}
/**
* Method to create a line on the current page.
*
- * @param x1
- * the first x coordinate of the line
- * @param y1
- * the first y coordinate of the line
- * @param x2
- * the second x coordinate of the line
- * @param y2
- * the second y coordinate of the line
- * @param thickness
- * the thickness of the line
- * @param col
- * The text color.
+ * @param lineDataInfo the line data information.
*/
- public void createLine(int x1, int y1, int x2, int y2, int thickness,
- Color col) {
- getCurrentPage().createLine(x1, y1, x2, y2, thickness, orientation, col);
+ public void createLine(LineDataInfo lineDataInfo) {
+ lineDataInfo.setOrientation(orientation);
+ getCurrentPage().createLine(lineDataInfo);
}
/**
import java.util.Iterator;
import java.util.List;
-import org.apache.fop.render.afp.AFPTextDataInfo;
+import org.apache.fop.render.afp.LineDataInfo;
+import org.apache.fop.render.afp.TextDataInfo;
import org.apache.fop.render.afp.DataObjectCache;
import org.apache.fop.render.afp.ResourceInfo;
import org.apache.fop.render.afp.fonts.AFPFont;
/**
* Helper method to create a line on the current page, this method delegates
* to the presentation text object in order to construct the line.
- *
- * @param x1
- * the first x coordinate of the line
- * @param y1
- * the first y coordinate of the line
- * @param x2
- * the second x coordinate of the line
- * @param y2
- * the second y coordinate of the line
- * @param thickness
- * the thickness of the line
- * @param lineRotation
- * the rotation of the line
- * @param col
- * The text color.
+ *
+ * @param lineDataInfo the line data information.
*/
- public void createLine(int x1, int y1, int x2, int y2, int thickness,
- int lineRotation, Color col) {
- getPresentationTextObject().createLineData(x1, y1, x2, y2, thickness, lineRotation, col);
+ public void createLine(LineDataInfo lineDataInfo) {
+ getPresentationTextObject().createLineData(lineDataInfo);
}
/**
* @param textDataInfo
* the afp text data
*/
- public void createText(AFPTextDataInfo textDataInfo) {
+ public void createText(TextDataInfo textDataInfo) {
getPresentationTextObject().createTextData(textDataInfo);
}
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.fop.render.afp.AFPTextDataInfo;
+import org.apache.fop.render.afp.LineDataInfo;
+import org.apache.fop.render.afp.TextDataInfo;
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
* @throws MaximumSizeExceededException
* thrown if the maximum number of text data is exceeded
*/
- public void createTextData(AFPTextDataInfo textDataInfo)
+ public void createTextData(TextDataInfo textDataInfo)
throws MaximumSizeExceededException {
ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
* Drawing of lines using the starting and ending coordinates, thickness and
* colour arguments.
*
- * @param x1
- * The starting X coordinate.
- * @param y1
- * The starting Y coordinate.
- * @param x2
- * The ending X coordinate.
- * @param y2
- * The ending Y coordinate.
- * @param thickness
- * The line thickness.
- * @param orientation
- * The orientation of the text data.
- * @param col
- * The text color.
+ * @param lineDataInfo the line data information.
* @throws MaximumSizeExceededException
* thrown if the maximum number of line data has been exceeded
*/
- public void createLineData(int x1, int y1, int x2, int y2, int thickness,
- int orientation, Color col) throws MaximumSizeExceededException {
+ public void createLineData(LineDataInfo lineDataInfo) throws MaximumSizeExceededException {
ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
+ int thickness = lineDataInfo.getThickness();
+ int orientation = lineDataInfo.getOrientation();
+ int x1 = lineDataInfo.getX1();
+ int y1 = lineDataInfo.getY1();
+ int x2 = lineDataInfo.getX2();
+ int y2 = lineDataInfo.getY2();
+ Color col = lineDataInfo.getColor();
+
if (currentOrientation != orientation) {
setTextOrientation(orientation, afpdata);
currentOrientation = orientation;
return;
}
- int s = afpdata.size();
+ int dataSize = afpdata.size();
- if (baos.size() + s > MAX_SIZE) {
+ if (baos.size() + dataSize > MAX_SIZE) {
currentXCoordinate = -1;
currentYCoordinate = -1;
throw new MaximumSizeExceededException();
}, 0, 5);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void write(OutputStream os) throws IOException {
byte[] data = baos.toByteArray();
byte[] size = BinaryUtils.convert(data.length - 1, 2);
import java.io.OutputStream;
import java.util.List;
-import org.apache.fop.render.afp.AFPTextDataInfo;
+import org.apache.fop.render.afp.LineDataInfo;
+import org.apache.fop.render.afp.TextDataInfo;
/**
* The Presentation Text object is the data object used in document processing
* @param textDataInfo
* The afp text data
*/
- public void createTextData(AFPTextDataInfo textDataInfo) {
+ public void createTextData(TextDataInfo textDataInfo) {
if (currentPresentationTextData == null) {
startPresentationTextData();
}
}
}
- /**
- * Drawing of lines using the starting and ending coordinates, thickness.
- *
- * @param x1
- * The first x coordinate of the line.
- * @param y1
- * The first y coordinate of the line.
- * @param x2
- * The second x coordinate of the line.
- * @param y2
- * The second y coordinate of the line.
- * @param thickness
- * The thickness of the line.
- * @param col
- * The text color.
- */
- public void createLineData(int x1, int y1, int x2, int y2, int thickness, Color col) {
- // Default orientation
- createLineData(x1, y1, x2, y2, thickness, 0, col);
- }
-
/**
* Drawing of lines using the starting and ending coordinates, thickness and
* orientation arguments.
*
- * @param x1
- * The first x coordinate of the line.
- * @param y1
- * The first y coordinate of the line.
- * @param x2
- * The second x coordinate of the line.
- * @param y2
- * The second y coordinate of the line.
- * @param thickness
- * The thickness of the line.
- * @param orientation
- * The orientation of the line.
- * @param col
- * The text color.
+ * @param lineDataInfo the line data information.
*/
- public void createLineData(int x1, int y1, int x2, int y2, int thickness,
- int orientation, Color col) {
+ public void createLineData(LineDataInfo lineDataInfo) {
if (currentPresentationTextData == null) {
startPresentationTextData();
}
try {
- currentPresentationTextData.createLineData(x1, y1, x2, y2,
- thickness, orientation, col);
+ currentPresentationTextData.createLineData(lineDataInfo);
} catch (MaximumSizeExceededException msee) {
endPresentationTextData();
- createLineData(x1, y1, x2, y2, thickness, orientation, col);
+ createLineData(lineDataInfo);
}
}