aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManuel Mall <manuel@apache.org>2006-05-03 12:38:14 +0000
committerManuel Mall <manuel@apache.org>2006-05-03 12:38:14 +0000
commit48d632c3c572444f32df26859e7d876eaed1dc2f (patch)
tree5e6eeaaeb65e4a8148d1888fc3e988bd44ab9c8f /src
parenta806e6360ab5f703dfd15e8565e3b456f800cd8b (diff)
downloadxmlgraphics-fop-48d632c3c572444f32df26859e7d876eaed1dc2f.tar.gz
xmlgraphics-fop-48d632c3c572444f32df26859e7d876eaed1dc2f.zip
Removed deprecated renderCharacter method from AFP Renderer and replaced AFPColor class with java.awt.Color in line with the rest of FOP
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@399286 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/sandbox/org/apache/fop/render/afp/AFPFontColor.java156
-rw-r--r--src/sandbox/org/apache/fop/render/afp/AFPRenderer.java124
-rw-r--r--src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java6
-rw-r--r--src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java7
-rw-r--r--src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java14
-rw-r--r--src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java11
6 files changed, 40 insertions, 278 deletions
diff --git a/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java b/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java
deleted file mode 100644
index d7cfad229..000000000
--- a/src/sandbox/org/apache/fop/render/afp/AFPFontColor.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.afp;
-
-import java.awt.Color;
-
-/**
- * AFP only supports very basic colours and this object provides a simple
- * bean for the colour attributes.
- * @todo Is this class really necessary? Should be replaced with java.awt.Color, if possible.
- */
-public class AFPFontColor {
-
- /**
- * Red value.
- */
- private int _red = 0;
-
- /**
- * Green value.
- */
- private int _green = 0;
-
- /**
- * Blue value.
- */
- private int _blue = 0;
-
- /**
- * Constructor for the AFPColor Object
- * @param red The red color intensity (0-255)
- * @param green The green color intensity (0-255)
- * @param blue The blue color intensity (0-255)
- */
- public AFPFontColor(int red, int green, int blue) {
-
- _red = red;
- _green = green;
- _blue = blue;
-
- }
-
- /**
- * Constructor for the AFPColor Object
- * @param col The java.awt.Color object
- */
- public AFPFontColor(Color col) {
-
- _red = col.getRed();
- _green = col.getGreen();
- _blue = col.getBlue();
-
- }
-
- /**
- * Returns the blue attribute
- * @return int
- */
- public int getBlue() {
- return _blue;
- }
-
- /**
- * Returns the green attribute
- * @return int
- */
- public int getGreen() {
- return _green;
- }
-
- /**
- * Returns the red attribute
- * @return int
- */
- public int getRed() {
- return _red;
- }
-
- /**
- * Sets the blue attribute
- * @param blue The blue value to set
- */
- public void setBlue(int blue) {
- _blue = blue;
- }
-
- /**
- * Sets the green attribute
- * @param green The green value to set
- */
- public void setGreen(int green) {
- _green = green;
- }
-
- /**
- * Sets the red attribute
- * @param red The red value to set
- */
- public void setRed(int red) {
- _red = red;
- }
-
- /**
- * Sets this color object to the same values
- * as the given object.
- * @param col the source color
- */
- public void setTo(AFPFontColor col) {
- _red = col.getRed();
- _green = col.getGreen();
- _blue = col.getBlue();
- }
-
- /**
- * Checks whether this object is equal to the parameter passed
- * as an argument. If the parameter is an instance of AFPColor
- * then the value are compared, otherwise the generalized equals
- * method is invoked on the parent class.
- *
- * @param obj the object to compare
- * @return boolean true if the object is equal
- */
- public boolean equals(Object obj) {
-
- if (obj instanceof AFPFontColor) {
- AFPFontColor c = (AFPFontColor) obj;
- if (c.getRed() == _red
- && c.getGreen() == _green
- && c.getBlue() == _blue) {
- return true;
- } else {
- return false;
- }
- } else {
- return super.equals(obj);
- }
-
- }
-
-}
diff --git a/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java b/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java
index b0839aa6d..fafaf6b6d 100644
--- a/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/sandbox/org/apache/fop/render/afp/AFPRenderer.java
@@ -44,7 +44,6 @@ import org.apache.fop.area.PageViewport;
import org.apache.fop.area.RegionReference;
import org.apache.fop.area.RegionViewport;
import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.Character;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.SpaceArea;
@@ -164,7 +163,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
/**
* The current color object
*/
- private AFPFontColor _currentColor = null;
+ private Color _currentColor = null;
/**
* The page font number counter, used to determine the next font reference
@@ -499,7 +498,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
*/
public void startRenderer(OutputStream outputStream) throws IOException {
_currentPageFonts = new HashMap();
- _currentColor = new AFPFontColor(255, 255, 255);
+ _currentColor = new Color(255, 255, 255);
_afpDataStream = new AFPDataStream();
_afpDataStream.setPortraitRotation(_portraitRotation);
_afpDataStream.setLandscapeRotation(_landscapeRotation);
@@ -883,7 +882,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x2),
pts2units(ym1),
pts2units(h3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(x1),
@@ -891,7 +890,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x2),
pts2units(ym2),
pts2units(h3),
- new AFPFontColor(col)
+ col
);
} else {
float w3 = w / 3;
@@ -903,7 +902,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(xm1),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(xm2),
@@ -911,7 +910,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(xm2),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(col)
+ col
);
}
break;
@@ -925,7 +924,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x1 + w2),
pts2units(y1),
pts2units(h),
- new AFPFontColor(col)
+ col
);
x1 += 2 * w2;
}
@@ -938,7 +937,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x1),
pts2units(y1 + h2),
pts2units(w),
- new AFPFontColor(col)
+ col
);
y1 += 2 * h2;
}
@@ -953,7 +952,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x1 + h),
pts2units(y1),
pts2units(h),
- new AFPFontColor(col)
+ col
);
x1 += 2 * h;
}
@@ -965,7 +964,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x1),
pts2units(y1 + w),
pts2units(w),
- new AFPFontColor(col)
+ col
);
y1 += 2 * w;
}
@@ -986,7 +985,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x2),
pts2units(ym1),
pts2units(h3),
- new AFPFontColor(uppercol)
+ uppercol
);
_afpDataStream.createLine(
pts2units(x1),
@@ -994,7 +993,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x2),
pts2units(ym1 + h3),
pts2units(h3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(x1),
@@ -1002,7 +1001,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(x2),
pts2units(ym1 + h3 + h3),
pts2units(h3),
- new AFPFontColor(lowercol)
+ lowercol
);
} else {
Color leftcol = lightenColor(col, -colFactor);
@@ -1015,7 +1014,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(xm1),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(leftcol)
+ leftcol
);
_afpDataStream.createLine(
pts2units(xm1 + w3),
@@ -1023,7 +1022,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(xm1 + w3),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(xm1 + w3 + w3),
@@ -1031,7 +1030,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(xm1 + w3 + w3),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(rightcol)
+ rightcol
);
}
break;
@@ -1047,7 +1046,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
pts2units(horz ? x2 : x1),
pts2units(horz ? y1 : y2),
pts2units(Math.abs(horz ? (y2 - y1) : (x2 - x1))),
- new AFPFontColor(col));
+ col
+ );
}
}
@@ -1194,7 +1194,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
*/
public void updateColor(Color col, boolean fill) {
if (fill) {
- _currentColor = new AFPFontColor(col);
+ _currentColor = col;
}
}
@@ -1243,90 +1243,6 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
}
/**
- * @see org.apache.fop.render.AbstractRenderer#renderCharacter(Character)
- */
- public void renderCharacter(Character ch) {
- renderInlineAreaBackAndBorders(ch);
-
- String name = getInternalFontNameForArea(ch);
- _currentFontSize = ((Integer) ch.getTrait(Trait.FONT_SIZE)).intValue();
- AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);
- _currentFontFamily = name;
-
- Color col = (Color) ch.getTrait(Trait.COLOR);
-
- int vsci = mpts2units(tf.getWidth(' ', _currentFontSize) / 1000
- + ch.getTextWordSpaceAdjust()
- + ch.getTextLetterSpaceAdjust());
-
- // word.getOffset() = only height of text itself
- // currentBlockIPPosition: 0 for beginning of line; nonzero
- // where previous line area failed to take up entire allocated space
- int rx = currentIPPosition + ch.getBorderAndPaddingWidthStart();
- int bl = currentBPPosition + ch.getOffset() + ch.getBaselineOffset();
-
- // Set letterSpacing
- //float ls = fs.getLetterSpacing() / this.currentFontSize;
-
- String worddata = ch.getChar();
-
- // Create an AFPFontAttributes object from the current font details
- AFPFontAttributes afpFontAttributes =
- new AFPFontAttributes(name, tf, _currentFontSize);
-
- if (!_currentPageFonts.containsKey(afpFontAttributes.getFontKey())) {
- // Font not found on current page, so add the new one
- _pageFontCounter++;
- afpFontAttributes.setFontReference(_pageFontCounter);
- _currentPageFonts.put(
- afpFontAttributes.getFontKey(),
- afpFontAttributes);
-
- } else {
- // Use the previously stored font attributes
- afpFontAttributes =
- (AFPFontAttributes) _currentPageFonts.get(afpFontAttributes.getFontKey());
-
- }
-
- // Try and get the encoding to use for the font
- String encoding = null;
-
- try {
- encoding = tf.getCharacterSet(_currentFontSize).getEncoding();
- } catch (Throwable ex) {
- encoding = AFPConstants.EBCIDIC_ENCODING;
- log.warn(
- "renderTextArea():: Error getting encoding for font "
- + " - using default encoding "
- + encoding);
- }
-
- try {
- _afpDataStream.createText(
- afpFontAttributes.getFontReference(),
- mpts2units(rx),
- mpts2units(bl),
- new AFPFontColor(col),
- vsci,
- mpts2units(ch.getTextLetterSpaceAdjust()),
- worddata.getBytes(encoding));
-
- } catch (UnsupportedEncodingException usee) {
- log.error(
- "renderWordArea:: Font "
- + afpFontAttributes.getFontKey()
- + " caused UnsupportedEncodingException");
-
- }
-
- super.renderCharacter(ch);
-
- renderTextDecoration(tf, _currentFontSize, ch, bl, rx);
-
- }
-
- /**
* @see org.apache.fop.render.AbstractRenderer#renderText(TextArea)
*/
public void renderText(TextArea text) {
@@ -1390,7 +1306,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
afpFontAttributes.getFontReference(),
mpts2units(rx),
mpts2units(bl),
- new AFPFontColor(col),
+ col,
vsci,
mpts2units(text.getTextLetterSpaceAdjust()),
worddata.getBytes(encoding));
diff --git a/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java b/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java
index 32fc29831..0babc927a 100644
--- a/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java
+++ b/src/sandbox/org/apache/fop/render/afp/modca/AFPDataStream.java
@@ -18,12 +18,12 @@
package org.apache.fop.render.afp.modca;
+import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.render.afp.AFPFontColor;
import org.apache.fop.render.afp.fonts.AFPFont;
import org.apache.fop.render.afp.tools.StringUtils;
@@ -347,7 +347,7 @@ public class AFPDataStream {
* @param data
* the text data to create
*/
- public void createText(int fontNumber, int x, int y, AFPFontColor col, int vsci, int ica, byte[] data) {
+ public void createText(int fontNumber, int x, int y, Color col, int vsci, int ica, byte[] data) {
_currentPage.createText(fontNumber, x + _xOffset, y + _yOffset, _rotation, col, vsci, ica, data);
@@ -419,7 +419,7 @@ public class AFPDataStream {
* @param col
* The text color.
*/
- public void createLine(int x1, int y1, int x2, int y2, int thickness, AFPFontColor col) {
+ public void createLine(int x1, int y1, int x2, int y2, int thickness, Color col) {
_currentPage.createLine(x1 + _xOffset, y1 + _yOffset, x2 + _xOffset, y2 + _yOffset, thickness, _rotation, col);
diff --git a/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java b/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java
index 5056e9b21..876537d7f 100644
--- a/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java
+++ b/src/sandbox/org/apache/fop/render/afp/modca/AbstractPageObject.java
@@ -17,11 +17,12 @@
/* $Id$ */
package org.apache.fop.render.afp.modca;
+
+import java.awt.Color;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.fop.render.afp.AFPFontColor;
import org.apache.fop.render.afp.fonts.AFPFont;
import org.apache.fop.render.afp.tools.StringUtils;
@@ -179,7 +180,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* @param col
* The text color.
*/
- public void createLine(int x1, int y1, int x2, int y2, int thickness, int rotation, AFPFontColor col) {
+ public void createLine(int x1, int y1, int x2, int y2, int thickness, int rotation, Color col) {
if (_presentationTextObject == null) {
_presentationTextObject = new PresentationTextObject();
@@ -210,7 +211,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject {
* @param data
* the text data to create
*/
- public void createText(int fontNumber, int x, int y, int rotation, AFPFontColor col, int vsci, int ica, byte[] data) {
+ public void createText(int fontNumber, int x, int y, int rotation, Color col, int vsci, int ica, byte[] data) {
if (_presentationTextObject == null) {
_presentationTextObject = new PresentationTextObject();
diff --git a/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java b/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java
index 99b6f452d..bd659c59d 100644
--- a/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java
+++ b/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java
@@ -18,10 +18,10 @@
package org.apache.fop.render.afp.modca;
+import java.awt.Color;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.fop.render.afp.AFPFontColor;
import org.apache.fop.render.afp.tools.BinaryUtils;
@@ -80,7 +80,7 @@ public class PresentationTextData extends AbstractAFPObject {
/**
* The current color
*/
- private AFPFontColor _currentColor = new AFPFontColor(0, 0, 0);
+ private Color _currentColor = new Color(0, 0, 0);
/**
* The current variable space increment
@@ -302,7 +302,7 @@ public class PresentationTextData extends AbstractAFPObject {
* @throws MaximumSizeExceededException
*/
public void createTextData(int fontNumber, int x, int y, int orientation,
- AFPFontColor col, int vsci, int ica, byte[] data)
+ Color col, int vsci, int ica, byte[] data)
throws MaximumSizeExceededException {
ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
@@ -340,7 +340,7 @@ public class PresentationTextData extends AbstractAFPObject {
// Avoid unnecessary specification of the text color
if (!col.equals(_currentColor)) {
setExtendedTextColor(col, afpdata);
- _currentColor.setTo(col);
+ _currentColor = col;
}
setCodedFont(BinaryUtils.convert(fontNumber)[0], afpdata);
@@ -380,7 +380,7 @@ public class PresentationTextData extends AbstractAFPObject {
* The text color.
*/
public void createLineData(int x1, int y1, int x2, int y2, int thickness,
- int orientation, AFPFontColor col) throws MaximumSizeExceededException {
+ int orientation, Color col) throws MaximumSizeExceededException {
ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
@@ -401,7 +401,7 @@ public class PresentationTextData extends AbstractAFPObject {
if (!col.equals(_currentColor)) {
setExtendedTextColor(col, afpdata);
- _currentColor.setTo(col);
+ _currentColor = col;
}
if (y1 == y2) {
@@ -484,7 +484,7 @@ public class PresentationTextData extends AbstractAFPObject {
* @param afpdata
* The output stream to which data should be written.
*/
- private void setExtendedTextColor(AFPFontColor col,
+ private void setExtendedTextColor(Color col,
ByteArrayOutputStream afpdata) {
afpdata.write(new byte[] {
diff --git a/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java b/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java
index ce54de152..eb7d5c1cd 100644
--- a/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java
+++ b/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java
@@ -17,11 +17,12 @@
/* $Id$ */
package org.apache.fop.render.afp.modca;
+
+import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
-import org.apache.fop.render.afp.AFPFontColor;
/**
* The Presentation Text object is the data object used in document processing
@@ -87,7 +88,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
* @param data
* The text data to be created.
*/
- public void createTextData(int fontNumber, int x, int y, AFPFontColor col, int vsci, int ica, byte[] data) {
+ public void createTextData(int fontNumber, int x, int y, Color col, int vsci, int ica, byte[] data) {
// Use a default orientation of zero
createTextData(fontNumber, x, y, 0, col, vsci, ica, data);
@@ -115,7 +116,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
* The text data to be created.
*/
public void createTextData(int fontNumber, int x, int y, int orientation,
- AFPFontColor col, int vsci, int ica, byte[] data) {
+ Color col, int vsci, int ica, byte[] data) {
if (currentPresentationTextData == null) {
startPresentationTextData();
@@ -151,7 +152,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
* @param col
* The text color.
*/
- public void createLineData(int x1, int y1, int x2, int y2, int thickness, AFPFontColor col) {
+ 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);
}
@@ -176,7 +177,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject {
* The text color.
*/
public void createLineData(int x1, int y1, int x2, int y2, int thickness,
- int orientation, AFPFontColor col) {
+ int orientation, Color col) {
if (currentPresentationTextData == null) {
startPresentationTextData();