foray-commit Mailing List for FOray (Page 12)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2025-05-05 09:30:09
|
Revision: 13603
http://sourceforge.net/p/foray/code/13603
Author: victormote
Date: 2025-05-05 09:29:49 +0000 (Mon, 05 May 2025)
Log Message:
-----------
Remove unused methods as incremental cleanup step.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java 2025-05-05 08:30:13 UTC (rev 13602)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java 2025-05-05 09:29:49 UTC (rev 13603)
@@ -116,14 +116,6 @@
}
/**
- * Indicates whether the font has been created.
- * @return True if and only if the {@link TrueTypeFont} instance has been instantiated.
- */
- public boolean ttfFontCreated() {
- return this.ttfFont != null;
- }
-
- /**
* Parses the font described by this table directory and stores the parsed instance in this for retrieval with
* {@link #getTTFFont()}.
* @throws IOException For I/O errors during parsing.
@@ -132,7 +124,7 @@
if (this.ttfFont != null) {
return;
}
- this.ttfFont = TrueTypeFont.parse(this, this.getTTFFile().getReader().getRandomInput());
+ this.ttfFont = TrueTypeFont.parse(this, this.container.getReader().getRandomInput());
}
/**
@@ -144,16 +136,6 @@
}
/**
- * Sets the TTFFont for this table directory.
- * @param newFont The TTFFont for this table directory.
- */
- public void setTTFFont(final TrueTypeFont newFont) {
- if (this.ttfFont == null) {
- this.ttfFont = newFont;
- }
- }
-
- /**
* Returns the parent TTFFile.
* @return The parent TTFFile.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-05 08:30:31
|
Revision: 13602
http://sourceforge.net/p/foray/code/13602
Author: victormote
Date: 2025-05-05 08:30:13 +0000 (Mon, 05 May 2025)
Log Message:
-----------
Rename TTC Header class to match the documentation.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcHeader.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-05 08:28:26 UTC (rev 13601)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-05 08:30:13 UTC (rev 13602)
@@ -49,7 +49,7 @@
public class TrueTypeCollection extends TrueTypeContainer {
/** The TTCHeader instance that represents this files TTC Header table. */
- private TtcTableHeader ttcHeader = null;
+ private TtcHeader ttcHeader = null;
/** Collection of TTFTableDirectory entries. There should be one entry for
* each logical font in the TTC file. */
@@ -78,7 +78,7 @@
* @throws IOException For I/O Error.
*/
protected void readFile(final TtfRandomAccessInput raInput) throws IOException {
- final ParserKit<TtcTableHeader, TtcHeaderHandler> parserKit = TtcTableHeader.createContentHandler();
+ final ParserKit<TtcHeader, TtcHeaderHandler> parserKit = TtcHeader.createContentHandler();
final TtcHeaderParser parser = new TtcHeaderParser();
/* Start parsing at the very beginning of the file. */
parser.parse(raInput, 0, parserKit.getHandler());
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcHeader.java (from rev 13601, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcHeader.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcHeader.java 2025-05-05 08:30:13 UTC (rev 13602)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf;
+
+import org.foray.fontParse.ttfHandler.TtcHeaderHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * A TTC (TrueType Collection) header.
+ */
+public final class TtcHeader extends RoTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements TtcHeaderHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private TtcHeader table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final TtcHeader table) {
+ this.table = table;
+ }
+
+ @Override
+ public void tableDirectoryOffsets(final @Unsigned int[] value) {
+ this.table.dirOffsets = value;
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+ /** Offsets to the directories. */
+ private @Unsigned int[] dirOffsets = null;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<TtcHeader, TtcHeaderHandler> createContentHandler() {
+ final TtcHeader table = new TtcHeader();
+ final TtcHeaderHandler handler = table.new ContentHandler(table);
+ return new ParserKit<TtcHeader, TtcHeaderHandler>(table, handler);
+ }
+
+ /**
+ * Returns the number of directories.
+ * @return The number of directories.
+ */
+ public int getNumDirectories() {
+ return this.dirOffsets.length;
+ }
+
+ /**
+ * Return the offset to a specific directory.
+ * @param directoryIndex The directory index.
+ * @return The offset to the directory.
+ */
+ public long getDirectoryOffset(final int directoryIndex) {
+ if (this.dirOffsets == null
+ || directoryIndex < 0
+ || directoryIndex >= this.dirOffsets.length) {
+ return Long.MIN_VALUE;
+ }
+ return this.dirOffsets[directoryIndex];
+ }
+
+}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java 2025-05-05 08:28:26 UTC (rev 13601)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java 2025-05-05 08:30:13 UTC (rev 13602)
@@ -1,107 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.ttf;
-
-import org.foray.fontParse.ttfHandler.TtcHeaderHandler;
-
-import org.checkerframework.checker.signedness.qual.Unsigned;
-
-/**
- * A TTC (TrueType Collection) header.
- */
-public final class TtcTableHeader extends RoTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ContentHandler implements TtcHeaderHandler {
-
- /** The table instance being created. */
- @SuppressWarnings("unused")
- private TtcTableHeader table;
-
- /**
- * Constructor.
- * @param table The table instance being created.
- */
- private ContentHandler(final TtcTableHeader table) {
- this.table = table;
- }
-
- @Override
- public void tableDirectoryOffsets(final @Unsigned int[] value) {
- this.table.dirOffsets = value;
- }
- }
-
-
-
-
-
-
-
-
-
-
- /** Offsets to the directories. */
- private @Unsigned int[] dirOffsets = null;
-
- /**
- * Creates a table instance and a content handler for that instance.
- * @return A new content handler.
- */
- public static ParserKit<TtcTableHeader, TtcHeaderHandler> createContentHandler() {
- final TtcTableHeader table = new TtcTableHeader();
- final TtcHeaderHandler handler = table.new ContentHandler(table);
- return new ParserKit<TtcTableHeader, TtcHeaderHandler>(table, handler);
- }
-
- /**
- * Returns the number of directories.
- * @return The number of directories.
- */
- public int getNumDirectories() {
- return this.dirOffsets.length;
- }
-
- /**
- * Return the offset to a specific directory.
- * @param directoryIndex The directory index.
- * @return The offset to the directory.
- */
- public long getDirectoryOffset(final int directoryIndex) {
- if (this.dirOffsets == null
- || directoryIndex < 0
- || directoryIndex >= this.dirOffsets.length) {
- return Long.MIN_VALUE;
- }
- return this.dirOffsets[directoryIndex];
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-05 08:28:43
|
Revision: 13601
http://sourceforge.net/p/foray/code/13601
Author: victormote
Date: 2025-05-05 08:28:26 +0000 (Mon, 05 May 2025)
Log Message:
-----------
Convert TtcHeader to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtcHeaderParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/TtcHeaderHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-04 22:23:02 UTC (rev 13600)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-05 08:28:26 UTC (rev 13601)
@@ -29,12 +29,13 @@
package org.foray.font.ttf;
-import org.foray.common.RandomAccessInput;
import org.foray.font.format.FontParser;
import org.foray.font.ttf.table.NameTable;
import org.foray.fontParse.ttf.NameTableParser;
+import org.foray.fontParse.ttf.TtcHeaderParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.NameTableHandler;
+import org.foray.fontParse.ttfHandler.TtcHeaderHandler;
import org.slf4j.LoggerFactory;
@@ -76,10 +77,14 @@
* @param raInput The input being parsed.
* @throws IOException For I/O Error.
*/
- protected void readFile(final RandomAccessInput raInput) throws IOException {
- this.ttcHeader = TtcTableHeader.parse(this, raInput);
- this.tableDirectories = new TableDirectory[
- this.ttcHeader.getNumDirectories()];
+ protected void readFile(final TtfRandomAccessInput raInput) throws IOException {
+ final ParserKit<TtcTableHeader, TtcHeaderHandler> parserKit = TtcTableHeader.createContentHandler();
+ final TtcHeaderParser parser = new TtcHeaderParser();
+ /* Start parsing at the very beginning of the file. */
+ parser.parse(raInput, 0, parserKit.getHandler());
+ this.ttcHeader = parserKit.getTable();
+
+ this.tableDirectories = new TableDirectory[this.ttcHeader.getNumDirectories()];
for (int i = 0; i < this.ttcHeader.getNumDirectories(); i++) {
final TableDirectory tableDir =
TableDirectory.parse(this, raInput, this.ttcHeader.getDirectoryOffset(i));
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java 2025-05-04 22:23:02 UTC (rev 13600)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java 2025-05-05 08:28:26 UTC (rev 13601)
@@ -28,61 +28,58 @@
package org.foray.font.ttf;
-import org.foray.common.RandomAccessInput;
+import org.foray.fontParse.ttfHandler.TtcHeaderHandler;
-import java.io.IOException;
+import org.checkerframework.checker.signedness.qual.Unsigned;
/**
* A TTC (TrueType Collection) header.
*/
-public final class TtcTableHeader {
+public final class TtcTableHeader extends RoTable {
- /** The parent TTCFile. */
- private TrueTypeCollection collection;
-
- /** Offsets to the directories. */
- private long[] dirOffsets = null;
-
/**
- * Constructor.
- * @param collection The parent TrueTypeCollection.
+ * The handler of events from the parser.
*/
- private TtcTableHeader(final TrueTypeCollection collection) {
- this.collection = collection;
- }
+ private final class ContentHandler implements TtcHeaderHandler {
- /**
- * Constructor.
- * @param collection The TTC file for which this table header is created.
- * @param raInput The input being parsed.
- * @return The parsed header instance.
- * @throws IOException For I/O Error.
- */
- public static TtcTableHeader parse(final TrueTypeCollection collection, final RandomAccessInput raInput)
- throws IOException {
- final TtcTableHeader ttcHeader = new TtcTableHeader(collection);
- /* Start at beginning of file. */
- raInput.seek(0);
- /* Skip TTCTag. */
- raInput.skipBytes(RoTable.FIXED_BYTES);
- /* Skip Version. */
- raInput.skipBytes(RoTable.FIXED_BYTES);
- /* Read DirectoryCount. */
- final int numDirectories = (int) raInput.readUnsignedInt();
- /* Read array of table directories. */
- ttcHeader.dirOffsets = new long[numDirectories];
- for (int i = 0; i < numDirectories; i++) {
- ttcHeader.dirOffsets[i] = raInput.readUnsignedInt();
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private TtcTableHeader table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final TtcTableHeader table) {
+ this.table = table;
}
- return ttcHeader;
+
+ @Override
+ public void tableDirectoryOffsets(final @Unsigned int[] value) {
+ this.table.dirOffsets = value;
+ }
}
+
+
+
+
+
+
+
+
+
+ /** Offsets to the directories. */
+ private @Unsigned int[] dirOffsets = null;
+
/**
- * Returns the parent TrueType collection.
- * @return The parent TrueType collection.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public TrueTypeCollection getCollection() {
- return this.collection;
+ public static ParserKit<TtcTableHeader, TtcHeaderHandler> createContentHandler() {
+ final TtcTableHeader table = new TtcTableHeader();
+ final TtcHeaderHandler handler = table.new ContentHandler(table);
+ return new ParserKit<TtcTableHeader, TtcHeaderHandler>(table, handler);
}
/**
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtcHeaderParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtcHeaderParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtcHeaderParser.java 2025-05-05 08:28:26 UTC (rev 13601)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.TtcHeaderHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Parses a TrueType Collection (TTC) Header.
+ */
+public class TtcHeaderParser extends TableParser<TtcHeaderHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final TtcHeaderHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+
+ /* TTC Header Version 1.0. */
+ handler.ttcTag(input.read_Tag()); // 4 bytes, 4 total
+ final @Unsigned short majorVersion = input.read_uint16(); // 2 bytes, 6 total
+ handler.majorVersion(majorVersion);
+ final @Unsigned short minorVersion = input.read_uint16(); // 2 bytes, 8 total
+ handler.minorVersion(minorVersion);
+
+ final @Unsigned int numFonts = input.read_uint32(); // 4 bytes, 12 total
+ handler.numFonts(numFonts);
+ final @Unsigned int[] tableDirectoryOffsets = new @Unsigned int[numFonts];
+ for (int index = 0; index < numFonts; index ++) {
+ final @Unsigned int tableDirectoryOffset = input.read_Offset32(); // 4 bytes @
+ handler.tableDirectoryOffset(tableDirectoryOffset);
+ tableDirectoryOffsets[index] = tableDirectoryOffset;
+ }
+ handler.tableDirectoryOffsets(tableDirectoryOffsets);
+
+
+ if (majorVersion < 2) {
+ return;
+ }
+
+
+ /* TTC Header Version 2.0.*/ // *** Restart Count ***
+ handler.dsigTag(input.read_uint32()); // 4 bytes, 4 total
+ handler.dsigLength(input.read_uint32()); // 4 bytes, 8 total
+ handler.dsigOffset(input.read_uint32()); // 4 bytes, 12 total
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtcHeaderParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/TtcHeaderHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/TtcHeaderHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/TtcHeaderHandler.java 2025-05-05 08:28:26 UTC (rev 13601)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.TtcHeaderParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link TtcHeaderParser}.
+ */
+public interface TtcHeaderHandler extends FontContentHandler {
+
+ default void ttcTag(final String value) { return; }
+ default void majorVersion(final @Unsigned short value) { return; }
+ default void minorVersion(final @Unsigned short value) { return; }
+ default void numFonts(final @Unsigned int value) { return; }
+
+ default void tableDirectoryOffset(final @Unsigned int value) { return; }
+ default void tableDirectoryOffsets(final @Unsigned int[] value) { return; }
+
+ default void dsigTag(final @Unsigned int value) { return; }
+ default void dsigLength(final @Unsigned int value) { return; }
+ default void dsigOffset(final @Unsigned int value) { return; }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/TtcHeaderHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 22:23:20
|
Revision: 13600
http://sourceforge.net/p/foray/code/13600
Author: victormote
Date: 2025-05-04 22:23:02 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Tighten up some differences between vector and bitmap graphics, using the new BitmapGraphic interface.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-04 21:15:45 UTC (rev 13599)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-04 22:23:02 UTC (rev 13600)
@@ -36,6 +36,7 @@
import org.foray.pdf.document.PdfDocument4a;
+import org.axsl.graphic.BitmapGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.pdf.PdfException;
@@ -55,7 +56,7 @@
public class PdfImageXobject extends PdfXobject4a {
/** The Graphic instance associated with this XObject. */
- private Graphic graphic;
+ private BitmapGraphic graphic;
/** The ICC stream. */
private PdfIccProfileStream pdfICCStream;
@@ -66,7 +67,7 @@
* @param graphic The graphic to be encapsulated.
* @throws GraphicException For errors getting the appropriate filter.
*/
- public PdfImageXobject(final PdfDocument4a doc, final Graphic graphic) throws GraphicException {
+ public PdfImageXobject(final PdfDocument4a doc, final BitmapGraphic graphic) throws GraphicException {
super(doc, graphic);
this.graphic = graphic;
final ColorSpace cs = getGraphic().getColorSpace();
@@ -163,7 +164,7 @@
}
@Override
- public Graphic getGraphic() {
+ public BitmapGraphic getGraphic() {
return this.graphic;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-04 21:15:45 UTC (rev 13599)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-04 22:23:02 UTC (rev 13600)
@@ -38,6 +38,7 @@
import org.foray.pdf.type.PdfStream;
import org.axsl.font.FontConsumer;
+import org.axsl.graphic.BitmapGraphic;
import org.axsl.graphic.EpsGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
@@ -114,12 +115,15 @@
xObject = new PdfXformMath(pdfDoc, mathGraphic, orthography, fontConsumer);
} else if (img.getGraphicType() == Graphic.Type.PDF) {
xObject = new PdfXreference(pdfDoc, img);
+ } else if (img instanceof BitmapGraphic) {
+ final BitmapGraphic bitmapGraphic = (BitmapGraphic) img;
+// /* The following line is bogus, and is intended only to make sure
+// * that no exceptions are thrown. If there are any exceptions
+// * thrown, we don't want to create the xObject. */
+// img.getColorSpace();
+ xObject = new PdfImageXobject(pdfDoc, bitmapGraphic);
} else {
- /* The following line is bogus, and is intended only to make sure
- * that no exceptions are thrown. If there are any exceptions
- * thrown, we don't want to create the xObject. */
- img.getColorSpace();
- xObject = new PdfImageXobject(pdfDoc, img);
+ throw new GraphicException("Unsupported Graphic Type: " + img.getGraphicType());
}
xObject.filter = xObject.getFilter(xObject.getOutputStream(), pdfDoc);
return xObject;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2025-05-04 21:15:45 UTC (rev 13599)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2025-05-04 22:23:02 UTC (rev 13600)
@@ -50,6 +50,7 @@
import org.axsl.galley.PageG5;
import org.axsl.galley.metadata.BookmarkTreeG5;
import org.axsl.galley.render.GalleyVisitorException;
+import org.axsl.graphic.BitmapGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.output.DocumentConfiguration;
@@ -385,7 +386,7 @@
* @return True if and only if the printing is successful.
* @throws GraphicException For errors during printing.
*/
- boolean printBMP(final Graphic img, final int x, final int y, final int w,
+ boolean printBMP(final BitmapGraphic img, final int x, final int y, final int w,
final int h) throws GraphicException {
// Print the passed image file in PCL.
final ByteSequence imgmap = img.getContent();
@@ -527,6 +528,10 @@
final int h = area.crBpd();
final Graphic img = area.getGraphic();
+ if (! (img instanceof BitmapGraphic)) {
+ return null;
+ }
+ final BitmapGraphic bitmap = (BitmapGraphic) img;
int xpos = this.xoffset + (x / TypographicConstants.DECIPOINTS_PER_POINT);
if (xpos < 0) {
@@ -539,7 +544,7 @@
+ "V");
try {
- printBMP(img, x, y, w, h);
+ printBMP(bitmap, x, y, w, h);
} catch (final GraphicException e) {
logError("PclRenderer.renderImageArea() Error printing "
+ "BMP (" + e.toString() + ")");
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-04 21:15:45 UTC (rev 13599)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-04 22:23:02 UTC (rev 13600)
@@ -55,6 +55,7 @@
import org.axsl.galley.PageG5;
import org.axsl.galley.metadata.BookmarkTreeG5;
import org.axsl.galley.render.GalleyVisitorException;
+import org.axsl.graphic.BitmapGraphic;
import org.axsl.graphic.EpsGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
@@ -588,9 +589,10 @@
renderEPS((EpsGraphic) image, contentRectangle.x,
contentRectangle.y, contentRectangle.width,
contentRectangle.height);
- } else {
+ } else if (image instanceof BitmapGraphic) {
+ final BitmapGraphic bitmap = (BitmapGraphic) image;
try {
- renderBitmap(image, contentRectangle.x, contentRectangle.y,
+ renderBitmap(bitmap, contentRectangle.x, contentRectangle.y,
contentRectangle.width, contentRectangle.height);
} catch (final IOException e) {
throw new GalleyVisitorException(e);
@@ -727,7 +729,7 @@
* drawn.
* @throws IOException For errors writing to output.
*/
- public void renderBitmap(final Graphic img, final int x, final int y,
+ public void renderBitmap(final BitmapGraphic img, final int x, final int y,
final int w, final int h) throws IOException {
try {
final boolean iscolor = img.getColorSpace().getType()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 21:16:03
|
Revision: 13599
http://sourceforge.net/p/foray/code/13599
Author: victormote
Date: 2025-05-04 21:15:45 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Utilize new BitmapGraphic marker interface.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java
Added: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic;
+
+import org.axsl.graphic.BitmapGraphic;
+
+import java.io.BufferedInputStream;
+import java.net.URL;
+
+/**
+ * Abstract superclass for bitmap graphic implementations.
+ */
+public abstract class BitmapGraphic4a extends Graphic4a implements BitmapGraphic {
+
+ /**
+ * Constructor.
+ * @param server The parent graphic server.
+ * @param url The URL which contains the graphic content.
+ * @param bis The reusable input stream containing the bytes from {@code url}.
+ */
+ public BitmapGraphic4a(final GraphicServer4a server, final URL url, final BufferedInputStream bis) {
+ super(server, url, bis);
+ }
+
+}
Property changes on: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-04 14:02:24 UTC (rev 13598)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -50,7 +50,7 @@
/**
* A BMP (bitmap) image.
*/
-public class BmpGraphic extends Graphic4a {
+public class BmpGraphic extends BitmapGraphic4a {
/** The length, in bytes, of the headermap. */
private static final int HEADERMAP_LENGTH = 54;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2025-05-04 14:02:24 UTC (rev 13598)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -52,7 +52,7 @@
* @author Modified by Eric Dalquist - 9/14/2001 - ebd...@mt...
* @see Graphic4a
*/
-public class GifGraphic extends Graphic4a {
+public class GifGraphic extends BitmapGraphic4a {
/** The number of bytes that need to be read to get the basic information
* for a GIF file. */
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2025-05-04 14:02:24 UTC (rev 13598)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -56,7 +56,7 @@
/**
* A JPEG image, using Java native classes.
*/
-public class JpegGraphic extends Graphic4a {
+public class JpegGraphic extends BitmapGraphic4a {
/** The size, in bytes, of the read buffer that should be used to read a
* JPEG file. */
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-04 14:02:24 UTC (rev 13598)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -44,7 +44,7 @@
/**
* A graphic encapsulated in a PDF document.
*/
-public class PdfGraphic extends Graphic4a {
+public class PdfGraphic extends VectorGraphic4a {
/** The default size, in bytes, of the read buffer to be used when reading
* a PDF file. */
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java 2025-05-04 14:02:24 UTC (rev 13598)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -58,7 +58,7 @@
/**
* A PNG (Portable Network Graphics) images.
*/
-public class PngGraphic extends Graphic4a {
+public class PngGraphic extends BitmapGraphic4a {
/** The number of bytes that need to be read to get the basic information
* for a PNG file. */
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-04 14:02:24 UTC (rev 13598)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-04 21:15:45 UTC (rev 13599)
@@ -60,7 +60,7 @@
* A TIFF image.
*/
-public class TiffGraphic extends Graphic4a {
+public class TiffGraphic extends BitmapGraphic4a {
/** Constant indicating that the image is uncompressed.
* @see "Graphics File Formats, 2nd Edition, O'Reilly, 1996, p. 891."
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 14:02:43
|
Revision: 13598
http://sourceforge.net/p/foray/code/13598
Author: victormote
Date: 2025-05-04 14:02:24 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Rename classes for output of vector graphics, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PsFactory.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 13:59:28 UTC (rev 13597)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -38,9 +38,9 @@
import org.foray.graphic.factory.PngFactory;
import org.foray.graphic.factory.SvgFactory;
import org.foray.graphic.factory.TiffFactory;
-import org.foray.graphic.output.GraphicJava2dFactory;
-import org.foray.graphic.output.GraphicPdfFactory;
-import org.foray.graphic.output.GraphicPsFactory;
+import org.foray.graphic.output.VectorOutput2Java2dFactory;
+import org.foray.graphic.output.VectorOutput2PdfFactory;
+import org.foray.graphic.output.VectorOutput2PsFactory;
import org.foray.graphic.output.VectorOutputFactory;
import org.foray.xml.SaxParser4a;
@@ -153,9 +153,9 @@
* Registers each of the standard output factories.
*/
private void registerStandardOutputFactories() {
- this.registerGraphicOutputFactory(new GraphicPdfFactory());
- this.registerGraphicOutputFactory(new GraphicPsFactory());
- this.registerGraphicOutputFactory(new GraphicJava2dFactory());
+ this.registerGraphicOutputFactory(new VectorOutput2PdfFactory());
+ this.registerGraphicOutputFactory(new VectorOutput2PsFactory());
+ this.registerGraphicOutputFactory(new VectorOutput2Java2dFactory());
}
@Override
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -1,65 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.graphic.Graphic4a;
-import org.foray.graphic.SvgGraphic4a;
-
-import org.axsl.constants.MimeConstants;
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-
-/**
- * Factory for creating instances of GraphicOutput for PostScript output.
- */
-public class GraphicJava2dFactory extends VectorOutputFactory {
-
- /**
- * Constructor.
- */
- public GraphicJava2dFactory() {
- }
-
- @Override
- public VectorOutput2Java2d4a createGraphicOutput(final Graphic graphic)
- throws GraphicException {
- final Graphic4a graphic4a = super.getGraphic4a(graphic);
- if (graphic4a instanceof SvgGraphic4a) {
- final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
- return new SvgOutput2Java2d(svgGraphic);
- }
- return null;
- }
-
- @Override
- public String getMimeType() {
- return MimeConstants.MIME_JAVA2D;
- }
-
-}
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -1,70 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.graphic.Graphic4a;
-import org.foray.graphic.MathGraphic4a;
-import org.foray.graphic.SvgGraphic4a;
-
-import org.axsl.constants.MimeConstants;
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-
-/**
- * Factory for creating instances of GraphicOutput for PDF output.
- */
-public class GraphicPdfFactory extends VectorOutputFactory {
-
- /**
- * Constructor.
- */
- public GraphicPdfFactory() {
- }
-
- @Override
- public VectorOutput2Pdf4a createGraphicOutput(final Graphic graphic)
- throws GraphicException {
- final Graphic4a graphic4a = super.getGraphic4a(graphic);
- if (graphic4a instanceof SvgGraphic4a) {
- final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
- return new SvgOutput2Pdf(svgGraphic);
- }
- if (graphic4a instanceof MathGraphic4a) {
- final MathGraphic4a mathGraphic = (MathGraphic4a) graphic4a;
- return new SvgOutput2Pdf(mathGraphic.getSvgGraphic());
- }
- return null;
- }
-
- @Override
- public String getMimeType() {
- return MimeConstants.MIME_PDF;
- }
-
-}
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -1,65 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.graphic.Graphic4a;
-import org.foray.graphic.SvgGraphic4a;
-
-import org.axsl.constants.MimeConstants;
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-
-/**
- * Factory for creating instances of GraphicOutput for PostScript output.
- */
-public class GraphicPsFactory extends VectorOutputFactory {
-
- /**
- * Constructor.
- */
- public GraphicPsFactory() {
- }
-
- @Override
- public VectorOutput2Ps4a createGraphicOutput(final Graphic graphic)
- throws GraphicException {
- final Graphic4a graphic4a = super.getGraphic4a(graphic);
- if (graphic4a instanceof SvgGraphic4a) {
- final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
- return new SvgOutput2Ps(svgGraphic);
- }
- return null;
- }
-
- @Override
- public String getMimeType() {
- return MimeConstants.MIME_POSTSCRIPT;
- }
-
-}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2dFactory.java (from rev 13597, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2dFactory.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2dFactory.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.graphic.Graphic4a;
+import org.foray.graphic.SvgGraphic4a;
+
+import org.axsl.constants.MimeConstants;
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+
+/**
+ * Factory for creating instances of GraphicOutput for PostScript output.
+ */
+public class VectorOutput2Java2dFactory extends VectorOutputFactory {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput2Java2dFactory() {
+ }
+
+ @Override
+ public VectorOutput2Java2d4a createGraphicOutput(final Graphic graphic)
+ throws GraphicException {
+ final Graphic4a graphic4a = super.getGraphic4a(graphic);
+ if (graphic4a instanceof SvgGraphic4a) {
+ final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
+ return new SvgOutput2Java2d(svgGraphic);
+ }
+ return null;
+ }
+
+ @Override
+ public String getMimeType() {
+ return MimeConstants.MIME_JAVA2D;
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PdfFactory.java (from rev 13597, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PdfFactory.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PdfFactory.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.graphic.Graphic4a;
+import org.foray.graphic.MathGraphic4a;
+import org.foray.graphic.SvgGraphic4a;
+
+import org.axsl.constants.MimeConstants;
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+
+/**
+ * Factory for creating instances of GraphicOutput for PDF output.
+ */
+public class VectorOutput2PdfFactory extends VectorOutputFactory {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput2PdfFactory() {
+ }
+
+ @Override
+ public VectorOutput2Pdf4a createGraphicOutput(final Graphic graphic)
+ throws GraphicException {
+ final Graphic4a graphic4a = super.getGraphic4a(graphic);
+ if (graphic4a instanceof SvgGraphic4a) {
+ final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
+ return new SvgOutput2Pdf(svgGraphic);
+ }
+ if (graphic4a instanceof MathGraphic4a) {
+ final MathGraphic4a mathGraphic = (MathGraphic4a) graphic4a;
+ return new SvgOutput2Pdf(mathGraphic.getSvgGraphic());
+ }
+ return null;
+ }
+
+ @Override
+ public String getMimeType() {
+ return MimeConstants.MIME_PDF;
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PsFactory.java (from rev 13597, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PsFactory.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2PsFactory.java 2025-05-04 14:02:24 UTC (rev 13598)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.graphic.Graphic4a;
+import org.foray.graphic.SvgGraphic4a;
+
+import org.axsl.constants.MimeConstants;
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+
+/**
+ * Factory for creating instances of GraphicOutput for PostScript output.
+ */
+public class VectorOutput2PsFactory extends VectorOutputFactory {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput2PsFactory() {
+ }
+
+ @Override
+ public VectorOutput2Ps4a createGraphicOutput(final Graphic graphic)
+ throws GraphicException {
+ final Graphic4a graphic4a = super.getGraphic4a(graphic);
+ if (graphic4a instanceof SvgGraphic4a) {
+ final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
+ return new SvgOutput2Ps(svgGraphic);
+ }
+ return null;
+ }
+
+ @Override
+ public String getMimeType() {
+ return MimeConstants.MIME_POSTSCRIPT;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 13:59:45
|
Revision: 13597
http://sourceforge.net/p/foray/code/13597
Author: victormote
Date: 2025-05-04 13:59:28 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Rename class for output of vector graphics, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutputFactory.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 13:51:56 UTC (rev 13596)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -39,9 +39,9 @@
import org.foray.graphic.factory.SvgFactory;
import org.foray.graphic.factory.TiffFactory;
import org.foray.graphic.output.GraphicJava2dFactory;
-import org.foray.graphic.output.GraphicOutputFactory;
import org.foray.graphic.output.GraphicPdfFactory;
import org.foray.graphic.output.GraphicPsFactory;
+import org.foray.graphic.output.VectorOutputFactory;
import org.foray.xml.SaxParser4a;
import org.axsl.constants.XmlConstants;
@@ -110,8 +110,8 @@
* The {@link MathMLDocument} is the key, and the {@link MathGraphic} instance is the value. */
private Map<MathMLDocument, MathGraphic> mathDocumentMap = new HashMap<MathMLDocument, MathGraphic>();
- /** Map of registered {@link GraphicOutputFactory} instances. */
- private Map<String, GraphicOutputFactory> graphicOutputFactories = new HashMap<String, GraphicOutputFactory>();
+ /** Map of registered {@link VectorOutputFactory} instances. */
+ private Map<String, VectorOutputFactory> graphicOutputFactories = new HashMap<String, VectorOutputFactory>();
/**
* Constructor.
@@ -294,7 +294,7 @@
}
/**
- * Registers a {@link GraphicOutputFactory} for use by this server.
+ * Registers a {@link VectorOutputFactory} for use by this server.
* This method can be used both to support custom {@link VectorOutput}
* types and to override standard types.
* Note that if a factory was previously registered for the mime-type
@@ -306,7 +306,7 @@
* @param factory The factory which should be registered.
*/
public void registerGraphicOutputFactory(
- final GraphicOutputFactory factory) {
+ final VectorOutputFactory factory) {
if (factory == null) {
throw new NullPointerException("Cannot register a null "
+ "GraphicOutputFactory");
@@ -327,12 +327,12 @@
* @return The appropriate output factory, or null if none is registered
* for the mime type.
*/
- public GraphicOutputFactory getOutputFactory(final String mimeType) {
+ public VectorOutputFactory getOutputFactory(final String mimeType) {
return this.graphicOutputFactories.get(mimeType);
}
/**
- * Reports on the availability of {@link GraphicOutputFactory} instances
+ * Reports on the availability of {@link VectorOutputFactory} instances
* by mime-type.
* @param mimeType The mime-type for which a factory is sought.
* @return True if and only if a factory has already been registered for the given
@@ -339,7 +339,7 @@
* mime-type.
*/
public boolean graphicOutputFactoryAvailable(final String mimeType) {
- final GraphicOutputFactory factory = getOutputFactory(mimeType);
+ final VectorOutputFactory factory = getOutputFactory(mimeType);
return factory != null;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java 2025-05-04 13:51:56 UTC (rev 13596)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -28,7 +28,7 @@
package org.foray.graphic;
-import org.foray.graphic.output.GraphicOutputFactory;
+import org.foray.graphic.output.VectorOutputFactory;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.VectorGraphic;
@@ -54,7 +54,7 @@
@Override
public VectorOutput getVectorOutput(final String mimeType) {
- final GraphicOutputFactory factory = getServer().getOutputFactory(mimeType);
+ final VectorOutputFactory factory = getServer().getOutputFactory(mimeType);
if (factory == null) {
throw new UnsupportedOperationException("Unable to create GraphicOutput instance for: " + mimeType);
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -38,7 +38,7 @@
/**
* Factory for creating instances of GraphicOutput for PostScript output.
*/
-public class GraphicJava2dFactory extends GraphicOutputFactory {
+public class GraphicJava2dFactory extends VectorOutputFactory {
/**
* Constructor.
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -1,85 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.graphic.Graphic4a;
-
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.output.VectorOutput;
-
-/**
- * Abstract superclass for the FOray GraphicOutputFactory implementations.
- */
-public abstract class GraphicOutputFactory {
-
- /**
- * Constructor.
- */
- public GraphicOutputFactory() {
- }
-
- /**
- * Returns the mime-type for this factory.
- * @return The mime type for which this factory generates {@link VectorOutput} instances.
- * For example, a factory returning {@link VectorOutput} instances for
- * use with PDF (Portable Document Format) should return "application/pdf".
- * @see <a href="http://www.iana.org/assignments/media-types/">Internet
- * Assigned Numbers Authority MIME Media Types</a>
- */
- public abstract String getMimeType();
-
- /**
- * Create a GraphicOutput implementation.
- * This method is not intended for use by client applications.
- * It is to be used only by Graphic implementations if they do not already have a GraphicOutput for the desired mime
- * type.
- * Client applications that need a GraphicOutput instance should instead use
- * {@link Graphic#getVectorOutput(String)}.
- * @param graphic The Graphic instance for which the VectorOutput instance should be created.
- * @return A VectorOutput implementation suitable for this factory's mime type.
- * @throws GraphicException For errors during creation of the VectorOutput instance.
- */
- public abstract VectorOutput createGraphicOutput(Graphic graphic) throws GraphicException;
-
- /**
- * Returns the {@link Graphic} instance, cast as a {@link Graphic4a}.
- * @param graphic The {@link Graphic} instance to be recast.
- * @return The {@code graphic} recast.
- * @throws GraphicException If {@code graphic} is not an instanceof {@link Graphic4a}.
- */
- public Graphic4a getGraphic4a(final Graphic graphic)
- throws GraphicException {
- if (! (graphic instanceof Graphic4a)) {
- throw new GraphicException("Unknown Graphic implementation.");
- }
- return (Graphic4a) graphic;
- }
-
-}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -39,7 +39,7 @@
/**
* Factory for creating instances of GraphicOutput for PDF output.
*/
-public class GraphicPdfFactory extends GraphicOutputFactory {
+public class GraphicPdfFactory extends VectorOutputFactory {
/**
* Constructor.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -38,7 +38,7 @@
/**
* Factory for creating instances of GraphicOutput for PostScript output.
*/
-public class GraphicPsFactory extends GraphicOutputFactory {
+public class GraphicPsFactory extends VectorOutputFactory {
/**
* Constructor.
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutputFactory.java (from rev 13593, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutputFactory.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutputFactory.java 2025-05-04 13:59:28 UTC (rev 13597)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.graphic.Graphic4a;
+
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.output.VectorOutput;
+
+/**
+ * Abstract superclass for the FOray GraphicOutputFactory implementations.
+ */
+public abstract class VectorOutputFactory {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutputFactory() {
+ }
+
+ /**
+ * Returns the mime-type for this factory.
+ * @return The mime type for which this factory generates {@link VectorOutput} instances.
+ * For example, a factory returning {@link VectorOutput} instances for
+ * use with PDF (Portable Document Format) should return "application/pdf".
+ * @see <a href="http://www.iana.org/assignments/media-types/">Internet
+ * Assigned Numbers Authority MIME Media Types</a>
+ */
+ public abstract String getMimeType();
+
+ /**
+ * Create a GraphicOutput implementation.
+ * This method is not intended for use by client applications.
+ * It is to be used only by Graphic implementations if they do not already have a GraphicOutput for the desired mime
+ * type.
+ * Client applications that need a GraphicOutput instance should instead use
+ * {@link Graphic#getVectorOutput(String)}.
+ * @param graphic The Graphic instance for which the VectorOutput instance should be created.
+ * @return A VectorOutput implementation suitable for this factory's mime type.
+ * @throws GraphicException For errors during creation of the VectorOutput instance.
+ */
+ public abstract VectorOutput createGraphicOutput(Graphic graphic) throws GraphicException;
+
+ /**
+ * Returns the {@link Graphic} instance, cast as a {@link Graphic4a}.
+ * @param graphic The {@link Graphic} instance to be recast.
+ * @return The {@code graphic} recast.
+ * @throws GraphicException If {@code graphic} is not an instanceof {@link Graphic4a}.
+ */
+ public Graphic4a getGraphic4a(final Graphic graphic)
+ throws GraphicException {
+ if (! (graphic instanceof Graphic4a)) {
+ throw new GraphicException("Unknown Graphic implementation.");
+ }
+ return (Graphic4a) graphic;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 13:52:13
|
Revision: 13596
http://sourceforge.net/p/foray/code/13596
Author: victormote
Date: 2025-05-04 13:51:56 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Rename classes for output of vector graphics, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Java2d.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Pdf.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Ps.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:49:08 UTC (rev 13595)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -52,7 +52,7 @@
final Graphic4a graphic4a = super.getGraphic4a(graphic);
if (graphic4a instanceof SvgGraphic4a) {
final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
- return new SvgJava2d(svgGraphic);
+ return new SvgOutput2Java2d(svgGraphic);
}
return null;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:49:08 UTC (rev 13595)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -53,11 +53,11 @@
final Graphic4a graphic4a = super.getGraphic4a(graphic);
if (graphic4a instanceof SvgGraphic4a) {
final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
- return new SvgPdf(svgGraphic);
+ return new SvgOutput2Pdf(svgGraphic);
}
if (graphic4a instanceof MathGraphic4a) {
final MathGraphic4a mathGraphic = (MathGraphic4a) graphic4a;
- return new SvgPdf(mathGraphic.getSvgGraphic());
+ return new SvgOutput2Pdf(mathGraphic.getSvgGraphic());
}
return null;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:49:08 UTC (rev 13595)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -52,7 +52,7 @@
final Graphic4a graphic4a = super.getGraphic4a(graphic);
if (graphic4a instanceof SvgGraphic4a) {
final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
- return new SvgPs(svgGraphic);
+ return new SvgOutput2Ps(svgGraphic);
}
return null;
}
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2025-05-04 13:49:08 UTC (rev 13595)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -1,124 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.graphic.SvgGraphic4a;
-import org.foray.graphic.batik.BatikUaAwt;
-
-import org.axsl.graphic.GraphicException;
-
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.bridge.ViewBox;
-import org.apache.batik.gvt.GraphicsNode;
-import org.w3c.dom.svg.SVGDocument;
-import org.w3c.dom.svg.SVGSVGElement;
-
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
-import java.awt.geom.Rectangle2D;
-
-/**
- * Helper class for applications using SVG in Java2d output.
- */
-public class SvgJava2d extends VectorOutput2Java2d4a {
-
- /** The encapsulated SVG graphic. */
- private SvgGraphic4a svg;
-
- /**
- * Constructor.
- * @param svg The encapsulated SVG graphic.
- */
- SvgJava2d(final SvgGraphic4a svg) {
- this.svg = svg;
- }
-
- @Override
- public SvgGraphic4a getGraphic() {
- return this.svg;
- }
-
- @Override
- public void drawGraphic(final Graphics2D graphics,
- final Rectangle2D.Float contentRectangle) throws GraphicException {
- final SVGDocument svgDocument = this.svg.getSvgDocument();
- final float x = contentRectangle.x;
- final float y = contentRectangle.y;
- final float w = contentRectangle.width;
- final float h = contentRectangle.height;
- final GraphicsNode root = getGraphicsNode(svgDocument);
- if (root == null) {
- return;
- }
-
- graphics.translate(x, y);
-
- final SVGSVGElement svg = svgDocument.getRootElement();
- final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg, w, h, null);
- AffineTransform inverse = null;
- try {
- inverse = at.createInverse();
- } catch (final NoninvertibleTransformException e) {
- }
- if (! at.isIdentity()) {
- graphics.transform(at);
- }
-
- root.paint(graphics);
-
- if (inverse != null && !inverse.isIdentity()) {
- graphics.transform(inverse);
- }
- graphics.translate(-x, -y);
- }
-
- /**
- * Returns the Batik GraphicsNode to be used.
- * @param doc The SVG document.
- * @return The Batik GraphicsNode.
- */
- protected GraphicsNode getGraphicsNode(final SVGDocument doc) {
- final BridgeContext ctx = makeBridgeContextAWT();
- final GVTBuilder builder = new GVTBuilder();
- return builder.build(ctx, doc);
- }
-
- /**
- * Creates a BridgeContext instance suitable for use by Batik when rendering
- * an SVG graphic in an AWT environment.
- * @return A Batik BridgeContext instance.
- */
- public BridgeContext makeBridgeContextAWT() {
- final BatikUaAwt userAgent = new BatikUaAwt(new AffineTransform());
- return new BridgeContext(userAgent);
- }
-
-}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Java2d.java (from rev 13595, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Java2d.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Java2d.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.graphic.SvgGraphic4a;
+import org.foray.graphic.batik.BatikUaAwt;
+
+import org.axsl.graphic.GraphicException;
+
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.bridge.ViewBox;
+import org.apache.batik.gvt.GraphicsNode;
+import org.w3c.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGSVGElement;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Helper class for applications using SVG in Java2d output.
+ */
+public class SvgOutput2Java2d extends VectorOutput2Java2d4a {
+
+ /** The encapsulated SVG graphic. */
+ private SvgGraphic4a svg;
+
+ /**
+ * Constructor.
+ * @param svg The encapsulated SVG graphic.
+ */
+ SvgOutput2Java2d(final SvgGraphic4a svg) {
+ this.svg = svg;
+ }
+
+ @Override
+ public SvgGraphic4a getGraphic() {
+ return this.svg;
+ }
+
+ @Override
+ public void drawGraphic(final Graphics2D graphics,
+ final Rectangle2D.Float contentRectangle) throws GraphicException {
+ final SVGDocument svgDocument = this.svg.getSvgDocument();
+ final float x = contentRectangle.x;
+ final float y = contentRectangle.y;
+ final float w = contentRectangle.width;
+ final float h = contentRectangle.height;
+ final GraphicsNode root = getGraphicsNode(svgDocument);
+ if (root == null) {
+ return;
+ }
+
+ graphics.translate(x, y);
+
+ final SVGSVGElement svg = svgDocument.getRootElement();
+ final AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg, w, h, null);
+ AffineTransform inverse = null;
+ try {
+ inverse = at.createInverse();
+ } catch (final NoninvertibleTransformException e) {
+ }
+ if (! at.isIdentity()) {
+ graphics.transform(at);
+ }
+
+ root.paint(graphics);
+
+ if (inverse != null && !inverse.isIdentity()) {
+ graphics.transform(inverse);
+ }
+ graphics.translate(-x, -y);
+ }
+
+ /**
+ * Returns the Batik GraphicsNode to be used.
+ * @param doc The SVG document.
+ * @return The Batik GraphicsNode.
+ */
+ protected GraphicsNode getGraphicsNode(final SVGDocument doc) {
+ final BridgeContext ctx = makeBridgeContextAWT();
+ final GVTBuilder builder = new GVTBuilder();
+ return builder.build(ctx, doc);
+ }
+
+ /**
+ * Creates a BridgeContext instance suitable for use by Batik when rendering
+ * an SVG graphic in an AWT environment.
+ * @return A Batik BridgeContext instance.
+ */
+ public BridgeContext makeBridgeContextAWT() {
+ final BatikUaAwt userAgent = new BatikUaAwt(new AffineTransform());
+ return new BridgeContext(userAgent);
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Pdf.java (from rev 13595, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Pdf.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Pdf.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.common.Environment;
+import org.foray.graphic.SvgGraphic4a;
+import org.foray.graphic.batik.BatikUaDocument;
+import org.foray.graphic.batik.PdfTextPainter;
+import org.foray.graphic.batik.PdfaElementBridge;
+
+import org.axsl.font.FontConsumer;
+import org.axsl.graphic.GraphicException;
+import org.axsl.orthography.Orthography;
+
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.bridge.StrokingTextPainter;
+import org.apache.batik.bridge.TextPainter;
+import org.apache.batik.gvt.GraphicsNode;
+import org.w3c.dom.svg.SVGDocument;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+
+/**
+ * Helper class for applications using or embedding SVG in PDF output.
+ */
+public class SvgOutput2Pdf extends VectorOutput2Pdf4a {
+
+ /** The encapsulated SVG graphic. */
+ private SvgGraphic4a svg;
+
+ /**
+ * Constructor.
+ * @param svg The encapsulated SVG graphic.
+ */
+ SvgOutput2Pdf(final SvgGraphic4a svg) {
+ this.svg = svg;
+ }
+
+ @Override
+ public SvgGraphic4a getGraphic() {
+ return this.svg;
+ }
+
+ @Override
+ public void drawVectorContent(final Graphics2D graphic2d, final FontConsumer fontConsumer,
+ final Orthography orthography) throws GraphicException {
+ /* If not running in a graphical environment, log an error message
+ * and skip the SVG. */
+ if (! Environment.isGraphicalEnvironment()) {
+ this.svg.getServer().logError("Unable to get Graphical Environment required to process SVG. Skipping.");
+ return;
+ }
+
+ final SVGDocument svgDocument = this.svg.getSvgDocument();
+
+ final BatikUaDocument userAgent = new BatikUaDocument(new AffineTransform());
+ BridgeContext ctx = new BridgeContext(userAgent);
+ GVTBuilder builder = new GVTBuilder();
+ TextPainter textPainter = null;
+ if (fontConsumer == null) {
+ textPainter = new StrokingTextPainter();
+ } else {
+ textPainter = new PdfTextPainter(fontConsumer, orthography);
+ }
+ ctx.setTextPainter(textPainter);
+
+ final PdfaElementBridge aBridge = new PdfaElementBridge();
+ ctx.putBridge(aBridge);
+
+ final GraphicsNode root = builder.build(ctx, svgDocument);
+ ctx = null;
+ builder = null;
+
+ root.paint(graphic2d);
+ graphic2d.dispose();
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Ps.java (from rev 13595, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Ps.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgOutput2Ps.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.foray.common.CharacterOutputStream;
+import org.foray.graphic.SvgGraphic4a;
+import org.foray.graphic.batik.BatikUaDocument;
+import org.foray.graphic.batik.PsGraphics2D;
+
+import org.axsl.font.FontConsumer;
+import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.output.VectorOutputContext;
+
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.GVTBuilder;
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.w3c.dom.svg.SVGDocument;
+
+import java.awt.geom.AffineTransform;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Helper class for applications using or embedding SVG in PostScript output.
+ */
+public class SvgOutput2Ps extends VectorOutput2Ps4a {
+
+ /** The encapsulated SVG graphic. */
+ private SvgGraphic4a svg;
+
+ /**
+ * Constructor.
+ * @param svg The encapsulated SVG graphic.
+ */
+ SvgOutput2Ps(final SvgGraphic4a svg) {
+ this.svg = svg;
+ }
+
+ @Override
+ public SvgGraphic4a getGraphic() {
+ return this.svg;
+ }
+
+ @Override
+ public void drawVectorContent(final OutputStream output,
+ final VectorOutputContext outputContext,
+ final FontConsumer fontConsumer, final boolean strokeText,
+ final boolean commentsEnabled) throws GraphicException {
+ SVGDocument doc = null;
+ try {
+ doc = this.svg.getSvgDocument();
+ } catch (final GraphicException e) {
+ this.svg.getServer().logError("Error getting SVGDocument in " + this.getClass().getName());
+ return;
+ }
+ BridgeContext ctx = makeBridgeContext();
+ GVTBuilder builder = new GVTBuilder();
+
+ final GraphicsNode root;
+ root = builder.build(ctx, doc);
+ ctx = null;
+ builder = null;
+
+ final CharacterOutputStream cos = new CharacterOutputStream(output, commentsEnabled);
+ final PsGraphics2D graphics = new PsGraphics2D(false, cos);
+ graphics.setGraphicContext(new GraphicContext());
+ root.paint(graphics);
+ try {
+ cos.close();
+ } catch (final IOException e) {
+ throw new GraphicException(e);
+ }
+ }
+
+ /**
+ * Creates a BridgeContext instance for use by Batik when rendering an SVG
+ * graphic.
+ * @return A Batik BridgeContext instance.
+ */
+ public BridgeContext makeBridgeContext() {
+ final BatikUaDocument userAgent = new BatikUaDocument(new AffineTransform());
+ return new BridgeContext(userAgent);
+ }
+
+}
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2025-05-04 13:49:08 UTC (rev 13595)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -1,106 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.common.Environment;
-import org.foray.graphic.SvgGraphic4a;
-import org.foray.graphic.batik.BatikUaDocument;
-import org.foray.graphic.batik.PdfTextPainter;
-import org.foray.graphic.batik.PdfaElementBridge;
-
-import org.axsl.font.FontConsumer;
-import org.axsl.graphic.GraphicException;
-import org.axsl.orthography.Orthography;
-
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.bridge.StrokingTextPainter;
-import org.apache.batik.bridge.TextPainter;
-import org.apache.batik.gvt.GraphicsNode;
-import org.w3c.dom.svg.SVGDocument;
-
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-
-/**
- * Helper class for applications using or embedding SVG in PDF output.
- */
-public class SvgPdf extends VectorOutput2Pdf4a {
-
- /** The encapsulated SVG graphic. */
- private SvgGraphic4a svg;
-
- /**
- * Constructor.
- * @param svg The encapsulated SVG graphic.
- */
- SvgPdf(final SvgGraphic4a svg) {
- this.svg = svg;
- }
-
- @Override
- public SvgGraphic4a getGraphic() {
- return this.svg;
- }
-
- @Override
- public void drawVectorContent(final Graphics2D graphic2d, final FontConsumer fontConsumer,
- final Orthography orthography) throws GraphicException {
- /* If not running in a graphical environment, log an error message
- * and skip the SVG. */
- if (! Environment.isGraphicalEnvironment()) {
- this.svg.getServer().logError("Unable to get Graphical Environment required to process SVG. Skipping.");
- return;
- }
-
- final SVGDocument svgDocument = this.svg.getSvgDocument();
-
- final BatikUaDocument userAgent = new BatikUaDocument(new AffineTransform());
- BridgeContext ctx = new BridgeContext(userAgent);
- GVTBuilder builder = new GVTBuilder();
- TextPainter textPainter = null;
- if (fontConsumer == null) {
- textPainter = new StrokingTextPainter();
- } else {
- textPainter = new PdfTextPainter(fontConsumer, orthography);
- }
- ctx.setTextPainter(textPainter);
-
- final PdfaElementBridge aBridge = new PdfaElementBridge();
- ctx.putBridge(aBridge);
-
- final GraphicsNode root = builder.build(ctx, svgDocument);
- ctx = null;
- builder = null;
-
- root.paint(graphic2d);
- graphic2d.dispose();
- }
-
-}
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:49:08 UTC (rev 13595)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:51:56 UTC (rev 13596)
@@ -1,112 +0,0 @@
-/*
- * Copyright 2007 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.foray.common.CharacterOutputStream;
-import org.foray.graphic.SvgGraphic4a;
-import org.foray.graphic.batik.BatikUaDocument;
-import org.foray.graphic.batik.PsGraphics2D;
-
-import org.axsl.font.FontConsumer;
-import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.output.VectorOutputContext;
-
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.gvt.GraphicsNode;
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.w3c.dom.svg.SVGDocument;
-
-import java.awt.geom.AffineTransform;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Helper class for applications using or embedding SVG in PostScript output.
- */
-public class SvgPs extends VectorOutput2Ps4a {
-
- /** The encapsulated SVG graphic. */
- private SvgGraphic4a svg;
-
- /**
- * Constructor.
- * @param svg The encapsulated SVG graphic.
- */
- SvgPs(final SvgGraphic4a svg) {
- this.svg = svg;
- }
-
- @Override
- public SvgGraphic4a getGraphic() {
- return this.svg;
- }
-
- @Override
- public void drawVectorContent(final OutputStream output,
- final VectorOutputContext outputContext,
- final FontConsumer fontConsumer, final boolean strokeText,
- final boolean commentsEnabled) throws GraphicException {
- SVGDocument doc = null;
- try {
- doc = this.svg.getSvgDocument();
- } catch (final GraphicException e) {
- this.svg.getServer().logError("Error getting SVGDocument in " + this.getClass().getName());
- return;
- }
- BridgeContext ctx = makeBridgeContext();
- GVTBuilder builder = new GVTBuilder();
-
- final GraphicsNode root;
- root = builder.build(ctx, doc);
- ctx = null;
- builder = null;
-
- final CharacterOutputStream cos = new CharacterOutputStream(output, commentsEnabled);
- final PsGraphics2D graphics = new PsGraphics2D(false, cos);
- graphics.setGraphicContext(new GraphicContext());
- root.paint(graphics);
- try {
- cos.close();
- } catch (final IOException e) {
- throw new GraphicException(e);
- }
- }
-
- /**
- * Creates a BridgeContext instance for use by Batik when rendering an SVG
- * graphic.
- * @return A Batik BridgeContext instance.
- */
- public BridgeContext makeBridgeContext() {
- final BatikUaDocument userAgent = new BatikUaDocument(new AffineTransform());
- return new BridgeContext(userAgent);
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 13:49:26
|
Revision: 13595
http://sourceforge.net/p/foray/code/13595
Author: victormote
Date: 2025-05-04 13:49:08 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Rename classes for output of vector graphics, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2d4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Pdf4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Ps4a.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -1,46 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.axsl.graphic.output.VectorOutput2Java2d;
-
-/**
- * Abstract superclass for all helper classes used to embed graphics in
- * PostScript output.
- */
-public abstract class GraphicJava2d4a extends VectorOutput4a implements VectorOutput2Java2d {
-
- /**
- * Constructor.
- */
- public GraphicJava2d4a() {
- super();
- }
-
-}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -47,7 +47,7 @@
}
@Override
- public GraphicJava2d4a createGraphicOutput(final Graphic graphic)
+ public VectorOutput2Java2d4a createGraphicOutput(final Graphic graphic)
throws GraphicException {
final Graphic4a graphic4a = super.getGraphic4a(graphic);
if (graphic4a instanceof SvgGraphic4a) {
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -1,46 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.axsl.graphic.output.VectorOutput2Pdf;
-
-/**
- * Abstract superclass for all helper classes used to embed graphics in PDF
- * output.
- */
-public abstract class GraphicPdf4a extends VectorOutput4a implements VectorOutput2Pdf {
-
- /**
- * Constructor.
- */
- public GraphicPdf4a() {
- super();
- }
-
-}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -48,7 +48,7 @@
}
@Override
- public GraphicPdf4a createGraphicOutput(final Graphic graphic)
+ public VectorOutput2Pdf4a createGraphicOutput(final Graphic graphic)
throws GraphicException {
final Graphic4a graphic4a = super.getGraphic4a(graphic);
if (graphic4a instanceof SvgGraphic4a) {
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -1,46 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.axsl.graphic.output.VectorOutput2Ps;
-
-/**
- * Abstract superclass for all helper classes used to embed graphics in
- * PostScript output.
- */
-public abstract class GraphicPs4a extends VectorOutput4a implements VectorOutput2Ps {
-
- /**
- * Constructor.
- */
- public GraphicPs4a() {
- super();
- }
-
-}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -47,7 +47,7 @@
}
@Override
- public GraphicPs4a createGraphicOutput(final Graphic graphic)
+ public VectorOutput2Ps4a createGraphicOutput(final Graphic graphic)
throws GraphicException {
final Graphic4a graphic4a = super.getGraphic4a(graphic);
if (graphic4a instanceof SvgGraphic4a) {
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -48,7 +48,7 @@
/**
* Helper class for applications using SVG in Java2d output.
*/
-public class SvgJava2d extends GraphicJava2d4a {
+public class SvgJava2d extends VectorOutput2Java2d4a {
/** The encapsulated SVG graphic. */
private SvgGraphic4a svg;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -51,7 +51,7 @@
/**
* Helper class for applications using or embedding SVG in PDF output.
*/
-public class SvgPdf extends GraphicPdf4a {
+public class SvgPdf extends VectorOutput2Pdf4a {
/** The encapsulated SVG graphic. */
private SvgGraphic4a svg;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:45:41 UTC (rev 13594)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -50,7 +50,7 @@
/**
* Helper class for applications using or embedding SVG in PostScript output.
*/
-public class SvgPs extends GraphicPs4a {
+public class SvgPs extends VectorOutput2Ps4a {
/** The encapsulated SVG graphic. */
private SvgGraphic4a svg;
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2d4a.java (from rev 13594, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2d4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Java2d4a.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.axsl.graphic.output.VectorOutput2Java2d;
+
+/**
+ * Abstract superclass for all helper classes used to embed graphics in
+ * PostScript output.
+ */
+public abstract class VectorOutput2Java2d4a extends VectorOutput4a implements VectorOutput2Java2d {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput2Java2d4a() {
+ super();
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Pdf4a.java (from rev 13594, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Pdf4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Pdf4a.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.axsl.graphic.output.VectorOutput2Pdf;
+
+/**
+ * Abstract superclass for all helper classes used to embed graphics in PDF
+ * output.
+ */
+public abstract class VectorOutput2Pdf4a extends VectorOutput4a implements VectorOutput2Pdf {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput2Pdf4a() {
+ super();
+ }
+
+}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Ps4a.java (from rev 13594, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Ps4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput2Ps4a.java 2025-05-04 13:49:08 UTC (rev 13595)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.axsl.graphic.output.VectorOutput2Ps;
+
+/**
+ * Abstract superclass for all helper classes used to embed graphics in
+ * PostScript output.
+ */
+public abstract class VectorOutput2Ps4a extends VectorOutput4a implements VectorOutput2Ps {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput2Ps4a() {
+ super();
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 13:45:58
|
Revision: 13594
http://sourceforge.net/p/foray/code/13594
Author: victormote
Date: 2025-05-04 13:45:41 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Rename class for output of vector graphics, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput4a.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java 2025-05-04 13:39:08 UTC (rev 13593)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java 2025-05-04 13:45:41 UTC (rev 13594)
@@ -34,7 +34,7 @@
* Abstract superclass for all helper classes used to embed graphics in
* PostScript output.
*/
-public abstract class GraphicJava2d4a extends GraphicOutput4a implements VectorOutput2Java2d {
+public abstract class GraphicJava2d4a extends VectorOutput4a implements VectorOutput2Java2d {
/**
* Constructor.
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java 2025-05-04 13:39:08 UTC (rev 13593)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java 2025-05-04 13:45:41 UTC (rev 13594)
@@ -1,44 +0,0 @@
-/*
- * Copyright 2006 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic.output;
-
-import org.axsl.graphic.output.VectorOutput;
-
-/**
- * Abstract superclass for all FOray Graphic output helper classes.
- */
-public abstract class GraphicOutput4a implements VectorOutput {
-
- /**
- * Constructor.
- */
- public GraphicOutput4a() {
- }
-
-}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java 2025-05-04 13:39:08 UTC (rev 13593)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java 2025-05-04 13:45:41 UTC (rev 13594)
@@ -34,7 +34,7 @@
* Abstract superclass for all helper classes used to embed graphics in PDF
* output.
*/
-public abstract class GraphicPdf4a extends GraphicOutput4a implements VectorOutput2Pdf {
+public abstract class GraphicPdf4a extends VectorOutput4a implements VectorOutput2Pdf {
/**
* Constructor.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java 2025-05-04 13:39:08 UTC (rev 13593)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java 2025-05-04 13:45:41 UTC (rev 13594)
@@ -34,7 +34,7 @@
* Abstract superclass for all helper classes used to embed graphics in
* PostScript output.
*/
-public abstract class GraphicPs4a extends GraphicOutput4a implements VectorOutput2Ps {
+public abstract class GraphicPs4a extends VectorOutput4a implements VectorOutput2Ps {
/**
* Constructor.
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput4a.java (from rev 13593, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/VectorOutput4a.java 2025-05-04 13:45:41 UTC (rev 13594)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic.output;
+
+import org.axsl.graphic.output.VectorOutput;
+
+/**
+ * Abstract superclass for all FOray Graphic output helper classes.
+ */
+public abstract class VectorOutput4a implements VectorOutput {
+
+ /**
+ * Constructor.
+ */
+ public VectorOutput4a() {
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 13:39:26
|
Revision: 13593
http://sourceforge.net/p/foray/code/13593
Author: victormote
Date: 2025-05-04 13:39:08 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Conform to aXSL change: Rename interfaces for output of vector graphics, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -48,7 +48,7 @@
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.GraphicServer;
import org.axsl.graphic.MathGraphic;
-import org.axsl.graphic.output.GraphicOutput;
+import org.axsl.graphic.output.VectorOutput;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
@@ -295,7 +295,7 @@
/**
* Registers a {@link GraphicOutputFactory} for use by this server.
- * This method can be used both to support custom {@link GraphicOutput}
+ * This method can be used both to support custom {@link VectorOutput}
* types and to override standard types.
* Note that if a factory was previously registered for the mime-type
* of the factory now being registered, the new registration overrides the
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -32,7 +32,7 @@
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.VectorGraphic;
-import org.axsl.graphic.output.GraphicOutput;
+import org.axsl.graphic.output.VectorOutput;
import java.io.BufferedInputStream;
import java.net.URL;
@@ -53,12 +53,12 @@
}
@Override
- public GraphicOutput getGraphicOutput(final String mimeType) {
+ public VectorOutput getVectorOutput(final String mimeType) {
final GraphicOutputFactory factory = getServer().getOutputFactory(mimeType);
if (factory == null) {
throw new UnsupportedOperationException("Unable to create GraphicOutput instance for: " + mimeType);
}
- GraphicOutput output = null;
+ VectorOutput output = null;
try {
output = factory.createGraphicOutput(this);
} catch (final GraphicException e) {
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2d4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -28,14 +28,13 @@
package org.foray.graphic.output;
-import org.axsl.graphic.output.GraphicJava2d;
+import org.axsl.graphic.output.VectorOutput2Java2d;
/**
* Abstract superclass for all helper classes used to embed graphics in
* PostScript output.
*/
-public abstract class GraphicJava2d4a extends GraphicOutput4a
- implements GraphicJava2d {
+public abstract class GraphicJava2d4a extends GraphicOutput4a implements VectorOutput2Java2d {
/**
* Constructor.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutput4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -28,12 +28,12 @@
package org.foray.graphic.output;
-import org.axsl.graphic.output.GraphicOutput;
+import org.axsl.graphic.output.VectorOutput;
/**
* Abstract superclass for all FOray Graphic output helper classes.
*/
-public abstract class GraphicOutput4a implements GraphicOutput {
+public abstract class GraphicOutput4a implements VectorOutput {
/**
* Constructor.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicOutputFactory.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -32,7 +32,7 @@
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.output.GraphicOutput;
+import org.axsl.graphic.output.VectorOutput;
/**
* Abstract superclass for the FOray GraphicOutputFactory implementations.
@@ -47,9 +47,8 @@
/**
* Returns the mime-type for this factory.
- * @return The mime type for which this factory generates GraphicOutput
- * instances.
- * For example, a factory returning {@link GraphicOutput} instances for
+ * @return The mime type for which this factory generates {@link VectorOutput} instances.
+ * For example, a factory returning {@link VectorOutput} instances for
* use with PDF (Portable Document Format) should return "application/pdf".
* @see <a href="http://www.iana.org/assignments/media-types/">Internet
* Assigned Numbers Authority MIME Media Types</a>
@@ -59,18 +58,15 @@
/**
* Create a GraphicOutput implementation.
* This method is not intended for use by client applications.
- * It is to be used only by Graphic implementations if they do not already
- * have a GraphicOutput for the desired mime type.
+ * It is to be used only by Graphic implementations if they do not already have a GraphicOutput for the desired mime
+ * type.
* Client applications that need a GraphicOutput instance should instead use
- * {@link Graphic#getGraphicOutput(String)}.
- * @param graphic The Graphic instance for which the GraphicOutput
- * instance should be created.
- * @return A GraphicOutput implementation suitable for this factory's
- * mime type.
- * @throws GraphicException For errors during creation of the GraphicOutput
- * instance.
+ * {@link Graphic#getVectorOutput(String)}.
+ * @param graphic The Graphic instance for which the VectorOutput instance should be created.
+ * @return A VectorOutput implementation suitable for this factory's mime type.
+ * @throws GraphicException For errors during creation of the VectorOutput instance.
*/
- public abstract GraphicOutput createGraphicOutput(Graphic graphic) throws GraphicException;
+ public abstract VectorOutput createGraphicOutput(Graphic graphic) throws GraphicException;
/**
* Returns the {@link Graphic} instance, cast as a {@link Graphic4a}.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdf4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -28,14 +28,13 @@
package org.foray.graphic.output;
-import org.axsl.graphic.output.GraphicPdf;
+import org.axsl.graphic.output.VectorOutput2Pdf;
/**
* Abstract superclass for all helper classes used to embed graphics in PDF
* output.
*/
-public abstract class GraphicPdf4a extends GraphicOutput4a
- implements GraphicPdf {
+public abstract class GraphicPdf4a extends GraphicOutput4a implements VectorOutput2Pdf {
/**
* Constructor.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPs4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -28,14 +28,13 @@
package org.foray.graphic.output;
-import org.axsl.graphic.output.GraphicPs;
+import org.axsl.graphic.output.VectorOutput2Ps;
/**
* Abstract superclass for all helper classes used to embed graphics in
* PostScript output.
*/
-public abstract class GraphicPs4a extends GraphicOutput4a
- implements GraphicPs {
+public abstract class GraphicPs4a extends GraphicOutput4a implements VectorOutput2Ps {
/**
* Constructor.
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -35,7 +35,7 @@
import org.axsl.font.FontConsumer;
import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.output.GraphicOutputContext;
+import org.axsl.graphic.output.VectorOutputContext;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
@@ -70,7 +70,7 @@
@Override
public void drawVectorContent(final OutputStream output,
- final GraphicOutputContext outputContext,
+ final VectorOutputContext outputContext,
final FontConsumer fontConsumer, final boolean strokeText,
final boolean commentsEnabled) throws GraphicException {
SVGDocument doc = null;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/document/PdfDocument4a.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -68,7 +68,7 @@
import org.axsl.font.FontUse;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.output.GraphicOutputContext;
+import org.axsl.graphic.output.VectorOutputContext;
import org.axsl.orthography.Orthography;
import org.axsl.pdf.PdfDocument;
import org.axsl.pdf.PdfException;
@@ -110,7 +110,7 @@
* keep track of the character position of each object. The document
* also keeps direct track of the /Root, /Info and /Resources objects.
*/
-public class PdfDocument4a implements PdfDocument<PdfPage4a>, GraphicOutputContext {
+public class PdfDocument4a implements PdfDocument<PdfPage4a>, VectorOutputContext {
/** Name of the CharSet that should be used when converting Strings to
* bytes. */
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -36,8 +36,8 @@
import org.axsl.font.FontConsumer;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.MathGraphic;
-import org.axsl.graphic.output.GraphicOutput;
-import org.axsl.graphic.output.GraphicPdf;
+import org.axsl.graphic.output.VectorOutput;
+import org.axsl.graphic.output.VectorOutput2Pdf;
import org.axsl.orthography.Orthography;
import org.axsl.ps.BoundingBox;
@@ -78,12 +78,12 @@
@Override
protected byte[] getPdfContent(final PdfDocument4a doc) throws GraphicException {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- final GraphicOutput graphicOutput = this.graphic.getGraphicOutput(MimeConstants.MIME_PDF);
- if (! (graphicOutput instanceof GraphicPdf)) {
+ final VectorOutput graphicOutput = this.graphic.getVectorOutput(MimeConstants.MIME_PDF);
+ if (! (graphicOutput instanceof VectorOutput2Pdf)) {
throw new GraphicException("Unable to get PDF output helper for "
+ this.graphic.getUrl());
}
- final GraphicPdf graphicPdf = (GraphicPdf) graphicOutput;
+ final VectorOutput2Pdf graphicPdf = (VectorOutput2Pdf) graphicOutput;
// graphicPdf.drawVectorContent(outputStream, doc, this.fontConsumer, this.strokeText, false);
final Graphics2D graphic2D = new PdfGraphics2D(this.orthography, this.fontConsumer, doc, outputStream);
graphicPdf.drawVectorContent(graphic2D, this.fontConsumer, this.orthography);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -36,8 +36,8 @@
import org.axsl.font.FontConsumer;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.SvgGraphic;
-import org.axsl.graphic.output.GraphicOutput;
-import org.axsl.graphic.output.GraphicPdf;
+import org.axsl.graphic.output.VectorOutput;
+import org.axsl.graphic.output.VectorOutput2Pdf;
import org.axsl.orthography.Orthography;
import org.axsl.ps.BoundingBox;
@@ -78,12 +78,12 @@
@Override
protected byte[] getPdfContent(final PdfDocument4a doc) throws GraphicException {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- final GraphicOutput graphicOutput = this.graphic.getGraphicOutput(MimeConstants.MIME_PDF);
- if (! (graphicOutput instanceof GraphicPdf)) {
+ final VectorOutput graphicOutput = this.graphic.getVectorOutput(MimeConstants.MIME_PDF);
+ if (! (graphicOutput instanceof VectorOutput2Pdf)) {
throw new GraphicException("Unable to get PDF output helper for "
+ this.graphic.getUrl());
}
- final GraphicPdf graphicPdf = (GraphicPdf) graphicOutput;
+ final VectorOutput2Pdf graphicPdf = (VectorOutput2Pdf) graphicOutput;
// graphicPdf.drawVectorContent(outputStream, doc, this.fontConsumer, this.strokeText, false);
final Graphics2D graphic2D = new PdfGraphics2D(this.orthography, this.fontConsumer, doc, outputStream);
graphicPdf.drawVectorContent(graphic2D, this.fontConsumer, this.orthography);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/util/PdfGraphics2D.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -46,7 +46,7 @@
import org.axsl.font.FontContext;
import org.axsl.font.FontUse;
import org.axsl.font.FontUtility;
-import org.axsl.graphic.output.GraphicOutputContext;
+import org.axsl.graphic.output.VectorOutputContext;
import org.axsl.orthography.Orthography;
import org.axsl.pdf.PdfColor;
import org.axsl.pdf.PdfPage;
@@ -158,7 +158,7 @@
private Graphics2D fmg;
/** The PDF context. */
- private GraphicOutputContext pdfContext;
+ private VectorOutputContext pdfContext;
/** The graphics state stack. The top item on the stack is always the
* current graphics state. The next one down is what will be current after
@@ -177,7 +177,7 @@
* @param outputStream The output stream to which this processor writes its PDF output.
*/
public PdfGraphics2D(final Orthography orthography, final FontConsumer fontConsumer,
- final GraphicOutputContext pdfContext, final OutputStream outputStream) {
+ final VectorOutputContext pdfContext, final OutputStream outputStream) {
super(fontConsumer == null);
this.gc = new GraphicContext();
/* TODO: Only write the comments if running in debug mode?? */
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -61,7 +61,7 @@
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.SvgGraphic;
-import org.axsl.graphic.output.GraphicJava2d;
+import org.axsl.graphic.output.VectorOutput2Java2d;
import org.axsl.output.OutputConfiguration;
import org.axsl.output.OutputException;
import org.axsl.value.RuleStyle;
@@ -724,8 +724,7 @@
protected void renderSVGDocument(final SvgGraphic graphic,
final Rectangle2D.Float contentRectangle,
final Rectangle2D.Float clipRectangle) {
- final GraphicJava2d output = (GraphicJava2d) graphic.getGraphicOutput(
- MimeConstants.MIME_JAVA2D);
+ final VectorOutput2Java2d output = (VectorOutput2Java2d) graphic.getVectorOutput(MimeConstants.MIME_JAVA2D);
if (output == null) {
/* TODO: Consider logging/displaying a warning. */
return;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-04 13:01:22 UTC (rev 13592)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-04 13:39:08 UTC (rev 13593)
@@ -59,8 +59,8 @@
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.SvgGraphic;
-import org.axsl.graphic.output.GraphicOutputContext;
-import org.axsl.graphic.output.GraphicPs;
+import org.axsl.graphic.output.VectorOutput2Ps;
+import org.axsl.graphic.output.VectorOutputContext;
import org.axsl.output.DocumentConfiguration;
import org.axsl.output.OutputException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -120,7 +120,7 @@
* is the FlateEncode filter which is a Level 3 feature. The PostScript code
* generated follows the Document Structuring Conventions (DSC) version 3.0.
*/
-public class PsRenderer extends PrintRenderer implements GraphicOutputContext {
+public class PsRenderer extends PrintRenderer implements VectorOutputContext {
/** Constant indicating use of PostScript Level 2. */
private static final byte POSTSCRIPT_LEVEL_2 = 2;
@@ -549,7 +549,7 @@
+ " translate");
this.write(sx * at.getScaleX() + " " + sy * at.getScaleY()
+ " scale");
- final GraphicPs graphicPs = (GraphicPs) svgGraphic.getGraphicOutput(MimeConstants.MIME_POSTSCRIPT);
+ final VectorOutput2Ps graphicPs = (VectorOutput2Ps) svgGraphic.getVectorOutput(MimeConstants.MIME_POSTSCRIPT);
if (graphicPs != null) {
try {
graphicPs.drawVectorContent(this.getOutputStream(), this,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 13:01:46
|
Revision: 13592
http://sourceforge.net/p/foray/code/13592
Author: victormote
Date: 2025-05-04 13:01:22 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Rename class, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/SvgFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -103,8 +103,8 @@
private Map<URL, Graphic4a> urlMap = new HashMap<URL, Graphic4a>();
/** The collection of cached graphic objects built directly from an XML {@link SVGDocument}.
- * The {@link SVGDocument} is the key, and the {@link SvgGraphic} instance is the value. */
- private Map<SVGDocument, SvgGraphic> svgDocumentMap = new HashMap<SVGDocument, SvgGraphic>();
+ * The {@link SVGDocument} is the key, and the {@link SvgGraphic4a} instance is the value. */
+ private Map<SVGDocument, SvgGraphic4a> svgDocumentMap = new HashMap<SVGDocument, SvgGraphic4a>();
/** The collection of cached graphic objects built directly from an XML {@link MathMLDocument}.
* The {@link MathMLDocument} is the key, and the {@link MathGraphic} instance is the value. */
@@ -254,10 +254,10 @@
}
@Override
- public SvgGraphic procureSvgGraphic(final SVGDocument svgDocument) throws GraphicException {
- SvgGraphic existing = this.svgDocumentMap.get(svgDocument);
+ public SvgGraphic4a procureSvgGraphic(final SVGDocument svgDocument) throws GraphicException {
+ SvgGraphic4a existing = this.svgDocumentMap.get(svgDocument);
if (existing == null) {
- existing = new org.foray.graphic.SvgGraphic(this, svgDocument);
+ existing = new org.foray.graphic.SvgGraphic4a(this, svgDocument);
this.svgDocumentMap.put(svgDocument, existing);
}
return existing;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -53,7 +53,7 @@
private MathMLDocument doc;
/** The wrapped SvgGraphic. */
- private SvgGraphic svgGraphic;
+ private SvgGraphic4a svgGraphic;
/**
* Constructor for the case of an unparsed URL.
@@ -81,7 +81,7 @@
}
this.doc = mathDocument;
final SVGDocument svgDocument = server.domToSvgDom(mathDocument);
- this.svgGraphic = new SvgGraphic(server, svgDocument);
+ this.svgGraphic = new SvgGraphic4a(server, svgDocument);
try {
this.parseBasics();
} catch (final IOException e) {
@@ -181,10 +181,10 @@
}
/**
- * Returns the wrapped {@link SvgGraphic} instance.
+ * Returns the wrapped {@link SvgGraphic4a} instance.
* @return The wrapped SVG.
*/
- public SvgGraphic getSvgGraphic() {
+ public SvgGraphic4a getSvgGraphic() {
return this.svgGraphic;
}
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -1,247 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic;
-
-import org.foray.graphic.batik.BatikUaAwt;
-
-import org.axsl.constants.MimeConstants;
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-import org.axsl.primitive.sequence.ByteSequence;
-
-import org.apache.batik.anim.dom.SAXSVGDocumentFactory;
-import org.apache.batik.anim.dom.SVGOMDocument;
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.UnitProcessor;
-import org.apache.batik.bridge.UserAgent;
-import org.apache.batik.util.XMLResourceDescriptor;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.svg.SVGDocument;
-
-import java.awt.Color;
-import java.awt.color.ColorSpace;
-import java.awt.geom.AffineTransform;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * An SVG Graphic.
- */
-public class SvgGraphic extends VectorGraphic4a implements org.axsl.graphic.SvgGraphic {
-
- /** The encapsulated SVG document. */
- private SVGDocument doc;
-
- /** Image width (in pixel). */
- private int pixelWidth = 0;
-
- /** Image height (in pixel). */
- private int pixelHeight = 0;
-
- /**
- * Constructor for the case of an unparsed URL.
- * @param server The parent graphic server.
- * @param url The URL which contains the graphic content.
- * @param bis The reusable input stream containing the bytes from {@code url}.
- */
- public SvgGraphic(final GraphicServer4a server, final URL url,
- final BufferedInputStream bis) {
- super(server, url, bis);
- }
-
- /**
- * Constructor for the case of a parsed {@link SVGDocument}.
- * @param server The parent graphic server.
- * @param svgDocument The parsed SVGDocument. This must not be null.
- */
- public SvgGraphic(final GraphicServer4a server,
- final SVGDocument svgDocument) {
- super(server, null, null);
- if (svgDocument == null) {
- throw new NullPointerException("Null SVGDocument");
- }
- this.doc = svgDocument;
- try {
- this.parseBasics();
- } catch (final IOException e) {
- /* The section that generates this exception is bypassed for this
- * case, so we can safely ignore this. */
- }
- this.setBasicsParsed(true);
- }
-
- @Override
- public void loadImage() throws GraphicException {
- try {
- final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
- getServer().getSVGParserClassName());
- this.doc = factory.createSVGDocument(getUrl().toExternalForm());
- } catch (final IOException e) {
- getServer().logError("Could not load external SVG: " + e.getMessage());
- }
- }
-
- @Override
- public SVGDocument getSvgDocument() throws GraphicException {
- if (this.doc == null) {
- this.loadImage();
- }
- return this.doc;
- }
-
- @Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.SVG;
- }
-
- @Override
- public Graphic.Compression getCompressionType() {
- return null;
- }
-
- @Override
- public String getMimeType() {
- return MimeConstants.MIME_SVG;
- }
-
- @Override
- public void parseBasics() throws IOException {
- /* If the document has not yet been parsed, parse it. */
- if (this.doc == null) {
- final String parser = XMLResourceDescriptor.getXMLParserClassName();
- final SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
-
- /* TODO: Some URLs seem to get mangled when converted to URIs, even when the URI is normalized.
- * We need to figure this out and use the URI instead of the URL, or document why the code below is
- * correct. */
-// try (InputStream inputStream = getUrl().openStream()) {
-// final String uriString = getUrl().toURI().toString();
- final String uriString = getUrl().toString();
- final Document doc = f.createDocument(uriString);
- this.doc = (SVGDocument) doc;
-// } catch (final URISyntaxException e) {
-// throw new IllegalStateException(e);
-// }
- }
-
- /* Get the size attributes of the svg element. */
- try {
-
- final UserAgent userAgent = new BatikUaAwt(new AffineTransform());
- final BridgeContext ctx = new BridgeContext(userAgent);
-
- final Element e = this.doc.getRootElement();
- final UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
- e);
-
- String s;
-
- /* Set the width (in pixels). */
- s = e.getAttributeNS(null, SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
- if (s.length() == 0) {
- /* Default is 100%. */
- s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
- }
- final float pixelWidth =
- UnitProcessor.svgHorizontalLengthToUserSpace(s,
- SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx);
- this.pixelWidth = (int) pixelWidth;
-
- /* Set the height (in pixels). */
- s = e.getAttributeNS(null, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE);
- if (s.length() == 0) {
- /* Default is 100%. */
- s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
- }
- final float pixelHeight =
- UnitProcessor.svgVerticalLengthToUserSpace(s,
- SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
- this.pixelHeight = (int) pixelHeight;
- } catch (final NoClassDefFoundError ncdfe) {
- getServer().logError("Batik not in class path");
- return;
- }
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public ByteSequence getRawSamples() throws GraphicException {
- /* SVG is not a raster format. */
- return null;
- }
-
- @Override
- public int absoluteWidthReal() throws GraphicException {
- return -1;
- }
-
- @Override
- public int absoluteHeightReal() throws GraphicException {
- return -1;
- }
-
- @Override
- public boolean isInverted() {
- return false;
- }
-
- @Override
- public ColorSpace getColorSpace() throws GraphicException {
- return null;
- }
-
- @Override
- public boolean isTransparent() throws GraphicException {
- return false;
- }
-
- @Override
- public Color getTransparentColor() throws GraphicException {
- return null;
- }
-
- @Override
- public int getPixelWidth() throws GraphicException {
- this.parseBasicsWrapper();
- return this.pixelWidth;
- }
-
- @Override
- public int getPixelHeight() throws GraphicException {
- this.parseBasicsWrapper();
- return this.pixelHeight;
- }
-
-}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java (from rev 13591, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic;
+
+import org.foray.graphic.batik.BatikUaAwt;
+
+import org.axsl.constants.MimeConstants;
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.SvgGraphic;
+import org.axsl.primitive.sequence.ByteSequence;
+
+import org.apache.batik.anim.dom.SAXSVGDocumentFactory;
+import org.apache.batik.anim.dom.SVGOMDocument;
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.UnitProcessor;
+import org.apache.batik.bridge.UserAgent;
+import org.apache.batik.util.XMLResourceDescriptor;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.svg.SVGDocument;
+
+import java.awt.Color;
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * An SVG Graphic.
+ */
+public class SvgGraphic4a extends VectorGraphic4a implements SvgGraphic {
+
+ /** The encapsulated SVG document. */
+ private SVGDocument doc;
+
+ /** Image width (in pixel). */
+ private int pixelWidth = 0;
+
+ /** Image height (in pixel). */
+ private int pixelHeight = 0;
+
+ /**
+ * Constructor for the case of an unparsed URL.
+ * @param server The parent graphic server.
+ * @param url The URL which contains the graphic content.
+ * @param bis The reusable input stream containing the bytes from {@code url}.
+ */
+ public SvgGraphic4a(final GraphicServer4a server, final URL url,
+ final BufferedInputStream bis) {
+ super(server, url, bis);
+ }
+
+ /**
+ * Constructor for the case of a parsed {@link SVGDocument}.
+ * @param server The parent graphic server.
+ * @param svgDocument The parsed SVGDocument. This must not be null.
+ */
+ public SvgGraphic4a(final GraphicServer4a server,
+ final SVGDocument svgDocument) {
+ super(server, null, null);
+ if (svgDocument == null) {
+ throw new NullPointerException("Null SVGDocument");
+ }
+ this.doc = svgDocument;
+ try {
+ this.parseBasics();
+ } catch (final IOException e) {
+ /* The section that generates this exception is bypassed for this
+ * case, so we can safely ignore this. */
+ }
+ this.setBasicsParsed(true);
+ }
+
+ @Override
+ public void loadImage() throws GraphicException {
+ try {
+ final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
+ getServer().getSVGParserClassName());
+ this.doc = factory.createSVGDocument(getUrl().toExternalForm());
+ } catch (final IOException e) {
+ getServer().logError("Could not load external SVG: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public SVGDocument getSvgDocument() throws GraphicException {
+ if (this.doc == null) {
+ this.loadImage();
+ }
+ return this.doc;
+ }
+
+ @Override
+ public Graphic.Type getGraphicType() {
+ return Graphic.Type.SVG;
+ }
+
+ @Override
+ public Graphic.Compression getCompressionType() {
+ return null;
+ }
+
+ @Override
+ public String getMimeType() {
+ return MimeConstants.MIME_SVG;
+ }
+
+ @Override
+ public void parseBasics() throws IOException {
+ /* If the document has not yet been parsed, parse it. */
+ if (this.doc == null) {
+ final String parser = XMLResourceDescriptor.getXMLParserClassName();
+ final SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
+
+ /* TODO: Some URLs seem to get mangled when converted to URIs, even when the URI is normalized.
+ * We need to figure this out and use the URI instead of the URL, or document why the code below is
+ * correct. */
+// try (InputStream inputStream = getUrl().openStream()) {
+// final String uriString = getUrl().toURI().toString();
+ final String uriString = getUrl().toString();
+ final Document doc = f.createDocument(uriString);
+ this.doc = (SVGDocument) doc;
+// } catch (final URISyntaxException e) {
+// throw new IllegalStateException(e);
+// }
+ }
+
+ /* Get the size attributes of the svg element. */
+ try {
+
+ final UserAgent userAgent = new BatikUaAwt(new AffineTransform());
+ final BridgeContext ctx = new BridgeContext(userAgent);
+
+ final Element e = this.doc.getRootElement();
+ final UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
+ e);
+
+ String s;
+
+ /* Set the width (in pixels). */
+ s = e.getAttributeNS(null, SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
+ if (s.length() == 0) {
+ /* Default is 100%. */
+ s = SVGOMDocument.SVG_SVG_WIDTH_DEFAULT_VALUE;
+ }
+ final float pixelWidth =
+ UnitProcessor.svgHorizontalLengthToUserSpace(s,
+ SVGOMDocument.SVG_WIDTH_ATTRIBUTE, uctx);
+ this.pixelWidth = (int) pixelWidth;
+
+ /* Set the height (in pixels). */
+ s = e.getAttributeNS(null, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE);
+ if (s.length() == 0) {
+ /* Default is 100%. */
+ s = SVGOMDocument.SVG_SVG_HEIGHT_DEFAULT_VALUE;
+ }
+ final float pixelHeight =
+ UnitProcessor.svgVerticalLengthToUserSpace(s,
+ SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx);
+ this.pixelHeight = (int) pixelHeight;
+ } catch (final NoClassDefFoundError ncdfe) {
+ getServer().logError("Batik not in class path");
+ return;
+ }
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public ByteSequence getRawSamples() throws GraphicException {
+ /* SVG is not a raster format. */
+ return null;
+ }
+
+ @Override
+ public int absoluteWidthReal() throws GraphicException {
+ return -1;
+ }
+
+ @Override
+ public int absoluteHeightReal() throws GraphicException {
+ return -1;
+ }
+
+ @Override
+ public boolean isInverted() {
+ return false;
+ }
+
+ @Override
+ public ColorSpace getColorSpace() throws GraphicException {
+ return null;
+ }
+
+ @Override
+ public boolean isTransparent() throws GraphicException {
+ return false;
+ }
+
+ @Override
+ public Color getTransparentColor() throws GraphicException {
+ return null;
+ }
+
+ @Override
+ public int getPixelWidth() throws GraphicException {
+ this.parseBasicsWrapper();
+ return this.pixelWidth;
+ }
+
+ @Override
+ public int getPixelHeight() throws GraphicException {
+ this.parseBasicsWrapper();
+ return this.pixelHeight;
+ }
+
+}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/MathFactory.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -29,7 +29,7 @@
package org.foray.graphic.factory;
import org.foray.graphic.GraphicServer4a;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.foray.xml.DomUtil;
import org.axsl.constants.XmlConstants;
@@ -65,7 +65,7 @@
}
@Override
- public SvgGraphic attemptCreate(final URL url,
+ public SvgGraphic4a attemptCreate(final URL url,
final BufferedInputStream bis) throws IOException {
final byte[] header = new byte[MathFactory.SIG_LENGTH];
bis.read(header);
@@ -91,7 +91,7 @@
}
/* Return an SvgGraphic instance. */
- return new SvgGraphic(this.getServer(), svgDocument);
+ return new SvgGraphic4a(this.getServer(), svgDocument);
}
/**
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/SvgFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/SvgFactory.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/SvgFactory.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -29,7 +29,7 @@
package org.foray.graphic.factory;
import org.foray.graphic.GraphicServer4a;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -55,7 +55,7 @@
}
@Override
- public SvgGraphic attemptCreate(final URL url,
+ public SvgGraphic4a attemptCreate(final URL url,
final BufferedInputStream bis) throws IOException {
final byte[] header = new byte[SvgFactory.SVG_SIG_LENGTH];
bis.read(header);
@@ -68,7 +68,7 @@
if (svgStringIndex < 0) {
return null;
}
- return new SvgGraphic(this.getServer(), url, bis);
+ return new SvgGraphic4a(this.getServer(), url, bis);
}
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicJava2dFactory.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -29,7 +29,7 @@
package org.foray.graphic.output;
import org.foray.graphic.Graphic4a;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
@@ -50,8 +50,8 @@
public GraphicJava2d4a createGraphicOutput(final Graphic graphic)
throws GraphicException {
final Graphic4a graphic4a = super.getGraphic4a(graphic);
- if (graphic4a instanceof SvgGraphic) {
- final SvgGraphic svgGraphic = (SvgGraphic) graphic4a;
+ if (graphic4a instanceof SvgGraphic4a) {
+ final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
return new SvgJava2d(svgGraphic);
}
return null;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPdfFactory.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -30,7 +30,7 @@
import org.foray.graphic.Graphic4a;
import org.foray.graphic.MathGraphic4a;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
@@ -51,8 +51,8 @@
public GraphicPdf4a createGraphicOutput(final Graphic graphic)
throws GraphicException {
final Graphic4a graphic4a = super.getGraphic4a(graphic);
- if (graphic4a instanceof SvgGraphic) {
- final SvgGraphic svgGraphic = (SvgGraphic) graphic4a;
+ if (graphic4a instanceof SvgGraphic4a) {
+ final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
return new SvgPdf(svgGraphic);
}
if (graphic4a instanceof MathGraphic4a) {
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/GraphicPsFactory.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -29,7 +29,7 @@
package org.foray.graphic.output;
import org.foray.graphic.Graphic4a;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
@@ -50,8 +50,8 @@
public GraphicPs4a createGraphicOutput(final Graphic graphic)
throws GraphicException {
final Graphic4a graphic4a = super.getGraphic4a(graphic);
- if (graphic4a instanceof SvgGraphic) {
- final SvgGraphic svgGraphic = (SvgGraphic) graphic4a;
+ if (graphic4a instanceof SvgGraphic4a) {
+ final SvgGraphic4a svgGraphic = (SvgGraphic4a) graphic4a;
return new SvgPs(svgGraphic);
}
return null;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgJava2d.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -28,7 +28,7 @@
package org.foray.graphic.output;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.foray.graphic.batik.BatikUaAwt;
import org.axsl.graphic.GraphicException;
@@ -51,18 +51,18 @@
public class SvgJava2d extends GraphicJava2d4a {
/** The encapsulated SVG graphic. */
- private SvgGraphic svg;
+ private SvgGraphic4a svg;
/**
* Constructor.
* @param svg The encapsulated SVG graphic.
*/
- SvgJava2d(final SvgGraphic svg) {
+ SvgJava2d(final SvgGraphic4a svg) {
this.svg = svg;
}
@Override
- public SvgGraphic getGraphic() {
+ public SvgGraphic4a getGraphic() {
return this.svg;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPdf.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -29,7 +29,7 @@
package org.foray.graphic.output;
import org.foray.common.Environment;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.foray.graphic.batik.BatikUaDocument;
import org.foray.graphic.batik.PdfTextPainter;
import org.foray.graphic.batik.PdfaElementBridge;
@@ -54,18 +54,18 @@
public class SvgPdf extends GraphicPdf4a {
/** The encapsulated SVG graphic. */
- private SvgGraphic svg;
+ private SvgGraphic4a svg;
/**
* Constructor.
* @param svg The encapsulated SVG graphic.
*/
- SvgPdf(final SvgGraphic svg) {
+ SvgPdf(final SvgGraphic4a svg) {
this.svg = svg;
}
@Override
- public SvgGraphic getGraphic() {
+ public SvgGraphic4a getGraphic() {
return this.svg;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/output/SvgPs.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -29,7 +29,7 @@
package org.foray.graphic.output;
import org.foray.common.CharacterOutputStream;
-import org.foray.graphic.SvgGraphic;
+import org.foray.graphic.SvgGraphic4a;
import org.foray.graphic.batik.BatikUaDocument;
import org.foray.graphic.batik.PsGraphics2D;
@@ -53,18 +53,18 @@
public class SvgPs extends GraphicPs4a {
/** The encapsulated SVG graphic. */
- private SvgGraphic svg;
+ private SvgGraphic4a svg;
/**
* Constructor.
* @param svg The encapsulated SVG graphic.
*/
- SvgPs(final SvgGraphic svg) {
+ SvgPs(final SvgGraphic4a svg) {
this.svg = svg;
}
@Override
- public SvgGraphic getGraphic() {
+ public SvgGraphic4a getGraphic() {
return this.svg;
}
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java 2025-05-04 12:58:26 UTC (rev 13591)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java 2025-05-04 13:01:22 UTC (rev 13592)
@@ -56,7 +56,7 @@
import java.net.URISyntaxException;
/**
- * JUnit test class for the class {@link SvgGraphic}.
+ * JUnit test class for the class {@link SvgGraphic4a}.
*/
public class SvgGraphicTests extends AbstractGraphicTests {
@@ -75,8 +75,8 @@
final URI graphicUri = UrlUtil.resolveURI(getBaseURLs(), new URI("text-001.svg"));
final Graphic4a graphic = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(graphic);
- assertTrue(graphic instanceof SvgGraphic);
- final SvgGraphic svg = (SvgGraphic) graphic;
+ assertTrue(graphic instanceof SvgGraphic4a);
+ final SvgGraphic4a svg = (SvgGraphic4a) graphic;
assertEquals(200, svg.getPixelWidth());
assertEquals(50, svg.getPixelHeight());
final SVGDocument svgDoc = svg.getSvgDocument();
@@ -153,8 +153,8 @@
final URI graphicUri = UrlUtil.resolveURI(getBaseURLs(), new URI("font-embed.svg"));
final Graphic4a graphic = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(graphic);
- assertTrue(graphic instanceof SvgGraphic);
- final SvgGraphic svg = (SvgGraphic) graphic;
+ assertTrue(graphic instanceof SvgGraphic4a);
+ final SvgGraphic4a svg = (SvgGraphic4a) graphic;
final SVGDocument svgDoc = svg.getSvgDocument();
assertNotNull(svgDoc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 12:58:44
|
Revision: 13591
http://sourceforge.net/p/foray/code/13591
Author: victormote
Date: 2025-05-04 12:58:26 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Conform to aXSL change: Create VectorGraphic interface, and move vector-specific method to it.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java 2025-05-04 12:00:24 UTC (rev 13590)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java 2025-05-04 12:58:26 UTC (rev 13591)
@@ -32,6 +32,7 @@
import org.foray.primitive.ByteUtils;
import org.foray.primitive.sequence.ByteArray;
+import org.axsl.graphic.EpsGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -47,7 +48,7 @@
/**
* An EPS (encapsulated Postscript) graphic.
*/
-public class EpsGraphic4a extends Graphic4a implements org.axsl.graphic.EpsGraphic {
+public class EpsGraphic4a extends VectorGraphic4a implements EpsGraphic {
/** The size, in bytes, of the read buffer to use when reading the file. */
private static final int READ_BUFFER_SIZE = 20480;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-04 12:00:24 UTC (rev 13590)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-04 12:58:26 UTC (rev 13591)
@@ -29,12 +29,10 @@
package org.foray.graphic;
import org.foray.graphic.factory.GraphicFactory;
-import org.foray.graphic.output.GraphicOutputFactory;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.constants.TypographicConstants;
import org.axsl.graphic.GraphicException;
-import org.axsl.graphic.output.GraphicOutput;
import org.axsl.primitive.sequence.ByteSequence;
import java.awt.color.ColorSpace;
@@ -439,19 +437,4 @@
this.links = links;
}
- @Override
- public GraphicOutput getGraphicOutput(final String mimeType) {
- final GraphicOutputFactory factory = getServer().getOutputFactory(mimeType);
- if (factory == null) {
- throw new UnsupportedOperationException("Unable to create GraphicOutput instance for: " + mimeType);
- }
- GraphicOutput output = null;
- try {
- output = factory.createGraphicOutput(this);
- } catch (final GraphicException e) {
- this.server.logError("Error creating Graphic output for: " + mimeType + "\n" + e.getMessage());
- }
- return output;
- }
-
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-04 12:00:24 UTC (rev 13590)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-04 12:58:26 UTC (rev 13591)
@@ -31,6 +31,7 @@
import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.MathGraphic;
import org.axsl.primitive.sequence.ByteSequence;
import org.w3c.dom.mathml.MathMLDocument;
@@ -46,8 +47,7 @@
* A MathML Graphic. The current approach to handling MathML is that it is
* treated internally as SVG.
*/
-public class MathGraphic4a extends Graphic4a
- implements org.axsl.graphic.MathGraphic {
+public class MathGraphic4a extends VectorGraphic4a implements MathGraphic {
/** The encapsulated MathML document. */
private MathMLDocument doc;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2025-05-04 12:00:24 UTC (rev 13590)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2025-05-04 12:58:26 UTC (rev 13591)
@@ -55,7 +55,7 @@
/**
* An SVG Graphic.
*/
-public class SvgGraphic extends Graphic4a implements org.axsl.graphic.SvgGraphic {
+public class SvgGraphic extends VectorGraphic4a implements org.axsl.graphic.SvgGraphic {
/** The encapsulated SVG document. */
private SVGDocument doc;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-04 12:00:24 UTC (rev 13590)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-04 12:58:26 UTC (rev 13591)
@@ -34,7 +34,6 @@
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.GraphicLink;
-import org.axsl.graphic.output.GraphicOutput;
import org.axsl.primitive.sequence.ByteSequence;
import java.awt.Color;
@@ -178,9 +177,4 @@
return Collections.emptyList();
}
- @Override
- public GraphicOutput getGraphicOutput(final String mimeType) {
- return null;
- }
-
}
Added: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java 2025-05-04 12:58:26 UTC (rev 13591)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic;
+
+import org.foray.graphic.output.GraphicOutputFactory;
+
+import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.VectorGraphic;
+import org.axsl.graphic.output.GraphicOutput;
+
+import java.io.BufferedInputStream;
+import java.net.URL;
+
+/**
+ * Abstract superclass for vector graphic implementations.
+ */
+public abstract class VectorGraphic4a extends Graphic4a implements VectorGraphic {
+
+ /**
+ * Constructor.
+ * @param server The parent graphic server.
+ * @param url The URL which contains the graphic content.
+ * @param bis The reusable input stream containing the bytes from {@code url}.
+ */
+ public VectorGraphic4a(final GraphicServer4a server, final URL url, final BufferedInputStream bis) {
+ super(server, url, bis);
+ }
+
+ @Override
+ public GraphicOutput getGraphicOutput(final String mimeType) {
+ final GraphicOutputFactory factory = getServer().getOutputFactory(mimeType);
+ if (factory == null) {
+ throw new UnsupportedOperationException("Unable to create GraphicOutput instance for: " + mimeType);
+ }
+ GraphicOutput output = null;
+ try {
+ output = factory.createGraphicOutput(this);
+ } catch (final GraphicException e) {
+ getServer().logError("Error creating Graphic output for: " + mimeType + "\n" + e.getMessage());
+ }
+ return output;
+ }
+
+}
Property changes on: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/VectorGraphic4a.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-04 12:00:42
|
Revision: 13590
http://sourceforge.net/p/foray/code/13590
Author: victormote
Date: 2025-05-04 12:00:24 +0000 (Sun, 04 May 2025)
Log Message:
-----------
Conform to aXSL change: Remove unnecessary method.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java
trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-03 22:54:53 UTC (rev 13589)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-04 12:00:24 UTC (rev 13590)
@@ -454,13 +454,4 @@
return output;
}
- @Override
- public boolean canMakeGraphicOutput(final String mimeType) {
- final GraphicOutputFactory factory = getServer().getOutputFactory(mimeType);
- if (factory == null) {
- return false;
- }
- return true;
- }
-
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-03 22:54:53 UTC (rev 13589)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-04 12:00:24 UTC (rev 13590)
@@ -183,9 +183,4 @@
return null;
}
- @Override
- public boolean canMakeGraphicOutput(final String mimeType) {
- return false;
- }
-
}
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2025-05-03 22:54:53 UTC (rev 13589)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/awt/AwtRenderer.java 2025-05-04 12:00:24 UTC (rev 13590)
@@ -724,12 +724,12 @@
protected void renderSVGDocument(final SvgGraphic graphic,
final Rectangle2D.Float contentRectangle,
final Rectangle2D.Float clipRectangle) {
- if (! graphic.canMakeGraphicOutput(MimeConstants.MIME_JAVA2D)) {
+ final GraphicJava2d output = (GraphicJava2d) graphic.getGraphicOutput(
+ MimeConstants.MIME_JAVA2D);
+ if (output == null) {
/* TODO: Consider logging/displaying a warning. */
return;
}
- final GraphicJava2d output = (GraphicJava2d) graphic.getGraphicOutput(
- MimeConstants.MIME_JAVA2D);
try {
output.drawGraphic(this.graphics, contentRectangle);
} catch (final GraphicException e) {
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-03 22:54:53 UTC (rev 13589)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-04 12:00:24 UTC (rev 13590)
@@ -549,10 +549,8 @@
+ " translate");
this.write(sx * at.getScaleX() + " " + sy * at.getScaleY()
+ " scale");
- final String mime = MimeConstants.MIME_POSTSCRIPT;
- if (svgGraphic.canMakeGraphicOutput(mime)) {
- final GraphicPs graphicPs = (GraphicPs) svgGraphic.getGraphicOutput(
- mime);
+ final GraphicPs graphicPs = (GraphicPs) svgGraphic.getGraphicOutput(MimeConstants.MIME_POSTSCRIPT);
+ if (graphicPs != null) {
try {
graphicPs.drawVectorContent(this.getOutputStream(), this,
this.getFontConsumer(), false, this.enableComments);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 22:55:10
|
Revision: 13589
http://sourceforge.net/p/foray/code/13589
Author: victormote
Date: 2025-05-03 22:54:53 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Move comments to fo:blocks, to assiste with debugging.
Modified Paths:
--------------
trunk/foray/src/dist/resource/fo-examples/basic/graphics.fo
Modified: trunk/foray/src/dist/resource/fo-examples/basic/graphics.fo
===================================================================
--- trunk/foray/src/dist/resource/fo-examples/basic/graphics.fo 2025-05-03 20:30:51 UTC (rev 13588)
+++ trunk/foray/src/dist/resource/fo-examples/basic/graphics.fo 2025-05-03 22:54:53 UTC (rev 13589)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<fo:root
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:math="http://www.w3.org/1998/Math/MathML"
font-family="Times Roman"
@@ -22,9 +23,10 @@
-<!-- Page 1. -->
+
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 1.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -38,9 +40,9 @@
-<!-- Page 2. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 2.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -55,9 +57,9 @@
-<!-- Page 3. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 3.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -72,9 +74,9 @@
-<!-- Page 4. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 4.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -89,9 +91,9 @@
-<!-- Page 5. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 5.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -106,9 +108,9 @@
-<!-- Page 6. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 6.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -123,9 +125,9 @@
-<!-- Page 7. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 7.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -141,9 +143,9 @@
-<!-- Page 8. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 8.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -159,9 +161,9 @@
-<!-- Page 9. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 9.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -177,9 +179,9 @@
-<!-- Page 10. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 10.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -194,9 +196,9 @@
-<!-- Page 11. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 11.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -211,9 +213,9 @@
-<!-- Page 12. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 12.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -231,9 +233,9 @@
-<!-- Page 13. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 13.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -273,9 +275,9 @@
-<!-- Page 14. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 14.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
@@ -307,9 +309,9 @@
-<!-- Page 15. -->
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
+ <fo:block>Page 15.</fo:block>
<fo:block
font-size="16pt"
font-weight="bold"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 20:31:12
|
Revision: 13588
http://sourceforge.net/p/foray/code/13588
Author: victormote
Date: 2025-05-03 20:30:51 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Conform to aXSL change: Include "get" in some getter methods, for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/GifGraphicTests.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/JpegGraphicTests.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/PngGraphicTests.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TiffGraphicTests.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java
trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -474,13 +474,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelWidth;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -349,13 +349,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelWidth;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -293,13 +293,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelWidth;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -248,7 +248,7 @@
}
@Override
- public final int absoluteWidth(final int pixelsPerInch) throws GraphicException {
+ public final int getAbsoluteWidth(final int pixelsPerInch) throws GraphicException {
final int absoluteWidth = absoluteWidthReal();
if (absoluteWidth > 0) {
// The graphic knows its absolute width.
@@ -258,7 +258,7 @@
// The user does not want the fallback computation.
return -1;
}
- final int pixelWidth = pixelWidth();
+ final int pixelWidth = getPixelWidth();
if (pixelWidth < 1) {
// pixel Width is not valid
return -1;
@@ -279,7 +279,7 @@
public abstract int absoluteWidthReal() throws GraphicException;
@Override
- public final int absoluteHeight(final int pixelsPerInch) throws GraphicException {
+ public final int getAbsoluteHeight(final int pixelsPerInch) throws GraphicException {
final int absoluteHeight = absoluteHeightReal();
if (absoluteHeight > 0) {
// The graphic knows its absolute height.
@@ -289,7 +289,7 @@
// The user does not want the fallback computation.
return -1;
}
- final int pixelHeight = pixelHeight();
+ final int pixelHeight = getPixelHeight();
if (pixelHeight < 1) {
// pixel Height is not valid
return -1;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -466,7 +466,7 @@
* to get its dimensions.
*/
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.loadImageWrapper();
return this.pixelWidth;
}
@@ -477,7 +477,7 @@
* to get its dimensions.
*/
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.loadImageWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -169,15 +169,15 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
- return this.svgGraphic.pixelWidth();
+ return this.svgGraphic.getPixelWidth();
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
- return this.svgGraphic.pixelHeight();
+ return this.svgGraphic.getPixelHeight();
}
/**
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -148,13 +148,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return -1;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return -1;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -226,7 +226,7 @@
// Get our current ColorModel
final ColorModel cm = this.cr.getColorModel();
- final int qtyPixels = this.pixelWidth() * this.pixelHeight();
+ final int qtyPixels = getPixelWidth() * getPixelHeight();
// It has an alpha channel so generate a soft mask.
if (! this.isTransparent
&& cm.hasAlpha()) {
@@ -345,13 +345,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelWidth;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -233,13 +233,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelWidth;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -94,12 +94,12 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
return this.width;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
return this.height;
}
@@ -159,12 +159,12 @@
}
@Override
- public int absoluteWidth(final int pixelsPerInch) throws GraphicException {
+ public int getAbsoluteWidth(final int pixelsPerInch) throws GraphicException {
return -1;
}
@Override
- public int absoluteHeight(final int pixelsPerInch) throws GraphicException {
+ public int getAbsoluteHeight(final int pixelsPerInch) throws GraphicException {
return -1;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -350,7 +350,7 @@
@Override
public int absoluteWidthReal() throws GraphicException {
- return Math.round(this.pixelWidth()
+ return Math.round(getPixelWidth()
/ this.xResolution
* TypographicConstants.POINTS_PER_INCH
* TypographicConstants.MILLIPOINTS_PER_POINT);
@@ -358,7 +358,7 @@
@Override
public int absoluteHeightReal() throws GraphicException {
- return Math.round(this.pixelHeight()
+ return Math.round(getPixelHeight()
/ this.yResolution
* TypographicConstants.POINTS_PER_INCH
* TypographicConstants.MILLIPOINTS_PER_POINT);
@@ -386,13 +386,13 @@
}
@Override
- public int pixelWidth() throws GraphicException {
+ public int getPixelWidth() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelWidth;
}
@Override
- public int pixelHeight() throws GraphicException {
+ public int getPixelHeight() throws GraphicException {
this.parseBasicsWrapper();
return this.pixelHeight;
}
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -62,8 +62,8 @@
final Graphic4a bmp = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(bmp);
assertTrue(bmp instanceof BmpGraphic);
- assertEquals(70, bmp.pixelWidth());
- assertEquals(62, bmp.pixelHeight());
+ assertEquals(70, bmp.getPixelWidth());
+ assertEquals(62, bmp.getPixelHeight());
assertEquals(8, bmp.getBitsPerComponent());
assertTrue(bmp.getColorSpace().getType() == ColorSpace.TYPE_RGB);
assertEquals(3, bmp.getColorSpace().getNumComponents());
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/GifGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/GifGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/GifGraphicTests.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -61,8 +61,8 @@
final Graphic4a gif = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(gif);
assertTrue(gif instanceof GifGraphic);
- assertEquals(221, gif.pixelWidth());
- assertEquals(96, gif.pixelHeight());
+ assertEquals(221, gif.getPixelWidth());
+ assertEquals(96, gif.getPixelHeight());
assertEquals(8, gif.getBitsPerComponent());
assertTrue(gif.getColorSpace().getType() == ColorSpace.TYPE_RGB);
@@ -92,8 +92,8 @@
final Graphic4a gif = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(gif);
assertTrue(gif instanceof GifGraphic);
- assertEquals(221, gif.pixelWidth());
- assertEquals(96, gif.pixelHeight());
+ assertEquals(221, gif.getPixelWidth());
+ assertEquals(96, gif.getPixelHeight());
assertEquals(8, gif.getBitsPerComponent());
assertTrue(gif.getColorSpace().getType() == ColorSpace.TYPE_RGB);
assertTrue(gif.isTransparent());
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/JpegGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/JpegGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/JpegGraphicTests.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -62,8 +62,8 @@
final Graphic4a jpeg = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(jpeg);
assertTrue(jpeg instanceof JpegGraphic);
- assertEquals(216, jpeg.pixelWidth());
- assertEquals(144, jpeg.pixelHeight());
+ assertEquals(216, jpeg.getPixelWidth());
+ assertEquals(144, jpeg.getPixelHeight());
assertEquals(8, jpeg.getBitsPerComponent());
assertTrue(jpeg.getColorSpace().getType() == ColorSpace.TYPE_RGB);
assertFalse(jpeg.isTransparent());
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/PngGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/PngGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/PngGraphicTests.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -62,8 +62,8 @@
final Graphic4a png = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(png);
assertTrue(png instanceof PngGraphic);
- assertEquals(216, png.pixelWidth());
- assertEquals(144, png.pixelHeight());
+ assertEquals(216, png.getPixelWidth());
+ assertEquals(144, png.getPixelHeight());
assertEquals(8, png.getBitsPerComponent());
assertTrue(png.getColorSpace().getType() == ColorSpace.TYPE_RGB);
assertFalse(png.isTransparent());
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/SvgGraphicTests.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -77,8 +77,8 @@
assertNotNull(graphic);
assertTrue(graphic instanceof SvgGraphic);
final SvgGraphic svg = (SvgGraphic) graphic;
- assertEquals(200, svg.pixelWidth());
- assertEquals(50, svg.pixelHeight());
+ assertEquals(200, svg.getPixelWidth());
+ assertEquals(50, svg.getPixelHeight());
final SVGDocument svgDoc = svg.getSvgDocument();
assertNotNull(svgDoc);
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TiffGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TiffGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/TiffGraphicTests.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -62,8 +62,8 @@
final Graphic4a tiff = this.getServer().procureGraphic(graphicUri.toURL(), false);
assertNotNull(tiff);
assertTrue(tiff instanceof TiffGraphic);
- assertEquals(700, tiff.pixelWidth());
- assertEquals(81, tiff.pixelHeight());
+ assertEquals(700, tiff.getPixelWidth());
+ assertEquals(81, tiff.getPixelHeight());
assertEquals(1, tiff.getBitsPerComponent());
assertTrue(tiff.getColorSpace().getType() == ColorSpace.TYPE_GRAY);
assertFalse(tiff.isTransparent());
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -117,8 +117,8 @@
ColorSpace cs = null;
boolean isTransparent = false;
Color transp = null;
- pixelWidth = getGraphic().pixelWidth();
- pixelHeight = getGraphic().pixelHeight();
+ pixelWidth = getGraphic().getPixelWidth();
+ pixelHeight = getGraphic().getPixelHeight();
bitsPerPixel = getGraphic().getBitsPerComponent();
cs = getGraphic().getColorSpace();
isTransparent = getGraphic().isTransparent();
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformMath.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -112,8 +112,8 @@
final float[] box = new float[BoundingBox.QTY_ENTRIES];
box[BoundingBox.LOWER_LEFT_X_INDEX] = 0;
box[BoundingBox.LOWER_LEFT_Y_INDEX] = 0;
- box[BoundingBox.UPPER_RIGHT_X_INDEX] = this.getGraphic().pixelWidth();
- box[BoundingBox.UPPER_RIGHT_Y_INDEX] = this.getGraphic().pixelHeight();
+ box[BoundingBox.UPPER_RIGHT_X_INDEX] = this.getGraphic().getPixelWidth();
+ box[BoundingBox.UPPER_RIGHT_Y_INDEX] = this.getGraphic().getPixelHeight();
return BoundingBoxUtils.makeBoundingBox(box);
}
@@ -133,7 +133,7 @@
* top of the image when it is actually at the bottom. Therefore, we
* need a translate to move it up the page by the height of the
* graphic. */
- transform.translate(0, this.getGraphic().pixelHeight() * -1);
+ transform.translate(0, this.getGraphic().getPixelHeight() * -1);
return transform;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformSvg.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -112,8 +112,8 @@
final float[] box = new float[BoundingBox.QTY_ENTRIES];
box[BoundingBox.LOWER_LEFT_X_INDEX] = 0;
box[BoundingBox.LOWER_LEFT_Y_INDEX] = 0;
- box[BoundingBox.UPPER_RIGHT_X_INDEX] = this.getGraphic().pixelWidth();
- box[BoundingBox.UPPER_RIGHT_Y_INDEX] = this.getGraphic().pixelHeight();
+ box[BoundingBox.UPPER_RIGHT_X_INDEX] = this.getGraphic().getPixelWidth();
+ box[BoundingBox.UPPER_RIGHT_Y_INDEX] = this.getGraphic().getPixelHeight();
return BoundingBoxUtils.makeBoundingBox(box);
}
@@ -133,7 +133,7 @@
* top of the image when it is actually at the bottom. Therefore, we
* need a translate to move it up the page by the height of the
* graphic. */
- transform.translate(0, this.getGraphic().pixelHeight() * -1);
+ transform.translate(0, this.getGraphic().getPixelHeight() * -1);
return transform;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -183,7 +183,7 @@
case CCITT_GROUP_4:
filter = psServer.createEncodeFilter(PsFilterType.CCITT_FAX, outputStream);
filter.setInactive();
- filter.setDecodeParms("<< /K -1 /Columns " + graphic.pixelWidth() + " >>");
+ filter.setDecodeParms("<< /K -1 /Columns " + graphic.getPixelWidth() + " >>");
return filter;
case JPEG:
filter = psServer.createEncodeFilter(PsFilterType.DCT, outputStream);
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/Renderer4a.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -177,8 +177,8 @@
final int imgW;
final int imgH;
try {
- imgW = backgroundImage.absoluteWidth(getPixelsPerInch());
- imgH = backgroundImage.absoluteHeight(getPixelsPerInch());
+ imgW = backgroundImage.getAbsoluteWidth(getPixelsPerInch());
+ imgH = backgroundImage.getAbsoluteHeight(getPixelsPerInch());
} catch (final GraphicException fie) {
logError("Error obtaining bg image width and height");
logError(fie.getMessage());
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pcl/PclRenderer.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -393,8 +393,8 @@
int ix = 0;
int iy = 0;
int indx = 0;
- final int iw = img.pixelWidth();
- final int ih = img.pixelHeight();
+ final int iw = img.getPixelWidth();
+ final int ih = img.getPixelHeight();
int bytewidth = iw / PrimitiveConstants.BITS_PER_BYTE;
if ((iw % PrimitiveConstants.BITS_PER_BYTE) != 0) {
bytewidth++;
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-03 19:00:29 UTC (rev 13587)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-03 20:30:51 UTC (rev 13588)
@@ -512,8 +512,8 @@
float w = 0;
float h = 0;
try {
- w = svgGraphic.pixelWidth();
- h = svgGraphic.pixelHeight();
+ w = svgGraphic.getPixelWidth();
+ h = svgGraphic.getPixelHeight();
} catch (final GraphicException e) {
logError("Error getting graphic dimensions in "
+ this.getClass().getName());
@@ -619,8 +619,8 @@
write("clippath");
try {
- final int w = image.pixelWidth() * 1000;
- final int h = image.pixelHeight() * 1000;
+ final int w = image.getPixelWidth() * 1000;
+ final int h = image.getPixelHeight() * 1000;
final Rectangle rect = new Rectangle(x, y, w, h);
drawGraphic(area, image, rect, null);
} catch (final GraphicException e) {
@@ -767,8 +767,8 @@
}
write("<<");
write(" /ImageType 1");
- write(" /Width " + img.pixelWidth());
- write(" /Height " + img.pixelHeight());
+ write(" /Width " + img.getPixelWidth());
+ write(" /Height " + img.getPixelHeight());
write(" /BitsPerComponent 8");
if (img.getColorSpace().getType() == ColorSpace.TYPE_CMYK) {
if (img.isInverted()) {
@@ -782,8 +782,8 @@
write(" /Decode [0 1]");
}
// Setup scanning for left-to-right and top-to-bottom
- write(" /ImageMatrix [" + img.pixelWidth() + " 0 0 -"
- + img.pixelHeight() + " 0 " + img.pixelHeight() + "]");
+ write(" /ImageMatrix [" + img.getPixelWidth() + " 0 0 -"
+ + img.getPixelHeight() + " 0 " + img.getPixelHeight() + "]");
write(" /DataSource Data");
write(">>");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 19:00:46
|
Revision: 13587
http://sourceforge.net/p/foray/code/13587
Author: victormote
Date: 2025-05-03 19:00:29 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Parse the basics of each graphic file as it is created.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-03 16:33:52 UTC (rev 13586)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GraphicServer4a.java 2025-05-03 19:00:29 UTC (rev 13587)
@@ -187,6 +187,10 @@
throw new GraphicException("No Graphic Factory for: " + graphicLocation.toString());
}
+ /* Parse enough of the graphic so that it can be laid out properly, i.e. so that its dimensions, color space,
+ * channel depth, etc. are known. We can get the content later if needed. */
+ graphic.parseBasicsWrapper();
+
/* TODO: For now, caching all graphics. Revisit this. Separate caching of the basics, which should always be
* done, from that of caching the input stream, which is more expensive. */
// if (cachingThisGraphic) {
Modified: trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java
===================================================================
--- trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-03 16:33:52 UTC (rev 13586)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-03 19:00:29 UTC (rev 13587)
@@ -66,6 +66,7 @@
assertEquals(62, bmp.pixelHeight());
assertEquals(8, bmp.getBitsPerComponent());
assertTrue(bmp.getColorSpace().getType() == ColorSpace.TYPE_RGB);
+ assertEquals(3, bmp.getColorSpace().getNumComponents());
assertFalse(bmp.isTransparent());
assertNull(bmp.getTransparentColor());
final ByteSequence content = bmp.getContent();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 16:34:09
|
Revision: 13586
http://sourceforge.net/p/foray/code/13586
Author: victormote
Date: 2025-05-03 16:33:52 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Rename class for clarity.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/EpsFactory.java
Added Paths:
-----------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java
Removed Paths:
-------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java
Deleted: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java 2025-05-03 12:40:55 UTC (rev 13585)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java 2025-05-03 16:33:52 UTC (rev 13586)
@@ -1,363 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.graphic;
-
-import org.foray.common.data.BoundingBoxUtils;
-import org.foray.primitive.ByteUtils;
-import org.foray.primitive.sequence.ByteArray;
-
-import org.axsl.graphic.Graphic;
-import org.axsl.graphic.GraphicException;
-import org.axsl.primitive.sequence.ByteSequence;
-import org.axsl.ps.BoundingBox;
-
-import java.awt.Color;
-import java.awt.color.ColorSpace;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * An EPS (encapsulated Postscript) graphic.
- */
-public class EpsGraphic extends Graphic4a implements org.axsl.graphic.EpsGraphic {
-
- /** The size, in bytes, of the read buffer to use when reading the file. */
- private static final int READ_BUFFER_SIZE = 20480;
-
- /** The offset to the location at which the start of the PostScript portion
- * of the graphic is recorded. */
- private static final int PS_START_OFFSET = 4;
-
- /** The offset to the location at which the length of the PostScript portion
- * of the graphic is recorded. */
- private static final int PS_LENGTH_OFFSET = 8;
-
- /** The offset to the location at which the start of the WMF portion of
- * the graphic, if any, is recorded. */
- private static final int WMF_START_OFFSET = 12;
-
- /** The offset to the location at which the length of the TIFF portion of
- * the graphic, if any, is recorded. */
- private static final int WMF_LENGTH_OFFSET = 16;
-
- /** The offset to the location at which the start of the TIFF portion of
- * the graphic, if any, is recorded. */
- private static final int TIFF_START_OFFSET = 20;
-
- /** The offset to the location at which the length of the TIFF portion of
- * the graphic, if any, is recorded. */
- private static final int TIFF_LENGTH_OFFSET = 24;
-
- /** The name of this EPS graphic. */
- private String docName;
-
- /** The bounding box. */
- private BoundingBox bbox;
-
- /** Indicates whether this EPS is in ASCII format (true) or in binary format
- * (false). */
- private boolean isAscii;
-
- /** For preview EPS, bytes 5-8 (index 4-7) of the file, indicating the
- * offset to the PostScript portion of the file. */
- private int psStart = 0;
-
- /** For preview EPS, bytes 9-12 (index 8-11) of the file, indicating the
- * size, in bytes, of the PostScript portion of the file. */
- private int psLength = 0;
-
- /** For preview EPS, bytes 13-16 (index 12-15) of the file, indicating the
- * offset to the Windows Metafile portion of the file, if any. */
- private int wmfStart = 0;
-
- /** For preview EPS, bytes 17-20 (index 16-19) of the file, indicating the
- * size, in bytes, of the Windows Metafile portion of the file, if any. */
- private int wmfLength = 0;
-
- /** For preview EPS, bytes 21-24 (index 20-23) of the file, indicating the
- * offset to the TIFF portion of the file, if any. */
- private int tiffStart = 0;
-
- /** For preview EPS, bytes 25-28 (index 24-27) of the file, indicating the
- * size, in bytes, of the TIFF portion of the file, if any. */
- private int tiffLength = 0;
-
- /** The entire contents of the file. */
- private ByteArray fileContents;
-
- /** Image width (in pixel). */
- private int pixelWidth = 0;
-
- /** Image height (in pixel). */
- private int pixelHeight = 0;
-
- /**
- * Constructor.
- * @param server The parent graphic server.
- * @param url The URL which contains the graphic content.
- * @param bis The reusable input stream containing the bytes from {@code url}.
- * @param isASCII Indicates whether this file format is ASCII (true) or
- * binary (false).
- */
- public EpsGraphic(final GraphicServer4a server, final URL url,
- final BufferedInputStream bis, final boolean isASCII) {
- super(server, url, bis);
- this.docName = url.toString();
- this.isAscii = isASCII;
- }
-
- @Override
- public String getName() {
- return this.docName;
- }
-
- @Override
- protected void loadImage() throws GraphicException {
- if (isImageLoaded()) {
- return;
- }
- setImageLoaded(true);
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final byte[] readBuf = new byte[EpsGraphic.READ_BUFFER_SIZE];
- int bytesRead;
-
- try {
- while (true) {
- bytesRead = getInputStream().read(readBuf);
- if (bytesRead != -1) {
- baos.write(readBuf, 0, bytesRead);
- } else {
- break;
- }
- }
- } catch (final IOException ex) {
- throw new GraphicException("Error while loading image " +
- getUrl().toString() + " : " + ex.getClass() +
- " - " + ex.getMessage());
- }
- this.fileContents = new ByteArray(baos.toByteArray());
- }
-
- @Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.EPS;
- }
-
- @Override
- public Graphic.Compression getCompressionType() {
- return null;
- }
-
- @Override
- public String getMimeType() {
- return "image/eps";
- }
-
- @Override
- protected void parseBasics() throws IOException {
- final byte[] fileStart = new byte[this.maxBytesToParseBasics()];
- getInputStream().read(fileStart);
- if (! this.isAscii) {
- this.psStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.PS_START_OFFSET);
- this.psLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.PS_LENGTH_OFFSET);
- this.wmfStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.WMF_START_OFFSET);
- this.wmfLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.WMF_LENGTH_OFFSET);
- this.tiffStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.TIFF_START_OFFSET);
- this.tiffLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic.TIFF_LENGTH_OFFSET);
- }
- readBBox(fileStart);
- if (this.bbox != null) {
- final float xUR = this.bbox.getCoordinateAsFloat(BoundingBox.UPPER_RIGHT_X_INDEX);
- final float xLL = this.bbox.getCoordinateAsFloat(BoundingBox.LOWER_LEFT_X_INDEX);
- final float pixelWidth = xUR - xLL;
- this.pixelWidth = Math.round(pixelWidth);
- final float yUR = this.bbox.getCoordinateAsFloat(BoundingBox.UPPER_RIGHT_Y_INDEX);
- final float yLL = this.bbox.getCoordinateAsFloat(BoundingBox.LOWER_LEFT_Y_INDEX);
- final float pixelHeight = yUR - yLL;
- this.pixelHeight = Math.round(pixelHeight);
- } else {
- // Invalid EPS if no bounding box.
- throw new IOException("EPS missing bbox: " + getUrl().toString());
- }
- }
-
- @Override
- public ByteSequence getContent() throws GraphicException {
- this.loadImageWrapper();
- if (this.isAscii) {
- return this.fileContents;
- }
- final byte[] epsFile = new byte[this.psLength];
- System.arraycopy(this.fileContents, this.psStart, epsFile, 0,
- this.psLength);
- return new ByteArray(epsFile);
- }
-
- /**
- * Returns the embedded preview.
- * @return The embedded preview, or null if there is no preview.
- */
- public byte[] getPreview() {
- byte[] preview = null;
- if (this.tiffLength > 0) {
- preview = new byte[this.tiffLength];
- System.arraycopy(this.fileContents, this.tiffStart, preview, 0,
- this.tiffLength);
- } else if (this.wmfLength > 0) {
- preview = new byte[this.tiffLength];
- System.arraycopy(this.fileContents, this.wmfStart, preview, 0,
- this.wmfLength);
- }
- return preview;
- }
-
- /**
- * Extract and cache the bounding box information.
- * @param fileStart The first bytes of the file, which should contain the
- * bounding box information.
- */
- private void readBBox(final byte[] fileStart) {
- final ByteArray fileStart2 = new ByteArray(fileStart);
- final String bbxName = "%%BoundingBox:";
- int index = fileStart2.indexOf(bbxName);
- if (index < 0) {
- return;
- }
- /* index now holds the index of the start of bbxName. Skip past it. */
- index += bbxName.length();
- final float[] bboxArray = new float[BoundingBox.QTY_ENTRIES];
- for (int i = 0; i < BoundingBox.QTY_ENTRIES; i++) {
- index += readBBoxString(fileStart, i, index, bboxArray);
- }
- this.bbox = BoundingBoxUtils.makeBoundingBox(bboxArray);
- }
-
- /**
- * Read the string describing a bounding box component.
- * @param fileStart The first bytes of the file, which should contain the bounding box information.
- * @param bboxIndex 0-based index inicating which bounding box component is being parsed.
- * @param inputIdx The starting index into {@code fileStart} at which this method should start reading.
- * @param bboxArray The array that is being built, which contains the bounding box elements.
- * @return The value of the bounding box component parsed.
- */
- private int readBBoxString(final byte[] fileStart, final int bboxIndex,
- final int inputIdx, final float[] bboxArray) {
- int idx = inputIdx;
- while (idx < fileStart.length && (fileStart[idx] == ' ')) {
- idx++;
- }
- int nidx = idx;
- while (nidx < fileStart.length &&
- isNumeric(fileStart[nidx])) {
- nidx++;
- }
- final byte[] num = new byte[nidx - idx];
- System.arraycopy(fileStart, idx, num, 0, nidx - idx);
- final String ns = new String(num);
- bboxArray[bboxIndex] = Float.parseFloat(ns);
- return 1 + nidx - idx;
- }
-
- /**
- * Indicates whether a given byte is numeric for purposes of parsing the
- * bounding box components.
- * @param testByte The byte to be tested.
- * @return True if and only if the byte is numeric for purposes of parsing a bounding
- * box component.
- */
- private boolean isNumeric(final byte testByte) {
- if (testByte >= '0'
- && testByte <= '9') {
- return true;
- }
- if (testByte == '-') {
- return true;
- }
- if (testByte == '.') {
- return true;
- }
- return false;
- }
-
- @Override
- public BoundingBox getBoundingBox() {
- return this.bbox;
- }
-
- @Override
- public ByteSequence getRawSamples() throws GraphicException {
- /* EPS is not typically a raster format. */
- return null;
- }
-
- @Override
- public int absoluteWidthReal() throws GraphicException {
- return -1;
- }
-
- @Override
- public int absoluteHeightReal() throws GraphicException {
- return -1;
- }
-
- @Override
- public boolean isInverted() {
- return false;
- }
-
- @Override
- public ColorSpace getColorSpace() throws GraphicException {
- return null;
- }
-
- @Override
- public boolean isTransparent() throws GraphicException {
- return false;
- }
-
- @Override
- public Color getTransparentColor() throws GraphicException {
- return null;
- }
-
- @Override
- public int pixelWidth() throws GraphicException {
- this.parseBasicsWrapper();
- return this.pixelWidth;
- }
-
- @Override
- public int pixelHeight() throws GraphicException {
- this.parseBasicsWrapper();
- return this.pixelHeight;
- }
-
-}
Copied: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java (from rev 13486, trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic.java)
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java (rev 0)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java 2025-05-03 16:33:52 UTC (rev 13586)
@@ -0,0 +1,363 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.graphic;
+
+import org.foray.common.data.BoundingBoxUtils;
+import org.foray.primitive.ByteUtils;
+import org.foray.primitive.sequence.ByteArray;
+
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+import org.axsl.primitive.sequence.ByteSequence;
+import org.axsl.ps.BoundingBox;
+
+import java.awt.Color;
+import java.awt.color.ColorSpace;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * An EPS (encapsulated Postscript) graphic.
+ */
+public class EpsGraphic4a extends Graphic4a implements org.axsl.graphic.EpsGraphic {
+
+ /** The size, in bytes, of the read buffer to use when reading the file. */
+ private static final int READ_BUFFER_SIZE = 20480;
+
+ /** The offset to the location at which the start of the PostScript portion
+ * of the graphic is recorded. */
+ private static final int PS_START_OFFSET = 4;
+
+ /** The offset to the location at which the length of the PostScript portion
+ * of the graphic is recorded. */
+ private static final int PS_LENGTH_OFFSET = 8;
+
+ /** The offset to the location at which the start of the WMF portion of
+ * the graphic, if any, is recorded. */
+ private static final int WMF_START_OFFSET = 12;
+
+ /** The offset to the location at which the length of the TIFF portion of
+ * the graphic, if any, is recorded. */
+ private static final int WMF_LENGTH_OFFSET = 16;
+
+ /** The offset to the location at which the start of the TIFF portion of
+ * the graphic, if any, is recorded. */
+ private static final int TIFF_START_OFFSET = 20;
+
+ /** The offset to the location at which the length of the TIFF portion of
+ * the graphic, if any, is recorded. */
+ private static final int TIFF_LENGTH_OFFSET = 24;
+
+ /** The name of this EPS graphic. */
+ private String docName;
+
+ /** The bounding box. */
+ private BoundingBox bbox;
+
+ /** Indicates whether this EPS is in ASCII format (true) or in binary format
+ * (false). */
+ private boolean isAscii;
+
+ /** For preview EPS, bytes 5-8 (index 4-7) of the file, indicating the
+ * offset to the PostScript portion of the file. */
+ private int psStart = 0;
+
+ /** For preview EPS, bytes 9-12 (index 8-11) of the file, indicating the
+ * size, in bytes, of the PostScript portion of the file. */
+ private int psLength = 0;
+
+ /** For preview EPS, bytes 13-16 (index 12-15) of the file, indicating the
+ * offset to the Windows Metafile portion of the file, if any. */
+ private int wmfStart = 0;
+
+ /** For preview EPS, bytes 17-20 (index 16-19) of the file, indicating the
+ * size, in bytes, of the Windows Metafile portion of the file, if any. */
+ private int wmfLength = 0;
+
+ /** For preview EPS, bytes 21-24 (index 20-23) of the file, indicating the
+ * offset to the TIFF portion of the file, if any. */
+ private int tiffStart = 0;
+
+ /** For preview EPS, bytes 25-28 (index 24-27) of the file, indicating the
+ * size, in bytes, of the TIFF portion of the file, if any. */
+ private int tiffLength = 0;
+
+ /** The entire contents of the file. */
+ private ByteArray fileContents;
+
+ /** Image width (in pixel). */
+ private int pixelWidth = 0;
+
+ /** Image height (in pixel). */
+ private int pixelHeight = 0;
+
+ /**
+ * Constructor.
+ * @param server The parent graphic server.
+ * @param url The URL which contains the graphic content.
+ * @param bis The reusable input stream containing the bytes from {@code url}.
+ * @param isASCII Indicates whether this file format is ASCII (true) or
+ * binary (false).
+ */
+ public EpsGraphic4a(final GraphicServer4a server, final URL url,
+ final BufferedInputStream bis, final boolean isASCII) {
+ super(server, url, bis);
+ this.docName = url.toString();
+ this.isAscii = isASCII;
+ }
+
+ @Override
+ public String getName() {
+ return this.docName;
+ }
+
+ @Override
+ protected void loadImage() throws GraphicException {
+ if (isImageLoaded()) {
+ return;
+ }
+ setImageLoaded(true);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final byte[] readBuf = new byte[EpsGraphic4a.READ_BUFFER_SIZE];
+ int bytesRead;
+
+ try {
+ while (true) {
+ bytesRead = getInputStream().read(readBuf);
+ if (bytesRead != -1) {
+ baos.write(readBuf, 0, bytesRead);
+ } else {
+ break;
+ }
+ }
+ } catch (final IOException ex) {
+ throw new GraphicException("Error while loading image " +
+ getUrl().toString() + " : " + ex.getClass() +
+ " - " + ex.getMessage());
+ }
+ this.fileContents = new ByteArray(baos.toByteArray());
+ }
+
+ @Override
+ public Graphic.Type getGraphicType() {
+ return Graphic.Type.EPS;
+ }
+
+ @Override
+ public Graphic.Compression getCompressionType() {
+ return null;
+ }
+
+ @Override
+ public String getMimeType() {
+ return "image/eps";
+ }
+
+ @Override
+ protected void parseBasics() throws IOException {
+ final byte[] fileStart = new byte[this.maxBytesToParseBasics()];
+ getInputStream().read(fileStart);
+ if (! this.isAscii) {
+ this.psStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic4a.PS_START_OFFSET);
+ this.psLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic4a.PS_LENGTH_OFFSET);
+ this.wmfStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic4a.WMF_START_OFFSET);
+ this.wmfLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic4a.WMF_LENGTH_OFFSET);
+ this.tiffStart = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic4a.TIFF_START_OFFSET);
+ this.tiffLength = (int) ByteUtils.unsignedBytesToLongBE(fileStart, EpsGraphic4a.TIFF_LENGTH_OFFSET);
+ }
+ readBBox(fileStart);
+ if (this.bbox != null) {
+ final float xUR = this.bbox.getCoordinateAsFloat(BoundingBox.UPPER_RIGHT_X_INDEX);
+ final float xLL = this.bbox.getCoordinateAsFloat(BoundingBox.LOWER_LEFT_X_INDEX);
+ final float pixelWidth = xUR - xLL;
+ this.pixelWidth = Math.round(pixelWidth);
+ final float yUR = this.bbox.getCoordinateAsFloat(BoundingBox.UPPER_RIGHT_Y_INDEX);
+ final float yLL = this.bbox.getCoordinateAsFloat(BoundingBox.LOWER_LEFT_Y_INDEX);
+ final float pixelHeight = yUR - yLL;
+ this.pixelHeight = Math.round(pixelHeight);
+ } else {
+ // Invalid EPS if no bounding box.
+ throw new IOException("EPS missing bbox: " + getUrl().toString());
+ }
+ }
+
+ @Override
+ public ByteSequence getContent() throws GraphicException {
+ this.loadImageWrapper();
+ if (this.isAscii) {
+ return this.fileContents;
+ }
+ final byte[] epsFile = new byte[this.psLength];
+ System.arraycopy(this.fileContents, this.psStart, epsFile, 0,
+ this.psLength);
+ return new ByteArray(epsFile);
+ }
+
+ /**
+ * Returns the embedded preview.
+ * @return The embedded preview, or null if there is no preview.
+ */
+ public byte[] getPreview() {
+ byte[] preview = null;
+ if (this.tiffLength > 0) {
+ preview = new byte[this.tiffLength];
+ System.arraycopy(this.fileContents, this.tiffStart, preview, 0,
+ this.tiffLength);
+ } else if (this.wmfLength > 0) {
+ preview = new byte[this.tiffLength];
+ System.arraycopy(this.fileContents, this.wmfStart, preview, 0,
+ this.wmfLength);
+ }
+ return preview;
+ }
+
+ /**
+ * Extract and cache the bounding box information.
+ * @param fileStart The first bytes of the file, which should contain the
+ * bounding box information.
+ */
+ private void readBBox(final byte[] fileStart) {
+ final ByteArray fileStart2 = new ByteArray(fileStart);
+ final String bbxName = "%%BoundingBox:";
+ int index = fileStart2.indexOf(bbxName);
+ if (index < 0) {
+ return;
+ }
+ /* index now holds the index of the start of bbxName. Skip past it. */
+ index += bbxName.length();
+ final float[] bboxArray = new float[BoundingBox.QTY_ENTRIES];
+ for (int i = 0; i < BoundingBox.QTY_ENTRIES; i++) {
+ index += readBBoxString(fileStart, i, index, bboxArray);
+ }
+ this.bbox = BoundingBoxUtils.makeBoundingBox(bboxArray);
+ }
+
+ /**
+ * Read the string describing a bounding box component.
+ * @param fileStart The first bytes of the file, which should contain the bounding box information.
+ * @param bboxIndex 0-based index inicating which bounding box component is being parsed.
+ * @param inputIdx The starting index into {@code fileStart} at which this method should start reading.
+ * @param bboxArray The array that is being built, which contains the bounding box elements.
+ * @return The value of the bounding box component parsed.
+ */
+ private int readBBoxString(final byte[] fileStart, final int bboxIndex,
+ final int inputIdx, final float[] bboxArray) {
+ int idx = inputIdx;
+ while (idx < fileStart.length && (fileStart[idx] == ' ')) {
+ idx++;
+ }
+ int nidx = idx;
+ while (nidx < fileStart.length &&
+ isNumeric(fileStart[nidx])) {
+ nidx++;
+ }
+ final byte[] num = new byte[nidx - idx];
+ System.arraycopy(fileStart, idx, num, 0, nidx - idx);
+ final String ns = new String(num);
+ bboxArray[bboxIndex] = Float.parseFloat(ns);
+ return 1 + nidx - idx;
+ }
+
+ /**
+ * Indicates whether a given byte is numeric for purposes of parsing the
+ * bounding box components.
+ * @param testByte The byte to be tested.
+ * @return True if and only if the byte is numeric for purposes of parsing a bounding
+ * box component.
+ */
+ private boolean isNumeric(final byte testByte) {
+ if (testByte >= '0'
+ && testByte <= '9') {
+ return true;
+ }
+ if (testByte == '-') {
+ return true;
+ }
+ if (testByte == '.') {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public BoundingBox getBoundingBox() {
+ return this.bbox;
+ }
+
+ @Override
+ public ByteSequence getRawSamples() throws GraphicException {
+ /* EPS is not typically a raster format. */
+ return null;
+ }
+
+ @Override
+ public int absoluteWidthReal() throws GraphicException {
+ return -1;
+ }
+
+ @Override
+ public int absoluteHeightReal() throws GraphicException {
+ return -1;
+ }
+
+ @Override
+ public boolean isInverted() {
+ return false;
+ }
+
+ @Override
+ public ColorSpace getColorSpace() throws GraphicException {
+ return null;
+ }
+
+ @Override
+ public boolean isTransparent() throws GraphicException {
+ return false;
+ }
+
+ @Override
+ public Color getTransparentColor() throws GraphicException {
+ return null;
+ }
+
+ @Override
+ public int pixelWidth() throws GraphicException {
+ this.parseBasicsWrapper();
+ return this.pixelWidth;
+ }
+
+ @Override
+ public int pixelHeight() throws GraphicException {
+ this.parseBasicsWrapper();
+ return this.pixelHeight;
+ }
+
+}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/EpsFactory.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/EpsFactory.java 2025-05-03 12:40:55 UTC (rev 13585)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/EpsFactory.java 2025-05-03 16:33:52 UTC (rev 13586)
@@ -28,7 +28,7 @@
package org.foray.graphic.factory;
-import org.foray.graphic.EpsGraphic;
+import org.foray.graphic.EpsGraphic4a;
import org.foray.graphic.GraphicServer4a;
import java.io.BufferedInputStream;
@@ -70,7 +70,7 @@
}
@Override
- public EpsGraphic attemptCreate(final URL url,
+ public EpsGraphic4a attemptCreate(final URL url,
final BufferedInputStream bis) throws IOException {
final byte[] header = new byte[EpsFactory.EPS_HEADER_BINARY.length];
bis.read(header);
@@ -96,7 +96,7 @@
if (! isEPS) {
return null;
}
- return new EpsGraphic(this.getServer(), url, bis, isAscii);
+ return new EpsGraphic4a(this.getServer(), url, bis, isAscii);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 12:41:14
|
Revision: 13585
http://sourceforge.net/p/foray/code/13585
Author: victormote
Date: 2025-05-03 12:40:55 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Remove unused/unneeded method.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-05-03 11:09:24 UTC (rev 13584)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-05-03 12:40:55 UTC (rev 13585)
@@ -38,7 +38,6 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
-import org.axsl.ps.PsServer;
import java.io.IOException;
import java.io.InputStream;
@@ -190,14 +189,6 @@
}
/**
- * Returns the font server.
- * @return The font server.
- */
- public PsServer getPsServer() {
- return this.parserClient.getPsServer();
- }
-
- /**
* Returns the font parser client.
* @return The font parser client.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 11:09:42
|
Revision: 13584
http://sourceforge.net/p/foray/code/13584
Author: victormote
Date: 2025-05-03 11:09:24 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Remove unneded relationship between TableRecord and its parsed content.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java 2025-05-03 11:04:53 UTC (rev 13583)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java 2025-05-03 11:09:24 UTC (rev 13584)
@@ -43,7 +43,6 @@
*/
public RwTable(final TableRecord tableDirEntry) {
this.tableDirEntry = tableDirEntry;
- tableDirEntry.setTable(this);
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java 2025-05-03 11:04:53 UTC (rev 13583)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java 2025-05-03 11:09:24 UTC (rev 13584)
@@ -42,10 +42,6 @@
/** The size, in bytes, of each Table Directory entry. */
public static final byte ENTRY_BYTES = 16;
- /** The related TtfTable. This is null until the table has been parsed.
- * There is a nominal one-to-one relationship between a TTFTableDirEntry and a TtfTable. */
- private RwTable ttfTable = null;
-
/** The tag for the table. */
private String tag;
@@ -104,23 +100,4 @@
return this.length;
}
- /**
- * Sets the TtfTable that corresponds to this table directory entry.
- * The table directory is typically read first, then the table itself is
- * read and parsed later.
- * @param table The table that corresponds to this entry.
- */
- protected void setTable(final RwTable table) {
- this.ttfTable = table;
- }
-
- /**
- * Returns the TtfTable that this entry points to.
- * @return The TtfTable that this entry points to, if it has been parsed,
- * or null otherwise.
- */
- public RwTable getTable() {
- return this.ttfTable;
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 11:05:10
|
Revision: 13583
http://sourceforge.net/p/foray/code/13583
Author: victormote
Date: 2025-05-03 11:04:53 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Remove unnecessary relationship between TableRecord and its parent TableDirectory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java 2025-05-03 10:51:05 UTC (rev 13582)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java 2025-05-03 11:04:53 UTC (rev 13583)
@@ -99,7 +99,7 @@
raInput.skipBytes(RoTable.USHORT_BYTES);
for (int i = 0; i < numberOfTables; i++) {
- final TableRecord entry = TableRecord.parse(directory, raInput);
+ final TableRecord entry = TableRecord.parse(raInput);
directory.entries.put(entry.getTag(), entry);
}
return directory;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java 2025-05-03 10:51:05 UTC (rev 13582)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java 2025-05-03 11:04:53 UTC (rev 13583)
@@ -42,9 +42,6 @@
/** The size, in bytes, of each Table Directory entry. */
public static final byte ENTRY_BYTES = 16;
- /** The parent directory. */
- private TableDirectory directory = null;
-
/** The related TtfTable. This is null until the table has been parsed.
* There is a nominal one-to-one relationship between a TTFTableDirEntry and a TtfTable. */
private RwTable ttfTable = null;
@@ -63,22 +60,13 @@
/**
* Constructor.
- * @param directory The parent directory.
- */
- private TableRecord(final TableDirectory directory) {
- this.directory = directory;
- }
-
- /**
- * Constructor.
- * @param directory The parent directory instance from which this entry is read.
* @param raInput The input being parsed.
* @return The parsed entry.
* @throws IOException For i/o errors when parsing the entry.
*/
- public static TableRecord parse(final TableDirectory directory, final RandomAccessInput raInput)
+ public static TableRecord parse(final RandomAccessInput raInput)
throws IOException {
- final TableRecord entry = new TableRecord(directory);
+ final TableRecord entry = new TableRecord();
/* Read the 4-byte table identifier. */
entry.tag = raInput.readString(RoTable.ULONG_BYTES, StandardCharsets.ISO_8859_1);
/* Skip the checkSum. */
@@ -91,14 +79,6 @@
}
/**
- * Returns the parent directory.
- * @return The parent directory.
- */
- public TableDirectory getDirectory() {
- return this.directory;
- }
-
- /**
* Return this table's tag name.
* @return this table's tag name.
*/
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java 2025-05-03 10:51:05 UTC (rev 13582)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java 2025-05-03 11:04:53 UTC (rev 13583)
@@ -30,7 +30,6 @@
import org.foray.font.format.FontParser;
-import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
@@ -53,7 +52,7 @@
try {
this.tableDirectory = TableDirectory.parse(this, reader.getRandomInput(), 0);
} catch (final IOException e) {
- getLogger().error(e.getMessage());
+ LoggerFactory.getLogger(getClass()).error(e.getMessage());
}
}
@@ -80,13 +79,4 @@
return returnArray;
}
- /**
- * Returns the logger.
- * @return The logger.
- */
- private Logger getLogger() {
- /* Not cached because not expected to get used much. */
- return LoggerFactory.getLogger(getClass());
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 10:51:23
|
Revision: 13582
http://sourceforge.net/p/foray/code/13582
Author: victormote
Date: 2025-05-03 10:51:05 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Let subset file do its own seek.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 10:29:16 UTC (rev 13581)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 10:51:05 UTC (rev 13582)
@@ -131,7 +131,7 @@
public class TrueTypeFont {
/** The parent offset table. */
- private TableDirectory ttfTableDir = null;
+ private TableDirectory tableDirectory = null;
/** The (required) "cmap" table instance. */
private CmapTable cmapTable = null;
@@ -211,10 +211,10 @@
/**
* Constructor.
* Note: To get an instance of TTFFont, use {@link TrueTypeFont#makeTTFFont(TableDirectory)}.
- * @param ttfTableDir The table directory from which this font should be created.
+ * @param tableDirectory The table directory from which this font should be created.
*/
- TrueTypeFont(final TableDirectory ttfTableDir) {
- this.ttfTableDir = ttfTableDir;
+ TrueTypeFont(final TableDirectory tableDirectory) {
+ this.tableDirectory = tableDirectory;
}
/**
@@ -676,20 +676,6 @@
}
/**
- * Position the reader's input to the beginning of a given table.
- * @param name The name of the table to which the cursor should be
- * positioned.
- * @throws IOException For I/O Error.
- */
- void seekTab(final String name) throws IOException {
- final TableRecord dt = this.ttfTableDir.getTableDirectoryEntry(name);
- if (dt != null) {
- final TtfRandomAccessInput input = this.ttfTableDir.getTTFFile().getReader().getRandomInput();
- input.seek(dt.getOffset());
- }
- }
-
- /**
* Converts a TrueType Funits value to millipoints, based on the "unitsPerEm" field in the "head" table.
* Note that no consideration of font size is used here: the returned value is scaled to 1 point.
* Multiply the returned value by the font size, in points, to get the number of millipoints scaled to that size.
@@ -951,7 +937,7 @@
* @return The table directory entry for {@code name}.
*/
protected TableRecord getTTFDirTabEntry(final String name) {
- return this.ttfTableDir.getTableDirectoryEntry(name);
+ return this.tableDirectory.getTableDirectoryEntry(name);
}
/**
@@ -967,7 +953,7 @@
* @return The related TTFFile.
*/
public TrueTypeContainer getTTFFile() {
- return this.ttfTableDir.getTTFFile();
+ return this.tableDirectory.getTTFFile();
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-05-03 10:29:16 UTC (rev 13581)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-05-03 10:51:05 UTC (rev 13582)
@@ -315,7 +315,7 @@
if (entry == null) {
return null;
}
- this.ttfFont.seekTab("cvt ");
+ input.seek(entry.getOffset());
return copyTableToByteArray(input, entry.getLength());
}
@@ -330,7 +330,7 @@
if (entry == null) {
return null;
}
- this.ttfFont.seekTab("fpgm");
+ input.seek(entry.getOffset());
return copyTableToByteArray(input, entry.getLength());
}
@@ -371,7 +371,7 @@
if (entry == null) {
return null;
}
- this.ttfFont.seekTab("maxp");
+ input.seek(entry.getOffset());
final byte[] byteArray = copyTableToByteArray(input, entry.getLength());
int arrayIndex = 0;
/* Skip the table name (already written). */
@@ -392,7 +392,7 @@
if (entry == null) {
return null;
}
- this.ttfFont.seekTab("prep");
+ input.seek(entry.getOffset());
return copyTableToByteArray(input, entry.getLength());
}
@@ -408,7 +408,7 @@
if (entry == null) {
return null;
}
- this.ttfFont.seekTab("hhea");
+ input.seek(entry.getOffset());
final byte[] byteArray = copyTableToByteArray(input, entry.getLength());
writeUShort(byteArray, entry.getLength() - 2,
this.subset.numGlyphsUsed());
@@ -428,7 +428,7 @@
if (entry == null) {
return null;
}
- this.ttfFont.seekTab("head");
+ input.seek(entry.getOffset());
final byte[] byteArray = copyTableToByteArray(input, entry.getLength());
/* Set checkSumAdjustment to 0. */
writeULong(byteArray, HeadTable.CHECK_SUM_ADJUSTMENT_OFFSET, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 10:29:34
|
Revision: 13581
http://sourceforge.net/p/foray/code/13581
Author: victormote
Date: 2025-05-03 10:29:16 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Rename classes to better match the TrueType/OTF documentation.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -28,9 +28,9 @@
package org.foray.font.format;
+import org.foray.font.ttf.TableDirectory;
import org.foray.font.ttf.TrueTypeCollection;
import org.foray.font.ttf.TrueTypeSingle;
-import org.foray.font.ttf.TtfOffsetTable;
import org.foray.font.type1.Type1FontParser;
import org.foray.font.type1.Type1FontParserPfa;
import org.foray.font.type1.Type1FontParserPfb;
@@ -149,7 +149,7 @@
// TrueType, single-font file
this.randomInput.seek(0);
sfntVersion = this.randomInput.readInt();
- if (sfntVersion == TtfOffsetTable.TTF_FILE_SFNT_VERSION_1) {
+ if (sfntVersion == TableDirectory.TTF_FILE_SFNT_VERSION_1) {
this.fontFormat = Font.Format.TRUETYPE;
this.fileFormat = FontFileFormat.TTF_SINGLEFONT;
return;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -35,13 +35,13 @@
/** The Table Directory Entry corresponding to this table. */
- private TtfOffsetTableRecord tableDirEntry;
+ private TableRecord tableDirEntry;
/**
* Constructor.
* @param tableDirEntry The TTFTableDirEntry that defines this table.
*/
- public RwTable(final TtfOffsetTableRecord tableDirEntry) {
+ public RwTable(final TableRecord tableDirEntry) {
this.tableDirEntry = tableDirEntry;
tableDirEntry.setTable(this);
}
@@ -56,7 +56,7 @@
* Returns the TTFTableDirEntry that goes with this table.
* @return The TTFTableDirEntry related to this table.
*/
- public TtfOffsetTableRecord getTableDirEntry() {
+ public TableRecord getTableDirEntry() {
return this.tableDirEntry;
}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java (from rev 13486, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableDirectory.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf;
+
+import org.foray.common.RandomAccessInput;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A TrueType or OpenType Offset Table, the very first item in the content of a font.
+ * Even though it calls itself a "table" it is not part of the TrueType table hierarchy.
+ * It is a table of tables that describes how to find each of the tables in the font.
+ * Note that although it is the first item in the content of a font, it may not be the first item in the content of a
+ * font file.
+ * If the file is a TrueType collection of some sort, the offset to the Offset Table for each font is indicated in the
+ * TTCHeader.
+ */
+public final class TableDirectory {
+
+ /** Constant indicating the sfnt version for the table directory. */
+ public static final int TTF_FILE_SFNT_VERSION_1 = 0x10000;
+
+ /** Constant used in the computation of the search range and range shift
+ * values. */
+ public static final byte SEARCH_RANGE_CONSTANT = 16;
+
+ /** Constant indicating the size of the table directory itself, in bytes. */
+ public static final byte OFFSET_TABLE_SIZE = 12;
+
+ /** The parent container. */
+ private TrueTypeContainer container = null;
+
+ /** Map of the table directory entries. The key is the table name and the
+ * value is the TTFTableDirEntry for the table of that name. */
+ private Map<String, TableRecord> entries = new HashMap<String, TableRecord>();
+
+ /** The parent TTFFont instance. */
+ private TrueTypeFont ttfFont;
+
+ /**
+ * Constructor suitable for parsing an existing Table Directory.
+ * @param container The font parent container.
+ */
+ private TableDirectory(final TrueTypeContainer container) {
+ this.container = container;
+ }
+
+ /**
+ * Parse a Table Directory from the appropriate offset.
+ * Create the HashMap entries using the table name as the key and the appropriate TTFDirTabEntry as the value.
+ * @param container The font parent container.
+ * @param raInput The input being parsed.
+ * @param fileOffset The offset to the specific font in {@code container} that should be parsed (remember that a
+ * TTF font file can contain more than one TTF font.
+ * @return The parsed instance.
+ * @throws IOException For I/O error.
+ */
+ public static TableDirectory parse(final TrueTypeContainer container, final RandomAccessInput raInput,
+ final long fileOffset) throws IOException {
+ final TableDirectory directory = new TableDirectory(container);
+ raInput.seek(fileOffset);
+ /* Skip sfnt version (format version). */
+ raInput.skipBytes(RoTable.FIXED_BYTES);
+ /* Read the number of tables. */
+ final int numberOfTables = raInput.readUnsignedShort();
+ /* Skip the searchRange. */
+ raInput.skipBytes(RoTable.USHORT_BYTES);
+ /* Skip the entrySelector. */
+ raInput.skipBytes(RoTable.USHORT_BYTES);
+ /* Skip the rangeShift. */
+ raInput.skipBytes(RoTable.USHORT_BYTES);
+
+ for (int i = 0; i < numberOfTables; i++) {
+ final TableRecord entry = TableRecord.parse(directory, raInput);
+ directory.entries.put(entry.getTag(), entry);
+ }
+ return directory;
+ }
+
+ /**
+ * Return the table directory entry for a given table name.
+ * @param tableName The name of the table whose table directory entry is
+ * sought.
+ * @return The table directory entry for {@code tableName}.
+ */
+ protected TableRecord getTableDirectoryEntry(final String tableName) {
+ return this.entries.get(tableName);
+ }
+
+ /**
+ * Indicates whether the font has been created.
+ * @return True if and only if the {@link TrueTypeFont} instance has been instantiated.
+ */
+ public boolean ttfFontCreated() {
+ return this.ttfFont != null;
+ }
+
+ /**
+ * Parses the font described by this table directory and stores the parsed instance in this for retrieval with
+ * {@link #getTTFFont()}.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public void parseFont() throws IOException {
+ if (this.ttfFont != null) {
+ return;
+ }
+ this.ttfFont = TrueTypeFont.parse(this, this.getTTFFile().getReader().getRandomInput());
+ }
+
+ /**
+ * Returns the TTFFont related to this table directory.
+ * @return The TTFFont related to this table directory.
+ */
+ public TrueTypeFont getTTFFont() {
+ return this.ttfFont;
+ }
+
+ /**
+ * Sets the TTFFont for this table directory.
+ * @param newFont The TTFFont for this table directory.
+ */
+ public void setTTFFont(final TrueTypeFont newFont) {
+ if (this.ttfFont == null) {
+ this.ttfFont = newFont;
+ }
+ }
+
+ /**
+ * Returns the parent TTFFile.
+ * @return The parent TTFFile.
+ */
+ public TrueTypeContainer getTTFFile() {
+ return this.container;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java (from rev 13486, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TableRecord.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf;
+
+import org.foray.common.RandomAccessInput;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * A TrueType or OpenType Offset Table Record.
+ * This stores the offset and length of one table in the font.
+ */
+public final class TableRecord {
+
+ /** The size, in bytes, of each Table Directory entry. */
+ public static final byte ENTRY_BYTES = 16;
+
+ /** The parent directory. */
+ private TableDirectory directory = null;
+
+ /** The related TtfTable. This is null until the table has been parsed.
+ * There is a nominal one-to-one relationship between a TTFTableDirEntry and a TtfTable. */
+ private RwTable ttfTable = null;
+
+ /** The tag for the table. */
+ private String tag;
+
+ /** The offset from the beginning of the file, in bytes, of this table entry.
+ * This should be an unsigned integer, but no such creature exists in Java. */
+ private int offset;
+
+ /**
+ * The length, in bytes, of this table entry.
+ * This should be an unsigned integer, but no such creature exists in Java. */
+ private int length;
+
+ /**
+ * Constructor.
+ * @param directory The parent directory.
+ */
+ private TableRecord(final TableDirectory directory) {
+ this.directory = directory;
+ }
+
+ /**
+ * Constructor.
+ * @param directory The parent directory instance from which this entry is read.
+ * @param raInput The input being parsed.
+ * @return The parsed entry.
+ * @throws IOException For i/o errors when parsing the entry.
+ */
+ public static TableRecord parse(final TableDirectory directory, final RandomAccessInput raInput)
+ throws IOException {
+ final TableRecord entry = new TableRecord(directory);
+ /* Read the 4-byte table identifier. */
+ entry.tag = raInput.readString(RoTable.ULONG_BYTES, StandardCharsets.ISO_8859_1);
+ /* Skip the checkSum. */
+ raInput.skipBytes(RoTable.ULONG_BYTES);
+ /* Read the offset to the table. */
+ entry.offset = (int) raInput.readUnsignedInt();
+ /* Read the length of the table. */
+ entry.length = (int) raInput.readUnsignedInt();
+ return entry;
+ }
+
+ /**
+ * Returns the parent directory.
+ * @return The parent directory.
+ */
+ public TableDirectory getDirectory() {
+ return this.directory;
+ }
+
+ /**
+ * Return this table's tag name.
+ * @return this table's tag name.
+ */
+ public String getTag() {
+ return this.tag;
+ }
+
+ /**
+ * Returns the offset from the beginning of the file, in bytes, of this
+ * table entry.
+ * @return The offset from the beginning of the file, in bytes, of this
+ * table entry.
+ */
+ public int getOffset() {
+ return this.offset;
+ }
+
+ /**
+ * Returns the length, in bytes, of this table entry.
+ * @return The length, in bytes, of this table entry.
+ */
+ public int getLength() {
+ return this.length;
+ }
+
+ /**
+ * Sets the TtfTable that corresponds to this table directory entry.
+ * The table directory is typically read first, then the table itself is
+ * read and parsed later.
+ * @param table The table that corresponds to this entry.
+ */
+ protected void setTable(final RwTable table) {
+ this.ttfTable = table;
+ }
+
+ /**
+ * Returns the TtfTable that this entry points to.
+ * @return The TtfTable that this entry points to, if it has been parsed,
+ * or null otherwise.
+ */
+ public RwTable getTable() {
+ return this.ttfTable;
+ }
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -52,7 +52,7 @@
/** Collection of TTFTableDirectory entries. There should be one entry for
* each logical font in the TTC file. */
- private TtfOffsetTable[] tableDirectories;
+ private TableDirectory[] tableDirectories;
/** TODO: Remove this. */
private TtfRandomAccessInput raInput;
@@ -78,11 +78,11 @@
*/
protected void readFile(final RandomAccessInput raInput) throws IOException {
this.ttcHeader = TtcTableHeader.parse(this, raInput);
- this.tableDirectories = new TtfOffsetTable[
+ this.tableDirectories = new TableDirectory[
this.ttcHeader.getNumDirectories()];
for (int i = 0; i < this.ttcHeader.getNumDirectories(); i++) {
- final TtfOffsetTable tableDir =
- TtfOffsetTable.parse(this, raInput, this.ttcHeader.getDirectoryOffset(i));
+ final TableDirectory tableDir =
+ TableDirectory.parse(this, raInput, this.ttcHeader.getDirectoryOffset(i));
this.tableDirectories[i] = tableDir;
}
}
@@ -104,9 +104,9 @@
public String[] getChildFontNames() throws IOException {
final String[] fontNames = new String[numFonts()];
for (int i = 0; i < numFonts(); i++) {
- final TtfOffsetTable tableDir = this.tableDirectories[i];
+ final TableDirectory tableDir = this.tableDirectories[i];
// Get the "name" table
- final TtfOffsetTableRecord tableDirEntry
+ final TableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
final ParserKit<NameTable, NameTableHandler> parseKit = NameTable.createContentHandler();
final NameTableParser parser = new NameTableParser();
@@ -124,9 +124,9 @@
return null;
}
for (int i = 0; i < numFonts(); i++) {
- final TtfOffsetTable tableDir = this.tableDirectories[i];
+ final TableDirectory tableDir = this.tableDirectories[i];
// Get the "name" table
- final TtfOffsetTableRecord tableDirEntry
+ final TableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
this.getReader().getRandomInput().seek(tableDirEntry.getOffset());
@@ -153,7 +153,7 @@
public TrueTypeFont[] getTTFFonts() {
final TrueTypeFont[] fontArray = new TrueTypeFont[numFonts()];
for (int i = 0; i < numFonts(); i++) {
- final TtfOffsetTable tableDir = this.tableDirectories[i];
+ final TableDirectory tableDir = this.tableDirectories[i];
fontArray[i] = tableDir.getTTFFont();
}
return fontArray;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -131,7 +131,7 @@
public class TrueTypeFont {
/** The parent offset table. */
- private TtfOffsetTable ttfTableDir = null;
+ private TableDirectory ttfTableDir = null;
/** The (required) "cmap" table instance. */
private CmapTable cmapTable = null;
@@ -210,10 +210,10 @@
/**
* Constructor.
- * Note: To get an instance of TTFFont, use {@link TrueTypeFont#makeTTFFont(TtfOffsetTable)}.
+ * Note: To get an instance of TTFFont, use {@link TrueTypeFont#makeTTFFont(TableDirectory)}.
* @param ttfTableDir The table directory from which this font should be created.
*/
- TrueTypeFont(final TtfOffsetTable ttfTableDir) {
+ TrueTypeFont(final TableDirectory ttfTableDir) {
this.ttfTableDir = ttfTableDir;
}
@@ -224,7 +224,7 @@
* @return The newly-created {@link TrueTypeFont} instance.
* @throws IOException For I/O errors parsing the input.
*/
- public static TrueTypeFont parse(final TtfOffsetTable ttfTableDir, final TtfRandomAccessInput raInput)
+ public static TrueTypeFont parse(final TableDirectory ttfTableDir, final TtfRandomAccessInput raInput)
throws IOException {
if (ttfTableDir.getTTFFont() != null) {
return ttfTableDir.getTTFFont();
@@ -236,7 +236,7 @@
/* BEGIN REQUIRED TABLES ************************************************************************************ */
/* Read the Font Header first. */
- TtfOffsetTableRecord dirEntry = ttfTableDir.getTableDirectoryEntry("head");
+ TableRecord dirEntry = ttfTableDir.getTableDirectoryEntry("head");
{
final ParserKit<HeadTable, HeadTableHandler> contentHandler = HeadTable.createContentHandler();
final TableParser<HeadTableHandler> parser = new HeadTableParser();
@@ -682,7 +682,7 @@
* @throws IOException For I/O Error.
*/
void seekTab(final String name) throws IOException {
- final TtfOffsetTableRecord dt = this.ttfTableDir.getTableDirectoryEntry(name);
+ final TableRecord dt = this.ttfTableDir.getTableDirectoryEntry(name);
if (dt != null) {
final TtfRandomAccessInput input = this.ttfTableDir.getTTFFile().getReader().getRandomInput();
input.seek(dt.getOffset());
@@ -950,7 +950,7 @@
* @param name The name of the table sought.
* @return The table directory entry for {@code name}.
*/
- protected TtfOffsetTableRecord getTTFDirTabEntry(final String name) {
+ protected TableRecord getTTFDirTabEntry(final String name) {
return this.ttfTableDir.getTableDirectoryEntry(name);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -41,7 +41,7 @@
public class TrueTypeSingle extends TrueTypeContainer {
/** The child table directory for this font file. */
- private TtfOffsetTable tableDirectory;
+ private TableDirectory tableDirectory;
/**
* Constructor. Parses the passed file and returns it as an object.
@@ -51,7 +51,7 @@
public TrueTypeSingle(final FontParser reader) {
super(reader);
try {
- this.tableDirectory = TtfOffsetTable.parse(this, reader.getRandomInput(), 0);
+ this.tableDirectory = TableDirectory.parse(this, reader.getRandomInput(), 0);
} catch (final IOException e) {
getLogger().error(e.getMessage());
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -1,164 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.ttf;
-
-import org.foray.common.RandomAccessInput;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A TrueType or OpenType Offset Table, the very first item in the content of a font.
- * Even though it calls itself a "table" it is not part of the TrueType table hierarchy.
- * It is a table of tables that describes how to find each of the tables in the font.
- * Note that although it is the first item in the content of a font, it may not be the first item in the content of a
- * font file.
- * If the file is a TrueType collection of some sort, the offset to the Offset Table for each font is indicated in the
- * TTCHeader.
- */
-public final class TtfOffsetTable {
-
- /** Constant indicating the sfnt version for the table directory. */
- public static final int TTF_FILE_SFNT_VERSION_1 = 0x10000;
-
- /** Constant used in the computation of the search range and range shift
- * values. */
- public static final byte SEARCH_RANGE_CONSTANT = 16;
-
- /** Constant indicating the size of the table directory itself, in bytes. */
- public static final byte OFFSET_TABLE_SIZE = 12;
-
- /** The parent container. */
- private TrueTypeContainer container = null;
-
- /** Map of the table directory entries. The key is the table name and the
- * value is the TTFTableDirEntry for the table of that name. */
- private Map<String, TtfOffsetTableRecord> entries = new HashMap<String, TtfOffsetTableRecord>();
-
- /** The parent TTFFont instance. */
- private TrueTypeFont ttfFont;
-
- /**
- * Constructor suitable for parsing an existing Table Directory.
- * @param container The font parent container.
- */
- private TtfOffsetTable(final TrueTypeContainer container) {
- this.container = container;
- }
-
- /**
- * Parse a Table Directory from the appropriate offset.
- * Create the HashMap entries using the table name as the key and the appropriate TTFDirTabEntry as the value.
- * @param container The font parent container.
- * @param raInput The input being parsed.
- * @param fileOffset The offset to the specific font in {@code container} that should be parsed (remember that a
- * TTF font file can contain more than one TTF font.
- * @return The parsed instance.
- * @throws IOException For I/O error.
- */
- public static TtfOffsetTable parse(final TrueTypeContainer container, final RandomAccessInput raInput,
- final long fileOffset) throws IOException {
- final TtfOffsetTable directory = new TtfOffsetTable(container);
- raInput.seek(fileOffset);
- /* Skip sfnt version (format version). */
- raInput.skipBytes(RoTable.FIXED_BYTES);
- /* Read the number of tables. */
- final int numberOfTables = raInput.readUnsignedShort();
- /* Skip the searchRange. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip the entrySelector. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip the rangeShift. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
-
- for (int i = 0; i < numberOfTables; i++) {
- final TtfOffsetTableRecord entry = TtfOffsetTableRecord.parse(directory, raInput);
- directory.entries.put(entry.getTag(), entry);
- }
- return directory;
- }
-
- /**
- * Return the table directory entry for a given table name.
- * @param tableName The name of the table whose table directory entry is
- * sought.
- * @return The table directory entry for {@code tableName}.
- */
- protected TtfOffsetTableRecord getTableDirectoryEntry(final String tableName) {
- return this.entries.get(tableName);
- }
-
- /**
- * Indicates whether the font has been created.
- * @return True if and only if the {@link TrueTypeFont} instance has been instantiated.
- */
- public boolean ttfFontCreated() {
- return this.ttfFont != null;
- }
-
- /**
- * Parses the font described by this table directory and stores the parsed instance in this for retrieval with
- * {@link #getTTFFont()}.
- * @throws IOException For I/O errors during parsing.
- */
- public void parseFont() throws IOException {
- if (this.ttfFont != null) {
- return;
- }
- this.ttfFont = TrueTypeFont.parse(this, this.getTTFFile().getReader().getRandomInput());
- }
-
- /**
- * Returns the TTFFont related to this table directory.
- * @return The TTFFont related to this table directory.
- */
- public TrueTypeFont getTTFFont() {
- return this.ttfFont;
- }
-
- /**
- * Sets the TTFFont for this table directory.
- * @param newFont The TTFFont for this table directory.
- */
- public void setTTFFont(final TrueTypeFont newFont) {
- if (this.ttfFont == null) {
- this.ttfFont = newFont;
- }
- }
-
- /**
- * Returns the parent TTFFile.
- * @return The parent TTFFile.
- */
- public TrueTypeContainer getTTFFile() {
- return this.container;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -1,146 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * 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.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.ttf;
-
-import org.foray.common.RandomAccessInput;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-
-/**
- * A TrueType or OpenType Offset Table Record.
- * This stores the offset and length of one table in the font.
- */
-public final class TtfOffsetTableRecord {
-
- /** The size, in bytes, of each Table Directory entry. */
- public static final byte ENTRY_BYTES = 16;
-
- /** The parent directory. */
- private TtfOffsetTable directory = null;
-
- /** The related TtfTable. This is null until the table has been parsed.
- * There is a nominal one-to-one relationship between a TTFTableDirEntry and a TtfTable. */
- private RwTable ttfTable = null;
-
- /** The tag for the table. */
- private String tag;
-
- /** The offset from the beginning of the file, in bytes, of this table entry.
- * This should be an unsigned integer, but no such creature exists in Java. */
- private int offset;
-
- /**
- * The length, in bytes, of this table entry.
- * This should be an unsigned integer, but no such creature exists in Java. */
- private int length;
-
- /**
- * Constructor.
- * @param directory The parent directory.
- */
- private TtfOffsetTableRecord(final TtfOffsetTable directory) {
- this.directory = directory;
- }
-
- /**
- * Constructor.
- * @param directory The parent directory instance from which this entry is read.
- * @param raInput The input being parsed.
- * @return The parsed entry.
- * @throws IOException For i/o errors when parsing the entry.
- */
- public static TtfOffsetTableRecord parse(final TtfOffsetTable directory, final RandomAccessInput raInput)
- throws IOException {
- final TtfOffsetTableRecord entry = new TtfOffsetTableRecord(directory);
- /* Read the 4-byte table identifier. */
- entry.tag = raInput.readString(RoTable.ULONG_BYTES, StandardCharsets.ISO_8859_1);
- /* Skip the checkSum. */
- raInput.skipBytes(RoTable.ULONG_BYTES);
- /* Read the offset to the table. */
- entry.offset = (int) raInput.readUnsignedInt();
- /* Read the length of the table. */
- entry.length = (int) raInput.readUnsignedInt();
- return entry;
- }
-
- /**
- * Returns the parent directory.
- * @return The parent directory.
- */
- public TtfOffsetTable getDirectory() {
- return this.directory;
- }
-
- /**
- * Return this table's tag name.
- * @return this table's tag name.
- */
- public String getTag() {
- return this.tag;
- }
-
- /**
- * Returns the offset from the beginning of the file, in bytes, of this
- * table entry.
- * @return The offset from the beginning of the file, in bytes, of this
- * table entry.
- */
- public int getOffset() {
- return this.offset;
- }
-
- /**
- * Returns the length, in bytes, of this table entry.
- * @return The length, in bytes, of this table entry.
- */
- public int getLength() {
- return this.length;
- }
-
- /**
- * Sets the TtfTable that corresponds to this table directory entry.
- * The table directory is typically read first, then the table itself is
- * read and parsed later.
- * @param table The table that corresponds to this entry.
- */
- protected void setTable(final RwTable table) {
- this.ttfTable = table;
- }
-
- /**
- * Returns the TtfTable that this entry points to.
- * @return The TtfTable that this entry points to, if it has been parsed,
- * or null otherwise.
- */
- public RwTable getTable() {
- return this.ttfTable;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-05-03 10:17:15 UTC (rev 13580)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-05-03 10:29:16 UTC (rev 13581)
@@ -227,7 +227,7 @@
/* Write the search range. */
final int maxPow = maxPow2(numTables);
final int searchRange = maxPow
- * TtfOffsetTable.SEARCH_RANGE_CONSTANT;
+ * TableDirectory.SEARCH_RANGE_CONSTANT;
writeUShort(byteArray, arrayIndex, searchRange);
arrayIndex += 2;
/* Write the entry selector. */
@@ -235,7 +235,7 @@
arrayIndex += 2;
/* Write the range shift. */
final int rangeShift = numTables
- * TtfOffsetTable.SEARCH_RANGE_CONSTANT
+ * TableDirectory.SEARCH_RANGE_CONSTANT
- searchRange;
writeUShort(byteArray, arrayIndex, rangeShift);
return byteArray;
@@ -289,10 +289,10 @@
private long getTableOffset(final String tableName) {
int tableOffset = 0;
/* Skip past the offset table. */
- tableOffset += TtfOffsetTable.OFFSET_TABLE_SIZE;
+ tableOffset += TableDirectory.OFFSET_TABLE_SIZE;
/* Skip past the directory table entries. */
tableOffset += this.tableFontOrderList.size()
- * TtfOffsetTableRecord.ENTRY_BYTES;
+ * TableRecord.ENTRY_BYTES;
for (String currentTableName : this.tableFontOrderList) {
if (currentTableName.equals(tableName)) {
break;
@@ -311,7 +311,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createCvt(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("cvt ", false);
+ final TableRecord entry = getEntry("cvt ", false);
if (entry == null) {
return null;
}
@@ -326,7 +326,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createFpgm(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("fpgm", false);
+ final TableRecord entry = getEntry("fpgm", false);
if (entry == null) {
return null;
}
@@ -367,7 +367,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createMaxp(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("maxp", true);
+ final TableRecord entry = getEntry("maxp", true);
if (entry == null) {
return null;
}
@@ -388,7 +388,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createPrep(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("prep", false);
+ final TableRecord entry = getEntry("prep", false);
if (entry == null) {
return null;
}
@@ -404,7 +404,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createHhea(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("hhea", true);
+ final TableRecord entry = getEntry("hhea", true);
if (entry == null) {
return null;
}
@@ -424,7 +424,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createHead(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("head", true);
+ final TableRecord entry = getEntry("head", true);
if (entry == null) {
return null;
}
@@ -448,7 +448,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createGlyf(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("glyf", true);
+ final TableRecord entry = getEntry("glyf", true);
if (entry == null) {
return null;
}
@@ -519,7 +519,7 @@
* @throws IOException For I/O Error.
*/
private byte[] createHmtx() throws IOException {
- final TtfOffsetTableRecord entry = getEntry("hmtx", true);
+ final TableRecord entry = getEntry("hmtx", true);
if (entry == null) {
return null;
}
@@ -613,7 +613,7 @@
* @throws IOException For I/O Error.
*/
private void scanGlyphs(final TtfRandomAccessInput input) throws IOException {
- final TtfOffsetTableRecord entry = getEntry("glyf", true);
+ final TableRecord entry = getEntry("glyf", true);
if (entry == null) {
return;
}
@@ -638,7 +638,7 @@
* @throws IOException for errors when reading the font file.
*/
private Map<Integer, Integer> getUsedCompositeGlyphs(final TtfRandomAccessInput input,
- final TtfOffsetTableRecord glyfTableDirEntry) throws IOException {
+ final TableRecord glyfTableDirEntry) throws IOException {
final Map<Integer, Integer> usedCompositeGlyphs
= new HashMap<Integer, Integer>();
boolean stillCheckingForCompositeGlyphs = true;
@@ -682,7 +682,7 @@
* @throws IOException for errors reading the font file.
*/
private Map<Integer, Integer> getComponentGlyphsToAdd(final TtfRandomAccessInput input,
- final TtfOffsetTableRecord glyfTableDirEntry,
+ final TableRecord glyfTableDirEntry,
final Map<Integer, Integer> usedCompositeGlyphs)
throws IOException {
final Map<Integer, Integer> componentGlyphsToAdd
@@ -908,9 +908,9 @@
* @param requiredTable Set to true if the table is a table that is required in all TTF fonts.
* @return The appropriate table directory entry.
*/
- private TtfOffsetTableRecord getEntry(final String tableName,
+ private TableRecord getEntry(final String tableName,
final boolean requiredTable) {
- final TtfOffsetTableRecord entry = this.ttfFont.getTTFDirTabEntry(
+ final TableRecord entry = this.ttfFont.getTTFDirTabEntry(
tableName);
if (entry == null && requiredTable) {
LoggerFactory.getLogger(getClass()).error(TtfSubSetFile.TTF_MESSAGE + "Can't find " + tableName + " table");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 10:17:34
|
Revision: 13580
http://sourceforge.net/p/foray/code/13580
Author: victormote
Date: 2025-05-03 10:17:15 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Peripheral cleanup of font parsing.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-03 00:32:40 UTC (rev 13579)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-05-03 10:17:15 UTC (rev 13580)
@@ -36,7 +36,6 @@
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.NameTableHandler;
-import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
@@ -68,7 +67,7 @@
try {
readFile(reader.getRandomInput());
} catch (final IOException e) {
- getLogger().error(e.getMessage());
+ LoggerFactory.getLogger(getClass()).error(e.getMessage());
}
}
@@ -160,13 +159,4 @@
return fontArray;
}
- /**
- * Returns the logger.
- * @return The logger.
- */
- private Logger getLogger() {
- /* Not cached because not expected to get used much. */
- return LoggerFactory.getLogger(getClass());
- }
-
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 00:32:40 UTC (rev 13579)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 10:17:15 UTC (rev 13580)
@@ -28,7 +28,6 @@
package org.foray.font.ttf;
-import org.foray.common.RandomAccessInput;
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
@@ -685,7 +684,8 @@
void seekTab(final String name) throws IOException {
final TtfOffsetTableRecord dt = this.ttfTableDir.getTableDirectoryEntry(name);
if (dt != null) {
- this.getRandomAccessInput().seek(dt.getOffset());
+ final TtfRandomAccessInput input = this.ttfTableDir.getTTFFile().getReader().getRandomInput();
+ input.seek(dt.getOffset());
}
}
@@ -1018,12 +1018,4 @@
return mpUnderlinePosition;
}
- /**
- * Returns the random access input.
- * @return The random access input.
- */
- private RandomAccessInput getRandomAccessInput() {
- return this.ttfTableDir.getTTFFile().getReader().getRandomInput();
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-03 00:32:59
|
Revision: 13579
http://sourceforge.net/p/foray/code/13579
Author: victormote
Date: 2025-05-03 00:32:40 +0000 (Sat, 03 May 2025)
Log Message:
-----------
Convert glyf table to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GlyfTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GlyfTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-02 22:47:29 UTC (rev 13578)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-03 00:32:40 UTC (rev 13579)
@@ -67,6 +67,7 @@
import org.foray.fontParse.ttf.FpgmTableParser;
import org.foray.fontParse.ttf.GaspTableParser;
import org.foray.fontParse.ttf.GdefTableParser;
+import org.foray.fontParse.ttf.GlyfTableParser;
import org.foray.fontParse.ttf.GposTableParser;
import org.foray.fontParse.ttf.GsubTableParser;
import org.foray.fontParse.ttf.HeadTableParser;
@@ -92,6 +93,7 @@
import org.foray.fontParse.ttfHandler.FpgmTableHandler;
import org.foray.fontParse.ttfHandler.GaspTableHandler;
import org.foray.fontParse.ttfHandler.GdefTableHandler;
+import org.foray.fontParse.ttfHandler.GlyfTableHandler;
import org.foray.fontParse.ttfHandler.GposTableHandler;
import org.foray.fontParse.ttfHandler.GsubTableHandler;
import org.foray.fontParse.ttfHandler.HeadTableHandler;
@@ -346,8 +348,11 @@
/* glyf must be parsed after hmtx and loca. */
dirEntry = ttfTableDir.getTableDirectoryEntry("glyf");
if (dirEntry != null) {
- font.glyfTable = GlyfTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), numberOfGlyphs,
- font.locaTable);
+ final ParserKit<GlyfTable, GlyfTableHandler> contentHandler = GlyfTable.createContentHandler(
+ font.getLocaTable(), numberOfGlyphs);
+ final GlyfTableParser parser = new GlyfTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.glyfTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("prep");
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-05-02 22:47:29 UTC (rev 13578)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-05-03 00:32:40 UTC (rev 13579)
@@ -28,7 +28,6 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
import org.foray.common.data.BoundingBoxShort;
import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
@@ -37,8 +36,6 @@
import org.axsl.ps.BoundingBox;
-import java.io.IOException;
-
/**
* A TrueType/OpenType "glyf" (Glyph Data) table.
* This table is used only in fonts that contain TrueType outlines.
@@ -51,16 +48,52 @@
private final class ContentHandler implements GlyfTableHandler {
/** The table instance being created. */
- @SuppressWarnings("unused")
private GlyfTable table;
+ /** The "loca" table containing the offsets to the glyph data. */
+ private LocaTable locaTable;
+
+ /** The number of glyph entries to be parsed. This information is derived from the "maxp" table. */
+ private int numberOfGlyphs;
+
+ /** The index of the bounding box currently being parsed. */
+ private int currentBboxIndex = -1;
+
/**
* Constructor.
* @param table The table instance being created.
+ * @param locaTable The "loca" table containing the offsets to the glyph data.
+ * @param numberOfGlyphs The number of glyph entries to be parsed.
*/
- private ContentHandler(final GlyfTable table) {
+ private ContentHandler(final GlyfTable table, final LocaTable locaTable, final int numberOfGlyphs) {
this.table = table;
+ this.locaTable = locaTable;
+ this.numberOfGlyphs = numberOfGlyphs;
+ this.table.bbox = new BoundingBox[numberOfGlyphs];
}
+
+ @Override
+ public int getNumberOfGlyphs() {
+ return this.numberOfGlyphs;
+ }
+
+ @Override
+ public int getGlyphTableOffset(final int glyphIndex) {
+ final int offset = this.locaTable.getOffset(glyphIndex);
+ final int offsetNext = this.locaTable.getOffset(glyphIndex + 1);
+ if ((offsetNext - offset) == 0) {
+ return -1;
+ } else {
+ return offset;
+ }
+ }
+
+ @Override
+ public void bbox(final short[] value) {
+ this.currentBboxIndex ++;
+ this.table.bbox[currentBboxIndex] = new BoundingBoxShort(value);
+ }
+
}
@@ -111,67 +144,18 @@
/**
* Creates a table instance and a content handler for that instance.
+ * @param locaTable The "loca" table containing the offsets to the glyph data.
+ * @param numberOfGlyphs The number of glyph entries to be parsed.
* @return A new content handler.
*/
- public static ParserKit<GlyfTable, GlyfTableHandler> createContentHandler() {
+ public static ParserKit<GlyfTable, GlyfTableHandler> createContentHandler(final LocaTable locaTable,
+ final int numberOfGlyphs) {
final GlyfTable table = new GlyfTable();
- final GlyfTableHandler handler = table.new ContentHandler(table);
+ final GlyfTableHandler handler = table.new ContentHandler(table, locaTable, numberOfGlyphs);
return new ParserKit<GlyfTable, GlyfTableHandler>(table, handler);
}
/**
- * Reads the "glyf" table to find the bounding boxes.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @param numberOfGlyphs The number of glyphs to be parsed.
- * This data is derived from the "maxp" table.
- * @param loca The loca table.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static GlyfTable parse(final RandomAccessInput input, final int offset, final int length,
- final int numberOfGlyphs, final LocaTable loca) throws IOException {
- input.seek(offset);
- final GlyfTable glyf = new GlyfTable();
- glyf.bbox = new BoundingBoxShort[numberOfGlyphs];
- for (int i = 0; i < (numberOfGlyphs - 1); i++) {
- final int thisOffset = loca.getOffset(i);
- final int nextOffset = loca.getOffset(i + 1);
- if (thisOffset != nextOffset) {
- input.seek(offset + thisOffset);
- input.skipBytes(2);
- final short[] bboxEntries = new short[BoundingBox.QTY_ENTRIES];
- for (int j = 0; j < BoundingBox.QTY_ENTRIES; j++) {
- bboxEntries[j] = input.readShort();
- }
- glyf.bbox[i] = new BoundingBoxShort(bboxEntries);
- } else {
- glyf.bbox[i] = glyf.bbox[0];
- }
- }
-
- final int n = offset;
- for (int i = 0; i < numberOfGlyphs; i++) {
- final int thisOffset = loca.getOffset(i);
- final int nextOffset = loca.getOffset(i + 1);
- if ((i + 1) >= numberOfGlyphs
- || thisOffset != nextOffset) {
- input.seek(n + thisOffset);
- input.skipBytes(2);
- final short[] bboxEntries = new short[BoundingBox.QTY_ENTRIES];
- for (int j = 0; j < BoundingBox.QTY_ENTRIES; j++) {
- bboxEntries[j] = input.readShort();
- }
- glyf.bbox[i] = new BoundingBoxShort(bboxEntries);
- } else {
- glyf.bbox[i] = glyf.bbox[0];
- }
- }
- return glyf;
- }
-
- /**
* Computes the size, in bytes, of a composite entry, based on the flags for that entry.
* @param compositeFlags The flags for the entry.
* @return The size, in bytes, of the composite entry.
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GlyfTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GlyfTableParser.java 2025-05-02 22:47:29 UTC (rev 13578)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GlyfTableParser.java 2025-05-03 00:32:40 UTC (rev 13579)
@@ -38,13 +38,41 @@
*/
public class GlyfTableParser extends TableParser<GlyfTableHandler> {
-
@Override
public void parse(final TtfRandomAccessInput input, final int offset, final GlyfTableHandler handler)
throws IOException {
input.seek(offset);
- /* TODO: Complete this. */
+ final int numGlyphs = handler.getNumberOfGlyphs();
+
+ for (int index = 0; index < numGlyphs; index ++) {
+ final int glyphOffset = handler.getGlyphTableOffset(index);
+
+ if (glyphOffset > -1) {
+ input.seek(offset + glyphOffset);
+ handler.numberOfContours(input.read_int16()); // 2 bytes, total 2
+ final short xMin = input.read_int16();
+ handler.xMin(xMin);
+ final short yMin = input.read_int16();
+ handler.yMin(yMin);
+ final short xMax = input.read_int16();
+ handler.xMax(xMax);
+ final short yMax = input.read_int16();
+ handler.yMax(yMax);
+ final short[] bbox = {xMin, yMin, xMax, yMax};
+ handler.bbox(bbox);
+ } else {
+ handler.xMin((short) 0);
+ handler.yMin((short) 0);
+ handler.xMax((short) 0);
+ handler.yMax((short) 0);
+ final short[] bbox = {0, 0, 0, 0};
+ handler.bbox(bbox);
+ }
+ }
+
+
+ /* We do not currently have need to parse more than the Header. TODO: Complete this. */
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GlyfTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GlyfTableHandler.java 2025-05-02 22:47:29 UTC (rev 13578)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GlyfTableHandler.java 2025-05-03 00:32:40 UTC (rev 13579)
@@ -36,6 +36,40 @@
*/
public interface GlyfTableHandler extends FontContentHandler {
- /* TODO: Complete this. */
+ /**
+ * Unlike most handler methods which are essentially "setters", this method is a getter.
+ * Although not documented as such, this value is obtained the same way that it is for
+ * {@link HmtxTableHandler#getNumberOfGlyphs()}, this is, from the "maxp" table, "numGlyphs" field.
+ * Also unlike most handler methods, implementation of this method is required.
+ * @return The total number of glyphs in this font.
+ */
+ int getNumberOfGlyphs();
+
+
+
+ /* Glyph Header. */
+ default void numberOfContours(final short value) { return; }
+
+ /**
+ * Unlike most handler methods which are essentially "setters", this method is a getter.
+ * Also unlike most handler methods, implementation of this method is required.
+ * @param glyphIndex The glyph index for which the offset should be returned.
+ * @return The offset, in the "glyf" table, at which the glyph data for {@code glyphIndex} is found, or -1 if there
+ * is no data.
+ */
+ int getGlyphTableOffset(int glyphIndex);
+
+
+ default void xMin(final short value) { return; }
+ default void yMin(final short value) { return; }
+ default void xMax(final short value) { return; }
+ default void yMax(final short value) { return; }
+
+ /* This is the same data that is in xMin, yMin, xMax, and yMax. */
+ default void bbox(final short[] value) { return; }
+
+
+ /* We do not currently have need to parse more than the Header. TODO: Complete this. */
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|