+++ /dev/null
-/*
- * 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);
- }
-
- }
-
-}
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;
/**
* The current color object
*/
- private AFPFontColor _currentColor = null;
+ private Color _currentColor = null;
/**
* The page font number counter, used to determine the next font reference
*/
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);
pts2units(x2),
pts2units(ym1),
pts2units(h3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(x1),
pts2units(x2),
pts2units(ym2),
pts2units(h3),
- new AFPFontColor(col)
+ col
);
} else {
float w3 = w / 3;
pts2units(xm1),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(xm2),
pts2units(xm2),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(col)
+ col
);
}
break;
pts2units(x1 + w2),
pts2units(y1),
pts2units(h),
- new AFPFontColor(col)
+ col
);
x1 += 2 * w2;
}
pts2units(x1),
pts2units(y1 + h2),
pts2units(w),
- new AFPFontColor(col)
+ col
);
y1 += 2 * h2;
}
pts2units(x1 + h),
pts2units(y1),
pts2units(h),
- new AFPFontColor(col)
+ col
);
x1 += 2 * h;
}
pts2units(x1),
pts2units(y1 + w),
pts2units(w),
- new AFPFontColor(col)
+ col
);
y1 += 2 * w;
}
pts2units(x2),
pts2units(ym1),
pts2units(h3),
- new AFPFontColor(uppercol)
+ uppercol
);
_afpDataStream.createLine(
pts2units(x1),
pts2units(x2),
pts2units(ym1 + h3),
pts2units(h3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(x1),
pts2units(x2),
pts2units(ym1 + h3 + h3),
pts2units(h3),
- new AFPFontColor(lowercol)
+ lowercol
);
} else {
Color leftcol = lightenColor(col, -colFactor);
pts2units(xm1),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(leftcol)
+ leftcol
);
_afpDataStream.createLine(
pts2units(xm1 + w3),
pts2units(xm1 + w3),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(col)
+ col
);
_afpDataStream.createLine(
pts2units(xm1 + w3 + w3),
pts2units(xm1 + w3 + w3),
pts2units(y2),
pts2units(w3),
- new AFPFontColor(rightcol)
+ rightcol
);
}
break;
pts2units(horz ? x2 : x1),
pts2units(horz ? y1 : y2),
pts2units(Math.abs(horz ? (y2 - y1) : (x2 - x1))),
- new AFPFontColor(col));
+ col
+ );
}
}
*/
public void updateColor(Color col, boolean fill) {
if (fill) {
- _currentColor = new AFPFontColor(col);
+ _currentColor = col;
}
}
drawImage(url, pos);
}
- /**
- * @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)
*/
afpFontAttributes.getFontReference(),
mpts2units(rx),
mpts2units(bl),
- new AFPFontColor(col),
+ col,
vsci,
mpts2units(text.getTextLetterSpaceAdjust()),
worddata.getBytes(encoding));
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;
* @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);
* @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);
/* $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;
* @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();
* @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();
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;
/**
* The current color
*/
- private AFPFontColor _currentColor = new AFPFontColor(0, 0, 0);
+ private Color _currentColor = new Color(0, 0, 0);
/**
* The current variable space increment
* @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();
// 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);
* 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();
if (!col.equals(_currentColor)) {
setExtendedTextColor(col, afpdata);
- _currentColor.setTo(col);
+ _currentColor = col;
}
if (y1 == y2) {
* @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[] {
/* $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
* @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);
* 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();
* @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);
}
* 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();