diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-03-27 15:50:59 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-03-27 15:50:59 +0000 |
commit | 3cb2a24bcdc2558d1db95bab63cba628fa554d3c (patch) | |
tree | 976632f6ec11a54a9e07107063bbf7ceb745f67f /src | |
parent | 2c656d6a2e912ac4893f298313005b96cd22b954 (diff) | |
download | xmlgraphics-fop-3cb2a24bcdc2558d1db95bab63cba628fa554d3c.tar.gz xmlgraphics-fop-3cb2a24bcdc2558d1db95bab63cba628fa554d3c.zip |
This package has been moved to its own top level.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@641860 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
21 files changed, 0 insertions, 1709 deletions
diff --git a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java b/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java deleted file mode 100644 index c0520fbf1..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.modca.goca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.List; - -import org.apache.fop.render.afp.modca.AbstractStructuredAFPObject; -import org.apache.fop.render.afp.modca.PreparedAFPObject; - -/** - * A base class container of GOCA structured objects - */ -public abstract class AbstractGraphicsContainer extends AbstractStructuredAFPObject -implements PreparedAFPObject { - - /** - * list of objects contained within this container - */ - protected List list = null; - - /** - * Default constructor - */ - public AbstractGraphicsContainer() { - } - - /** - * Named constructor - * @param name the name of the container - */ - public AbstractGraphicsContainer(String name) { - super(name); - } - - /** - * {@inheritDoc} - */ - protected void writeContent(OutputStream os) throws IOException { - if (list != null) { - super.writeObjectList(list, os); - } - } - - /** - * Adds a given graphics drawing order to this container - * @param drawingOrder the graphics drawing order - * @return the drawingOrder if it was added, null otherwise - */ - protected PreparedAFPObject addDrawingOrder(PreparedAFPObject drawingOrder) { - log.debug(this + " adding " + drawingOrder); - if (list == null) { - this.list = new java.util.ArrayList(); - } - list.add(drawingOrder); - return drawingOrder; - } - - /** - * @return the current data length of this container including - * all enclosed GOCA drawing objects (and their containers) - */ - public int getDataLength() { - int dataLen = 0; - if (list != null) { - Iterator it = list.iterator(); - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof PreparedAFPObject) { - dataLen += ((PreparedAFPObject)obj).getDataLength(); - } - } - } - return dataLen; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java deleted file mode 100644 index 8f6e55b23..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.modca.goca; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A base class encapsulating the structure of coordinate based GOCA objects - */ -public abstract class AbstractGraphicsCoord extends AbstractPreparedAFPObject { - - /** array of x/y coordinates */ - protected int[] coords = null; - - /** - * @param coords the x/y coordinates for this object - */ - public AbstractGraphicsCoord(int[] coords) { - this.coords = coords; - prepareData(); - } - - /** - * @param x the x coordinate for this object - * @param y the y coordinate for this object - */ - public AbstractGraphicsCoord(int x, int y) { - this(new int[] {x, y}); - } - - /** - * @param x1 the x1 coordinate for this object - * @param y1 the y1 coordinate for this object - * @param x2 the x2 coordinate for this object - * @param y2 the y2 coordinate for this object - */ - public AbstractGraphicsCoord(int x1, int y1, int x2, int y2) { - this(new int[] {x1, y1, x2, y2}); - } - - /** - * @return the order code to use - */ - protected abstract byte getOrderCode(); - - /** - * @return the length of this order code - * (typically this is the same as the coordinate length) - */ - protected int getLength() { - return this.coords.length * 2; - } - - /** - * Creates a newly created and initialized byte data - * @return a newly created and initialized byte data - */ - protected byte[] createData() { - int len = getLength(); - byte[] data = new byte[len + 2]; - data[0] = getOrderCode(); // ORDER CODE - data[1] = (byte)len; // LENGTH - return data; - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = createData(); - int fromIndex = data.length - getLength(); - addCoords(data, fromIndex); - } - - /** - * Adds the coordinates to the structured field data - * @param data the structured field data - * @param fromIndex the start index - */ - protected void addCoords(byte[] data, int fromIndex) { - // X/Y POS - for (int i = 0; i < coords.length; i++, fromIndex += 2) { - byte[] coord = BinaryUtils.convert(coords[i], 2); - data[fromIndex] = coord[0]; - data[fromIndex + 1] = coord[1]; - } - } - - /** - * @return the short name of this GOCA object - */ - protected String getName() { - String className = getClass().getName(); - return className.substring(className.lastIndexOf(".") + 1); - } - - /** - * {@inheritDoc} - */ - public String toString() { - String coordsStr = ""; - for (int i = 0; i < coords.length; i++) { - coordsStr += (i % 2 == 0) ? "x" : "y"; - coordsStr += (i / 2) + "=" + coords[i] + ","; - } - coordsStr = coordsStr.substring(0, coordsStr.length() - 1); - return getName() + "(" + coordsStr + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java deleted file mode 100644 index b064896c7..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.modca.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractAFPObject; -import org.apache.fop.render.afp.modca.PreparedAFPObject; - -/** - * A base class that carries out early preparation of structured field data - * for the AFP object (so the data length can be pre-calculated) - */ -public abstract class AbstractPreparedAFPObject extends AbstractAFPObject -implements PreparedAFPObject { - - /** structured field data to be written */ - protected byte[] data = null; - - /** - * {@inheritDoc} - */ - public void writeDataStream(OutputStream os) throws IOException { - if (this.data != null) { - os.write(this.data); - } - } - - /** - * @return the data length of this prepared AFP object - */ - public int getDataLength() { - if (this.data != null) { - return this.data.length; - } - return 0; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java deleted file mode 100644 index 88173d6d1..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.modca.goca; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A GOCA graphics area (container for filled shapes/objects) - */ -public final class GraphicsArea extends AbstractGraphicsContainer { - - /** draw boundary lines around this area */ - private boolean drawBoundary = false; - - /** - * Sets whether boundary lines are drawn - * @param drawBoundaryLines whether boundary lines are drawn - */ - public void setDrawBoundaryLines(boolean drawBoundaryLines) { - this.drawBoundary = drawBoundaryLines; - } - - private static final int RES1 = 1; - private static final int BOUNDARY = 2; - private static final int NO_BOUNDARY = 0; - - /** - * {@inheritDoc} - */ - public int getDataLength() { - // start len + end len + data len - return 4 + super.getDataLength(); - } - - /** - * {@inheritDoc} - */ - protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - byte[] data = new byte[] { - (byte)0x68, // GBAR order code - (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY)) - }; - os.write(data); - } - - /** - * {@inheritDoc} - */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] endData = new byte[] { - (byte)0x60, // GEAR order code - 0x00, // LENGTH - }; - os.write(endData); - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsArea"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java deleted file mode 100644 index ba87dad9f..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.modca.goca; - -/** - * A GOCA graphics rectangular box - */ -public final class GraphicsBox extends AbstractGraphicsCoord { - - /** - * @param coords the x/y coordinates for this object - */ - public GraphicsBox(int[] coords) { - super(coords); - } - - /** - * {@inheritDoc} - */ - protected byte getOrderCode() { - return (byte)0xC0; - } - - /** - * {@inheritDoc} - */ - protected int getLength() { - return 10; - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = createData(); - final int fromIndex = 4; - addCoords(data, fromIndex); - } - - /** - * {@inheritDoc} - */ - protected byte[] createData() { - byte[] data = super.createData(); - data[2] = (byte)0x20; // CONTROL draw control flags - data[3] = 0x00; // reserved - return data; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java deleted file mode 100644 index 4485370b9..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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.modca.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.PreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics segment - */ -public final class GraphicsChainedSegment extends AbstractGraphicsContainer { - - /** - * The maximum segment data length - */ - protected static final int MAX_DATA_LEN = 8192; - - /** the current area */ - private GraphicsArea currentArea = null; - - /** the previous segment in the chain */ - private GraphicsChainedSegment previous = null; - - /** the next segment in the chain */ - private GraphicsChainedSegment next = null; - - /** - * Main constructor - * - * @param name - * the name of this graphics segment - */ - public GraphicsChainedSegment(String name) { - super(name); - } - - /** - * Constructor - * - * @param name - * the name of this graphics segment - * @param previous - * the previous graphics segment in this chain - */ - public GraphicsChainedSegment(String name, GraphicsChainedSegment previous) { - super(name); - previous.next = this; - this.previous = previous; - } - - /** - * {@inheritDoc} - */ - public int getDataLength() { - int dataLen = 14 + super.getDataLength(); - if (previous == null) { - GraphicsChainedSegment current = this.next; - while (current != null) { - dataLen += current.getDataLength(); - current = current.next; - } - } - return dataLen; - } - - /** - * {@inheritDoc} - */ - protected int getNameLength() { - return 4; - } - - private static final byte APPEND_NEW_SEGMENT = 0; - - private static final byte PROLOG = 4; - - private static final byte APPEND_TO_EXISING = 48; - - /** - * {@inheritDoc} - */ - protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - int len = super.getDataLength(); - byte[] segLen = BinaryUtils.convert(len, 2); - byte[] data = new byte[] { - 0x70, // BEGIN_SEGMENT - 0x0C, // Length of following parameters - this.nameBytes[0], - this.nameBytes[1], - this.nameBytes[2], - this.nameBytes[3], - 0x00, // FLAG1 (ignored) - APPEND_NEW_SEGMENT, - segLen[0], // SEGL - segLen[1], - 0x00, - 0x00, - 0x00, - 0x00 - }; - // P/S NAME (predecessor name) - if (previous != null) { - data[10] = previous.nameBytes[0]; - data[11] = previous.nameBytes[1]; - data[12] = previous.nameBytes[2]; - data[13] = previous.nameBytes[3]; - } - os.write(data); - } - - /** - * {@inheritDoc} - */ - protected void writeEnd(OutputStream os) throws IOException { - // I am the first segment in the chain so write out the rest - if (previous == null) { - GraphicsChainedSegment current = this.next; - while (current != null) { - current.writeDataStream(os); - current = current.next; - } - } - } - - /** - * Begins a graphics area (start of fill) - */ - protected void beginArea() { - this.currentArea = new GraphicsArea(); - super.addDrawingOrder(currentArea); - } - - /** - * Ends a graphics area (end of fill) - */ - protected void endArea() { - this.currentArea = null; - } - - /** - * {@inheritDoc} - */ - protected PreparedAFPObject addDrawingOrder(PreparedAFPObject drawingOrder) { - if (currentArea != null) { - currentArea.addDrawingOrder(drawingOrder); - } else { - super.addDrawingOrder(drawingOrder); - } - return drawingOrder; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsChainedSegment(name=" + super.name + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java deleted file mode 100644 index ccbb537f6..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.modca.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.PreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; -import org.apache.fop.render.afp.tools.StringUtils; - -/** - * A GOCA graphics data - */ -public final class GraphicsData extends AbstractGraphicsContainer { - - /** - * The maximum graphics data length - */ - public static final int MAX_DATA_LEN = 32767; - - /** - * Default constructor - */ - public GraphicsData() { - } - - /** - * The graphics segment - */ - private GraphicsChainedSegment currentSegment = null; - - /** - * {@inheritDoc} - */ - public int getDataLength() { - return 8 + super.getDataLength(); - } - - /** - * {@inheritDoc} - */ - protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - int l = getDataLength(); - byte[] len = BinaryUtils.convert(l, 2); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - len[0], // Length byte 1 - len[1], // Length byte 2 - (byte) 0xD3, // Structured field id byte 1 - (byte) 0xEE, // Structured field id byte 2 - (byte) 0xBB, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00 // Reserved - }; - os.write(data); - } - - /** - * Begins a graphics area (start of fill) - */ - public void beginArea() { - getSegment().beginArea(); - } - - /** - * Ends a graphics area (end of fill) - */ - public void endArea() { - getSegment().endArea(); - } - - /** - * Returns a new segment name - * @return a new segment name - */ - private String createSegmentName() { - return StringUtils.lpad(String.valueOf( - (super.list != null ? super.list.size() : 0) + 1), - '0', 4); - } - - /** - * Returns the current graphics segment, creating one if one does not exist - * @return the current graphics chained segment - */ - GraphicsChainedSegment getSegment() { - if (currentSegment == null) { - newSegment(); - } - return this.currentSegment; - } - - /** - * Creates a new graphics segment - * @return a newly created graphics segment - */ - public GraphicsChainedSegment newSegment() { - String name = createSegmentName(); - if (currentSegment == null) { - this.currentSegment = new GraphicsChainedSegment(name); - } else { - this.currentSegment = new GraphicsChainedSegment(name, currentSegment); - } - super.addDrawingOrder(currentSegment); - return currentSegment; - } - - /** - * {@inheritDoc} - */ - public PreparedAFPObject addDrawingOrder(PreparedAFPObject drawingOrder) { - if (currentSegment == null - || (currentSegment.getDataLength() + drawingOrder.getDataLength()) - >= GraphicsChainedSegment.MAX_DATA_LEN) { - newSegment(); - } - currentSegment.addDrawingOrder(drawingOrder); - return drawingOrder; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsData"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java deleted file mode 100644 index 1bac5b149..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.modca.goca; - -/** - * A GOCA graphics curved tangential line to a specified set of - * straight lines drawn from the given position or current position - */ -public final class GraphicsFillet extends AbstractGraphicsCoord { - - /** - * @param coords the x/y coordinates for this object - */ - public GraphicsFillet(int[] coords) { - super(coords); - } - - /** - * {@inheritDoc} - */ - protected byte getOrderCode() { - return (byte)0xC5; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java deleted file mode 100644 index 43f0d370d..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.modca.goca; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics arc (circle/ellipse) - */ -public class GraphicsFullArc extends AbstractGraphicsCoord { - /** the integer portion of the multiplier */ - private int mh; - - /** the fractional portion of the multiplier */ - private int mhr; - - /** - * @param x the x coordinate of the center of the circle/ellipse - * @param y the y coordinate of the center of the circle/ellipse - * @param mh the integer portion of the multiplier - * @param mhr the fractional portion of the multiplier - */ - public GraphicsFullArc(int x, int y, int mh, int mhr) { - super(x, y); - this.mh = mh; - this.mhr = mhr; - // integer portion of multiplier - data[data.length - 2] = BinaryUtils.convert(mh, 1)[0]; - // fractional portion of multiplier - data[data.length - 1] = BinaryUtils.convert(mhr, 1)[0]; - } - - /** - * {@inheritDoc} - */ - protected byte getOrderCode() { - return (byte)0xC7; - } - - /** - * {@inheritDoc} - */ - protected int getLength() { - return super.getLength() + 2; - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = super.createData(); - final int fromIndex = 2; - super.addCoords(data, fromIndex); - } - - /** - * {@inheritDoc} - */ - public String toString() { - return super.getName() - + "(centerx=" + coords[0] + ",centery=" + coords[1] - + ",mh=" + mh + ",mhr=" + mhr + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java deleted file mode 100644 index e37b4b196..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.modca.goca; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics begin image object - */ -public final class GraphicsImageBegin extends AbstractPreparedAFPObject { - /** x coordinate */ - private int x; - - /** y coordinate */ - private int y; - - /** width */ - private int width; - - /** height */ - private int height; - - /** - * @param x the x coordinate of the image - * @param y the y coordinate of the image - * @param width the image width - * @param height the image height - */ - public GraphicsImageBegin(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - byte[] xcoord = BinaryUtils.convert(x, 2); - byte[] ycoord = BinaryUtils.convert(y, 2); - byte[] w = BinaryUtils.convert(width, 2); - byte[] h = BinaryUtils.convert(height, 2); - super.data = new byte[] { - (byte) 0xD1, // GBIMG order code - (byte) 0x0A, // LENGTH - xcoord[0], - xcoord[1], - ycoord[0], - ycoord[1], - 0x00, // FORMAT - 0x00, // RES - w[0], // WIDTH - w[1], // - h[0], // HEIGHT - h[1] // - }; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsImageBegin(x=" + x + ",y=" + y - + ",width=" + width + ",height=" + height + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java deleted file mode 100644 index 38b81ecd6..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.modca.goca; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics image data - */ -public final class GraphicsImageData extends AbstractPreparedAFPObject { - - /** the maximum image data length */ - public static final short MAX_DATA_LEN = 255; - - /** - * Main constructor - * - * @param imageData the image data - * @param startIndex the start index to read the image data from - */ - public GraphicsImageData(byte[] imageData, int startIndex) { - int dataLen = MAX_DATA_LEN; - if (startIndex + MAX_DATA_LEN >= imageData.length) { - dataLen = imageData.length - startIndex - 1; - } - super.data = new byte[dataLen + 2]; - data[0] = (byte) 0x92; // GIMD - data[1] = BinaryUtils.convert(dataLen, 1)[0]; // LENGTH - System.arraycopy(imageData, startIndex, data, 2, dataLen); - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsImageData(" - + (data != null ? "" + (data.length - 2) : "null") - + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java deleted file mode 100644 index 40a518c4b..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.modca.goca; - -/** - * A GOCA graphics image data - */ -public class GraphicsImageEnd extends AbstractPreparedAFPObject { - - /** - * Default constructor - */ - public GraphicsImageEnd() { - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = new byte[] { - (byte) 0x93, // GEIMG order code - 0x00 // LENGTH - }; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsImageEnd"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java deleted file mode 100644 index 07127c387..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.modca.goca; - - -/** - * A GOCA graphics straight line drawn from the - * given position or current position. - */ -public class GraphicsLine extends AbstractGraphicsCoord { - - /** - * @param coords the x/y coordinates for this object - */ - public GraphicsLine(int[] coords) { - super(coords); - } - - /** - * {@inheritDoc} - */ - protected byte getOrderCode() { - return (byte)0xC1; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java deleted file mode 100644 index d39e1e167..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.modca.goca; - -/** - * Sets the arc parameters for a GOCA graphics arc (circle/ellipse) - */ -public class GraphicsSetArcParameters extends AbstractGraphicsCoord { - - /** - * @param xmaj x coordinate of the major axis point - * @param ymin y coordinate of the minor axis point - * @param xmin x coordinate of the minor axis point - * @param ymaj y coordinate of the major axis point - */ - public GraphicsSetArcParameters(int xmaj, int ymin, int xmin, int ymaj) { - super(xmaj, ymin, xmin, ymaj); - } - - /** - * {@inheritDoc} - */ - protected byte getOrderCode() { - return 0x22; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return getName() + "(xmaj=" + coords[0] - + ",ymin=" + coords[1] - + ",xmin=" + coords[2] - + ",ymaj=" + coords[3] + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java deleted file mode 100644 index aeca3e9c5..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.modca.goca; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Sets the current character set (font) to be used for following graphics strings - */ -public class GraphicsSetCharacterSet extends AbstractPreparedAFPObject { - /** font character set reference */ - private int fontReference; - - /** - * @param fontReference character set font reference - */ - public GraphicsSetCharacterSet(int fontReference) { - this.fontReference = fontReference; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = new byte[] { - 0x38, // GSCS order code - BinaryUtils.convert(fontReference)[0] - }; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsSetCharacterSet(" + fontReference + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java deleted file mode 100644 index 91597e8e3..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.modca.goca; - - -/** - * Sets the current painting position of the graphics object - */ -public class GraphicsSetCurrentPosition extends AbstractGraphicsCoord { - - /** - * @param coords the x/y coordinates for this object - */ - public GraphicsSetCurrentPosition(int[] coords) { - super(coords); - } - - /** - * {@inheritDoc} - */ - protected byte getOrderCode() { - return (byte)0x21; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java deleted file mode 100644 index 339902e2c..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.modca.goca; - -/** - * Sets the value of the current line type attribute when stroking GOCA shapes (structured fields) - */ -public class GraphicsSetLineType extends AbstractPreparedAFPObject { - /** the default line type */ - public static final byte DEFAULT = 0x00; // normally SOLID - - /** the default line type */ - public static final byte DOTTED = 0x01; - - /** short dashed line type */ - public static final byte SHORT_DASHED = 0x02; - - /** dashed dotted line type */ - public static final byte DASH_DOT = 0x03; - - /** double dotted line type */ - public static final byte DOUBLE_DOTTED = 0x04; - - /** long dashed line type */ - public static final byte LONG_DASHED = 0x05; - - /** dash double dotted line type */ - public static final byte DASH_DOUBLE_DOTTED = 0x06; - - /** solid line type */ - public static final byte SOLID = 0x07; - - /** invisible line type */ - public static final byte INVISIBLE = 0x08; - - /** line type */ - private byte type = DEFAULT; - - /** - * Main constructor - * @param type line type - */ - public GraphicsSetLineType(byte type) { - this.type = type; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = new byte[] { - 0x18, // GSLW order code - type // line type - }; - } - - private static final String[] TYPES = { - "DEFAULT", "DOTTED", "SHORT_DASHED", "DASH_DOT", "DOUBLE_DOTTED", - "LONG_DASHED", "DASH_DOUBLE_DOTTED", "SOLID", "INVISIBLE" - }; - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsSetLineType(type=" + TYPES[type] + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java deleted file mode 100644 index 0cd077567..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.modca.goca; - -/** - * Sets the line width to use when stroking GOCA shapes (structured fields) - */ -public class GraphicsSetLineWidth extends AbstractPreparedAFPObject { - /** line width multiplier */ - private int multiplier = 1; - - /** - * Main constructor - * @param multiplier the line width multiplier - */ - public GraphicsSetLineWidth(int multiplier) { - this.multiplier = multiplier; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = new byte[] { - 0x19, // GSLW order code - (byte)multiplier // MH (line-width) - }; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsSetLineWidth(multiplier=" + multiplier + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java deleted file mode 100644 index 23c0ac73c..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.modca.goca; - -/** - * Sets the pattern symbol to use when filling following GOCA structured fields - */ -public class GraphicsSetPatternSymbol extends AbstractPreparedAFPObject { - /** dotted density 1 */ - public static final byte DOTTED_DENSITY_1 = 0x01; - - /** dotted density 2 */ - public static final byte DOTTED_DENSITY_2 = 0x02; - - /** dotted density 3 */ - public static final byte DOTTED_DENSITY_3 = 0x03; - - /** dotted density 4 */ - public static final byte DOTTED_DENSITY_4 = 0x04; - - /** dotted density 5 */ - public static final byte DOTTED_DENSITY_5 = 0x05; - - /** dotted density 6 */ - public static final byte DOTTED_DENSITY_6 = 0x06; - - /** dotted density 7 */ - public static final byte DOTTED_DENSITY_7 = 0x07; - - /** dotted density 8 */ - public static final byte DOTTED_DENSITY_8 = 0x08; - - /** dotted density 9 */ - public static final byte VERTICAL_LINES = 0x09; - - /** horizontal lines */ - public static final byte HORIZONTAL_LINES = 0x0A; - - /** diagonal lines, bottom left to top right 1 */ - public static final byte DIAGONAL_LINES_BLTR_1 = 0x0B; - - /** diagonal lines, bottom left to top right 2 */ - public static final byte DIAGONAL_LINES_BLTR_2 = 0x0C; - - /** diagonal lines, top left to bottom right 1 */ - public static final byte DIAGONAL_LINES_TLBR_1 = 0x0D; - - /** diagonal lines, top left to bottom right 2 */ - public static final byte DIAGONAL_LINES_TLBR_2 = 0x0E; - - /** no fill */ - public static final byte NO_FILL = 0x0F; - - /** solid fill */ - public static final byte SOLID_FILL = 0x10; - - /** blank (same as no fill) */ - public static final byte BLANK = 0x40; // processed same as NO_FILL - - /** the graphics pattern symbol to use */ - private byte symbol; - - /** - * Main constructor - * @param symb the pattern symbol to use - */ - public GraphicsSetPatternSymbol(byte symb) { - this.symbol = symb; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - super.data = new byte[] { - 0x28, // GSPT order code - symbol - }; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsSetPatternSymbol(fill=" - + (symbol == SOLID_FILL ? true : false) + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java deleted file mode 100644 index 51153f065..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.modca.goca; - -import java.awt.Color; -import java.awt.color.ColorSpace; - -import org.apache.fop.render.afp.modca.GraphicsObject; - -/** - * Sets the current processing color for the following GOCA structured fields - */ -public class GraphicsSetProcessColor extends AbstractPreparedAFPObject { - /** the color to set */ - private Color col; - - /** - * Main constructor - * @param col the color to set - */ - public GraphicsSetProcessColor(Color col) { - this.col = col; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - // COLSPCE - byte colspace; - int colSpaceType = col.getColorSpace().getType(); - if (colSpaceType == ColorSpace.TYPE_CMYK) { - colspace = 0x04; - } else if (colSpaceType == ColorSpace.TYPE_RGB) { - colspace = 0x01; - } else { - GraphicsObject.log.error("unsupported colorspace " + colSpaceType); - colspace = 0x01; - } - - // COLSIZE(S) - float[] colcomp = col.getColorComponents(null); - byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00}; - for (int i = 0; i < colcomp.length; i++) { - colsizes[i] = (byte)8; - } - - int len = 10 + colcomp.length; - super.data = new byte[len + 2]; - data[0] = (byte)0xB2; // GSPCOL order code - data[1] = (byte)len; // LEN - data[2] = 0x00; // reserved; must be zero - data[3] = colspace; // COLSPCE - data[4] = 0x00; // reserved; must be zero - data[5] = 0x00; // reserved; must be zero - data[6] = 0x00; // reserved; must be zero - data[7] = 0x00; // reserved; must be zero - data[8] = colsizes[0]; // COLSIZE(S) - data[9] = colsizes[1]; - data[10] = colsizes[2]; - data[11] = colsizes[3]; - // COLVALUE(S) - for (int i = 0; i < colcomp.length; i++) { - data[i + 12] = (byte)(colcomp[i] * 255); - } - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "GraphicsSetProcessColor(col=" + col + ")"; - } -}
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java deleted file mode 100644 index 7033ce92f..000000000 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.modca.goca; - -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.modca.AFPConstants; -import org.apache.fop.render.afp.modca.GraphicsObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics string - */ -public class GraphicsString extends AbstractPreparedAFPObject { - /** Up to 255 bytes of character data */ - private static final int MAX_STR_LEN = 255; - - /** drawn from the current position */ - private boolean fromCurrentPosition = false; - - /** the string to draw */ - private String str = null; - - /** x coordinate */ - private int x; - - /** y coordinate */ - private int y; - - /** - * @param str the character string - */ - public GraphicsString(String str) { - this.str = str; - fromCurrentPosition = true; - prepareData(); - } - - /** - * @param str the character string - * @param x the x coordinate - * @param y the y coordinate - */ - public GraphicsString(String str, int x, int y) { - this.str = str; - this.x = x; - this.y = y; - prepareData(); - } - - /** - * {@inheritDoc} - */ - protected void prepareData() { - int maxStrLen = MAX_STR_LEN - (fromCurrentPosition ? 0 : 4); - if (str.length() > maxStrLen) { - str = str.substring(0, maxStrLen); - log.warn("truncated character string, longer than " + maxStrLen + " chars"); - } - byte[] strData = null; - try { - strData = str.getBytes(AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException ex) { - GraphicsObject.log.error("unsupported encoding: " + ex.getMessage()); - } - int len = strData.length; - if (fromCurrentPosition) { - data = new byte[len + 2]; - data[0] = (byte)0x83; - data[1] = (byte)len; - System.arraycopy(strData, 0, data, 2, strData.length); - } else { - len += 4; // x/y coordinates - byte[] osx = BinaryUtils.convert(x, 2); - byte[] osy = BinaryUtils.convert(y, 2); - data = new byte[len + 2]; - data[0] = (byte)0xC3; - data[1] = (byte)len; - data[2] = osx[0]; - data[3] = osx[1]; - data[4] = osy[0]; - data[5] = osy[1]; - System.arraycopy(strData, 0, data, 6, strData.length); - } - } - - /** - * {@inheritDoc} - */ - public String toString() { - String string = "GraphicsString(str='" + str + "'"; - if (!fromCurrentPosition) { - string += ",x=" + x + ",y=" + y; - } - string += ")"; - return string; - } -}
\ No newline at end of file |