foray-commit Mailing List for FOray (Page 7)
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-24 13:42:18
|
Revision: 13728
http://sourceforge.net/p/foray/code/13728
Author: victormote
Date: 2025-05-24 13:42:17 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Add more infrastructure for foray-pdf-core.
Modified Paths:
--------------
trunk/foray/settings.gradle
Added Paths:
-----------
trunk/foray/foray-pdf-core/src/main/java/org/
trunk/foray/foray-pdf-core/src/main/java/org/foray/
trunk/foray/foray-pdf-core/src/main/java/org/foray/pdf/
trunk/foray/foray-pdf-core/src/test/java/
Modified: trunk/foray/settings.gradle
===================================================================
--- trunk/foray/settings.gradle 2025-05-24 12:31:48 UTC (rev 13727)
+++ trunk/foray/settings.gradle 2025-05-24 13:42:17 UTC (rev 13728)
@@ -16,6 +16,7 @@
include 'foray-orthography'
include 'foray-output'
include 'foray-pdf'
+include 'foray-pdf-core'
include 'foray-pdf-parse'
include 'foray-pioneer'
include 'foray-primitive'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 12:31:49
|
Revision: 13727
http://sourceforge.net/p/foray/code/13727
Author: victormote
Date: 2025-05-24 12:31:48 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Rough-in PDF Core project, for shared code.
Added Paths:
-----------
trunk/foray/foray-pdf-core/
trunk/foray/foray-pdf-core/build.gradle
trunk/foray/foray-pdf-core/src/
trunk/foray/foray-pdf-core/src/main/
trunk/foray/foray-pdf-core/src/main/java/
trunk/foray/foray-pdf-core/src/test/
Added: trunk/foray/foray-pdf-core/build.gradle
===================================================================
--- trunk/foray/foray-pdf-core/build.gradle (rev 0)
+++ trunk/foray/foray-pdf-core/build.gradle 2025-05-24 12:31:48 UTC (rev 13727)
@@ -0,0 +1,18 @@
+plugins {
+ id 'foray.library-conventions'
+ id 'foray.test-conventions'
+ id 'foray.logging-conventions'
+}
+
+description = 'foray-pdf-core'
+
+dependencies {
+}
+
+javadoc {
+ options.windowTitle = "FOray PDF Core API"
+ options.docTitle = "FOray PDF Core API"
+ options.header = "FOray PDF Core API ${version}"
+}
+
+/* Last line of script. */
Property changes on: trunk/foray/foray-pdf-core/build.gradle
___________________________________________________________________
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-24 12:13:58
|
Revision: 13726
http://sourceforge.net/p/foray/code/13726
Author: victormote
Date: 2025-05-24 12:13:56 +0000 (Sat, 24 May 2025)
Log Message:
-----------
First steps toward breaking PDF parsing off as a separate project.
Modified Paths:
--------------
trunk/foray/settings.gradle
Added Paths:
-----------
trunk/foray/foray-pdf-parse/
trunk/foray/foray-pdf-parse/build.gradle
trunk/foray/foray-pdf-parse/src/
trunk/foray/foray-pdf-parse/src/main/
trunk/foray/foray-pdf-parse/src/main/java/
trunk/foray/foray-pdf-parse/src/test/
Added: trunk/foray/foray-pdf-parse/build.gradle
===================================================================
--- trunk/foray/foray-pdf-parse/build.gradle (rev 0)
+++ trunk/foray/foray-pdf-parse/build.gradle 2025-05-24 12:13:56 UTC (rev 13726)
@@ -0,0 +1,18 @@
+plugins {
+ id 'foray.library-conventions'
+ id 'foray.test-conventions'
+ id 'foray.logging-conventions'
+}
+
+description = 'foray-pdf-parse'
+
+dependencies {
+}
+
+javadoc {
+ options.windowTitle = "FOray PDF Parse API"
+ options.docTitle = "FOray PDF Parse API"
+ options.header = "FOray PDF Parse API ${version}"
+}
+
+/* Last line of script. */
Property changes on: trunk/foray/foray-pdf-parse/build.gradle
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/settings.gradle
===================================================================
--- trunk/foray/settings.gradle 2025-05-24 11:14:57 UTC (rev 13725)
+++ trunk/foray/settings.gradle 2025-05-24 12:13:56 UTC (rev 13726)
@@ -16,6 +16,7 @@
include 'foray-orthography'
include 'foray-output'
include 'foray-pdf'
+include 'foray-pdf-parse'
include 'foray-pioneer'
include 'foray-primitive'
include 'foray-ps'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 11:15:00
|
Revision: 13725
http://sourceforge.net/p/foray/code/13725
Author: victormote
Date: 2025-05-24 11:14:57 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Narrow the type processed to EpsVectorGraphic.
Modified Paths:
--------------
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
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-24 11:14:15 UTC (rev 13724)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-24 11:14:57 UTC (rev 13725)
@@ -56,7 +56,7 @@
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.EpsVectorGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.GraphicFormat;
@@ -581,8 +581,8 @@
} catch (final IOException e) {
throw new GalleyVisitorException(e);
}
- } else if (image instanceof EpsGraphic) {
- renderEPS((EpsGraphic) image, contentRectangle.x,
+ } else if (image instanceof EpsVectorGraphic) {
+ renderEPS((EpsVectorGraphic) image, contentRectangle.x,
contentRectangle.y, contentRectangle.width,
contentRectangle.height);
} else if (image instanceof BitmapGraphic) {
@@ -636,7 +636,7 @@
* drawn.
* @throws GalleyVisitorException For errors during rendering.
*/
- public void renderEPS(final EpsGraphic img, final int x, final int y,
+ public void renderEPS(final EpsVectorGraphic img, final int x, final int y,
final int w, final int h) throws GalleyVisitorException {
try {
this.out.writeByteArr(epsToPostScript(img, x, y, w, h));
@@ -660,14 +660,14 @@
* @return The byte array containing the graphic as PostScript.
* @throws GraphicException For errors processing the graphic.
*/
- public byte[] epsToPostScript(final EpsGraphic image, final int x,
+ public byte[] epsToPostScript(final EpsVectorGraphic image, final int x,
final int y, final int w, final int h) throws GraphicException {
- final BoundingBox bbox = image.getVectorGraphic().getBoundingBox();
+ final BoundingBox bbox = image.getBoundingBox();
final float bboxw = bbox.computeWidthAsFloat();
final float bboxh = bbox.computeHeightAsFloat();
StringBuilder buffer = new StringBuilder();
- buffer.append("%%BeginDocument: " + image.getVectorGraphic().getName());
+ buffer.append("%%BeginDocument: " + image.getName());
buffer.append("BeginEPSF");
buffer.append(x + " " + (y - h) + " translate");
@@ -694,15 +694,15 @@
buffer.append("");
final String string2 = buffer.toString();
final byte[] output = new byte[string1.length()
- + image.getVectorGraphic().getContent().length()
+ + image.getContent().length()
+ string2.length()];
int offset = 0;
System.arraycopy(string1.getBytes(), 0, output, offset,
string1.getBytes().length);
offset += string1.getBytes().length;
- System.arraycopy(image.getVectorGraphic().getContent(), 0, output, offset,
- image.getVectorGraphic().getContent().length());
- offset += image.getVectorGraphic().getContent().length();
+ System.arraycopy(image.getContent(), 0, output, offset,
+ image.getContent().length());
+ offset += image.getContent().length();
System.arraycopy(string2.getBytes(), 0, output, offset,
string2.getBytes().length);
return output;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-24 11:14:20
|
Revision: 13724
http://sourceforge.net/p/foray/code/13724
Author: victormote
Date: 2025-05-24 11:14:15 +0000 (Sat, 24 May 2025)
Log Message:
-----------
Whitespace changes only.
Modified Paths:
--------------
trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2025-05-23 16:21:57 UTC (rev 13723)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/pdf/PdfRenderer.java 2025-05-24 11:14:15 UTC (rev 13724)
@@ -164,8 +164,7 @@
}
/**
- * Checks the encryption options, and adds encryption to this document if
- * it has been specified.
+ * Checks the encryption options, and adds encryption to this document if it has been specified.
*/
private void addEncryption() throws PdfException {
if (this.getOutputConfiguration() == null) {
@@ -177,10 +176,8 @@
final String uPassword = this.getOutputConfiguration().getUserPassword();
final boolean allowPrint = this.getOutputConfiguration().canUserPrint();
final boolean allowCopyContent = this.getOutputConfiguration().canUserCopy();
- final boolean allowEditContent =
- this.getOutputConfiguration().canUserModify();
- final boolean allowEditAnnotations =
- this.getOutputConfiguration().canUserAnnotate();
+ final boolean allowEditContent = this.getOutputConfiguration().canUserModify();
+ final boolean allowEditAnnotations = this.getOutputConfiguration().canUserAnnotate();
if (oPassword != null) {
encrypt = true;
@@ -205,8 +202,7 @@
public void startOutput() throws OutputException {
final String pdfVersion = this.getOutputConfiguration().getPdfVersion();
if (pdfVersion != null) {
- final PdfVersion pdfVersionConstant = PdfVersion.fromString(
- pdfVersion);
+ final PdfVersion pdfVersionConstant = PdfVersion.fromString(pdfVersion);
this.pdfDoc.setVersion(pdfVersionConstant);
}
final PdfDocumentInfo info = this.pdfDoc.getDocumentInfo(true);
@@ -251,9 +247,8 @@
}
@Override
- protected void drawLine(final int startX, final int startY, final int endX,
- final int endY, final int thickness, final RuleStyle ruleStyle,
- final Color strokeColor) throws GalleyVisitorException {
+ protected void drawLine(final int startX, final int startY, final int endX, final int endY, final int thickness,
+ final RuleStyle ruleStyle, final Color strokeColor) throws GalleyVisitorException {
final PdfColor newStrokeColor;
if (strokeColor == null) {
newStrokeColor = null;
@@ -277,11 +272,9 @@
}
}
- final Line2D.Float line = new Line2D.Float(toPoints(startX),
- toPoints(startY), toPoints(endX), toPoints(endY));
+ final Line2D.Float line = new Line2D.Float(toPoints(startX), toPoints(startY), toPoints(endX), toPoints(endY));
try {
- getContentStream().setLineCapStyle(
- PdfLineCapStyle.PROJECTING_SQUARE_CAP);
+ getContentStream().setLineCapStyle(PdfLineCapStyle.PROJECTING_SQUARE_CAP);
getContentStream().setLineWidth(toPoints(thickness));
getContentStream().setDashPattern(dashArray, BigDecimal.ZERO);
getContentStream().setStrokeColor(newStrokeColor);
@@ -292,9 +285,8 @@
}
@Override
- protected void drawRectangle(final int x, final int y, final int w,
- final int h, final Color strokeColor, final Color fillColor)
- throws GalleyVisitorException {
+ protected void drawRectangle(final int x, final int y, final int w, final int h, final Color strokeColor,
+ final Color fillColor) throws GalleyVisitorException {
PdfPathPaint strokePaint = null;
if (strokeColor != null) {
strokePaint = this.getPDFDocument().createPdfColor(strokeColor);
@@ -303,8 +295,7 @@
if (fillColor != null) {
fillPaint = this.getPDFDocument().createPdfColor(fillColor);
}
- final Rectangle2D.Float rectangle = new Rectangle2D.Float(toPoints(x),
- toPoints(y), toPoints(w), toPoints(h));
+ final Rectangle2D.Float rectangle = new Rectangle2D.Float(toPoints(x), toPoints(y), toPoints(w), toPoints(h));
try {
/* Adjust the stroke paint. */
@@ -317,8 +308,7 @@
final PdfColor newFillColor = this.getPDFDocument().createPdfColor(fillColor);
this.getContentStream().setFillColor(newFillColor);
}
- getContentStream().drawRectangle(rectangle, strokePaint != null,
- fillPaint != null);
+ getContentStream().drawRectangle(rectangle, strokePaint != null, fillPaint != null);
} catch (final PdfException e) {
throw new GalleyVisitorException(e);
}
@@ -325,13 +315,10 @@
}
@Override
- protected void drawGraphic(final GraphicAreaG5 area, final Graphic image,
- final Rectangle contentRectangle, final Rectangle clipRectangle)
- throws GalleyVisitorException {
- final Rectangle2D.Float pdfContentRectangle =
- convertMillipointRectangle(contentRectangle);
- final Rectangle2D.Float pdfClipRectangle = convertMillipointRectangle(
- clipRectangle);
+ protected void drawGraphic(final GraphicAreaG5 area, final Graphic image, final Rectangle contentRectangle,
+ final Rectangle clipRectangle) throws GalleyVisitorException {
+ final Rectangle2D.Float pdfContentRectangle = convertMillipointRectangle(contentRectangle);
+ final Rectangle2D.Float pdfClipRectangle = convertMillipointRectangle(clipRectangle);
try {
final PdfXobject xObject = this.pdfDoc.createXobject(image, area.getOrthography(), getFontConsumer());
getContentStream().drawXobject(xObject, pdfContentRectangle, pdfClipRectangle);
@@ -389,8 +376,7 @@
/* TODO: Need to compute this value from the URI?? However, if
* computable, it doesn't need to be in the interface. */
final boolean isExternal = true;
- this.currentPage.createLink(shape.getBounds2D(), target.toString(),
- isExternal);
+ this.currentPage.createLink(shape.getBounds2D(), target.toString(), isExternal);
}
}
@@ -438,8 +424,8 @@
}
}
if (startIndex < text.length()) {
- paintText(area, currentFont, text, startIndex, text.length() - startIndex,
- area.fontContext(), area.getOrthography());
+ paintText(area, currentFont, text, startIndex, text.length() - startIndex, area.fontContext(),
+ area.getOrthography());
}
} catch (final PdfException e) {
throw new GalleyVisitorException(e);
@@ -493,8 +479,7 @@
* @param area The area being rendered.
* @param fontUse The font to use in rendering this text.
* @param text The array containing the text to be rendered.
- * @param startIndex The starting index into {@code text} which should
- * be rendered.
+ * @param startIndex The starting index into {@code text} which should be rendered.
* @param size The size of {@code text} which should be rendered.
* @param fontContext The font options, such as ligatures and small-caps that should be used when computing the
* glyphs for this word.
@@ -501,9 +486,9 @@
* @param orthography The orthography that should be used when applying font features like subsitutions.
* @throws PdfException For errors painting the text.
*/
- private void paintText(final GlyphAreaSequenceG5 area, final FontUse fontUse,
- final CharSequence text, final int startIndex, final int size,
- final FontContext fontContext, final Orthography orthography) throws PdfException {
+ private void paintText(final GlyphAreaSequenceG5 area, final FontUse fontUse, final CharSequence text,
+ final int startIndex, final int size, final FontContext fontContext, final Orthography orthography)
+ throws PdfException {
if (size < 1) {
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-23 16:22:00
|
Revision: 13723
http://sourceforge.net/p/foray/code/13723
Author: victormote
Date: 2025-05-23 16:21:57 +0000 (Fri, 23 May 2025)
Log Message:
-----------
Conform to aXSL change: Move Font format from enum to standalone class, so that it is extensible.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeContainer.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java
trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/Font4a.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -33,6 +33,7 @@
import org.foray.font.format.Panose4a;
import org.axsl.font.Font;
+import org.axsl.font.FontFormat;
import org.axsl.i18n.Script;
import org.axsl.ps.CharSet;
import org.axsl.unicode.block.U0000_Basic_Latin;
@@ -193,7 +194,7 @@
public abstract org.axsl.ps.Encoding getInternalEncoding();
@Override
- public abstract Font.Format getFontFormat();
+ public abstract FontFormat getFormat();
/**
* Returns the kerning for this font.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FreeStandingFont.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -35,6 +35,7 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
@@ -270,7 +271,7 @@
return false;
}
/* TODO: We don't know how to subset CFF fonts yet. */
- if (getFontFormat() == Format.OTF_CFF) {
+ if (getFormat() == FontFormat.OTF_CFF) {
return false;
}
/* Only subset if we have been told to. */
@@ -328,22 +329,19 @@
* If the font is any other format: -1.
*/
public int getAWTFontFormat() {
- switch (this.getFontFormat()) {
- case TRUETYPE: {
+ if (FontFormat.TRUETYPE == getFormat()) {
return java.awt.Font.TRUETYPE_FONT;
}
- case TYPE1: {
+ if (FontFormat.TYPE1 == getFormat()) {
return java.awt.Font.TYPE1_FONT;
}
- case OTF_CFF: {
+ if (FontFormat.OTF_CFF == getFormat()) {
return java.awt.Font.TYPE1_FONT;
}
- case OTF_TRUETYPE: {
+ if (FontFormat.OTF_TRUETYPE == getFormat()) {
return java.awt.Font.TRUETYPE_FONT;
}
- default:
- break;
- }
+
return -1;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -40,6 +40,7 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
@@ -69,7 +70,7 @@
private int stemV = 0;
/** The font format. */
- private Font.Format fontFormat;
+ private FontFormat fontFormat;
/**
* Construct an instance.
@@ -144,7 +145,7 @@
this.setPanose(this.ttf.getPanose());
this.setAllowsEmbedding(this.ttf.isEmbeddable());
- this.fontFormat = this.ttf.getFontFormat();
+ this.fontFormat = this.ttf.getFormat();
}
/**
@@ -177,7 +178,7 @@
}
@Override
- public Font.Format getFontFormat() {
+ public FontFormat getFormat() {
return this.fontFormat;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -43,6 +43,7 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.EncodingVector;
@@ -258,8 +259,8 @@
}
@Override
- public Font.Format getFontFormat() {
- return Format.TYPE1;
+ public FontFormat getFormat() {
+ return FontFormat.TYPE1;
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/SystemFont.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -36,6 +36,7 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
@@ -254,13 +255,13 @@
}
@Override
- public org.axsl.font.Font.Format getFontFormat() {
+ public FontFormat getFormat() {
final FreeStandingFont relatedFSFont =
this.freeStandingFontManifestation();
if (relatedFSFont == null) {
return null;
}
- return relatedFSFont.getFontFormat();
+ return relatedFSFont.getFormat();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -44,6 +44,7 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import org.axsl.ps.PsServer;
import org.slf4j.Logger;
@@ -314,22 +315,22 @@
* @throws FontException For error during FreeStandingFont creation.
*/
private FreeStandingFont createFSFont() throws FontException {
- final Font.Format fontFormat;
+ final FontFormat fontFormat;
if (this.fontFileSource == null) {
/* The assumption here is that we have a metrics file for this
* font, but not a font file, therefore it is Type 1. */
- fontFormat = Font.Format.TYPE1;
+ fontFormat = FontFormat.TYPE1;
} else {
/* TODO: See if we ca*/
fontFormat = createFontFileReader().getFontFormat();
}
- switch (fontFormat) {
- case TYPE1: {
+
+ if (FontFormat.TYPE1 == fontFormat) {
return new FsType1Font(this);
}
- case TRUETYPE:
- case OTF_CFF:
- case OTF_TRUETYPE: {
+ if (FontFormat.TRUETYPE == fontFormat
+ || FontFormat.OTF_CFF == fontFormat
+ || FontFormat.TRUETYPE == fontFormat) {
try {
return new FsTrueTypeFont(this);
} catch (final IOException e) {
@@ -337,9 +338,7 @@
throw new IllegalStateException(e);
}
}
- }
- throw new FontException("Font " + this.configuredFontName
- + " is an unknown format.");
+ throw new FontException("Font " + this.configuredFontName + " is an unknown format.");
}
/**
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-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -36,8 +36,8 @@
import org.foray.font.type1.Type1FontParserPfb;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
-import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import java.io.IOException;
import java.io.InputStream;
@@ -63,7 +63,7 @@
private static final String OPENTYPE_CFF_HEADER = "OTTO";
/** Set to one of the Font.FORMAT constants. */
- private Font.Format fontFormat;
+ private FontFormat fontFormat;
/** Set to one of the FILEFORMAT constants. */
private FontFileFormat fileFormat = FontFileFormat.UNKNOWN;
@@ -127,7 +127,7 @@
if (tag.startsWith(FontParser.TYPE_1_HEADER_2)
|| tag.startsWith(FontParser.TYPE_1_HEADER_3)
|| tag.equals(FontParser.TYPE_1_HEADER_1)) {
- this.fontFormat = Font.Format.TYPE1;
+ this.fontFormat = FontFormat.TYPE1;
this.fileFormat = FontFileFormat.TYPE1_PFA;
return;
}
@@ -140,7 +140,7 @@
if (tag.startsWith(FontParser.TYPE_1_HEADER_2)
|| tag.startsWith(FontParser.TYPE_1_HEADER_3)
|| tag.equals(FontParser.TYPE_1_HEADER_1)) {
- this.fontFormat = Font.Format.TYPE1;
+ this.fontFormat = FontFormat.TYPE1;
this.fileFormat = FontFileFormat.TYPE1_PFB;
return;
}
@@ -149,7 +149,7 @@
this.randomInput.seek(0);
sfntVersion = this.randomInput.readInt();
if (sfntVersion == TableDirectory.TTF_FILE_SFNT_VERSION_1) {
- this.fontFormat = Font.Format.TRUETYPE;
+ this.fontFormat = FontFormat.TRUETYPE;
this.fileFormat = FontFileFormat.TTF_SINGLEFONT;
return;
}
@@ -157,7 +157,7 @@
this.randomInput.seek(0);
tag = this.randomInput.readStringASCII(FontParser.TTF_HEADER.length());
if (tag.equals(FontParser.TTF_HEADER)) {
- this.fontFormat = Font.Format.TRUETYPE;
+ this.fontFormat = FontFormat.TRUETYPE;
this.fileFormat = FontFileFormat.TTF_COLLECTION;
return;
}
@@ -165,7 +165,7 @@
this.randomInput.seek(0);
tag = this.randomInput.readStringASCII(FontParser.OPENTYPE_CFF_HEADER.length());
if (tag.equals(FontParser.OPENTYPE_CFF_HEADER)) {
- this.fontFormat = Font.Format.OTF_CFF;
+ this.fontFormat = FontFormat.OTF_CFF;
this.fileFormat = FontFileFormat.OTF_CFF;
return;
}
@@ -176,7 +176,7 @@
* Returns the format of this font.
* @return The format of this font.
*/
- public Font.Format getFontFormat() {
+ public FontFormat getFontFormat() {
return this.fontFormat;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeContainer.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeContainer.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeContainer.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -31,7 +31,7 @@
import org.foray.font.format.FontContent;
import org.foray.font.format.FontParser;
-import org.axsl.font.Font;
+import org.axsl.font.FontFormat;
/**
* Class representing a TrueType file.
@@ -85,7 +85,7 @@
* Returns the format of this file.
* @return The format of this file.
*/
- public Font.Format getFontFormat() {
+ public FontFormat getFontFormat() {
return this.parser.getFontFormat();
}
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-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -89,7 +89,7 @@
import org.axsl.constants.NumericConstants;
import org.axsl.constants.TypographicConstants;
-import org.axsl.font.Font;
+import org.axsl.font.FontFormat;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.Encoding;
@@ -999,7 +999,7 @@
* Returns the format of this font.
* @return The format of this font.
*/
- public Font.Format getFontFormat() {
+ public FontFormat getFormat() {
return getTTFFile().getFontFormat();
}
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -34,8 +34,8 @@
import org.foray.font.ttf.TrueTypeFont;
import org.foray.font.ttf.TrueTypeSingle;
-import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.font.FontFormat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -58,7 +58,7 @@
final FontParser parser = new FontParser(null, new FileInputStream(
"./src/test/resources/source-dejavu/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf"));
assertEquals(FontFileFormat.TTF_SINGLEFONT, parser.getFileFormat());
- assertEquals(Font.Format.TRUETYPE, parser.getFontFormat());
+ assertEquals(FontFormat.TRUETYPE, parser.getFontFormat());
final FontContent fontContent = parser.parseFontFile();
assertTrue(fontContent instanceof TrueTypeSingle);
Modified: trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java
===================================================================
--- trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-font-tf/src/main/java/org/foray/font/fixture/MockFont.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -29,6 +29,7 @@
package org.foray.font.fixture;
import org.axsl.font.Font;
+import org.axsl.font.FontFormat;
import org.axsl.i18n.Script;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
@@ -153,7 +154,7 @@
}
@Override
- public Format getFontFormat() {
+ public FontFormat getFormat() {
// TODO Auto-generated method stub
return null;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfCidFont.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -39,6 +39,7 @@
import org.foray.primitive.sequence.ByteArray;
import org.axsl.font.Font;
+import org.axsl.font.FontFormat;
import org.axsl.font.FontUse;
import org.axsl.primitive.sequence.ByteSequencePlus;
import org.axsl.primitive.sequence.ShortSequence;
@@ -173,7 +174,7 @@
*/
protected static PdfCidFont.SubType getCidType(final FontUse fsFont) {
final Font font = fsFont.getFont();
- if (font.getFontFormat() == Font.Format.TRUETYPE) {
+ if (font.getFormat() == FontFormat.TRUETYPE) {
return PdfCidFont.SubType.CID_TYPE2;
}
return PdfCidFont.SubType.CID_TYPE0;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -37,6 +37,7 @@
import org.axsl.constants.NumericConstants;
import org.axsl.font.Font;
import org.axsl.font.FontContext;
+import org.axsl.font.FontFormat;
import org.axsl.font.FontUse;
import org.axsl.orthography.Orthography;
import org.axsl.pdf.PdfFont;
@@ -409,7 +410,7 @@
if (fontUse.getFont().getFontComplexity() == Font.Complexity.COMPOSITE) {
return PdfFont4a.SubType.TYPE0;
}
- if (fontUse.getFont().getFontFormat() == Font.Format.TYPE1) {
+ if (FontFormat.TYPE1 == fontUse.getFont().getFormat()) {
return PdfFont4a.SubType.TYPE1;
}
return PdfFont4a.SubType.TRUETYPE;
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java 2025-05-23 15:39:23 UTC (rev 13722)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFontFileStream.java 2025-05-23 16:21:57 UTC (rev 13723)
@@ -31,6 +31,7 @@
import org.foray.pdf.document.PdfDocument4a;
import org.foray.pdf.type.PdfStream;
+import org.axsl.font.FontFormat;
import org.axsl.font.FontUse;
import org.axsl.pdf.PdfException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -83,16 +84,12 @@
return null;
}
- switch (font.getFont().getFontFormat()) {
- case TYPE1: {
+ if (FontFormat.TYPE1 == font.getFont().getFormat()) {
return " /Length1 " + font.getEmbeddableLength1()
+ " /Length2 " + font.getEmbeddableLength2()
+ " /Length3 " + font.getEmbeddableLength3();
}
- default: {
- return " /Length1 " + font.getEmbeddableLength1();
- }
- }
+ return " /Length1 " + font.getEmbeddableLength1();
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-23 15:39:26
|
Revision: 13722
http://sourceforge.net/p/foray/code/13722
Author: victormote
Date: 2025-05-23 15:39:23 +0000 (Fri, 23 May 2025)
Log Message:
-----------
Move version number magic numbers to aXSL.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/PostTableParser.java
Removed Paths:
-------------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.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-23 15:11:55 UTC (rev 13721)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-23 15:39:23 UTC (rev 13722)
@@ -57,7 +57,6 @@
import org.foray.font.ttf.table.PostTable;
import org.foray.font.ttf.table.PrepTable;
import org.foray.font.ttf.table.VorgTable;
-import org.foray.fontParse.FontFormat;
import org.foray.fontParse.ttf.handler.BaseTableHandler;
import org.foray.fontParse.ttf.handler.Cff2TableHandler;
import org.foray.fontParse.ttf.handler.CffTableHandler;
@@ -88,6 +87,7 @@
import org.foray.primitive.BitUtils;
import org.foray.primitive.sequence.ShortArrayBuilder;
+import org.axsl.constants.NumericConstants;
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
import org.axsl.primitive.sequence.ShortSequence;
@@ -808,7 +808,7 @@
*/
public int getCapHeight() {
if ((this.os2Table != null)
- && (this.os2Table.getVersion() >= FontFormat.VERSION_2)) {
+ && (this.os2Table.getVersion() >= NumericConstants.VERSION_2)) {
return this.os2Table.getCapHeight();
}
if (this.pcltTable != null) {
@@ -830,7 +830,7 @@
*/
public int getXHeight() {
if ((this.os2Table != null)
- && (this.os2Table.getVersion() >= FontFormat.VERSION_2)) {
+ && (this.os2Table.getVersion() >= NumericConstants.VERSION_2)) {
return this.os2Table.getXHeight();
}
if (this.pcltTable != null) {
Deleted: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java 2025-05-23 15:11:55 UTC (rev 13721)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java 2025-05-23 15:39:23 UTC (rev 13722)
@@ -1,61 +0,0 @@
-/*
- * 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;
-
-/**
- * Constants related to font formats.
- */
-public final class FontFormat {
-
- /** Magic number indicating version 0 of a font or a font table. */
- public static final byte VERSION_0 = 0;
-
- /** Magic number indicating version 1 of a font or a font table. */
- public static final byte VERSION_1 = 1;
-
- /** Magic number indicating version 2 of a font or a font table. */
- public static final byte VERSION_2 = 2;
-
- /** Magic number indicating version 3 of a font or a font table. */
- public static final byte VERSION_3 = 3;
-
- /** Magic number indicating version 4 of a font or a font table. */
- public static final byte VERSION_4 = 4;
-
- /** Magic number indicating version 5 of a font or a font table. */
- public static final byte VERSION_5 = 5;
-
-
-
-
-
- /** Private Constructor. Utility class should naver be instantiated. */
- private FontFormat() { }
-
-}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java 2025-05-23 15:11:55 UTC (rev 13721)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java 2025-05-23 15:39:23 UTC (rev 13722)
@@ -28,11 +28,12 @@
package org.foray.fontParse.ttf.parser;
-import org.foray.fontParse.FontFormat;
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttf.handler.Os2TableHandler;
+import org.axsl.constants.NumericConstants;
+
import org.checkerframework.checker.signedness.qual.Unsigned;
import java.io.IOException;
@@ -90,7 +91,7 @@
handler.usWinAscent(input.read_UFWORD()); // 2 bytes, total 76
handler.usWinDescent(input.read_UFWORD()); // 2 bytes, total 78
- if (version < FontFormat.VERSION_1) {
+ if (version < NumericConstants.VERSION_1) {
return;
}
@@ -98,7 +99,7 @@
handler.ulCodePageRange1(input.read_uint32()); // 4 bytes, total 82
handler.ulCodePageRange2(input.read_uint32()); // 4 bytes, total 86
- if (version < FontFormat.VERSION_2) {
+ if (version < NumericConstants.VERSION_2) {
return;
}
@@ -109,7 +110,7 @@
handler.usBreakChar(input.read_uint16()); // 2 bytes, total 94
handler.usMaxContext(input.read_uint16()); // 2 bytes, total 96
- if (version < FontFormat.VERSION_5) {
+ if (version < NumericConstants.VERSION_5) {
return;
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/PostTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/PostTableParser.java 2025-05-23 15:11:55 UTC (rev 13721)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/PostTableParser.java 2025-05-23 15:39:23 UTC (rev 13722)
@@ -28,11 +28,12 @@
package org.foray.fontParse.ttf.parser;
-import org.foray.fontParse.FontFormat;
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttf.handler.PostTableHandler;
+import org.axsl.constants.NumericConstants;
+
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -70,10 +71,10 @@
switch (majorVersion) {
- case FontFormat.VERSION_1:
+ case NumericConstants.VERSION_1:
// Nothing needs to be read for this format.
break;
- case FontFormat.VERSION_2:
+ case NumericConstants.VERSION_2:
final short numGlyphs = input.read_uint16();
handler.numGlyphs(numGlyphs);
@@ -82,13 +83,13 @@
parse2v0Glyphs(input, numGlyphs, handler);
break;
}
- case FontFormat.VERSION_5: {
+ case NumericConstants.VERSION_5: {
/* TODO: Add this functionality if needed. Version 2.5 is deprecated and may not be used much. */
break;
}
}
break;
- case FontFormat.VERSION_3:
+ case NumericConstants.VERSION_3:
// Postscript format 3 contains no glyph names
break;
default:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-23 15:11:58
|
Revision: 13721
http://sourceforge.net/p/foray/code/13721
Author: victormote
Date: 2025-05-23 15:11:55 +0000 (Fri, 23 May 2025)
Log Message:
-----------
Remove unnecessary version numbering enum.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.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-23 14:51:19 UTC (rev 13720)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-23 15:11:55 UTC (rev 13721)
@@ -808,7 +808,7 @@
*/
public int getCapHeight() {
if ((this.os2Table != null)
- && (this.os2Table.getVersion() >= FontFormat.MajorVersion.v2.getValue())) {
+ && (this.os2Table.getVersion() >= FontFormat.VERSION_2)) {
return this.os2Table.getCapHeight();
}
if (this.pcltTable != null) {
@@ -830,7 +830,7 @@
*/
public int getXHeight() {
if ((this.os2Table != null)
- && (this.os2Table.getVersion() >= FontFormat.MajorVersion.v2.getValue())) {
+ && (this.os2Table.getVersion() >= FontFormat.VERSION_2)) {
return this.os2Table.getXHeight();
}
if (this.pcltTable != null) {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java 2025-05-23 14:51:19 UTC (rev 13720)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/FontFormat.java 2025-05-23 15:11:55 UTC (rev 13721)
@@ -33,71 +33,29 @@
*/
public final class FontFormat {
- /** Magic number indicating version 0. */
+ /** Magic number indicating version 0 of a font or a font table. */
public static final byte VERSION_0 = 0;
- /** Magic number indicating version 1. */
+ /** Magic number indicating version 1 of a font or a font table. */
public static final byte VERSION_1 = 1;
- /** Magic number indicating version 2. */
+ /** Magic number indicating version 2 of a font or a font table. */
public static final byte VERSION_2 = 2;
- /** Magic number indicating version 3. */
+ /** Magic number indicating version 3 of a font or a font table. */
public static final byte VERSION_3 = 3;
- /** Magic number indicating version 4. */
+ /** Magic number indicating version 4 of a font or a font table. */
public static final byte VERSION_4 = 4;
- /** Magic number indicating version 5. */
+ /** Magic number indicating version 5 of a font or a font table. */
public static final byte VERSION_5 = 5;
- /**
- * Enumeration of valid <em>table</em> major versions, not to be confused with TrueType or OpenType version numbers.
- */
- public enum MajorVersion {
- /** Major version 0. */
- v0(0),
- /** Major version 0. */
- v1(1),
- /** Major version 0. */
- v2(2),
-
- /** Major version 0. */
- v3(3),
-
- /** Major version 0. */
- v4(4),
-
- /** Major version 0. */
- v5(5);
-
- /** The numeric value. */
- private byte value;
-
- /**
- * Constructor.
- * @param value The numeric value.
- */
- MajorVersion(final int value) {
- this.value = (byte) value;
- }
-
- /**
- * Returns the numeric value.
- * @return The numeric value.
- */
- public byte getValue() {
- return this.value;
- }
- }
-
- /**
- * Private Constructor. Utility class should naver be instantiated.
- */
+ /** Private Constructor. Utility class should naver be instantiated. */
private FontFormat() { }
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java 2025-05-23 14:51:19 UTC (rev 13720)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/parser/Os2TableParser.java 2025-05-23 15:11:55 UTC (rev 13721)
@@ -90,7 +90,7 @@
handler.usWinAscent(input.read_UFWORD()); // 2 bytes, total 76
handler.usWinDescent(input.read_UFWORD()); // 2 bytes, total 78
- if (version < FontFormat.MajorVersion.v1.getValue()) {
+ if (version < FontFormat.VERSION_1) {
return;
}
@@ -98,7 +98,7 @@
handler.ulCodePageRange1(input.read_uint32()); // 4 bytes, total 82
handler.ulCodePageRange2(input.read_uint32()); // 4 bytes, total 86
- if (version < FontFormat.MajorVersion.v2.getValue()) {
+ if (version < FontFormat.VERSION_2) {
return;
}
@@ -109,7 +109,7 @@
handler.usBreakChar(input.read_uint16()); // 2 bytes, total 94
handler.usMaxContext(input.read_uint16()); // 2 bytes, total 96
- if (version < FontFormat.MajorVersion.v5.getValue()) {
+ if (version < FontFormat.VERSION_5) {
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-23 14:51:21
|
Revision: 13720
http://sourceforge.net/p/foray/code/13720
Author: victormote
Date: 2025-05-23 14:51:19 +0000 (Fri, 23 May 2025)
Log Message:
-----------
If no encoding is configured, use the native one.
Modified Paths:
--------------
trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/app-fonts-basic.launch
trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
Modified: trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/app-fonts-basic.launch
===================================================================
--- trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/app-fonts-basic.launch 2025-05-23 12:23:48 UTC (rev 13719)
+++ trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/app-fonts-basic.launch 2025-05-23 14:51:19 UTC (rev 13720)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
- <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/foray-app/src/main/java/org/foray/app/FOray.java"/>
</listAttribute>
@@ -17,7 +16,7 @@
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.foray.app.FOray"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="foray-app"/>
- <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${build_files}-configuration-file ${foray-config} -fo ${fo-example-path}/basic/fonts.fo -pdf ${foray-test-output-file}/fonts-basic.pdf"/>
+ <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-configuration-file ${foray-config} -fo ${fo-example-path}/basic/fonts.fo -pdf ${foray-test-output-file}/fonts-basic.pdf"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="foray-app"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2025-05-23 12:23:48 UTC (rev 13719)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2025-05-23 14:51:19 UTC (rev 13720)
@@ -29,6 +29,7 @@
package org.foray.font;
import org.foray.font.config.RegisteredFont;
+import org.foray.font.config.RegisteredFontContent;
import org.foray.ps.encode.EncodingVector4a;
import org.axsl.ps.Encoding;
@@ -194,9 +195,15 @@
/* We don't care about encodings for SystemFonts. */
fontUse = new FontUse4a(this, rfd, null);
} else {
- final Encoding encoding = rfd.getEncoding();
+ Encoding encoding = rfd.getEncoding();
// final Encoding encoding = findEncoding(rfd, codePoint);
if (encoding == null) {
+ /* No encoding was configured, meaning that the native encoding should be used. */
+ final RegisteredFontContent content = rfd.getRegisteredFont();
+ final Font4a font = content.getBestFont();
+ encoding = font.getInternalEncoding();
+ }
+ if (encoding == null) {
/* We can't encode this character.
* Return null so that the upstream font selection routines can
* try another font family. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-23 12:23:51
|
Revision: 13719
http://sourceforge.net/p/foray/code/13719
Author: victormote
Date: 2025-05-23 12:23:48 +0000 (Fri, 23 May 2025)
Log Message:
-----------
Conform to aXSL change: Combine Type enumeration and MIME type into a single extensible class.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsBitmapGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.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/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/SvgGraphic4a.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-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/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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -43,6 +43,7 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.primitive.sequence.ByteSequence;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -373,8 +374,8 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.BMP;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.BMP;
}
@Override
@@ -383,11 +384,6 @@
}
@Override
- public String getMimeType() {
- return "image/bmp";
- }
-
- @Override
public String getName() {
return null;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsBitmapGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsBitmapGraphic4a.java 2025-05-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsBitmapGraphic4a.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -29,6 +29,7 @@
package org.foray.graphic;
import org.axsl.graphic.BitmapGraphic;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.graphic.GraphicLink;
import org.axsl.primitive.sequence.ByteSequence;
@@ -121,7 +122,7 @@
}
@Override
- public Type getGraphicType() {
+ public GraphicFormat getFormat() {
// TODO Auto-generated method stub
return null;
}
@@ -133,12 +134,6 @@
}
@Override
- public String getMimeType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
public String getName() {
// TODO Auto-generated method stub
return null;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -33,8 +33,8 @@
import org.foray.primitive.sequence.ByteArray;
import org.axsl.graphic.EpsVectorGraphic;
-import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.primitive.sequence.ByteSequence;
import org.axsl.ps.BoundingBox;
@@ -166,16 +166,11 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.EPS;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.EPS;
}
@Override
- public String getMimeType() {
- return "image/eps";
- }
-
- @Override
protected void parseBasics() throws IOException {
final byte[] fileStart = new byte[this.maxBytesToParseBasics()];
getInputStream().read(fileStart);
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -39,6 +39,7 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.primitive.sequence.ByteSequence;
import java.awt.Color;
@@ -192,8 +193,8 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.GIF;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.GIF;
}
@Override
@@ -202,11 +203,6 @@
}
@Override
- public String getMimeType() {
- return "image/gif";
- }
-
- @Override
public void parseBasics() throws IOException, GraphicException {
try {
final ImageProducer ip = (ImageProducer) getUrl().getContent();
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -47,6 +47,7 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.primitive.sequence.ByteSequence;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -375,8 +376,8 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.JPEG;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.JPEG;
}
@Override
@@ -385,11 +386,6 @@
}
@Override
- public String getMimeType() {
- return "image/jpeg";
- }
-
- @Override
public int getPixelWidth() {
return this.pixelWidth;
}
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -28,9 +28,8 @@
package org.foray.graphic;
-import org.axsl.constants.MimeConstants;
-import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.graphic.MathGraphic;
import org.w3c.dom.mathml.MathMLDocument;
@@ -103,16 +102,11 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.MATHML;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.MATHML;
}
@Override
- public String getMimeType() {
- return MimeConstants.MIME_MATHML;
- }
-
- @Override
public void parseBasics() throws IOException {
this.svgGraphic.parseBasics();
}
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -30,8 +30,8 @@
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import java.awt.color.ColorSpace;
import java.io.BufferedInputStream;
@@ -91,16 +91,11 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.PDF;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.PDF;
}
@Override
- public String getMimeType() {
- return "text/pdf";
- }
-
- @Override
protected void parseBasics() {
}
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -33,6 +33,7 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.primitive.sequence.ByteSequence;
import org.apache.xmlgraphics.image.GraphicsUtil;
@@ -116,11 +117,6 @@
}
@Override
- public String getMimeType() {
- return "image/png";
- }
-
- @Override
public String getName() {
return null;
}
@@ -131,8 +127,8 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.PNG;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.PNG;
}
@Override
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -30,8 +30,7 @@
import org.foray.graphic.batik.BatikUaAwt;
-import org.axsl.constants.MimeConstants;
-import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.graphic.SvgGraphic;
import org.apache.batik.anim.dom.SAXSVGDocumentFactory;
@@ -117,16 +116,11 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.SVG;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.SVG;
}
@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) {
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TempImage.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -33,6 +33,7 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.BitmapGraphic;
import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.graphic.GraphicLink;
import org.axsl.primitive.sequence.ByteSequence;
@@ -132,7 +133,7 @@
public void close() { }
@Override
- public Graphic.Type getGraphicType() {
+ public GraphicFormat getFormat() {
return null;
}
@@ -142,11 +143,6 @@
}
@Override
- public String getMimeType() {
- return "";
- }
-
- @Override
public String getName() {
return null;
}
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -39,6 +39,7 @@
import org.axsl.constants.TypographicConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.primitive.sequence.ByteSequence;
import org.apache.xmlgraphics.image.codec.tiff.TIFFDecodeParam;
@@ -208,16 +209,11 @@
}
@Override
- public Graphic.Type getGraphicType() {
- return Graphic.Type.TIFF;
+ public GraphicFormat getFormat() {
+ return GraphicFormat.TIFF;
}
@Override
- public String getMimeType() {
- return "image/tiff";
- }
-
- @Override
public String getName() {
return null;
}
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfImageXobject.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -37,8 +37,8 @@
import org.foray.pdf.document.PdfDocument4a;
import org.axsl.graphic.BitmapGraphic;
-import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.pdf.PdfException;
import java.awt.Color;
@@ -71,7 +71,7 @@
super(doc, graphic);
this.graphic = graphic;
final ColorSpace cs = getGraphic().getColorSpace();
- if (getGraphic().getGraphicType() == Graphic.Type.JPEG
+ if (getGraphic().getFormat() == GraphicFormat.JPEG
&& cs instanceof ICC_ColorSpace) {
final ICC_ColorSpace iccCS = (ICC_ColorSpace) cs;
this.pdfICCStream = new PdfIccProfileStream(iccCS);
@@ -94,8 +94,8 @@
@Override
protected void xObjectContent(final PdfDocument4a doc) throws PdfException {
try {
- if (getGraphic().getGraphicType() == Graphic.Type.JPEG
- || getGraphic().getGraphicType() == Graphic.Type.TIFF) {
+ if (getGraphic().getFormat() == GraphicFormat.JPEG
+ || getGraphic().getFormat() == GraphicFormat.TIFF) {
/* JPEG is natively compressed using DTD, so use its raw
* content.
* TIFF is currently presumed to be compressed natively also,
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -42,6 +42,7 @@
import org.axsl.graphic.EpsVectorGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.graphic.MathGraphic;
import org.axsl.graphic.SvgGraphic;
import org.axsl.orthography.Orthography;
@@ -113,7 +114,7 @@
} else if (img instanceof MathGraphic) {
final MathGraphic mathGraphic = (MathGraphic) img;
xObject = new PdfXformMath(pdfDoc, mathGraphic, orthography, fontConsumer);
- } else if (img.getGraphicType() == Graphic.Type.PDF) {
+ } else if (img.getFormat() == GraphicFormat.PDF) {
xObject = new PdfXreference(pdfDoc, img);
} else if (img instanceof BitmapGraphic) {
final BitmapGraphic bitmapGraphic = (BitmapGraphic) img;
@@ -123,7 +124,7 @@
// img.getColorSpace();
xObject = new PdfImageXobject(pdfDoc, bitmapGraphic);
} else {
- throw new GraphicException("Unsupported Graphic Type: " + img.getGraphicType());
+ throw new GraphicException("Unsupported Graphic Type: " + img.getFormat());
}
xObject.filter = xObject.getFilter(xObject.getOutputStream(), pdfDoc);
return xObject;
@@ -169,12 +170,12 @@
final PsServer psServer = doc.getPsServer();
PsEncodeFilter filter = null;
final Graphic graphic = this.getGraphic();
- if (graphic.getGraphicType() == Graphic.Type.JPEG) {
+ if (graphic.getFormat() == GraphicFormat.JPEG) {
filter = psServer.createEncodeFilter(PsFilterType.DCT, outputStream);
filter.setInactive();
return filter;
}
- if (graphic.getGraphicType() == Graphic.Type.TIFF) {
+ if (graphic.getFormat() == GraphicFormat.TIFF) {
final BitmapGraphic bitmapGraphic = (BitmapGraphic) graphic;
final Graphic.Compression imageCompression = bitmapGraphic.getCompressionType();
switch (imageCompression) {
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-22 21:15:39 UTC (rev 13718)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-05-23 12:23:48 UTC (rev 13719)
@@ -59,6 +59,7 @@
import org.axsl.graphic.EpsGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicFormat;
import org.axsl.graphic.SvgGraphic;
import org.axsl.graphic.output.VectorOutput2Ps;
import org.axsl.graphic.output.VectorOutputContext;
@@ -743,7 +744,7 @@
// Template: (RawData is used for the EOF signal only)
// write("/RawData currentfile <first filter> filter def");
// write("/Data RawData <second filter> <third filter> [...] def");
- if (img.getGraphicType() == Graphic.Type.JPEG) {
+ if (img.getFormat() == GraphicFormat.JPEG) {
write("/RawData currentfile /ASCII85Decode filter def");
write("/Data RawData << >> /DCTDecode filter def");
} else {
@@ -805,7 +806,7 @@
// imgmap[0] = 1;
OutputStream out = this.out;
out = this.psServer.createEncodeFilter(PsFilterType.ASCII_85, out);
- if (img.getGraphicType() == Graphic.Type.JPEG) {
+ if (img.getFormat() == GraphicFormat.JPEG) {
//nop
} else {
if (this.psLevel >= PsRenderer.POSTSCRIPT_LEVEL_3) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-22 21:15:41
|
Revision: 13718
http://sourceforge.net/p/foray/code/13718
Author: victormote
Date: 2025-05-22 21:15:39 +0000 (Thu, 22 May 2025)
Log Message:
-----------
Conform to aXSL change: Move compression method from Graphic to BitmapGraphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.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/SvgGraphic4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 21:13:43 UTC (rev 13717)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 21:15:39 UTC (rev 13718)
@@ -171,11 +171,6 @@
}
@Override
- public Graphic.Compression getCompressionType() {
- return null;
- }
-
- @Override
public String getMimeType() {
return "image/eps";
}
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-22 21:13:43 UTC (rev 13717)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-22 21:15:39 UTC (rev 13718)
@@ -108,11 +108,6 @@
}
@Override
- public Graphic.Compression getCompressionType() {
- return null;
- }
-
- @Override
public String getMimeType() {
return MimeConstants.MIME_MATHML;
}
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-22 21:13:43 UTC (rev 13717)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-22 21:15:39 UTC (rev 13718)
@@ -96,11 +96,6 @@
}
@Override
- public Graphic.Compression getCompressionType() {
- return null;
- }
-
- @Override
public String getMimeType() {
return "text/pdf";
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 21:13:43 UTC (rev 13717)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 21:15:39 UTC (rev 13718)
@@ -122,11 +122,6 @@
}
@Override
- public Graphic.Compression getCompressionType() {
- return null;
- }
-
- @Override
public String getMimeType() {
return MimeConstants.MIME_SVG;
}
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-22 21:13:43 UTC (rev 13717)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-22 21:15:39 UTC (rev 13718)
@@ -175,8 +175,8 @@
return filter;
}
if (graphic.getGraphicType() == Graphic.Type.TIFF) {
- final Graphic.Compression imageCompression
- = graphic.getCompressionType();
+ final BitmapGraphic bitmapGraphic = (BitmapGraphic) graphic;
+ final Graphic.Compression imageCompression = bitmapGraphic.getCompressionType();
switch (imageCompression) {
case UNCOMPRESSED:
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-22 21:13:46
|
Revision: 13717
http://sourceforge.net/p/foray/code/13717
Author: victormote
Date: 2025-05-22 21:13:43 +0000 (Thu, 22 May 2025)
Log Message:
-----------
Fix test document to match recent change to the length of a stream.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf
Modified: trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf
===================================================================
--- trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf 2025-05-22 16:30:18 UTC (rev 13716)
+++ trunk/foray/foray-pdf/src/test/resources/example/002-hello-world.pdf 2025-05-22 21:13:43 UTC (rev 13717)
@@ -18,7 +18,7 @@
endobj
6 0 obj
<<
-/Length 60
+/Length 59
>>
stream
BT
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-22 16:30:27
|
Revision: 13716
http://sourceforge.net/p/foray/code/13716
Author: victormote
Date: 2025-05-22 16:30:18 +0000 (Thu, 22 May 2025)
Log Message:
-----------
Conform to aXSL change: Move a bitmap-only method from Graphic to BitmapGraphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.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/SvgGraphic4a.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 16:10:34 UTC (rev 13715)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 16:30:18 UTC (rev 13716)
@@ -312,12 +312,6 @@
}
@Override
- public ByteSequence getRawSamples() {
- /* EPS is not typically a raster format. */
- return null;
- }
-
- @Override
public int absoluteWidthReal() {
return -1;
}
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-22 16:10:34 UTC (rev 13715)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-22 16:30:18 UTC (rev 13716)
@@ -32,7 +32,6 @@
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;
import org.w3c.dom.svg.SVGDocument;
@@ -129,12 +128,6 @@
}
@Override
- public ByteSequence getRawSamples() {
- /* MathML is not a raster format. */
- return null;
- }
-
- @Override
public int absoluteWidthReal() {
return this.svgGraphic.absoluteWidthReal();
}
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-22 16:10:34 UTC (rev 13715)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-22 16:30:18 UTC (rev 13716)
@@ -32,7 +32,6 @@
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
-import org.axsl.primitive.sequence.ByteSequence;
import java.awt.color.ColorSpace;
import java.io.BufferedInputStream;
@@ -111,12 +110,6 @@
}
@Override
- public ByteSequence getRawSamples() {
- /* PDF is not a raster format. */
- return null;
- }
-
- @Override
public int absoluteWidthReal() {
return -1;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 16:10:34 UTC (rev 13715)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 16:30:18 UTC (rev 13716)
@@ -33,7 +33,6 @@
import org.axsl.constants.MimeConstants;
import org.axsl.graphic.Graphic;
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;
@@ -197,12 +196,6 @@
}
@Override
- public ByteSequence getRawSamples() {
- /* SVG is not a raster format. */
- return null;
- }
-
- @Override
public int absoluteWidthReal() {
return -1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-22 16:10:39
|
Revision: 13715
http://sourceforge.net/p/foray/code/13715
Author: victormote
Date: 2025-05-22 16:10:34 +0000 (Thu, 22 May 2025)
Log Message:
-----------
Conform to aXSL change: Move two bitmap-only methods from Graphic to BitmapGraphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.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/SvgGraphic4a.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 15:47:06 UTC (rev 13714)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsVectorGraphic4a.java 2025-05-22 16:10:34 UTC (rev 13715)
@@ -38,7 +38,6 @@
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;
@@ -334,16 +333,6 @@
}
@Override
- public boolean isTransparent() {
- return false;
- }
-
- @Override
- public Color getTransparentColor() {
- return null;
- }
-
- @Override
public int getPixelWidth() {
return this.pixelWidth;
}
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-22 15:47:06 UTC (rev 13714)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/MathGraphic4a.java 2025-05-22 16:10:34 UTC (rev 13715)
@@ -37,7 +37,6 @@
import org.w3c.dom.mathml.MathMLDocument;
import org.w3c.dom.svg.SVGDocument;
-import java.awt.Color;
import java.awt.color.ColorSpace;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -151,16 +150,6 @@
}
@Override
- public boolean isTransparent() {
- return this.svgGraphic.isTransparent();
- }
-
- @Override
- public Color getTransparentColor() {
- return this.svgGraphic.getTransparentColor();
- }
-
- @Override
public int getPixelWidth() {
return this.svgGraphic.getPixelWidth();
}
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-22 15:47:06 UTC (rev 13714)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PdfGraphic.java 2025-05-22 16:10:34 UTC (rev 13715)
@@ -34,7 +34,6 @@
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
-import java.awt.Color;
import java.awt.color.ColorSpace;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@@ -133,16 +132,6 @@
}
@Override
- public boolean isTransparent() {
- return false;
- }
-
- @Override
- public Color getTransparentColor() {
- return null;
- }
-
- @Override
public int getPixelWidth() {
return -1;
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 15:47:06 UTC (rev 13714)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/SvgGraphic4a.java 2025-05-22 16:10:34 UTC (rev 13715)
@@ -46,7 +46,6 @@
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;
@@ -219,16 +218,6 @@
}
@Override
- public boolean isTransparent() {
- return false;
- }
-
- @Override
- public Color getTransparentColor() {
- return null;
- }
-
- @Override
public int getPixelWidth() {
return this.pixelWidth;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-22 15:47:12
|
Revision: 13714
http://sourceforge.net/p/foray/code/13714
Author: victormote
Date: 2025-05-22 15:47:06 +0000 (Thu, 22 May 2025)
Log Message:
-----------
Conform to aXSL change: Move a bitmap-only method from Graphic to BitmapGraphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/GifGraphicTests.java
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java 2025-05-21 13:55:35 UTC (rev 13713)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BitmapGraphic4a.java 2025-05-22 15:47:06 UTC (rev 13714)
@@ -38,6 +38,10 @@
*/
public abstract class BitmapGraphic4a extends Graphic4a implements BitmapGraphic {
+ /** The number of bits per color component. For example, an RGB (3 component) image with 24 bits per pixel, has
+ * 8 bits per component. */
+ private int bitsPerComponent = 0;
+
/**
* Constructor.
* @param server The parent graphic server.
@@ -48,4 +52,17 @@
super(server, url, bis);
}
+ /**
+ * Sets the bit depth for this graphic.
+ * @param bitDepth The new bit depth.
+ */
+ public void setBitsPerComponent(final int bitDepth) {
+ this.bitsPerComponent = bitDepth;
+ }
+
+ @Override
+ public int getBitsPerComponent() {
+ return this.bitsPerComponent;
+ }
+
}
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-21 13:55:35 UTC (rev 13713)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-22 15:47:06 UTC (rev 13714)
@@ -78,10 +78,6 @@
/** The physical file. */
private BufferedInputStream bis = null;
- /** The number of bits per color component. For example, an RGB (3 component) image with 24 bits per pixel, has
- * 8 bits per component. */
- private int bitsPerComponent = 0;
-
/** Image data (uncompressed). */
private ByteArray content = null;
@@ -322,19 +318,6 @@
}
/**
- * Sets the bit depth for this graphic.
- * @param bitDepth The new bit depth.
- */
- public void setBitsPerComponent(final int bitDepth) {
- this.bitsPerComponent = bitDepth;
- }
-
- @Override
- public int getBitsPerComponent() {
- return this.bitsPerComponent;
- }
-
- /**
* Returns the input stream for this file.
* @return Returns the input stream.
*/
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-21 13:55:35 UTC (rev 13713)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/GifGraphicTests.java 2025-05-22 15:47:06 UTC (rev 13714)
@@ -90,9 +90,10 @@
@Test
public void testGraphic02() throws GraphicException, IOException, URISyntaxException {
final URI graphicUri = UrlUtil.resolveURI(getBaseURLs(), new URI("gif/xml_feather_transparent.gif"));
- final Graphic4a gif = this.getServer().procureGraphic(graphicUri.toURL(), false);
- assertNotNull(gif);
- assertTrue(gif instanceof GifGraphic);
+ final Graphic4a graphic = this.getServer().procureGraphic(graphicUri.toURL(), false);
+ assertNotNull(graphic);
+ assertTrue(graphic instanceof GifGraphic);
+ final GifGraphic gif = (GifGraphic) graphic;
assertEquals(221, gif.getPixelWidth());
assertEquals(96, gif.getPixelHeight());
assertEquals(8, gif.getBitsPerComponent());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-21 13:55:38
|
Revision: 13713
http://sourceforge.net/p/foray/code/13713
Author: victormote
Date: 2025-05-21 13:55:35 +0000 (Wed, 21 May 2025)
Log Message:
-----------
Add tests of the parsed content.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java
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-21 13:54:35 UTC (rev 13712)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-21 13:55:35 UTC (rev 13713)
@@ -30,6 +30,7 @@
import org.foray.common.url.UrlUtil;
import org.foray.graphic.format.Bmp;
+import org.foray.primitive.ByteUtils;
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
@@ -82,6 +83,22 @@
* 4,340 pixels * 3 channels * 8 bits per channel = 104,160 bits.
* 104,160 / 8 bits per byte = 13,020 bytes. */
assertEquals(13020, content.length());
+ final byte[] contentArray = content.asPlus().toArray();
+
+ final byte[] expectedContentStart = new byte [16];
+ Arrays.fill(expectedContentStart, (byte) 0xFF);
+ final byte[] contentStart = Arrays.copyOfRange(contentArray, 0, 16);
+ assertArrayEquals(expectedContentStart, contentStart);
+
+ /* Random-ish sample from the middle, starting at index 900. */
+ final byte[] expectedContent900 = ByteUtils.fromHexChars("FF FF FF C1 C1 C2 51 50 4E 33 32 31 1C 1A 16 1C");
+ final byte[] content900 = Arrays.copyOfRange(contentArray, 900, 916);
+ assertArrayEquals(expectedContent900, content900);
+
+ final byte[] expectedContentEnd = new byte [16];
+ Arrays.fill(expectedContentEnd, (byte) 0xFF);
+ final byte[] contentEnd = Arrays.copyOfRange(contentArray, contentArray.length - 16, contentArray.length);
+ assertArrayEquals(expectedContentEnd, contentEnd);
}
/**
@@ -111,32 +128,16 @@
assertEquals(256 * 3, colorPalette.length);
/* WIN_3 color palettes have a byte of padding after each 3-byte BGR value. Also, the parsing logic reverses the
* BGR order to RGB. The color palette starts at index 54 (0x36). */
- final byte[] expectedPaletteStart = {
- 0x00, 0x00, 0x00,
- 0x3c, 0x2c, 0x18,
- 0x33, 0x26, 0x23,
- 0x26, 0x22, 0x37,
- 0x29, 0x28, 0x3a };
+ final byte[] expectedPaletteStart = ByteUtils.fromHexChars("00 00 00 3C 2C 18 33 26 23 26 22 37 29 28 3A");
final byte[] paletteStart = Arrays.copyOfRange(colorPalette, 0, 15);
assertArrayEquals(expectedPaletteStart, paletteStart);
/* 54 + (256 * 4) = 1078. The last 20 bytes start at 1058 (0x422) */
- final byte[] expectedPaletteEnd = {
- (byte) 0xB9, 0x5A, (byte) 0xBA,
- (byte) 0xAF, 0x63, (byte) 0xB9,
- (byte) 0xB9, 0x5D, (byte) 0xC0,
- (byte) 0xC2, 0x57, (byte) 0xC2,
- (byte) 0x8D, (byte) 0xA8, (byte) 0xC3 };
+ final byte[] expectedPaletteEnd = ByteUtils.fromHexChars("B9 5A BA AF 63 B9 B9 5D C0 C2 57 C2 8D A8 C3");
final byte[] paletteEnd = Arrays.copyOfRange(colorPalette, colorPalette.length - 15, colorPalette.length);
assertArrayEquals(expectedPaletteEnd, paletteEnd);
assertFalse(bmp.isTransparent());
assertNull(bmp.getTransparentColor());
-// final ByteSequence content = bmp.getContent();
-// assertNotNull(content);
- /* 1024 pixel width * 768 pixel height = 786,432 pixels.
- * 786,432 * 8 bits per channel = 6,291,456 bits.
- * 6,291,456 / 8 bits per byte = 786,432 bytes. */
-// assertEquals(13020, content.length());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-21 13:54:42
|
Revision: 13712
http://sourceforge.net/p/foray/code/13712
Author: victormote
Date: 2025-05-21 13:54:35 +0000 (Wed, 21 May 2025)
Log Message:
-----------
Add method to make creation of byte[] for tests easier to read.
Modified Paths:
--------------
trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java
trunk/foray/foray-primitive/src/test/java/org/foray/primitive/ByteUtilsTests.java
Modified: trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java
===================================================================
--- trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java 2025-05-21 10:41:57 UTC (rev 13711)
+++ trunk/foray/foray-primitive/src/main/java/org/foray/primitive/ByteUtils.java 2025-05-21 13:54:35 UTC (rev 13712)
@@ -79,6 +79,27 @@
}
/**
+ * Converts a String, each character expected to be either 1) the ASCII representation of a nibble, or 2) a
+ * delimiter between bytes, into a byte array.
+ * Every third char in the string is treated as a delimiter to be ignored.
+ * For example, The String "34 B9 55 6E" should return byte[] {0x34, 0xB9, 0x55, 0x6E}.
+ * This is useful primarily for tests, where readability is paramount.
+ * @param chars The {@link String} or other {@link CharSequence} containing the hex characters.
+ * @return The byte[] represented by {@code chars}.
+ */
+ public static byte[] fromHexChars(final CharSequence chars) {
+ final int wordSize = PrimitiveConstants.NIBBLES_PER_BYTE + 1;
+ final int outputSize = (chars.length() + 1) / wordSize;
+ final byte[] output = new byte[outputSize];
+ int inputIndex = 0;
+ for (int outputIndex = 0; outputIndex < outputSize; outputIndex ++) {
+ output[outputIndex] = fromHexChars(chars, inputIndex);
+ inputIndex += wordSize;
+ }
+ return output;
+ }
+
+ /**
* Converts two bytes, each expected to be the ASCII representation of a nibble, into a byte.
* For example, the sequence "FF" should be returned as 0xFF, the sequence "06" should return 0x06.
* @param highOrderByte The byte containing the high order nibble.
Modified: trunk/foray/foray-primitive/src/test/java/org/foray/primitive/ByteUtilsTests.java
===================================================================
--- trunk/foray/foray-primitive/src/test/java/org/foray/primitive/ByteUtilsTests.java 2025-05-21 10:41:57 UTC (rev 13711)
+++ trunk/foray/foray-primitive/src/test/java/org/foray/primitive/ByteUtilsTests.java 2025-05-21 13:54:35 UTC (rev 13712)
@@ -28,6 +28,7 @@
package org.foray.primitive;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
@@ -95,6 +96,17 @@
}
/**
+ * Test of {@link ByteUtils#fromHexChars(CharSequence)}.
+ */
+ @Test
+ public void fromDelimitedHexCharsTest() {
+ final String testString = "23 FA 7E";
+ final byte[] expected = new byte[] { 0x23, (byte) 0xFA, (byte) 0x7E };
+ final byte[] actual = ByteUtils.fromHexChars(testString);
+ assertArrayEquals(expected, actual);
+ }
+
+ /**
* Tests of {@link ByteUtils#toHexCharHigh(byte)}.
*/
@Test
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-21 10:41:59
|
Revision: 13711
http://sourceforge.net/p/foray/code/13711
Author: victormote
Date: 2025-05-21 10:41:57 +0000 (Wed, 21 May 2025)
Log Message:
-----------
Match the size of the stream to the /Length entry in the dictionary, i.e. remove the extra byte that was added to account for the newline before "endstream". Document why this is correct.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-20 15:40:21 UTC (rev 13710)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/type/PdfStream.java 2025-05-21 10:41:57 UTC (rev 13711)
@@ -261,8 +261,10 @@
}
/* Write the length last so that the subclasses can update the stream
* content in specialStreamDictEntries() if they need to. */
- builder.append("/Length " + (this.streamData.size() + 1) + EOL
- + ">>" + EOL);
+ /* Per PDF Reference, Sixth Edition, Section 3.2.7 (See "Stream Extent" section and "Length" key in Table 3.4),
+ * neither the newline immediately after the keyword "stream", nor the newline immediately before the keyword
+ * "endstream" need to be included in the /Length dictionary entry. */
+ builder.append("/Length " + this.streamData.size() + EOL + ">>" + EOL);
byte[] bytes = PdfObject.bufferToByteArray(builder);
byteArrayToStream(bytes, stream);
length += bytes.length;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-20 15:40:25
|
Revision: 13710
http://sourceforge.net/p/foray/code/13710
Author: victormote
Date: 2025-05-20 15:40:21 +0000 (Tue, 20 May 2025)
Log Message:
-----------
Better handle the difference between the EPS graphic and the embedded EPS vector graphic.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/EpsFactory.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.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-20 14:40:42 UTC (rev 13709)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/EpsGraphic4a.java 2025-05-20 15:40:21 UTC (rev 13710)
@@ -29,25 +29,19 @@
package org.foray.graphic;
import org.axsl.graphic.EpsGraphic;
-import org.axsl.graphic.EpsVectorGraphic;
-import org.axsl.graphic.GraphicException;
-import org.axsl.primitive.sequence.ByteSequence;
-import java.awt.Color;
-import java.awt.color.ColorSpace;
import java.io.BufferedInputStream;
-import java.io.IOException;
import java.net.URL;
/**
* An EPS (encapsulated Postscript) graphic.
*/
-public class EpsGraphic4a extends Graphic4a implements EpsGraphic {
+public class EpsGraphic4a implements EpsGraphic {
/** The vector portion of this graphic. */
private EpsVectorGraphic4a vectorGraphic;
- /** The vector portion of this graphic. */
+ /** The bitmap portion of this graphic. */
private EpsBitmapGraphic4a bitmapGraphic;
/**
@@ -59,12 +53,12 @@
*/
public EpsGraphic4a(final GraphicServer4a server, final URL url, final BufferedInputStream bis,
final boolean isAscii) {
- super(server, url, bis);
+// super(server, url, bis);
this.vectorGraphic = new EpsVectorGraphic4a(server, url, bis, isAscii);
}
@Override
- public EpsVectorGraphic getVectorGraphic() {
+ public EpsVectorGraphic4a getVectorGraphic() {
return this.vectorGraphic;
}
@@ -73,86 +67,4 @@
return this.bitmapGraphic;
}
- @Override
- public int getPixelWidth() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public int getPixelHeight() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public ColorSpace getColorSpace() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isTransparent() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Color getTransparentColor() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ByteSequence getRawSamples() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Type getGraphicType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Compression getCompressionType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getMimeType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected void loadImage() throws GraphicException {
- this.vectorGraphic.loadImage();
- }
-
- @Override
- protected void parseBasics() throws IOException {
- this.vectorGraphic.parseBasics();
- }
-
- @Override
- public int absoluteWidthReal() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public int absoluteHeightReal() {
- // TODO Auto-generated method stub
- return 0;
- }
-
}
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-20 14:40:42 UTC (rev 13709)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/factory/EpsFactory.java 2025-05-20 15:40:21 UTC (rev 13710)
@@ -29,6 +29,7 @@
package org.foray.graphic.factory;
import org.foray.graphic.EpsGraphic4a;
+import org.foray.graphic.EpsVectorGraphic4a;
import org.foray.graphic.GraphicServer4a;
import java.io.BufferedInputStream;
@@ -70,7 +71,7 @@
}
@Override
- public EpsGraphic4a attemptCreate(final URL url, final BufferedInputStream bis) throws IOException {
+ public EpsVectorGraphic4a attemptCreate(final URL url, final BufferedInputStream bis) throws IOException {
final byte[] header = new byte[EpsFactory.EPS_HEADER_BINARY.length];
bis.read(header);
boolean isEPS = false;
@@ -95,7 +96,9 @@
if (! isEPS) {
return null;
}
- return new EpsGraphic4a(this.getServer(), url, bis, isAscii);
+
+ final EpsGraphic4a epsGraphic = new EpsGraphic4a(this.getServer(), url, bis, isAscii);
+ return epsGraphic.getVectorGraphic();
}
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java 2025-05-20 14:40:42 UTC (rev 13709)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXformEps.java 2025-05-20 15:40:21 UTC (rev 13710)
@@ -31,7 +31,6 @@
import org.foray.pdf.document.PdfDocument4a;
import org.foray.primitive.sequence.ByteArray;
-import org.axsl.graphic.EpsGraphic;
import org.axsl.graphic.EpsVectorGraphic;
import org.axsl.graphic.GraphicException;
import org.axsl.ps.BoundingBox;
@@ -60,9 +59,9 @@
* @param doc The parent PDF document.
* @param graphic The form to be encapsulated.
*/
- public PdfXformEps(final PdfDocument4a doc, final EpsGraphic graphic) {
- super(doc, graphic.getVectorGraphic());
- this.graphic = graphic.getVectorGraphic();
+ public PdfXformEps(final PdfDocument4a doc, final EpsVectorGraphic graphic) {
+ super(doc, graphic);
+ this.graphic = graphic;
}
@Override
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-20 14:40:42 UTC (rev 13709)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/graphics/PdfXobject4a.java 2025-05-20 15:40:21 UTC (rev 13710)
@@ -39,7 +39,7 @@
import org.axsl.font.FontConsumer;
import org.axsl.graphic.BitmapGraphic;
-import org.axsl.graphic.EpsGraphic;
+import org.axsl.graphic.EpsVectorGraphic;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.MathGraphic;
@@ -104,9 +104,9 @@
}
/* ... otherwise, create a new one. */
- if (img instanceof EpsGraphic) {
- final EpsGraphic epsGraphic = (EpsGraphic) img;
- xObject = new PdfXformEps(pdfDoc, epsGraphic);
+ if (img instanceof EpsVectorGraphic) {
+ final EpsVectorGraphic epsVectorGraphic = (EpsVectorGraphic) img;
+ xObject = new PdfXformEps(pdfDoc, epsVectorGraphic);
} else if (img instanceof SvgGraphic) {
final SvgGraphic svgGraphic = (SvgGraphic) img;
xObject = new PdfXformSvg(pdfDoc, svgGraphic, orthography, fontConsumer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-20 14:40:48
|
Revision: 13709
http://sourceforge.net/p/foray/code/13709
Author: victormote
Date: 2025-05-20 14:40:42 +0000 (Tue, 20 May 2025)
Log Message:
-----------
Conform to aXSL change: Move responsibility for reporting intrinsic width and height from the FO Tree to the Area Tree.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoScalable4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentHeight.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentWidth.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2025-05-20 13:34:51 UTC (rev 13708)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/ExternalGraphic4a.java 2025-05-20 14:40:42 UTC (rev 13709)
@@ -153,16 +153,4 @@
return true;
}
- @Override
- public int getIntrinsicWidth() {
- /* Implement this. */
- return -1;
- }
-
- @Override
- public int getIntrinsicHeight() {
- /* Implement this. */
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoScalable4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoScalable4a.java 2025-05-20 13:34:51 UTC (rev 13708)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/FoScalable4a.java 2025-05-20 14:40:42 UTC (rev 13709)
@@ -70,7 +70,7 @@
* However, the documentation on the fo:external-graphic and
* fo:instream-foreign-object say that the "content size" should be
* used, and then define it. */
- final int intrinsicWidth = getIntrinsicWidth();
+ final int intrinsicWidth = context.getIntrinsicWidth(this);
/* We already know that the viewport IPD is dependent on the
* content-width.
@@ -90,7 +90,7 @@
} else {
/* We can use the other dimension to compute this one. */
final int viewportBpd = this.viewportBpd(context);
- final int intrinsicHeight = getIntrinsicWidth();
+ final int intrinsicHeight = context.getIntrinsicWidth(this);
final float widthToHeight = (float) intrinsicWidth
/ (float) intrinsicHeight;
return Math.round(widthToHeight * viewportBpd);
@@ -137,7 +137,7 @@
* However, the documentation on the fo:external-graphic and
* fo:instream-foreign-object say that the "content size" should be
* used, and then define it. */
- final int intrinsicHeight = getIntrinsicHeight();
+ final int intrinsicHeight = context.getIntrinsicHeight(this);
/* We already know that the viewport BPD is dependent on the
* content-height.
@@ -157,7 +157,7 @@
} else {
/* We can use the other dimension to compute this one. */
final int viewportIpd = this.viewportIpd(context);
- final int intrinsicWidth = getIntrinsicWidth();
+ final int intrinsicWidth = context.getIntrinsicWidth(this);
final float heightToWidth = (float) intrinsicHeight
/ (float) intrinsicWidth;
return Math.round(heightToWidth * viewportIpd);
@@ -167,7 +167,7 @@
/* The content-height is not dependent on the viewport BPD, so we can
* compute it first, then use it to compute the viewport BPD. */
final float scalingFactor = this.getContentHeight(context, this);
- return Math.round(getIntrinsicHeight() * scalingFactor);
+ return Math.round(context.getIntrinsicHeight(this) * scalingFactor);
}
/**
@@ -191,7 +191,7 @@
@Override
public int referenceIpd(final FoContext context) {
- final int intrinsicWidth = getIntrinsicWidth();
+ final int intrinsicWidth = context.getIntrinsicWidth(this);
final float scaling = this.getContentWidth(context, this);
return Math.round(intrinsicWidth * scaling);
}
@@ -198,7 +198,7 @@
@Override
public int referenceBpd(final FoContext context) {
- final int intrinsicHeight = getIntrinsicHeight();
+ final int intrinsicHeight = context.getIntrinsicHeight(this);
final float scaling = this.getContentHeight(context, this);
return Math.round(intrinsicHeight * scaling);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2025-05-20 13:34:51 UTC (rev 13708)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/InstreamForeignObject4a.java 2025-05-20 14:40:42 UTC (rev 13709)
@@ -157,18 +157,6 @@
}
@Override
- public int getIntrinsicWidth() {
- /* Implement this. */
- return -1;
- }
-
- @Override
- public int getIntrinsicHeight() {
- /* Implement this. */
- return -1;
- }
-
- @Override
public Document getXmlDocument() {
return this.foreignXml;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentHeight.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentHeight.java 2025-05-20 13:34:51 UTC (rev 13708)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentHeight.java 2025-05-20 14:40:42 UTC (rev 13709)
@@ -34,8 +34,6 @@
import org.foray.fotree.fo.obj.FoScalable4a;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.fo.ExternalGraphic;
-import org.axsl.fotree.fo.InstreamForeignObject;
/**
* The "content-height" property in XSL-FO.
@@ -58,27 +56,17 @@
}
@Override
- protected float getInheritedValue(final FoContext context,
- final FoScalable4a fobjScaled, final FoObj parent) {
+ protected float getInheritedValue(final FoContext context, final FoScalable4a fobjScaled, final FoObj parent) {
return parent.getContentHeight(context, fobjScaled);
}
@Override
protected int intrinsicContentDimension(final FoScalable4a fobjScaled, final FoContext context) {
- if (fobjScaled instanceof ExternalGraphic) {
- final ExternalGraphic eg = (ExternalGraphic) fobjScaled;
- return eg.getIntrinsicHeight();
- }
- if (fobjScaled instanceof InstreamForeignObject) {
- final InstreamForeignObject ifo = (InstreamForeignObject) fobjScaled;
- return ifo.getIntrinsicHeight();
- }
- throw new IllegalStateException("Unexpected FO: " + fobjScaled.getClass().getName());
+ return context.getIntrinsicHeight(fobjScaled);
}
@Override
- protected int viewportDimension(final FoScalable4a fobjScaled,
- final FoContext context) {
+ protected int viewportDimension(final FoScalable4a fobjScaled, final FoContext context) {
return fobjScaled.viewportBpd(context);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentWidth.java 2025-05-20 13:34:51 UTC (rev 13708)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdContentWidth.java 2025-05-20 14:40:42 UTC (rev 13709)
@@ -34,8 +34,6 @@
import org.foray.fotree.fo.obj.FoScalable4a;
import org.axsl.fotree.FoContext;
-import org.axsl.fotree.fo.ExternalGraphic;
-import org.axsl.fotree.fo.InstreamForeignObject;
/**
* The "content-width" property in XSL-FO.
@@ -58,27 +56,17 @@
}
@Override
- protected float getInheritedValue(final FoContext context,
- final FoScalable4a fobjScaled, final FoObj parent) {
+ protected float getInheritedValue(final FoContext context, final FoScalable4a fobjScaled, final FoObj parent) {
return parent.getContentWidth(context, fobjScaled);
}
@Override
protected int intrinsicContentDimension(final FoScalable4a fobjScaled, final FoContext context) {
- if (fobjScaled instanceof ExternalGraphic) {
- final ExternalGraphic eg = (ExternalGraphic) fobjScaled;
- return eg.getIntrinsicWidth();
- }
- if (fobjScaled instanceof InstreamForeignObject) {
- final InstreamForeignObject ifo = (InstreamForeignObject) fobjScaled;
- return ifo.getIntrinsicWidth();
- }
- throw new IllegalStateException("Unexpected FO: " + fobjScaled.getClass().getName());
+ return context.getIntrinsicWidth(fobjScaled);
}
@Override
- protected int viewportDimension(final FoScalable4a fobjScaled,
- final FoContext context) {
+ protected int viewportDimension(final FoScalable4a fobjScaled, final FoContext context) {
return fobjScaled.viewportBpd(context);
}
Modified: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java 2025-05-20 13:34:51 UTC (rev 13708)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/doc/InlineLevelFoTests.java 2025-05-20 14:40:42 UTC (rev 13709)
@@ -37,8 +37,8 @@
import org.axsl.fotree.FoTreeException;
import org.axsl.fotree.fixture.FoTreeBoilerplate;
-import org.apache.batik.anim.dom.SVGOMDocument;
import org.w3c.dom.Document;
+import org.w3c.dom.svg.SVGDocument;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -90,14 +90,7 @@
/* ... which contains an SVGElement ... */
final Document domDocument = ifo.getXmlDocument();
assertNotNull(domDocument);
- assertEquals(SVGOMDocument.class, domDocument.getClass());
-
- /* ... for which we can find the width and height. */
-
- /* The pixel width is 20. At the default screen resolution of 96 dpi,
- * the millipoints are (20 / 96) * 72000 = 15000. */
- assertEquals(15_000, ifo.getIntrinsicWidth());
- assertEquals(15_000, ifo.getIntrinsicHeight());
+ assertTrue(domDocument instanceof SVGDocument);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-20 13:34:55
|
Revision: 13708
http://sourceforge.net/p/foray/code/13708
Author: victormote
Date: 2025-05-20 13:34:51 +0000 (Tue, 20 May 2025)
Log Message:
-----------
Conform to aXSL change: Add methods to FoContext for retrieving the resolved intrinsic-width and intrinsic-height of scalable items.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTests.java
trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2025-05-19 22:39:32 UTC (rev 13707)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2025-05-20 13:34:51 UTC (rev 13708)
@@ -35,11 +35,15 @@
import org.axsl.area.AreaNode;
import org.axsl.area.AreaTreeException;
import org.axsl.area.factory.BlockLevelAreaFactory;
+import org.axsl.constants.TypographicConstants;
import org.axsl.context.FontData;
import org.axsl.font.Font;
import org.axsl.font.FontUse;
import org.axsl.fotree.Fo;
+import org.axsl.fotree.FoScalable;
+import org.axsl.fotree.fo.ExternalGraphic;
import org.axsl.fotree.fo.GraftingPoint;
+import org.axsl.fotree.fo.InstreamForeignObject;
import org.axsl.fotree.fo.Table;
import org.axsl.fotree.fo.prop.ColorPa;
import org.axsl.fotree.fo.prop.CommonHyphenationPa;
@@ -47,6 +51,9 @@
import org.axsl.fotree.role.NormalBlockAreaGenerator;
import org.axsl.galley.AreaNodeG5;
import org.axsl.galley.Galley;
+import org.axsl.graphic.Graphic;
+import org.axsl.graphic.GraphicException;
+import org.axsl.graphic.GraphicServer;
import org.axsl.orthography.Orthography;
import org.axsl.value.BaselineIdentifier;
import org.axsl.value.LinefeedTreatment;
@@ -53,7 +60,11 @@
import org.axsl.value.TextTransform;
import org.axsl.value.WhiteSpaceTreatment;
+import org.w3c.dom.mathml.MathMLDocument;
+import org.w3c.dom.svg.SVGDocument;
+
import java.awt.Color;
+import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
@@ -831,81 +842,119 @@
return null;
}
-// @Override
-// public int getIntrinsicWidth(final ExternalGraphic externalGraphic) {
-// final URL location = externalGraphic.traitSrc(this);
-// if (location == null) {
-// return FoPropertyConstants.DIMENSION_AUTO;
-// }
-// try {
-// final int pixelDensity = getAreaTree().getPixelDensity();
-// final Graphic graphic = getAreaTree().getGraphicServer().procureGraphic(location, false);
-// if (graphic.absoluteWidth(pixelDensity) > 0) {
-// return graphic.absoluteWidth(pixelDensity);
-// }
-// return TypographicConstants.pixelsToMillipoints(graphic.pixelWidth(), pixelDensity);
-// } catch (final GraphicException e) {
-// return FoPropertyConstants.DIMENSION_AUTO;
-// }
-// }
+ @Override
+ public int getIntrinsicWidth(final FoScalable scalable) {
+ if (scalable instanceof ExternalGraphic) {
+ return getIntrinsicWidth((ExternalGraphic) scalable);
+ }
+ if (scalable instanceof InstreamForeignObject) {
+ return getIntrinsicWidth((InstreamForeignObject) scalable);
+ }
+ return 0;
+ }
-// @Override
-// public int getIntrinsicHeight(final ExternalGraphic externalGraphic) {
-// final URL location = externalGraphic.traitSrc(this);
-// if (location == null) {
-// return FoPropertyConstants.DIMENSION_AUTO;
-// }
-// try {
-// final int pixelDensity = getAreaTree().getPixelDensity();
-// final Graphic graphic = getAreaTree().getGraphicServer().procureGraphic(location, false);
-// if (graphic.absoluteHeight(pixelDensity) > 0) {
-// return graphic.absoluteHeight(pixelDensity);
-// }
-// return TypographicConstants.pixelsToMillipoints(graphic.pixelHeight(), pixelDensity);
-// } catch (final GraphicException e) {
-// return FoPropertyConstants.DIMENSION_AUTO;
-// }
-// }
+ @Override
+ public int getIntrinsicHeight(final FoScalable scalable) {
+ if (scalable instanceof ExternalGraphic) {
+ return getIntrinsicHeight((ExternalGraphic) scalable);
+ }
+ if (scalable instanceof InstreamForeignObject) {
+ return getIntrinsicHeight((InstreamForeignObject) scalable);
+ }
+ return 0;
+ }
-// @Override
-// public int getIntrinsicWidth(final InstreamForeignObject instreamForeign) {
-// final int pixelDensity = getAreaTree().getPixelDensity();
-// try {
-// final Graphic graphic = getGraphicForForeign(instreamForeign);
-// return graphic.absoluteWidth(pixelDensity);
-// } catch (final GraphicException e) {
-// return -1;
-// }
-// }
+ /**
+ * Returns the intrinsic width of a given fo:external-graphic.
+ * @param externalGraphic The fo:external-graphic for which the intrinsic width is needed.
+ * @return The intrinsic width of {@code externalGraphic}, or -1 for problems finding or parsing the graphic.
+ */
+ public int getIntrinsicWidth(final ExternalGraphic externalGraphic) {
+ final URL location = externalGraphic.traitSrc(this);
+ if (location == null) {
+ return -1;
+ }
+ final int pixelDensity = getAreaTree().getPixelDensity();
+ try {
+ final Graphic graphic = getAreaTree().getGraphicServer().procureGraphic(location, false);
+ if (graphic.getAbsoluteWidth(pixelDensity) > 0) {
+ return graphic.getAbsoluteWidth(pixelDensity);
+ }
+ return TypographicConstants.pixelsToMillipoints(graphic.getPixelWidth(), pixelDensity);
+ } catch (final GraphicException e) {
+ return -1;
+ }
+ }
-// @Override
-// public int getIntrinsicHeight(final InstreamForeignObject instreamForeign) {
-// final int pixelDensity = getAreaTree().getPixelDensity();
-// try {
-// final Graphic graphic = getGraphicForForeign(instreamForeign);
-// return graphic.absoluteHeight(pixelDensity);
-// } catch (final GraphicException e) {
-// return -1;
-// }
-// }
+ /**
+ * Returns the intrinsic height of a given fo:external-graphic.
+ * @param externalGraphic The fo:external-graphic for which the intrinsic height is needed.
+ * @return The intrinsic height of {@code externalGraphic}, or -1 for problems finding or parsing the graphic.
+ */
+ public int getIntrinsicHeight(final ExternalGraphic externalGraphic) {
+ final URL location = externalGraphic.traitSrc(this);
+ if (location == null) {
+ return -1;
+ }
+ try {
+ final int pixelDensity = getAreaTree().getPixelDensity();
+ final Graphic graphic = getAreaTree().getGraphicServer().procureGraphic(location, false);
+ if (graphic.getAbsoluteHeight(pixelDensity) > 0) {
+ return graphic.getAbsoluteHeight(pixelDensity);
+ }
+ return TypographicConstants.pixelsToMillipoints(graphic.getPixelHeight(), pixelDensity);
+ } catch (final GraphicException e) {
+ return -1;
+ }
+ }
-// /**
-// * Returns the Graphic instance that was created from a given Foreign XML instance.
-// * @param instreamForeign The foreign XML.
-// * @return The graphic for {@code foreignXml}.
-// * @throws GraphicException For errors creating the graphic.
-// */
-// private Graphic getGraphicForForeign(final InstreamForeignObject instreamForeign) throws GraphicException {
-// final GraphicServer server = getAreaTree().getGraphicServer();
-// if (instreamForeign.getXmlDocument() instanceof MathMLDocument) {
-// final MathMLDocument document = (MathMLDocument) instreamForeign.getXmlDocument();
-// return server.procureMathGraphic(document);
-// }
-// if (instreamForeign.getXmlDocument() instanceof SVGDocument) {
-// final SVGDocument document = (SVGDocument) instreamForeign.getXmlDocument();
-// return server.procureSvgGraphic(document);
-// }
-// return null;
-// }
+ /**
+ * Returns the intrinsic width of a given fo:instream-foreign-object.
+ * @param instreamForeign The fo:instream-foreign-object for which the intrinsic width is needed.
+ * @return The intrinsic width of {@code instreamForeign}, or -1 for problems parsing the object.
+ */
+ public int getIntrinsicWidth(final InstreamForeignObject instreamForeign) {
+ final int pixelDensity = getAreaTree().getPixelDensity();
+ try {
+ final Graphic graphic = getGraphicForForeign(instreamForeign);
+ return graphic.getAbsoluteWidth(pixelDensity);
+ } catch (final GraphicException e) {
+ return -1;
+ }
+ }
+ /**
+ * Returns the intrinsic height of a given fo:instream-foreign-object.
+ * @param instreamForeign The fo:instream-foreign-object for which the intrinsic height is needed.
+ * @return The intrinsic height of {@code instreamForeign}, or -1 for problems parsing the object.
+ */
+ public int getIntrinsicHeight(final InstreamForeignObject instreamForeign) {
+ final int pixelDensity = getAreaTree().getPixelDensity();
+ try {
+ final Graphic graphic = getGraphicForForeign(instreamForeign);
+ return graphic.getAbsoluteHeight(pixelDensity);
+ } catch (final GraphicException e) {
+ return -1;
+ }
+ }
+
+ /**
+ * Returns the Graphic instance that was created from a given Foreign XML instance.
+ * @param instreamForeign The foreign XML.
+ * @return The graphic for {@code foreignXml}.
+ * @throws GraphicException For errors creating the graphic.
+ */
+ private Graphic getGraphicForForeign(final InstreamForeignObject instreamForeign) throws GraphicException {
+ final GraphicServer server = getAreaTree().getGraphicServer();
+ if (instreamForeign.getXmlDocument() instanceof MathMLDocument) {
+ final MathMLDocument document = (MathMLDocument) instreamForeign.getXmlDocument();
+ return server.procureMathGraphic(document);
+ }
+ if (instreamForeign.getXmlDocument() instanceof SVGDocument) {
+ final SVGDocument document = (SVGDocument) instreamForeign.getXmlDocument();
+ return server.procureSvgGraphic(document);
+ }
+ return null;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTests.java
===================================================================
--- trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTests.java 2025-05-19 22:39:32 UTC (rev 13707)
+++ trunk/foray/foray-fotree/src/test/java/org/foray/fotree/AbstractPropertyTests.java 2025-05-20 13:34:51 UTC (rev 13708)
@@ -33,6 +33,7 @@
import org.axsl.context.FontData;
import org.axsl.fotree.FoContext;
import org.axsl.fotree.FoInlineContext;
+import org.axsl.fotree.FoScalable;
import org.axsl.fotree.FoTreeCreator;
import org.axsl.fotree.fo.GraftingPoint;
import org.axsl.i18n.Script;
@@ -197,6 +198,16 @@
return STD_FONT_DATA;
}
+ @Override
+ public int getIntrinsicWidth(final FoScalable scalable) {
+ return -1;
+ }
+
+ @Override
+ public int getIntrinsicHeight(final FoScalable scalable) {
+ return -1;
+ }
+
};
/** Constant providing a standard, but completely bogus context to be
Modified: trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java
===================================================================
--- trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java 2025-05-19 22:39:32 UTC (rev 13707)
+++ trunk/foray/foray-pioneer/src/main/java/org/foray/pioneer/OverrideGraftingContext.java 2025-05-20 13:34:51 UTC (rev 13708)
@@ -30,6 +30,7 @@
import org.axsl.context.FontData;
import org.axsl.fotree.FoContext;
+import org.axsl.fotree.FoScalable;
import org.axsl.fotree.fo.GraftingPoint;
import org.axsl.value.BaselineIdentifier;
import org.axsl.value.LinefeedTreatment;
@@ -162,4 +163,14 @@
return this.wrappedContext.getFontData();
}
+ @Override
+ public int getIntrinsicWidth(final FoScalable scalable) {
+ return this.wrappedContext.getIntrinsicWidth(scalable);
+ }
+
+ @Override
+ public int getIntrinsicHeight(final FoScalable scalable) {
+ return this.wrappedContext.getIntrinsicHeight(scalable);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-19 22:39:35
|
Revision: 13707
http://sourceforge.net/p/foray/code/13707
Author: victormote
Date: 2025-05-19 22:39:32 +0000 (Mon, 19 May 2025)
Log Message:
-----------
Move parsing of color palette to parser.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.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-19 21:39:24 UTC (rev 13706)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-19 22:39:32 UTC (rev 13707)
@@ -39,6 +39,7 @@
import org.foray.graphic.parser.GraphicRandomAccessInput;
import org.foray.primitive.sequence.ByteArray;
+import org.axsl.constants.MeasurementConstants;
import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.Graphic;
import org.axsl.graphic.GraphicException;
@@ -123,7 +124,8 @@
/** The number of bytes that must be read for a row of pixels in this image. */
private int bytesPerRow;
- /** The color palette parsed from the input file. This will be null for 24-bit color images. */
+ /** The color palette parsed from the input file. This will be null for 24-bit color images.
+ * Any padding bytes have been removed, and the order has been reversed from BGR to RGB. */
private byte[] colorPalette;
/** Image width (in pixel). */
@@ -154,7 +156,6 @@
final BmpGraphicHandler handler = this.new Handler(this);
final BmpGraphicParser1 parser = new BmpGraphicParser1();
parser.parse(input, 0, handler);
- this.colorPalette = readPalette(input.getOffset());
}
@Override
@@ -391,53 +392,6 @@
return null;
}
- /**
- * Computes the color palette, if any, for this image.
- * @param offset The offset to the start of the color palette.
- * @return The color palette for this image, or, if the image is not color,
- * returns null.
- * @throws GraphicException For erros when loading the image content.
- */
- private byte[] readPalette(final long offset) throws GraphicException {
- try {
- getInputStream().reset();
- getInputStream().skip(offset);
- } catch (final IOException e) {
- throw new GraphicException(e);
- }
- if (this.bitsPerPixel != BIT_DEPTH_4
- && this.bitsPerPixel != BIT_DEPTH_8) {
- return null;
- }
- final int numChannels = getColorSpace().getNumComponents();
- byte palette[] = null;
- final int palettesize = 1 << this.bitsPerPixel;
- palette = new byte[palettesize * getColorSpace().getNumComponents()];
- int countr = 0;
- while (countr < palettesize) {
- int count2 = 2;
- while (count2 >= -1) {
- int input = 0;
- try {
- input = getInputStream().read();
- } catch (final IOException e) {
- loadImageError(e);
- }
- if (input == -1) {
- /* End of file reached prematurely. */
- loadImageError(null);
- }
- if (count2 >= 0) {
- final int paletteIndex = countr * numChannels + count2;
- palette[paletteIndex] = (byte) (input
- & PrimitiveConstants.MAX_8_BIT_UNSIGNED_INT);
- }
- count2--;
- }
- countr++;
- }
- return palette;
- }
/**
* Computes the number of bytes of graphic data for each row of pixels in
@@ -539,4 +493,9 @@
return this.fileFormat;
}
+ @Override
+ protected int maxBytesToParseBasics() {
+ /* The color profile can be as large as 1024. 1300 is probably enough, but round up to 2K. */
+ return MeasurementConstants.BYTES_PER_KILOBYTE * 2;
+ }
}
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-19 21:39:24 UTC (rev 13706)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-19 22:39:32 UTC (rev 13707)
@@ -67,7 +67,7 @@
* The default maximimum number of bytes that need to be read in order to
* extract the basic information from a file.
*/
- private static final int DEFAULT_MAX_BYTES_TO_PARSE_BASICS = 1024;
+ public static final int DEFAULT_MAX_BYTES_TO_PARSE_BASICS = 1024;
/** The parent server instance. */
private GraphicServer4a server;
@@ -215,15 +215,13 @@
protected abstract void parseBasics() throws IOException, GraphicException;
/**
- * Tells {@link #parseBasicsWrapper()} how large to set the
- * {@code readlimit} value when marking the beginning of the stream,
- * so that is can be reused.
- * The default value is 1024. Subclasses that need to read more than this
- * amount when parsing the basics from the stream should override this
- * method and return a higher amount. Otherwise, subsequent attempts to
- * use the stream will result in i/o errors.
- * @return The maximum number of bytes that might need to be read from
- * the stream to be able to parse the basics.
+ * Tells {@link #parseBasicsWrapper()} how large to set the {@code readlimit} value when marking the beginning of
+ * the stream, so that is can be reused.
+ * The default value is 1024.
+ * Subclasses that need to read more than this amount when parsing the basics from the stream should override this
+ * method and return a higher amount.
+ * Otherwise, subsequent attempts to use the stream will result in i/o errors.
+ * @return The maximum number of bytes that might need to be read from the stream to be able to parse the basics.
*/
protected int maxBytesToParseBasics() {
return Graphic4a.DEFAULT_MAX_BYTES_TO_PARSE_BASICS;
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java 2025-05-19 21:39:24 UTC (rev 13706)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java 2025-05-19 22:39:32 UTC (rev 13707)
@@ -31,11 +31,13 @@
import org.foray.graphic.Graphic4a;
import org.foray.graphic.format.Bmp;
import org.foray.graphic.handler.BmpGraphicHandler;
+import org.foray.primitive.sequence.ByteArrayBuilder;
import org.axsl.graphic.GraphicException;
import org.checkerframework.checker.signedness.qual.Unsigned;
+import java.awt.color.ColorSpace;
import java.io.IOException;
/**
@@ -49,6 +51,8 @@
/** The bits-per-pixel parsed from the bitmap header. */
private @Unsigned short bmhBitsPerPixel;
+ /** The inferred file format. */
+ private Bmp.Format fileFormat;
@Override
public void parse(final GraphicRandomAccessInput input, final long offset, final BmpGraphicHandler handler)
@@ -62,17 +66,7 @@
parseBitmapHeader(input, handler);
- /* Color Palette. */
- /* There is ALWAYS a color palette for 1-, 4-, and 8-bit BMP files. There is NEVER one for 24-bit. */
-// if (this.bmhBitsPerPixel != Graphic4a.BIT_DEPTH_24) {
-// final int numColorPaletteEntries = 1 << bmhBitsPerPixel;
-// handler.numPaletteEntries(numColorPaletteEntries);
-// /* Each entry has 3 bytes, one each for Blue, Green, Red. */
-// final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
-// final byte[] palette = new byte[numColorPaletteEntries * cs.getNumComponents()];
-// input.readFully(palette);
-// handler.colorPalette(palette);
-// }
+ parseColorPalette(input, handler);
}
/**
@@ -127,7 +121,7 @@
handler.bmhSize(bmhSize);
/* We now know enough to compute a tentative file format. */
- final Bmp.Format fileFormat = computeTentativeFileFormat(fileType, bmhSize);
+ this.fileFormat = computeTentativeFileFormat(fileType, bmhSize);
switch (fileFormat) {
case WIN_1: break;
@@ -226,4 +220,48 @@
throw new GraphicException("Unknown BMP format: file type [" + fileType + "], bitmap header size [" +
bmhSize + "]");
}
+
+ /**
+ * Parses the color palette.
+ * @param input The bytes being parsed.
+ * @param handler The handler catching events thrown by this parser.
+ * @throws IOException For errors reading the input.
+ */
+ private void parseColorPalette(final GraphicRandomAccessInput input, final BmpGraphicHandler handler)
+ throws IOException {
+ /* There is ALWAYS a color palette for 1-, 4-, and 8-bit BMP files. There is NEVER one for 24-bit. */
+ if (this.bmhBitsPerPixel == Graphic4a.BIT_DEPTH_24) {
+ return;
+ }
+ final int numColorPaletteEntries = 1 << bmhBitsPerPixel;
+ handler.numPaletteEntries(numColorPaletteEntries);
+ /* Each entry has 3 bytes, one each for Blue, Green, Red. */
+ final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ final ByteArrayBuilder builder = new ByteArrayBuilder(numColorPaletteEntries * cs.getNumComponents());
+ for (int index = 0; index < numColorPaletteEntries; index ++) {
+ /* We read them in BGR order... */
+ final byte blue = input.read_BYTE();
+ final byte green = input.read_BYTE();
+ final byte red = input.read_BYTE();
+ /* ... but append them in RGB order. */
+ builder.append(red);
+ builder.append(green);
+ builder.append(blue);
+
+ /* For WIN_3 and above, skip the extra padding byte. */
+ switch (this.fileFormat) {
+ case WIN_1:
+ case WIN_2:
+ case OS2_1: {
+ break;
+ }
+ default: {
+ input.skipBytes(1);
+ }
+ }
+ }
+
+ handler.colorPalette(builder.toArray());
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-19 21:39:29
|
Revision: 13706
http://sourceforge.net/p/foray/code/13706
Author: victormote
Date: 2025-05-19 21:39:24 +0000 (Mon, 19 May 2025)
Log Message:
-----------
Add test for color palette parsing.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/handler/BmpGraphicHandler.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java
trunk/foray/foray-graphic/src/test/resources/readme.txt
Added Paths:
-----------
trunk/foray/foray-graphic/src/test/resources/bmp/LAND.BMP
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-19 15:23:52 UTC (rev 13705)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-19 21:39:24 UTC (rev 13706)
@@ -33,6 +33,7 @@
package org.foray.graphic;
+import org.foray.graphic.format.Bmp;
import org.foray.graphic.handler.BmpGraphicHandler;
import org.foray.graphic.parser.BmpGraphicParser1;
import org.foray.graphic.parser.GraphicRandomAccessInput;
@@ -94,6 +95,11 @@
}
@Override
+ public void fileFormat(final Bmp.Format value) {
+ graphic.fileFormat = value;
+ }
+
+ @Override
public void colorPalette(final @Unsigned byte[] value) {
graphic.colorPalette = value;
}
@@ -108,6 +114,9 @@
/** Mask for bits 1 and 2. */
private static final byte BITS_1_AND_2_MASK = 0x03;
+ /** The file format. */
+ private Bmp.Format fileFormat;
+
/** Offset to the image data. */
private int bitmapOffset;
@@ -138,20 +147,18 @@
}
@Override
+ public void parseBasics() throws IOException, GraphicException {
+ final byte[] header = new byte[maxBytesToParseBasics()];
+ getInputStream().read(header);
+ final GraphicRandomAccessInput input = new GraphicRandomAccessInput.Impl(header);
+ final BmpGraphicHandler handler = this.new Handler(this);
+ final BmpGraphicParser1 parser = new BmpGraphicParser1();
+ parser.parse(input, 0, handler);
+ this.colorPalette = readPalette(input.getOffset());
+ }
+
+ @Override
public void loadImage() throws GraphicException {
-// final byte[] headermap = new byte[BmpGraphic.HEADERMAP_LENGTH];
-// try {
-// getInputStream().read(headermap);
-// } catch (final IOException e) {
-// loadImageError(e);
-// }
-//// int filepos = BmpGraphic.HEADERMAP_LENGTH;
-// setBitDepth(headermap[BmpGraphic.BIT_DEPTH_OFFSET]);
- this.colorPalette = readPalette();
-// if (this.colorPalette != null) {
-//// filepos += this.colorPalette.length
-//// * getRawColorSpace().getNumComponents();
-// }
try {
getInputStream().skip(this.bitmapOffset);
@@ -380,16 +387,6 @@
}
@Override
- public void parseBasics() throws IOException, GraphicException {
- final byte[] header = new byte[maxBytesToParseBasics()];
- getInputStream().read(header);
- final GraphicRandomAccessInput input = new GraphicRandomAccessInput.Impl(header);
- final BmpGraphicHandler handler = this.new Handler(this);
- final BmpGraphicParser1 parser = new BmpGraphicParser1();
- parser.parse(input, 0, handler);
- }
-
- @Override
public String getName() {
return null;
}
@@ -396,11 +393,18 @@
/**
* Computes the color palette, if any, for this image.
+ * @param offset The offset to the start of the color palette.
* @return The color palette for this image, or, if the image is not color,
* returns null.
* @throws GraphicException For erros when loading the image content.
*/
- private byte[] readPalette() throws GraphicException {
+ private byte[] readPalette(final long offset) throws GraphicException {
+ try {
+ getInputStream().reset();
+ getInputStream().skip(offset);
+ } catch (final IOException e) {
+ throw new GraphicException(e);
+ }
if (this.bitsPerPixel != BIT_DEPTH_4
&& this.bitsPerPixel != BIT_DEPTH_8) {
return null;
@@ -527,4 +531,12 @@
return this.bitsPerPixel;
}
+ /**
+ * Returns the file format.
+ * @return The file format.
+ */
+ public Bmp.Format getFileFormat() {
+ return this.fileFormat;
+ }
+
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/handler/BmpGraphicHandler.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/handler/BmpGraphicHandler.java 2025-05-19 15:23:52 UTC (rev 13705)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/handler/BmpGraphicHandler.java 2025-05-19 21:39:24 UTC (rev 13706)
@@ -28,6 +28,7 @@
package org.foray.graphic.handler;
+import org.foray.graphic.format.Bmp;
import org.foray.graphic.parser.BmpGraphicParser1;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -51,9 +52,21 @@
default void bmhNumPlanes(final @Unsigned short value) { return; }
default void bmhBitsPerPixel(final @Unsigned short value) { return; }
+ default void bmhCompression(final @Unsigned int value) { return; }
+ default void bmhSizeOfBitmap(final @Unsigned int value) { return; }
+ default void bmhHorzResolution(final int value) { return; }
+ default void bmhVertResolution(final int value) { return; }
+ default void bmhColorsUsed(final @Unsigned int value) { return; }
+ default void bmhColorsImportant(final @Unsigned int value) { return; }
+
+
+ default void fileFormat(final Bmp.Format value) { return; }
+
+
+
default void numPaletteEntries(final @Unsigned int value) { return; }
- default void blueComponent(final @Unsigned byte value) { return; }
- default void greenComponent(final @Unsigned byte value) { return; }
- default void redComponent(final @Unsigned byte value) { return; }
+// default void blueComponent(final @Unsigned byte value) { return; }
+// default void greenComponent(final @Unsigned byte value) { return; }
+// default void redComponent(final @Unsigned byte value) { return; }
default void colorPalette(final @Unsigned byte[] value) { return; }
}
Modified: trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java
===================================================================
--- trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java 2025-05-19 15:23:52 UTC (rev 13705)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/parser/BmpGraphicParser1.java 2025-05-19 21:39:24 UTC (rev 13706)
@@ -28,10 +28,10 @@
package org.foray.graphic.parser;
+import org.foray.graphic.Graphic4a;
import org.foray.graphic.format.Bmp;
import org.foray.graphic.handler.BmpGraphicHandler;
-import org.axsl.constants.PrimitiveConstants;
import org.axsl.graphic.GraphicException;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -62,21 +62,17 @@
parseBitmapHeader(input, handler);
-
- /* Color Palette. */ // *** Restart Count ***
- int numColorPaletteEntries = 1 << bmhBitsPerPixel;
- if (numColorPaletteEntries > PrimitiveConstants.MAX_8_BIT_UNSIGNED_VALUES) {
- numColorPaletteEntries = 0;
- }
- handler.numPaletteEntries(numColorPaletteEntries);
-
- /* Each entry has 3 bytes, one each for Blue, Green, Red. */
-// final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
-// final byte[] palette = new byte[numColorPaletteEntries * cs.getNumComponents()];
-// for (int index = 0; index < numColorPaletteEntries; index ++) {
+ /* Color Palette. */
+ /* There is ALWAYS a color palette for 1-, 4-, and 8-bit BMP files. There is NEVER one for 24-bit. */
+// if (this.bmhBitsPerPixel != Graphic4a.BIT_DEPTH_24) {
+// final int numColorPaletteEntries = 1 << bmhBitsPerPixel;
+// handler.numPaletteEntries(numColorPaletteEntries);
+// /* Each entry has 3 bytes, one each for Blue, Green, Red. */
+// final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+// final byte[] palette = new byte[numColorPaletteEntries * cs.getNumComponents()];
+// input.readFully(palette);
+// handler.colorPalette(palette);
// }
-
-
}
/**
@@ -162,7 +158,36 @@
handler.bmhNumPlanes(Short.reverseBytes(input.read_WORD())); // 2 bytes
this.bmhBitsPerPixel = Short.reverseBytes(input.read_WORD()); // 2 bytes
+ switch (this.bmhBitsPerPixel) {
+ case Graphic4a.BIT_DEPTH_1:
+ case Graphic4a.BIT_DEPTH_4:
+ case Graphic4a.BIT_DEPTH_8:
+ case Graphic4a.BIT_DEPTH_24:
+ break;
+ default: throw new GraphicException("Unexpected value for 'bits per pixel': " + this.bmhBitsPerPixel);
+ }
handler.bmhBitsPerPixel(bmhBitsPerPixel);
+
+
+ /* Anything older than WIN_3 bails out here. */
+ switch (fileFormat) {
+ case WIN_1:
+ case WIN_2:
+ case OS2_1:
+ return;
+ default: { }
+ }
+
+
+ /* *** WIN_3 and higher. *** */
+ handler.bmhCompression(Integer.reverseBytes(input.read_DWORD()));
+ handler.bmhSizeOfBitmap(Integer.reverseBytes(input.read_DWORD()));
+ handler.bmhHorzResolution(Integer.reverseBytes(input.read_LONG()));
+ handler.bmhVertResolution(Integer.reverseBytes(input.read_LONG()));
+ handler.bmhColorsUsed(Integer.reverseBytes(input.read_DWORD()));
+ handler.bmhColorsImportant(Integer.reverseBytes(input.read_DWORD()));
+
+ handler.fileFormat(fileFormat);
}
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-19 15:23:52 UTC (rev 13705)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-19 21:39:24 UTC (rev 13706)
@@ -29,10 +29,12 @@
package org.foray.graphic;
import org.foray.common.url.UrlUtil;
+import org.foray.graphic.format.Bmp;
import org.axsl.graphic.GraphicException;
import org.axsl.primitive.sequence.ByteSequence;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -44,6 +46,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Arrays;
/**
* JUnit test class for the class {@link BmpGraphic}.
@@ -51,7 +54,7 @@
public class BmpGraphicTests extends AbstractGraphicTests {
/**
- * Functional test of a specific image.
+ * Functional test of a specific 24-bit image.
* @throws GraphicException For errors processing image.
* @throws IOException For errors reading image.
* @throws URISyntaxException Not expected here.
@@ -63,9 +66,9 @@
assertNotNull(graphic);
assertTrue(graphic instanceof BmpGraphic);
final BmpGraphic bmp = (BmpGraphic) graphic;
+ assertEquals(Bmp.Format.WIN_3, bmp.getFileFormat());
assertEquals(70, bmp.getPixelWidth());
assertEquals(62, bmp.getPixelHeight());
- assertEquals(8, bmp.getBitsPerComponent());
assertEquals(24, bmp.getBitsPerPixel());
assertEquals(8, bmp.getBitsPerComponent());
assertTrue(bmp.getColorSpace().getType() == ColorSpace.TYPE_RGB);
@@ -81,4 +84,59 @@
assertEquals(13020, content.length());
}
+ /**
+ * Functional test of a specific 8-bit image.
+ * @throws GraphicException For errors processing image.
+ * @throws IOException For errors reading image.
+ * @throws URISyntaxException Not expected here.
+ */
+ @Test
+ public void testGraphic02() throws GraphicException, IOException, URISyntaxException {
+ final URI graphicUri = UrlUtil.resolveURI(getBaseURLs(), new URI("bmp/LAND.BMP"));
+ final Graphic4a graphic = this.getServer().procureGraphic(graphicUri.toURL(), false);
+ assertNotNull(graphic);
+ assertTrue(graphic instanceof BmpGraphic);
+ final BmpGraphic bmp = (BmpGraphic) graphic;
+ assertEquals(Bmp.Format.WIN_3, bmp.getFileFormat());
+ assertEquals(1024, bmp.getPixelWidth());
+ assertEquals(768, bmp.getPixelHeight());
+ assertEquals(8, bmp.getBitsPerPixel());
+ assertEquals(2, bmp.getBitsPerComponent());
+ assertTrue(bmp.getColorSpace().getType() == ColorSpace.TYPE_RGB);
+ assertEquals(3, bmp.getColorSpace().getNumComponents());
+ final byte[] expectedColorPalette = new byte[256 * 3];
+ Arrays.fill(expectedColorPalette, (byte) 0xFF);
+ final byte[] colorPalette = bmp.getColorPalette();
+ assertNotNull(colorPalette);
+ assertEquals(256 * 3, colorPalette.length);
+ /* WIN_3 color palettes have a byte of padding after each 3-byte BGR value. Also, the parsing logic reverses the
+ * BGR order to RGB. The color palette starts at index 54 (0x36). */
+ final byte[] expectedPaletteStart = {
+ 0x00, 0x00, 0x00,
+ 0x3c, 0x2c, 0x18,
+ 0x33, 0x26, 0x23,
+ 0x26, 0x22, 0x37,
+ 0x29, 0x28, 0x3a };
+ final byte[] paletteStart = Arrays.copyOfRange(colorPalette, 0, 15);
+ assertArrayEquals(expectedPaletteStart, paletteStart);
+
+ /* 54 + (256 * 4) = 1078. The last 20 bytes start at 1058 (0x422) */
+ final byte[] expectedPaletteEnd = {
+ (byte) 0xB9, 0x5A, (byte) 0xBA,
+ (byte) 0xAF, 0x63, (byte) 0xB9,
+ (byte) 0xB9, 0x5D, (byte) 0xC0,
+ (byte) 0xC2, 0x57, (byte) 0xC2,
+ (byte) 0x8D, (byte) 0xA8, (byte) 0xC3 };
+ final byte[] paletteEnd = Arrays.copyOfRange(colorPalette, colorPalette.length - 15, colorPalette.length);
+ assertArrayEquals(expectedPaletteEnd, paletteEnd);
+ assertFalse(bmp.isTransparent());
+ assertNull(bmp.getTransparentColor());
+// final ByteSequence content = bmp.getContent();
+// assertNotNull(content);
+ /* 1024 pixel width * 768 pixel height = 786,432 pixels.
+ * 786,432 * 8 bits per channel = 6,291,456 bits.
+ * 6,291,456 / 8 bits per byte = 786,432 bytes. */
+// assertEquals(13020, content.length());
+ }
+
}
Added: trunk/foray/foray-graphic/src/test/resources/bmp/LAND.BMP
===================================================================
(Binary files differ)
Index: trunk/foray/foray-graphic/src/test/resources/bmp/LAND.BMP
===================================================================
--- trunk/foray/foray-graphic/src/test/resources/bmp/LAND.BMP 2025-05-19 15:23:52 UTC (rev 13705)
+++ trunk/foray/foray-graphic/src/test/resources/bmp/LAND.BMP 2025-05-19 21:39:24 UTC (rev 13706)
Property changes on: trunk/foray/foray-graphic/src/test/resources/bmp/LAND.BMP
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/foray/foray-graphic/src/test/resources/readme.txt
===================================================================
--- trunk/foray/foray-graphic/src/test/resources/readme.txt 2025-05-19 15:23:52 UTC (rev 13705)
+++ trunk/foray/foray-graphic/src/test/resources/readme.txt 2025-05-19 21:39:24 UTC (rev 13706)
@@ -7,33 +7,42 @@
of these files will ensure that images in this directory will remain in
that state.
-1. The file jpeg-test1.jpg was created by Victor Mote on Feb 5, 2005,
-using Adobe Photoshop.
+bmp/LAND.BMP
+ Copied from the CD accompanying "Encyclopedia of Graphics File Formats,
+ Second Edition" (O'Reilly & Associates). We understand from the Preface,
+ "About the Images," to be licensed to "use these sample images to test
+ whether you are successfully reading or converting a particular file
+ format."
-2. The file 29_coffeeshop_inv.ps (An EPS file) was downloaded by Victor
-Mote on Feb 5, 2005, from the following URL:
-http://www.aiga.org/Resources/SymbolSigns/eps/29_coffeeshop_inv.eps
-The following URL contained a link to the above URL:
-http://www.aiga.org/content.cfm?ContentAlias=symbolsigns
-and contained the following text:
-"The complete set of 50 passenger/pedestrian symbols developed by AIGA
-is now available on the web, free of charge. Signs are available in EPS
-and GIF formats."
-and the following:
-"These copyright-free symbols have become the standard for off-the-shelf
-symbols in the catalogues of U.S. sign companies."
+eps/01_telephone_inv.eps
+ Downloaded by Victor Mote on Aug 8, 2007 from the following URL:
+ http://www.aiga.org/Resources/SymbolSigns/eps/01_telephone_inv.eps
+ The following URL contained a link to the above URL:
+ http://www.aiga.org/content.cfm/symbol-signs
+ which contained the same text noted above for 29_coffeeshop.
-3. The file 01_telephone_inv.eps was downloaded by Victor Mote on Aug
-8, 2007 from the following URL:
-http://www.aiga.org/Resources/SymbolSigns/eps/01_telephone_inv.eps
-The following URL contained a ling to the above URL:
-http://www.aiga.org/content.cfm/symbol-signs
-which contained the same text noted above for 29_coffeeshop.
+eps/29_coffeeshop_inv.ps (An EPS file)
+ Downloaded by Victor Mote on Feb 5, 2005, from the following URL:
+ http://www.aiga.org/Resources/SymbolSigns/eps/29_coffeeshop_inv.eps
+ The following URL contained a link to the above URL:
+ http://www.aiga.org/content.cfm?ContentAlias=symbolsigns
+ and contained the following text:
+ "The complete set of 50 passenger/pedestrian symbols developed by AIGA
+ is now available on the web, free of charge. Signs are available in EPS
+ and GIF formats."
+ and the following:
+ "These copyright-free symbols have become the standard for off-the-shelf
+ symbols in the catalogues of U.S. sign companies."
-4. The file 01_telephone_inv.pdf was distilled from 01_telephone_inv.eps
-by Victor Mote on Aug 8, 2007, using Acrobat Distiller 6.0.
+eps/barcode1.eps
+ Contributed by Jeremias Maerki on Feb 6, 2005, being created by his
+ Krysalis software.
-5. The file barcode1.eps was contributed by Jeremias Maerki on Feb 6, 2005,
-being created by his Krysalis software.
+jpg/jpeg-test1.jpg
+ Created by Victor Mote on Feb 5, 2005, using Adobe Photoshop.
+pdf/01_telephone_inv.pdf
+ Ddistilled from 01_telephone_inv.eps by Victor Mote on Aug 8, 2007, using
+ Acrobat Distiller 6.0.
+
----- Last line of file -----
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-19 15:24:01
|
Revision: 13705
http://sourceforge.net/p/foray/code/13705
Author: victormote
Date: 2025-05-19 15:23:52 +0000 (Mon, 19 May 2025)
Log Message:
-----------
Sort out differences between "bits per pixel" and "bits per component".
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/Graphic4a.java
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.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
trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/BmpGraphic.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -90,7 +90,7 @@
@Override
public void bmhBitsPerPixel(final @Unsigned short value) {
graphic.bitsPerPixel = value;
- graphic.setBitDepth(value);
+ graphic.setBitsPerComponent(value / graphic.getColorSpace().getNumComponents());
}
@Override
@@ -172,12 +172,6 @@
processRow(normalizedBytes, inputBytes, row);
}
- /*
- * This seems really strange to me, but I noticed that JimiImage
- * hardcodes m_bitsPerPixel to 8. If I do not do this Acrobat is unable
- * to read the resultant PDF, so we will hardcode this...
- */
- setBitDepth(BIT_DEPTH_8);
setContent(new ByteArray(normalizedBytes));
}
@@ -198,20 +192,19 @@
final int index = (int) ((this.pixelHeight - row - 1) * this.bytesPerRow + byteInRow);
final byte p = inputBytes[index];
- if (getBitDepth() == BIT_DEPTH_24
+ if (this.bitsPerPixel == BIT_DEPTH_24
&& column < this.pixelWidth) {
byteInRow = processColorPixel(normalizedBytes, inputBytes,
row, column, byteInRow);
column++;
- } else if (getBitDepth() == BIT_DEPTH_1) {
+ } else if (this.bitsPerPixel == BIT_DEPTH_1) {
column = processMonochromeByte(normalizedBytes, row, column, p);
byteInRow++;
- } else if (getBitDepth() == BIT_DEPTH_4) {
+ } else if (this.bitsPerPixel == BIT_DEPTH_4) {
column = process4BitsByte(normalizedBytes, row, column, p);
byteInRow++;
- } else if (getBitDepth() == BIT_DEPTH_8) {
- byteInRow = processGrayscaleByte(normalizedBytes,
- row, column, byteInRow, p);
+ } else if (this.bitsPerPixel == BIT_DEPTH_8) {
+ byteInRow = processGrayscaleByte(normalizedBytes, row, column, byteInRow, p);
column++;
} else {
byteInRow++;
@@ -408,13 +401,13 @@
* @throws GraphicException For erros when loading the image content.
*/
private byte[] readPalette() throws GraphicException {
- if (getBitDepth() != BIT_DEPTH_4
- && getBitDepth() != BIT_DEPTH_8) {
+ if (this.bitsPerPixel != BIT_DEPTH_4
+ && this.bitsPerPixel != BIT_DEPTH_8) {
return null;
}
final int numChannels = getColorSpace().getNumComponents();
byte palette[] = null;
- final int palettesize = 1 << getBitDepth();
+ final int palettesize = 1 << this.bitsPerPixel;
palette = new byte[palettesize * getColorSpace().getNumComponents()];
int countr = 0;
while (countr < palettesize) {
@@ -450,15 +443,15 @@
*/
private int computeBytesPerRow() throws GraphicException {
int bytesPerRow = 0;
- if (getBitDepth() == BIT_DEPTH_1) {
+ if (this.bitsPerPixel == BIT_DEPTH_1) {
bytesPerRow = (int) this.pixelWidth;
- } else if (getBitDepth() == BIT_DEPTH_24) {
+ } else if (this.bitsPerPixel == BIT_DEPTH_24) {
bytesPerRow = (int) (this.pixelWidth * getColorSpace().getNumComponents());
- } else if (getBitDepth() == BIT_DEPTH_4
- || getBitDepth() == BIT_DEPTH_8) {
- bytesPerRow = (int) (this.pixelWidth * getBitDepth() / PrimitiveConstants.BITS_PER_BYTE);
+ } else if (this.bitsPerPixel == BIT_DEPTH_4
+ || this.bitsPerPixel == BIT_DEPTH_8) {
+ bytesPerRow = (int) (this.pixelWidth * this.bitsPerPixel / PrimitiveConstants.BITS_PER_BYTE);
} else {
- throw new GraphicException("Image (" + getUrl().toString() + ") has " + getBitDepth()
+ throw new GraphicException("Image (" + getUrl().toString() + ") has " + this.bitsPerPixel
+ " which is not a supported BMP format.");
}
if ((bytesPerRow & BmpGraphic.BITS_1_AND_2_MASK) != 0) {
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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/GifGraphic.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -222,7 +222,7 @@
this.pixelWidth = consumer.getWidth();
final ColorModel cm = consumer.getColorModel();
- setBitDepth(BIT_DEPTH_8);
+ setBitsPerComponent(BIT_DEPTH_8);
// this.m_bitsPerPixel = cm.getPixelSize();
if (cm.hasAlpha()) {
loadTransparency(cm);
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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/Graphic4a.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -78,8 +78,9 @@
/** The physical file. */
private BufferedInputStream bis = null;
- /** Bits per pixel. */
- private int bitDepth = 0;
+ /** The number of bits per color component. For example, an RGB (3 component) image with 24 bits per pixel, has
+ * 8 bits per component. */
+ private int bitsPerComponent = 0;
/** Image data (uncompressed). */
private ByteArray content = null;
@@ -118,12 +119,6 @@
}
@Override
- public int getBitsPerComponent() throws GraphicException {
- this.loadImageWrapper();
- return this.bitDepth;
- }
-
- @Override
public ByteSequence getContent() throws GraphicException {
this.loadImageWrapper();
return this.content;
@@ -332,16 +327,13 @@
* Sets the bit depth for this graphic.
* @param bitDepth The new bit depth.
*/
- public void setBitDepth(final int bitDepth) {
- this.bitDepth = bitDepth;
+ public void setBitsPerComponent(final int bitDepth) {
+ this.bitsPerComponent = bitDepth;
}
- /**
- * Returns the bit depth for this graphic.
- * @return The bit depth for this graphic.
- */
- public int getBitDepth() {
- return this.bitDepth;
+ @Override
+ public int getBitsPerComponent() {
+ return this.bitsPerComponent;
}
/**
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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/JpegGraphic.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -165,7 +165,7 @@
final ByteArrayOutputStream iccStream = new ByteArrayOutputStream();
final int index = 0;
- setBitDepth(PrimitiveConstants.BITS_PER_BYTE);
+ setBitsPerComponent(PrimitiveConstants.BITS_PER_BYTE);
if (this.rawContent.length() > (index + 2) &&
this.rawContent.byteAt(index) == Jpeg.MARK &&
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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/PngGraphic.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -151,7 +151,7 @@
this.getInputStream());
}
- this.setBitDepth(PngGraphic.DEFAULT_BIT_DEPTH);
+ this.setBitsPerComponent(PngGraphic.DEFAULT_BIT_DEPTH);
this.cr = decodeImage(this.seekableInput);
this.pixelHeight = this.cr.getHeight();
this.pixelWidth = this.cr.getWidth();
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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -259,7 +259,7 @@
fld = dir.getField(TIFFImageDecoder.TIFF_BITS_PER_SAMPLE);
if (fld != null) {
final int bitDepth = fld.getAsInt(0);
- this.setBitDepth(bitDepth);
+ this.setBitsPerComponent(bitDepth);
}
fld = dir.getField(TIFFImageDecoder.TIFF_ROWS_PER_STRIP);
if (fld == null) {
@@ -280,7 +280,7 @@
this.stripLength = dir.getField(
TIFFImageDecoder.TIFF_STRIP_BYTE_COUNTS).getAsLong(0);
- if (this.getBitDepth() == 1) {
+ if (this.getBitsPerComponent() == 1) {
this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
}
}
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-19 14:52:52 UTC (rev 13704)
+++ trunk/foray/foray-graphic/src/test/java/org/foray/graphic/BmpGraphicTests.java 2025-05-19 15:23:52 UTC (rev 13705)
@@ -65,7 +65,7 @@
final BmpGraphic bmp = (BmpGraphic) graphic;
assertEquals(70, bmp.getPixelWidth());
assertEquals(62, bmp.getPixelHeight());
- assertEquals(24, bmp.getBitDepth());
+ assertEquals(8, bmp.getBitsPerComponent());
assertEquals(24, bmp.getBitsPerPixel());
assertEquals(8, bmp.getBitsPerComponent());
assertTrue(bmp.getColorSpace().getType() == ColorSpace.TYPE_RGB);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-19 14:52:55
|
Revision: 13704
http://sourceforge.net/p/foray/code/13704
Author: victormote
Date: 2025-05-19 14:52:52 +0000 (Mon, 19 May 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed "throws" clause.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java
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-19 14:36:06 UTC (rev 13703)
+++ trunk/foray/foray-graphic/src/main/java/org/foray/graphic/TiffGraphic.java 2025-05-19 14:52:52 UTC (rev 13704)
@@ -198,8 +198,7 @@
}
@Override
- public Graphic.Compression getCompressionType() throws GraphicException {
- this.loadImageWrapper();
+ public Graphic.Compression getCompressionType() {
switch (this.compression) {
case TiffGraphic.COMPRESSION_CCITT_GROUP_4:
return Graphic.Compression.CCITT_GROUP_4;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|