foray-commit Mailing List for FOray (Page 276)
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...> - 2006-03-20 02:31:15
|
Revision: 6985 Author: victormote Date: 2006-03-19 18:31:09 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6985&view=rev Log Message: ----------- Conform to new axsl requirements regarding registration of font-description items. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-20 02:25:17 UTC (rev 6984) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-20 02:31:09 UTC (rev 6985) @@ -717,4 +717,19 @@ return (object != null); } + /** + * {@inheritDoc} + */ + public void registerFontDescription(String fontFamily, String fontID, + Encoding encoding, byte style, short weight, byte variant, + byte stretch, float simulatedSmallCaps, float simulatedOblique, + float simulatedBackslant, float[] simulatedStretch) + throws FontException { + RegisteredFontFamily rff = this.getRegisteredFontFamily(fontFamily); + RegisteredFont rf = this.getRegisteredFont(fontID); + rff.registerFontDesc(rf, encoding, style, weight, variant, stretch, + simulatedSmallCaps, simulatedOblique, simulatedBackslant, + simulatedStretch); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-20 02:25:21
|
Revision: 6984 Author: victormote Date: 2006-03-19 18:25:17 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6984&view=rev Log Message: ----------- Add overloaded method for normalized input. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java 2006-03-20 02:24:44 UTC (rev 6983) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java 2006-03-20 02:25:17 UTC (rev 6984) @@ -93,21 +93,43 @@ if (fontStretch < 0) { fontStretch = org.axsl.font.Font.FONT_STRETCH_NORMAL; } - RegisteredFontDesc description = new RegisteredFontDesc(registeredFont, - this, encoding, fontStyle, fontWeight, fontVariant, - fontStretch); - float percent = convertPercent(simulatedSmallCaps); - description.setSimulateSmallCaps(percent); - percent = convertPercent(simulatedOblique); - description.setSimulateOblique(percent); - percent = convertPercent(simulatedBackslant); - description.setSimulateBackslant(percent); + float simSmallCaps = convertPercent(simulatedSmallCaps); + float simOblique = convertPercent(simulatedOblique); + float simBackslant = convertPercent(simulatedBackslant); + float[] simStretch = new float[8]; + for (int i = 0; i < simStretch.length; i++) { + simStretch[i] = Float.NaN; + } if (simulatedStretch != null) { - for (int i = 0; i < simulatedStretch.length; i++) { - percent = convertPercent(simulatedStretch[i]); - description.setSimulateStretch(i, percent); + for (int i = 0; i < simStretch.length; i++) { + if (i < simulatedStretch.length) { + simStretch[i] = convertPercent(simulatedStretch[i]); + } } } + registerFontDesc(registeredFont, encoding, fontStyle, fontWeight, + fontVariant, fontStretch, simSmallCaps, simOblique, + simBackslant, simStretch); + } + + /** + * Maps a font-description to a RegisteredFont for this font-family. + * @param style The style (normal, italic, etc.). + * @param weight The weight (normal, bold, 100, etc.). + * @param registeredFont the RegisteredFont that should be supplied when + * a font matching this description is requested. + */ + protected void registerFontDesc(RegisteredFont registeredFont, + Encoding encoding, byte style, short weight, byte variant, + byte stretch, float simulatedSmallCaps, float simulatedOblique, + float simulatedBackslant, float[] simulatedStretch) + throws FontException { + RegisteredFontDesc description = new RegisteredFontDesc(registeredFont, + this, encoding, style, weight, variant, stretch); + description.setSimulateSmallCaps(simulatedSmallCaps); + description.setSimulateOblique(simulatedOblique); + description.setSimulateBackslant(simulatedBackslant); + description.setSimulateStretch(simulatedStretch); for (int i = 0; i < fontDescriptions.size(); i++) { RegisteredFontDesc registeredDesc = (RegisteredFontDesc) fontDescriptions.get(i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-20 02:24:48
|
Revision: 6983 Author: victormote Date: 2006-03-19 18:24:44 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6983&view=rev Log Message: ----------- Add method allowing an en masse replacement of the simulated stretch values. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java 2006-03-20 02:01:26 UTC (rev 6982) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java 2006-03-20 02:24:44 UTC (rev 6983) @@ -173,6 +173,14 @@ this.simulateStretch[index] = value; } + public void setSimulateStretch(float[] newStretchArray) { + if (newStretchArray == null + || newStretchArray.length != this.simulateStretch.length) { + return; + } + this.simulateStretch = newStretchArray; + } + public void setSimulateUltraCondensed(float value) { this.simulateStretch[0] = value; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-20 02:01:33
|
Revision: 6982 Author: victormote Date: 2006-03-19 18:01:26 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6982&view=rev Log Message: ----------- Use axsl Encoding instances. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java trunk/foray/foray-font/src/java/org/foray/font/FOrayFontConsumer.java trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java 2006-03-20 01:50:17 UTC (rev 6981) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayConsumerFont.java 2006-03-20 02:01:26 UTC (rev 6982) @@ -24,12 +24,13 @@ package org.foray.font; -import org.foray.ps.encode.Encoding; import org.foray.ps.encode.EncodingStandard; import org.foray.ps.encode.EncodingSymbol; import org.foray.ps.encode.EncodingVector; import org.foray.ps.encode.EncodingZapfDingbats; +import org.axsl.ps.Encoding; + import org.apache.commons.logging.Log; import java.util.ArrayList; @@ -164,7 +165,7 @@ return rfd.getEncoding(); } case FOrayFontConsumer.ENCODING_INTERNAL_ONLY: { - return (Encoding) this.font.getInternalEncoding(); + return this.font.getInternalEncoding(); } case FOrayFontConsumer.ENCODING_ANY: { return getBestEncoding(codePoint); @@ -175,7 +176,7 @@ private Encoding getBestEncoding(int codePoint) { Encoding trialEncoding = null; - Encoding internalEncoding = (Encoding) this.font.getInternalEncoding(); + Encoding internalEncoding = this.font.getInternalEncoding(); if (! (internalEncoding instanceof EncodingVector)) { /* CMap encodings should be able to handle any character in the * font's character set. */ Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFontConsumer.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontConsumer.java 2006-03-20 01:50:17 UTC (rev 6981) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontConsumer.java 2006-03-20 02:01:26 UTC (rev 6982) @@ -230,7 +230,6 @@ } FOrayConsumerFont consumerFont = registerFontUse(fontSelected); return consumerFont.getFontUse(fontDescSelected, - (org.foray.ps.encode.Encoding) fontSelected.getInternalEncoding()); } Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java 2006-03-20 01:50:17 UTC (rev 6981) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontDesc.java 2006-03-20 02:01:26 UTC (rev 6982) @@ -24,7 +24,7 @@ package org.foray.font; -import org.foray.ps.encode.Encoding; +import org.axsl.ps.Encoding; /** * <p>RegisteredFontDesc encapsulates the set of characteristics about how a Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java 2006-03-20 01:50:17 UTC (rev 6981) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFontFamily.java 2006-03-20 02:01:26 UTC (rev 6982) @@ -24,10 +24,9 @@ package org.foray.font; -import org.foray.ps.encode.Encoding; - import org.axsl.font.FontException; import org.axsl.font.FontUtility; +import org.axsl.ps.Encoding; import java.util.ArrayList; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-20 01:50:26
|
Revision: 6981 Author: victormote Date: 2006-03-19 17:50:17 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6981&view=rev Log Message: ----------- Allow any axsl Encoding. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java 2006-03-19 23:56:43 UTC (rev 6980) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java 2006-03-20 01:50:17 UTC (rev 6981) @@ -24,12 +24,11 @@ package org.foray.font; -import org.foray.ps.encode.Encoding; - import org.axsl.font.FontConsumer; import org.axsl.font.FontException; import org.axsl.font.output.FontOutput; import org.axsl.font.output.FontOutputFactory; +import org.axsl.ps.Encoding; import org.apache.commons.logging.Log; @@ -103,7 +102,7 @@ /** * {@inheritDoc} */ - public org.axsl.ps.Encoding getEncoding() { + public Encoding getEncoding() { return this.encoding; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-19 23:56:53
|
Revision: 6980 Author: victormote Date: 2006-03-19 15:56:43 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6980&view=rev Log Message: ----------- Conform to axsl changes enhancing external font registration. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-19 19:18:39 UTC (rev 6979) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-19 23:56:43 UTC (rev 6980) @@ -116,6 +116,12 @@ private HashMap fontOutputFactories = new HashMap(); /** + * Map whose key is a String containing a font ID, and whose value is the + * RegisteredFont for that font ID. + */ + private HashMap registeredFonts = new HashMap(); + + /** * Constructor. * @param logger The Logger to be used for system-level messages. Please * note that the FontConsumer also has a method for obtaining a Logger @@ -176,9 +182,9 @@ return this.defaultSystemFont; } /* Punt and try to create something that will work. */ - RegisteredFont rf = new RegisteredFont(this, null, null, null, null, - null, "serif"); try { + RegisteredFont rf = new RegisteredFont(this, null, null, null, null, + null, "serif"); RegisteredFontFamily rff = this.registerFontFamily2("serif"); rff.registerFontDesc(rf, null, "normal", "normal", "normal", "normal", null, null, null, null); @@ -323,8 +329,14 @@ continue; } } - RegisteredFont rf = new RegisteredFont(this, awtFont.getFontName(), - null, null, null, "none", awtFont.getFontName()); + RegisteredFont rf; + try { + rf = new RegisteredFont(this, awtFont.getFontName(), + null, null, null, "none", awtFont.getFontName()); + } catch (FontException e) { + this.logger.error(e.getMessage()); + continue; + } byte fontStyle = org.axsl.font.Font.FONT_STYLE_NORMAL; if (awtFont.isItalic()) { fontStyle = org.axsl.font.Font.FONT_STYLE_ITALIC; @@ -658,4 +670,51 @@ return registeredAlias.getFontFamily(null).getName(); } + /** + * {@inheritDoc} + */ + public void registerFont(String fontID, URL fontFileURL, + URL metricsFileURL, String collectionID, String embed, + String systemName) throws FontException { + if (! usingFreeStandingFonts) { + /* If not using FreeStandingFonts, then this font should not be + * registered unless it will be able to generate a SystemFont. */ + if (systemName == null || systemName.equals("")) { + return; + } + } + if (! usingSystemFonts) { + /* If not using SystemFonts, then this font should not be + * registered unless it will be able to generate a FreeStandingFont. + */ + if (fontFileURL == null + && metricsFileURL == null) { + return; + } + } + new RegisteredFont(this, fontID, fontFileURL, metricsFileURL, + collectionID, embed, systemName); + } + + public RegisteredFont getRegisteredFont(String name) { + return (RegisteredFont) this.registeredFonts.get(name); + } + + public void registerFont(String fontID, RegisteredFont rf) + throws FontException { + Object object = this.registeredFonts.get(fontID); + if (object != null) { + throw new FontException("Font ID alread registered: " + fontID); + } + this.registeredFonts.put(fontID, rf); + } + + /** + * {@inheritDoc} + */ + public boolean isRegisteredFont(String fontID) { + Object object = this.registeredFonts.get(fontID); + return (object != null); + } + } Modified: trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java 2006-03-19 19:18:39 UTC (rev 6979) +++ trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java 2006-03-19 23:56:43 UTC (rev 6980) @@ -93,10 +93,6 @@ * axsl-font-config element. */ private String parsedRootEmbed; - /** Map whose key is the "id" attribute of the "font" element, and whose - * value is the RegisteredFont object that was created for that id. */ - private HashMap fontIDMap = new HashMap(); - /** * inputsource for configuration file */ @@ -391,8 +387,8 @@ } String simulateOblique = attributes.getValue("simulate-oblique"); String simulateBackslant = attributes.getValue("simulate-backslant"); - RegisteredFont registeredFont - = (RegisteredFont) this.fontIDMap.get(fontID); + RegisteredFont registeredFont = this.fontServer.getRegisteredFont( + fontID); String encodingName = attributes.getValue("encoding"); if (encodingName == null) { /* Inherit the value from font-family. */ @@ -455,28 +451,12 @@ fontServer.setFatalConfigurationError(true); } - if (! fontServer.usingFreeStandingFonts) { - /* If not using FreeStandingFonts, then this font should not be - * registered unless it will be able to generate a SystemFont. */ - if (systemName == null || systemName.equals("")) { - return; - } + try { + fontServer.registerFont(fontID, fontFileURL, metricsFileURL, + collectionID, embed, systemName); + } catch (FontException e) { + this.logError(e.getMessage()); } - - if (! fontServer.usingSystemFonts) { - /* If not using SystemFonts, then this font should not be - * registered unless it will be able to generate a FreeStandingFont. - */ - if (fontFileURL == null - && metricsFileURL == null) { - return; - } - } - - RegisteredFont currentRegisteredFont = new RegisteredFont(fontServer, - fontID, fontFileURL, collectionID, metricsFileURL, - embed, systemName); - this.fontIDMap.put(fontID, currentRegisteredFont); } /** Modified: trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2006-03-19 19:18:39 UTC (rev 6979) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2006-03-19 23:56:43 UTC (rev 6980) @@ -140,9 +140,8 @@ * @param fontEmbedPath URL to the physical font file. */ public RegisteredFont(FOrayFontServer server, String fontName, - URL fontEmbedPath, - String ttcName, URL metricsFileURL, String embedding, - String systemName) { + URL fontEmbedPath, URL metricsFileURL, String ttcName, + String embedding, String systemName) throws FontException { this.fontServer = server; this.configuredFontName = fontName; this.fontFile = fontEmbedPath; @@ -162,6 +161,7 @@ this.subsetting = false; } this.systemName = systemName; + server.registerFont(fontName, this); } private void createFreeStandingFont() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-19 19:18:45
|
Revision: 6979 Author: victormote Date: 2006-03-19 11:18:39 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6979&view=rev Log Message: ----------- Conform to axsl changes enhancing external font registration. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-15 18:32:02 UTC (rev 6978) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-19 19:18:39 UTC (rev 6979) @@ -179,7 +179,7 @@ RegisteredFont rf = new RegisteredFont(this, null, null, null, null, null, "serif"); try { - RegisteredFontFamily rff = this.registerFontFamily("serif"); + RegisteredFontFamily rff = this.registerFontFamily2("serif"); rff.registerFontDesc(rf, null, "normal", "normal", "normal", "normal", null, null, null, null); } catch (FontException e) { @@ -403,7 +403,7 @@ * Add a RegisteredFontFamily to the Collection. * @param name the name of the font family (e.g. "Courier") */ - protected RegisteredFontFamily registerFontFamily(String name) + protected RegisteredFontFamily registerFontFamily2(String name) throws FontException { /* Make sure it is not already registered. */ RegisteredFontFamily rff = this.getRegisteredFontFamily(name); @@ -423,13 +423,12 @@ * should be associated (e.g. "Helvetica"). */ protected void registerFontFamilyAlias(String alias, String configuration, - String realFamily) { + String realFamily) throws FontException { RegisteredFontFamily rff = (RegisteredFontFamily)fontFamilies.get(realFamily); if (rff == null) { - getLogger().info("Font family " + realFamily + throw new FontException("Font family " + realFamily + " not found. Can't register alias: " + alias); - return; } /* Get or create the RegisteredAlias instance. */ RegisteredAlias registeredAlias = (RegisteredAlias) @@ -624,4 +623,39 @@ return factory != null; } + /** + * {@inheritDoc} + */ + public void registerFontFamily(String name) throws FontException { + registerFontFamily2(name); + } + + /** + * {@inheritDoc} + */ + public boolean isRegisteredFontFamily(String name) { + RegisteredFontFamily rff = this.getRegisteredFontFamily(name); + return (rff != null); + } + + /** + * {@inheritDoc} + */ + public void registerFontFamilyAlias(String alias, String realFamily) + throws FontException { + registerFontFamilyAlias(alias, null, realFamily); + } + + /** + * {@inheritDoc} + */ + public String getFontFamilyForAlias(String alias) { + RegisteredAlias registeredAlias = (RegisteredAlias) + this.fontFamilyAliases.get(alias); + if (registeredAlias == null) { + return null; + } + return registeredAlias.getFontFamily(null).getName(); + } + } Modified: trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java 2006-03-15 18:32:02 UTC (rev 6978) +++ trunk/foray/foray-font/src/java/org/foray/font/FontConfigParser.java 2006-03-19 19:18:39 UTC (rev 6979) @@ -248,7 +248,11 @@ || family.equals("")) { logError("font-family-alias entry invalid. " + "Ignored."); } else { - fontServer.registerFontFamilyAlias(alias, "default", family); + try { + fontServer.registerFontFamilyAlias(alias, "default", family); + } catch (FontException e) { + logError(e.getMessage()); + } this.currentFontFamilyAlias = alias; } } @@ -265,8 +269,12 @@ || family.equals("")) { logError("alias-configuration entry invalid. " + "Ignored."); } else { - fontServer.registerFontFamilyAlias(this.currentFontFamilyAlias, - name, family); + try { + fontServer.registerFontFamilyAlias(this.currentFontFamilyAlias, + name, family); + } catch (FontException e) { + logError(e.getMessage()); + } } } @@ -334,7 +342,7 @@ } try { this.currentFontFamily - = fontServer.registerFontFamily(name); + = fontServer.registerFontFamily2(name); } catch (FontException e) { /* Log a warning. */ logWarning(e.getMessage()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 18:32:09
|
Revision: 6978 Author: victormote Date: 2006-03-15 10:32:02 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6978&view=rev Log Message: ----------- Remove all Renderer package dependencies on FOrayPDF. Modified Paths: -------------- trunk/foray/foray-render/.classpath trunk/foray/foray-render/scripts/build.xml Modified: trunk/foray/foray-render/.classpath =================================================================== --- trunk/foray/foray-render/.classpath 2006-03-15 18:27:06 UTC (rev 6977) +++ trunk/foray/foray-render/.classpath 2006-03-15 18:32:02 UTC (rev 6978) @@ -4,7 +4,6 @@ <classpathentry kind="src" path="scripts"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="/FOrayCommon"/> - <classpathentry kind="src" path="/FOrayPS"/> <classpathentry kind="src" path="/axslFont"/> <classpathentry kind="src" path="/axslGraphic"/> <classpathentry kind="src" path="/axslAreaOut"/> @@ -15,6 +14,6 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/batik.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/axslPDF"/> - <classpathentry combineaccessrules="false" kind="src" path="/FOrayPDF"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-render/scripts/build.xml =================================================================== --- trunk/foray/foray-render/scripts/build.xml 2006-03-15 18:27:06 UTC (rev 6977) +++ trunk/foray/foray-render/scripts/build.xml 2006-03-15 18:32:02 UTC (rev 6978) @@ -44,9 +44,6 @@ <fileset dir="${foray.home}/foray-ps/build/ant"> <include name="*.jar"/> </fileset> - <fileset dir="${foray.home}/foray-pdf/build/ant"> - <include name="*.jar"/> - </fileset> <fileset dir="${foray.home}/foray-output/build/ant"> <include name="*.jar"/> </fileset> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 18:27:22
|
Revision: 6977 Author: victormote Date: 2006-03-15 10:27:06 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6977&view=rev Log Message: ----------- Move SVGUtilities class from PDF package to Renderer package. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java Added Paths: ----------- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java Removed Paths: ------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/SVGUtilities.java Deleted: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/SVGUtilities.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/SVGUtilities.java 2006-03-15 18:19:29 UTC (rev 6976) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/SVGUtilities.java 2006-03-15 18:27:06 UTC (rev 6977) @@ -1,214 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.pdf.svg.batik; - -import org.apache.batik.dom.svg.SVGDOMImplementation; - -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Text; - -import java.awt.Font; -import java.awt.font.FontRenderContext; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.util.StringTokenizer; - -/** - * Some utilities for creating svg DOM documents and elements. - */ -public class SVGUtilities { - static final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; - - - public static final Document createSVGDocument(float width, - float height) { - DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); - Document doc = impl.createDocument(svgNS, "svg", null); - - Element svgRoot = doc.getDocumentElement(); - svgRoot.setAttributeNS(null, "width", "" + width); - svgRoot.setAttributeNS(null, "height", "" + height); - return doc; - } - - /** - * Get the string width for a particular string given the font. - */ - public static final float getStringWidth(String str, Font font) { - Rectangle2D rect = - font.getStringBounds(str, 0, str.length(), - new FontRenderContext(new AffineTransform(), - true, true)); - return (float)rect.getWidth(); - } - - /** - * Get the string height for a particular string given the font. - */ - public static final float getStringHeight(String str, Font font) { - Rectangle2D rect = - font.getStringBounds(str, 0, str.length(), - new FontRenderContext(new AffineTransform(), - true, true)); - return (float)rect.getHeight(); - } - - /** - * Get the string bounds for a particular string given the font. - */ - public static final Rectangle2D getStringBounds(String str, Font font) { - return font.getStringBounds(str, 0, str.length(), - new FontRenderContext(new AffineTransform(), - true, true)); - } - - /** - * Create an SVG Line - */ - public static final Element createLine(Document doc, float x, float y, - float x2, float y2) { - Element ellipse = doc.createElementNS(svgNS, "line"); - ellipse.setAttributeNS(null, "x1", "" + x); - ellipse.setAttributeNS(null, "x2", "" + x2); - ellipse.setAttributeNS(null, "y1", "" + y); - ellipse.setAttributeNS(null, "y2", "" + y2); - return ellipse; - } - - /** - * Create an SVG Ellipse - */ - public static final Element createEllipse(Document doc, float cx, - float cy, float rx, float ry) { - Element ellipse = doc.createElementNS(svgNS, "ellipse"); - ellipse.setAttributeNS(null, "cx", "" + cx); - ellipse.setAttributeNS(null, "rx", "" + rx); - ellipse.setAttributeNS(null, "cy", "" + cy); - ellipse.setAttributeNS(null, "ry", "" + ry); - return ellipse; - } - - /** - * Create an SVG Path. - */ - public static final Element createPath(Document doc, String str) { - Element path = doc.createElementNS(svgNS, "path"); - path.setAttributeNS(null, "d", str); - return path; - } - - /** - * Create an SVG Text object. - */ - public static final Element createText(Document doc, float x, float y, - String str) { - Element textGraph = doc.createElementNS(svgNS, "text"); - textGraph.setAttributeNS(null, "x", "" + x); - textGraph.setAttributeNS(null, "y", "" + y); - Text text = doc.createTextNode(str); - textGraph.appendChild(text); - return textGraph; - } - - /** - * Create an SVG Rectangle. - */ - public static final Element createRect(Document doc, float x, float y, - float width, float height) { - Element border = doc.createElementNS(svgNS, "rect"); - border.setAttributeNS(null, "x", "" + x); - border.setAttributeNS(null, "y", "" + y); - border.setAttributeNS(null, "width", "" + width); - border.setAttributeNS(null, "height", "" + height); - return border; - } - - /** - * Create an SVG G. - */ - public static final Element createG(Document doc) { - Element border = doc.createElementNS(svgNS, "g"); - return border; - } - - /** - * Create an SVG Clip. - */ - public static final Element createClip(Document doc, Element els, - String id) { - Element border = doc.createElementNS(svgNS, "clipPath"); - border.setAttributeNS(null, "id", id); - border.appendChild(els); - return border; - } - - public static final Element createImage(Document doc, String ref, - float width, float height) { - Element border = doc.createElementNS(svgNS, "image"); - border.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", - ref); - border.setAttributeNS(null, "width", "" + width); - border.setAttributeNS(null, "height", "" + height); - return border; - } - - /** - * Create some SVG text that is wrapped into a specified width.. - */ - public static final Element wrapText(Document doc, String str, Font font, - float width) { - Element g = createG(doc); - Element text; - StringTokenizer st = new StringTokenizer(str, " \t\r\n"); - float totalWidth = 0; - String totalStr = ""; - int line = 0; - float height = getStringHeight(str, font); - while (st.hasMoreTokens()) { - String token = st.nextToken(); - float strwidth = getStringWidth(token, font); - totalWidth += strwidth; - if (totalWidth > width) { - if (totalStr.equals("")) { - totalStr = token; - token = ""; - strwidth = 0; - } - text = createText(doc, 0, line * (height + 5), totalStr); - g.appendChild(text); - totalStr = token; - totalWidth = strwidth; - line++; - } else { - totalStr = totalStr + " " + token; - } - } - - return g; - } - -} Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-03-15 18:19:29 UTC (rev 6976) +++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-03-15 18:27:06 UTC (rev 6977) @@ -25,7 +25,6 @@ package org.foray.render.svg; import org.foray.output.OutputConfig; -import org.foray.pdf.svg.batik.SVGUtilities; import org.foray.render.Renderer; import org.axsl.areaOut.Area; Copied: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java (from rev 6864, trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/SVGUtilities.java) =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java (rev 0) +++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGUtilities.java 2006-03-15 18:27:06 UTC (rev 6977) @@ -0,0 +1,214 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.render.svg; + +import org.apache.batik.dom.svg.SVGDOMImplementation; + +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Text; + +import java.awt.Font; +import java.awt.font.FontRenderContext; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.util.StringTokenizer; + +/** + * Some utilities for creating svg DOM documents and elements. + */ +public class SVGUtilities { + static final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; + + + public static final Document createSVGDocument(float width, + float height) { + DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); + Document doc = impl.createDocument(svgNS, "svg", null); + + Element svgRoot = doc.getDocumentElement(); + svgRoot.setAttributeNS(null, "width", "" + width); + svgRoot.setAttributeNS(null, "height", "" + height); + return doc; + } + + /** + * Get the string width for a particular string given the font. + */ + public static final float getStringWidth(String str, Font font) { + Rectangle2D rect = + font.getStringBounds(str, 0, str.length(), + new FontRenderContext(new AffineTransform(), + true, true)); + return (float)rect.getWidth(); + } + + /** + * Get the string height for a particular string given the font. + */ + public static final float getStringHeight(String str, Font font) { + Rectangle2D rect = + font.getStringBounds(str, 0, str.length(), + new FontRenderContext(new AffineTransform(), + true, true)); + return (float)rect.getHeight(); + } + + /** + * Get the string bounds for a particular string given the font. + */ + public static final Rectangle2D getStringBounds(String str, Font font) { + return font.getStringBounds(str, 0, str.length(), + new FontRenderContext(new AffineTransform(), + true, true)); + } + + /** + * Create an SVG Line + */ + public static final Element createLine(Document doc, float x, float y, + float x2, float y2) { + Element ellipse = doc.createElementNS(svgNS, "line"); + ellipse.setAttributeNS(null, "x1", "" + x); + ellipse.setAttributeNS(null, "x2", "" + x2); + ellipse.setAttributeNS(null, "y1", "" + y); + ellipse.setAttributeNS(null, "y2", "" + y2); + return ellipse; + } + + /** + * Create an SVG Ellipse + */ + public static final Element createEllipse(Document doc, float cx, + float cy, float rx, float ry) { + Element ellipse = doc.createElementNS(svgNS, "ellipse"); + ellipse.setAttributeNS(null, "cx", "" + cx); + ellipse.setAttributeNS(null, "rx", "" + rx); + ellipse.setAttributeNS(null, "cy", "" + cy); + ellipse.setAttributeNS(null, "ry", "" + ry); + return ellipse; + } + + /** + * Create an SVG Path. + */ + public static final Element createPath(Document doc, String str) { + Element path = doc.createElementNS(svgNS, "path"); + path.setAttributeNS(null, "d", str); + return path; + } + + /** + * Create an SVG Text object. + */ + public static final Element createText(Document doc, float x, float y, + String str) { + Element textGraph = doc.createElementNS(svgNS, "text"); + textGraph.setAttributeNS(null, "x", "" + x); + textGraph.setAttributeNS(null, "y", "" + y); + Text text = doc.createTextNode(str); + textGraph.appendChild(text); + return textGraph; + } + + /** + * Create an SVG Rectangle. + */ + public static final Element createRect(Document doc, float x, float y, + float width, float height) { + Element border = doc.createElementNS(svgNS, "rect"); + border.setAttributeNS(null, "x", "" + x); + border.setAttributeNS(null, "y", "" + y); + border.setAttributeNS(null, "width", "" + width); + border.setAttributeNS(null, "height", "" + height); + return border; + } + + /** + * Create an SVG G. + */ + public static final Element createG(Document doc) { + Element border = doc.createElementNS(svgNS, "g"); + return border; + } + + /** + * Create an SVG Clip. + */ + public static final Element createClip(Document doc, Element els, + String id) { + Element border = doc.createElementNS(svgNS, "clipPath"); + border.setAttributeNS(null, "id", id); + border.appendChild(els); + return border; + } + + public static final Element createImage(Document doc, String ref, + float width, float height) { + Element border = doc.createElementNS(svgNS, "image"); + border.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", + ref); + border.setAttributeNS(null, "width", "" + width); + border.setAttributeNS(null, "height", "" + height); + return border; + } + + /** + * Create some SVG text that is wrapped into a specified width.. + */ + public static final Element wrapText(Document doc, String str, Font font, + float width) { + Element g = createG(doc); + Element text; + StringTokenizer st = new StringTokenizer(str, " \t\r\n"); + float totalWidth = 0; + String totalStr = ""; + int line = 0; + float height = getStringHeight(str, font); + while (st.hasMoreTokens()) { + String token = st.nextToken(); + float strwidth = getStringWidth(token, font); + totalWidth += strwidth; + if (totalWidth > width) { + if (totalStr.equals("")) { + totalStr = token; + token = ""; + strwidth = 0; + } + text = createText(doc, 0, line * (height + 5), totalStr); + g.appendChild(text); + totalStr = token; + totalWidth = strwidth; + line++; + } else { + totalStr = totalStr + " " + token; + } + } + + return g; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 18:19:38
|
Revision: 6976 Author: victormote Date: 2006-03-15 10:19:29 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6976&view=rev Log Message: ----------- Remove another dependency on FOrayPDF. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 18:13:34 UTC (rev 6975) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 18:19:29 UTC (rev 6976) @@ -24,7 +24,7 @@ package org.foray.render.ps; -import org.foray.pdf.object.PDFColor; +import org.foray.ps.PSColor; import org.foray.ps.PSReal; import org.foray.render.TempImage; @@ -105,11 +105,6 @@ */ protected int currentXPosition = 0; - /** - * the current colour for use in svg - */ - PDFColor currentColour = new PDFColor(new Color(0, 0, 0)); - FontServer fontInfo; /** @@ -322,7 +317,6 @@ public void dispose() { psRenderer = null; currentFontName = null; - currentColour = null; fontInfo = null; } @@ -666,12 +660,8 @@ psRenderer.write("BT"); Shape imclip = getClip(); writeClip(imclip); - Color c = getColor(); - currentColour = new PDFColor(c); - psRenderer.write(currentColour.getColorSpaceOut(true)); - c = getBackground(); - PDFColor col = new PDFColor(c); - psRenderer.write(col.getColorSpaceOut(false)); + psRenderer.write(PSColor.toPS(getColor(), true, "\n")); + psRenderer.write(PSColor.toPS(getBackground(), true, "\n")); AffineTransform trans = getTransform(); trans.translate(x, y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 18:13:44
|
Revision: 6975 Author: victormote Date: 2006-03-15 10:13:34 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6975&view=rev Log Message: ----------- More PDFColor cleanup. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 18:01:22 UTC (rev 6974) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 18:13:34 UTC (rev 6975) @@ -33,33 +33,23 @@ protected Color color; - public static PDFColor PDF_RGB_BLACK = new PDFColor(Color.BLACK); - public PDFColor(Color theColor) { this.color = theColor; this.colorSpace = this.color.getColorSpace(); } - public double red() { - return this.color.getRed(); - } - - public double green() { - return (this.color.getGreen()); - } - - public double blue() { - return (this.color.getBlue()); - } - public String getColorSpaceOut(boolean fillNotStroke) { return PSColor.toPS(this.color, fillNotStroke, "\n"); } String toPDF() { - String string = new String("[" + this.red() + " " + this.green() + " " - + this.blue() + "]"); - return string; + StringBuffer buffer = new StringBuffer(); + buffer.append("["); + buffer.append(this.color.getRed() + " "); + buffer.append(this.color.getGreen() + " "); + buffer.append(this.color.getBlue()); + buffer.append("]"); + return buffer.toString(); } public boolean equals(Object obj) { @@ -88,9 +78,9 @@ } public boolean isBlack() { - if (red() == 0 - && green() == 0 - && blue() == 0) { + if (this.color.getRed() == 0 + && this.color.getGreen() == 0 + && this.color.getBlue() == 0) { return true; } return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 18:01:39
|
Revision: 6974 Author: victormote Date: 2006-03-15 10:01:22 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6974&view=rev Log Message: ----------- Remove no-longer-useful convenience constructors. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java Modified: trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java 2006-03-15 17:47:52 UTC (rev 6973) +++ trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java 2006-03-15 18:01:22 UTC (rev 6974) @@ -24,6 +24,7 @@ package org.foray.common; +import java.awt.Color; import java.awt.color.ColorSpace; public class ColorSpaceCMYK extends ColorSpace { @@ -106,4 +107,10 @@ return THE_INSTANCE; } + public static Color makeColor(float cyan, float magenta, float yellow, + float black) { + float[] cmykArray = new float[] {cyan, magenta, yellow, black}; + return new Color(ColorSpaceCMYK.theInstance(), cmykArray, 0); + } + } Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 17:47:52 UTC (rev 6973) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 18:01:22 UTC (rev 6974) @@ -24,7 +24,6 @@ package org.foray.pdf.object; -import org.foray.common.ColorSpaceCMYK; import org.foray.ps.PSColor; import java.awt.Color; @@ -41,20 +40,6 @@ this.colorSpace = this.color.getColorSpace(); } - // components from 0 to 255 - public PDFColor(int theRed, int theGreen, int theBlue) { - this.color = new Color(theRed, theGreen, theBlue); - this.colorSpace = this.color.getColorSpace(); - } - - public PDFColor(float theCyan, float theMagenta, float theYellow, - float theBlack) { - float[] cmykArray = new float[] {theCyan, theMagenta, theYellow, - theBlack}; - this.color = new Color(ColorSpaceCMYK.theInstance(), cmykArray, 0); - this.colorSpace = this.color.getColorSpace(); - } - public double red() { return this.color.getRed(); } Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-03-15 17:47:52 UTC (rev 6973) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-03-15 18:01:22 UTC (rev 6974) @@ -135,8 +135,7 @@ * Rather than leaving it as the default white. */ public void setBackgroundColor(Color col) { - Color c = col; - currentColour = new PDFColor(c.getRed(), c.getGreen(), c.getBlue()); + currentColour = new PDFColor(col); currentStream.write("q\n"); currentStream.write(currentColour.getColorSpaceOut(true)); Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-03-15 17:47:52 UTC (rev 6973) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-03-15 18:01:22 UTC (rev 6974) @@ -24,6 +24,7 @@ package org.foray.pdf.svg.batik; +import org.foray.common.ColorSpaceCMYK; import org.foray.pdf.object.PDFAnnotList; import org.foray.pdf.object.PDFColor; import org.foray.pdf.object.PDFDocument; @@ -131,7 +132,7 @@ /** * the current colour for use in svg */ - PDFColor currentColour = new PDFColor(0, 0, 0); + PDFColor currentColour = new PDFColor(new Color(0, 0, 0)); private PDFXObject xObject; @@ -580,8 +581,7 @@ Color c = col; if (c.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_RGB) { - currentColour = new PDFColor(c.getRed(), c.getGreen(), - c.getBlue()); + currentColour = new PDFColor(c); currentStream.write(currentColour.getColorSpaceOut(fill)); } else if (c.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_CMYK) { @@ -591,7 +591,9 @@ // convert the float elements to doubles for pdf cmyk[i] = cComps[i]; } - currentColour = new PDFColor(cmyk[0], cmyk[1], cmyk[2], cmyk[3]); + Color cmykColor = ColorSpaceCMYK.makeColor(cmyk[0], cmyk[1], + cmyk[2], cmyk[3]); + currentColour = new PDFColor(cmykColor); currentStream.write(currentColour.getColorSpaceOut(fill)); } else if (c.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_2CLR) { @@ -643,11 +645,9 @@ List someColors = new ArrayList(); - PDFColor color1 = new PDFColor(c1.getRed(), c1.getGreen(), - c1.getBlue()); + PDFColor color1 = new PDFColor(c1); someColors.add(color1); - PDFColor color2 = new PDFColor(c2.getRed(), c2.getGreen(), - c2.getBlue()); + PDFColor color2 = new PDFColor(c2); someColors.add(color2); ColorSpace aColorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 17:47:52 UTC (rev 6973) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 18:01:22 UTC (rev 6974) @@ -108,7 +108,7 @@ /** * the current colour for use in svg */ - PDFColor currentColour = new PDFColor(0, 0, 0); + PDFColor currentColour = new PDFColor(new Color(0, 0, 0)); FontServer fontInfo; @@ -667,10 +667,10 @@ Shape imclip = getClip(); writeClip(imclip); Color c = getColor(); - currentColour = new PDFColor(c.getRed(), c.getGreen(), c.getBlue()); + currentColour = new PDFColor(c); psRenderer.write(currentColour.getColorSpaceOut(true)); c = getBackground(); - PDFColor col = new PDFColor(c.getRed(), c.getGreen(), c.getBlue()); + PDFColor col = new PDFColor(c); psRenderer.write(col.getColorSpaceOut(false)); AffineTransform trans = getTransform(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 17:47:59
|
Revision: 6973 Author: victormote Date: 2006-03-15 09:47:52 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6973&view=rev Log Message: ----------- Clean up PDFColor a bit by moving specialized method to PDFPattern. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 17:30:54 UTC (rev 6972) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 17:47:52 UTC (rev 6973) @@ -29,7 +29,6 @@ import java.awt.Color; import java.awt.color.ColorSpace; -import java.util.ArrayList; public class PDFColor extends PDFPathPaint implements org.axsl.pdf.PDFColor { @@ -56,32 +55,6 @@ this.colorSpace = this.color.getColorSpace(); } - /** - * @return A vector representation of the color in the appropriate - * colorspace. - */ - public ArrayList getVector() { - ArrayList theColorVector = new ArrayList(); - // RGB - if (this.colorSpace.getType() == ColorSpace.TYPE_RGB) { - theColorVector.add(new Double(this.red())); - theColorVector.add(new Double(this.green())); - theColorVector.add(new Double(this.blue())); - // CMYK - } else if (this.colorSpace.getType() == ColorSpace.TYPE_CMYK) { - float[] cmykArray = this.color.getColorComponents(null); - theColorVector.add(new Double(cmykArray[0])); - theColorVector.add(new Double(cmykArray[1])); - theColorVector.add(new Double(cmykArray[2])); - theColorVector.add(new Double(cmykArray[3])); - // GRAY - } else { - float[] grayArray = this.color.getColorComponents(null); - theColorVector.add(new Double(grayArray[0])); - } - return (theColorVector); - } - public double red() { return this.color.getRed(); } Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2006-03-15 17:30:54 UTC (rev 6972) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2006-03-15 17:47:52 UTC (rev 6973) @@ -26,6 +26,7 @@ import org.foray.ps.PSReal; +import java.awt.Color; import java.awt.color.ColorSpace; import java.util.ArrayList; import java.util.List; @@ -236,8 +237,8 @@ nextColor.setColorSpace(theColorSpace); } - theCzero = currentColor.getVector(); - theCone = nextColor.getVector(); + theCzero = colorToDoubleList(currentColor.getColor()); + theCone = colorToDoubleList(nextColor.getColor()); myfunc = new PDFFunction(document, 2, null, null, theCzero, theCone, interpolation); @@ -276,7 +277,19 @@ null, null); return (myPattern); } - + + static ArrayList colorToDoubleList(Color theColor) { + ArrayList theColorVector = new ArrayList(); + if (theColor == null) { + return theColorVector; + } + float[] colorComponents = theColor.getColorComponents(null); + for (int i = 0; i < colorComponents.length; i++) { + theColorVector.add(new Double(colorComponents[i])); + } + return theColorVector; + } + /** * represent as PDF. Whatever the FunctionType is, the correct * representation spits out. The sets of required and optional This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 17:30:59
|
Revision: 6972 Author: victormote Date: 2006-03-15 09:30:54 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6972&view=rev Log Message: ----------- Remove more cruft from PDFColor. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 17:17:45 UTC (rev 6971) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 17:30:54 UTC (rev 6972) @@ -35,29 +35,17 @@ protected Color color; - protected float red = -1.0f; - protected float green = -1.0f; - protected float blue = -1.0f; - - protected float cyan = -1.0f; - protected float magenta = -1.0f; - protected float yellow = -1.0f; - protected float black = -1.0f; - public static PDFColor PDF_RGB_BLACK = new PDFColor(Color.BLACK); public PDFColor(Color theColor) { this.color = theColor; - this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); - // super(theNumber) - this.red = theColor.getRed() / 255f; - this.green = theColor.getGreen() / 255f; - this.blue = theColor.getBlue() / 255f; + this.colorSpace = this.color.getColorSpace(); } // components from 0 to 255 public PDFColor(int theRed, int theGreen, int theBlue) { this.color = new Color(theRed, theGreen, theBlue); + this.colorSpace = this.color.getColorSpace(); } public PDFColor(float theCyan, float theMagenta, float theYellow, @@ -65,6 +53,7 @@ float[] cmykArray = new float[] {theCyan, theMagenta, theYellow, theBlack}; this.color = new Color(ColorSpaceCMYK.theInstance(), cmykArray, 0); + this.colorSpace = this.color.getColorSpace(); } /** @@ -75,62 +64,36 @@ ArrayList theColorVector = new ArrayList(); // RGB if (this.colorSpace.getType() == ColorSpace.TYPE_RGB) { - theColorVector.add(new Double(this.red)); - theColorVector.add(new Double(this.green)); - theColorVector.add(new Double(this.blue)); + theColorVector.add(new Double(this.red())); + theColorVector.add(new Double(this.green())); + theColorVector.add(new Double(this.blue())); // CMYK } else if (this.colorSpace.getType() == ColorSpace.TYPE_CMYK) { - theColorVector.add(new Double(this.cyan)); - theColorVector.add(new Double(this.magenta)); - theColorVector.add(new Double(this.yellow)); - theColorVector.add(new Double(this.black)); + float[] cmykArray = this.color.getColorComponents(null); + theColorVector.add(new Double(cmykArray[0])); + theColorVector.add(new Double(cmykArray[1])); + theColorVector.add(new Double(cmykArray[2])); + theColorVector.add(new Double(cmykArray[3])); // GRAY } else { - theColorVector.add(new Double(this.black)); + float[] grayArray = this.color.getColorComponents(null); + theColorVector.add(new Double(grayArray[0])); } return (theColorVector); } public double red() { - return (this.red); + return this.color.getRed(); } public double green() { - return (this.green); + return (this.color.getGreen()); } public double blue() { - return (this.blue); + return (this.color.getBlue()); } - public int red255() { - return (int)(this.red * 255d); - } - - public int green255() { - return (int)(this.green * 255d); - } - - public int blue255() { - return (int)(this.blue * 255d); - } - - public double cyan() { - return (this.cyan); - } - - public double magenta() { - return (this.magenta); - } - - public double yellow() { - return (this.yellow); - } - - public double black() { - return (this.black); - } - public String getColorSpaceOut(boolean fillNotStroke) { return PSColor.toPS(this.color, fillNotStroke, "\n"); } @@ -145,13 +108,8 @@ if (!(obj instanceof PDFColor)) { return false; } - PDFColor color = (PDFColor)obj; - - if (color.red == this.red && color.green == this.green - && color.blue == this.blue) { - return true; - } - return false; + PDFColor otherColor = (PDFColor) obj; + return this.getColor().equals(otherColor.getColor()); } public static String getColorSpacePDFString(ColorSpace colorSpace) { @@ -180,4 +138,8 @@ return false; } + public Color getColor() { + return this.color; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 17:18:01
|
Revision: 6971 Author: victormote Date: 2006-03-15 09:17:45 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6971&view=rev Log Message: ----------- Add back the rgb-to-cmyk and cmyk-to-rbg conversions recently removed from PDFColor into the new ColorSpaceCMYK class. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java Modified: trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java 2006-03-15 16:44:05 UTC (rev 6970) +++ trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java 2006-03-15 17:17:45 UTC (rev 6971) @@ -29,27 +29,71 @@ public class ColorSpaceCMYK extends ColorSpace { static final long serialVersionUID = 34959014422981446L; + protected static final float BLACK_FACTOR = 2.0f; // could be 3.0 as well. + private static ColorSpaceCMYK THE_INSTANCE; public ColorSpaceCMYK() { super(ColorSpace.TYPE_CMYK, 4); } + /** + * {@inheritDoc} + */ public float[] toRGB(float[] colorvalue) { - /* TODO: Implement this. */ - return null; + if (colorvalue == null) { + return null; + } + if (colorvalue.length < this.getNumComponents()) { + throw new ArrayIndexOutOfBoundsException(); + } + float cyan = colorvalue[0]; + float magenta = colorvalue[1]; + float yellow = colorvalue[2]; + float black = colorvalue[3]; + + float red = 1.0f - cyan + (black / BLACK_FACTOR); + float green = 1.0f - magenta + (black / BLACK_FACTOR); + float blue = 1.0f - yellow + (black / BLACK_FACTOR); + return new float[] {red, green, blue}; } + /** + * {@inheritDoc} + */ public float[] fromRGB(float[] rgbvalue) { - /* TODO: Implement this. */ - return null; + if (rgbvalue == null) { + return null; + } + if (rgbvalue.length < 3) { + throw new ArrayIndexOutOfBoundsException(); + } + float red = rgbvalue[0]; + float green = rgbvalue[1]; + float blue = rgbvalue[2]; + + float cyan = 1.0f - red; + float magenta = 1.0f - green; + float yellow = 1.0f - blue; + + /* Pick the lowest color. */ + float temp = Math.min(red, Math.min(green, blue)); + float black = temp / BLACK_FACTOR; + + return new float[] {cyan, magenta, yellow, black}; } + /** + * {@inheritDoc} + */ public float[] toCIEXYZ(float[] colorvalue) { /* TODO: Implement this. */ return null; } + /** + * {@inheritDoc} + */ public float[] fromCIEXYZ(float[] colorvalue) { /* TODO: Implement this. */ return null; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 16:44:05 UTC (rev 6970) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 17:17:45 UTC (rev 6971) @@ -35,7 +35,6 @@ protected Color color; - protected static float blackFactor = 2.0f; // could be 3.0 as well. protected float red = -1.0f; protected float green = -1.0f; protected float blue = -1.0f; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 16:44:18
|
Revision: 6970 Author: victormote Date: 2006-03-15 08:44:05 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6970&view=rev Log Message: ----------- Move the color-to-string conversion work over to the PS module where it can be reused. Also, build it around java.awt.Color instead of PDFColor. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java Added Paths: ----------- trunk/foray/foray-ps/src/java/org/foray/ps/PSColor.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 16:37:15 UTC (rev 6969) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 16:44:05 UTC (rev 6970) @@ -25,7 +25,7 @@ package org.foray.pdf.object; import org.foray.common.ColorSpaceCMYK; -import org.foray.ps.PSReal; +import org.foray.ps.PSColor; import java.awt.Color; import java.awt.color.ColorSpace; @@ -48,6 +48,7 @@ public static PDFColor PDF_RGB_BLACK = new PDFColor(Color.BLACK); public PDFColor(Color theColor) { + this.color = theColor; this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); // super(theNumber) this.red = theColor.getRed() / 255f; @@ -132,64 +133,7 @@ } public String getColorSpaceOut(boolean fillNotStroke) { - StringBuffer p = new StringBuffer(""); - - // colorspace is RGB - if (this.colorSpace.getType() == ColorSpace.TYPE_RGB) { - // according to pdfspec 12.1 p.399 - // if the colors are the same then just use the g or G operator - boolean same = false; - if (this.red == this.green && this.red == this.blue) { - same = true; - } - // output RGB - // fill - if (fillNotStroke) { - if (same) { - p.append(PSReal.doubleOut(this.red) + " g" + EOL); - } else { - p.append(PSReal.doubleOut(this.red) + " " - + PSReal.doubleOut(this.green) + " " - + PSReal.doubleOut(this.blue) - + " rg" + EOL); - } - // stroke/border - } else { - if (same) { - p.append(PSReal.doubleOut(this.red) + " G" + EOL); - } else { - p.append(PSReal.doubleOut(this.red) + " " - + PSReal.doubleOut(this.green) + " " - + PSReal.doubleOut(this.blue) - + " RG" + EOL); - } - } - } // end of output RGB - else if (this.colorSpace.getType() == ColorSpace.TYPE_CMYK) { - // colorspace is CMYK - if (fillNotStroke) { // fill - p.append(PSReal.doubleOut(this.cyan) + " " - + PSReal.doubleOut(this.magenta) + " " - + PSReal.doubleOut(this.yellow) + " " - + PSReal.doubleOut(this.black) + " k" + EOL); - } else { // fill - p.append(PSReal.doubleOut(this.cyan) + " " - + PSReal.doubleOut(this.magenta) + " " - + PSReal.doubleOut(this.yellow) + " " - + PSReal.doubleOut(this.black) + " K" + EOL); - } - - } // end of if CMYK - // means we're in DeviceGray or Unknown. - // assume we're in DeviceGray, because otherwise we're screwed. - else { - if (fillNotStroke) { - p.append(PSReal.doubleOut(this.black) + " g" + EOL); - } else { - p.append(PSReal.doubleOut(this.black) + " G" + EOL); - } - } - return (p.toString()); + return PSColor.toPS(this.color, fillNotStroke, "\n"); } String toPDF() { Added: trunk/foray/foray-ps/src/java/org/foray/ps/PSColor.java =================================================================== --- trunk/foray/foray-ps/src/java/org/foray/ps/PSColor.java (rev 0) +++ trunk/foray/foray-ps/src/java/org/foray/ps/PSColor.java 2006-03-15 16:44:05 UTC (rev 6970) @@ -0,0 +1,107 @@ +/* + * Copyright 2006 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.ps; + +import java.awt.Color; +import java.awt.color.ColorSpace; + +public class PSColor { + + /** + * Private constructor. This currently has only static methods. + */ + private PSColor() { + } + + /** + * Convert a Color to PostScript. + * @param fillNotStroke + * @return The PostScript code that represents this color. + */ + public static String toPS(Color color, boolean fillNotStroke, String eol) { + StringBuffer p = new StringBuffer(""); + + // colorspace is RGB + if (color.getColorSpace().getType() == ColorSpace.TYPE_RGB) { + // according to pdfspec 12.1 p.399 + // if the colors are the same then just use the g or G operator + boolean same = false; + if (color.getRed() == color.getGreen() + && color.getRed() == color.getBlue()) { + same = true; + } + // output RGB + // fill + if (fillNotStroke) { + if (same) { + p.append(PSReal.doubleOut(color.getRed()) + " g" + eol); + } else { + p.append(PSReal.doubleOut(color.getRed()) + " " + + PSReal.doubleOut(color.getGreen()) + " " + + PSReal.doubleOut(color.getBlue()) + + " rg" + eol); + } + // stroke/border + } else { + if (same) { + p.append(PSReal.doubleOut(color.getRed()) + " G" + eol); + } else { + p.append(PSReal.doubleOut(color.getRed()) + " " + + PSReal.doubleOut(color.getGreen()) + " " + + PSReal.doubleOut(color.getBlue()) + + " RG" + eol); + } + } + } /* end of RGB */ + else if (color.getColorSpace().getType() == ColorSpace.TYPE_CMYK) { + // colorspace is CMYK + float[] cmykColors = color.getComponents(null); + if (fillNotStroke) { // fill + p.append(PSReal.doubleOut(cmykColors[0]) + " " + + PSReal.doubleOut(cmykColors[1]) + " " + + PSReal.doubleOut(cmykColors[2]) + " " + + PSReal.doubleOut(cmykColors[3]) + " k" + eol); + } else { // fill + p.append(PSReal.doubleOut(cmykColors[0]) + " " + + PSReal.doubleOut(cmykColors[1]) + " " + + PSReal.doubleOut(cmykColors[2]) + " " + + PSReal.doubleOut(cmykColors[3]) + " K" + eol); + } + + } /* end of CMYK */ + // means we're in DeviceGray or Unknown. + // assume we're in DeviceGray, because otherwise we're screwed. + else if (color.getColorSpace().getType() == ColorSpace.CS_GRAY) { + float[] grayColors = color.getComponents(null); + if (fillNotStroke) { + p.append(PSReal.doubleOut(grayColors[0]) + " g" + eol); + } else { + p.append(PSReal.doubleOut(grayColors[0]) + " G" + eol); + } + } + return (p.toString()); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 16:37:38
|
Revision: 6969 Author: victormote Date: 2006-03-15 08:37:15 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6969&view=rev Log Message: ----------- Add and use a basic and incomplete cmyk ColorSpace subclass. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java Added Paths: ----------- trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java Added: trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java (rev 0) +++ trunk/foray/foray-common/src/java/org/foray/common/ColorSpaceCMYK.java 2006-03-15 16:37:15 UTC (rev 6969) @@ -0,0 +1,65 @@ +/* + * Copyright 2006 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.common; + +import java.awt.color.ColorSpace; + +public class ColorSpaceCMYK extends ColorSpace { + static final long serialVersionUID = 34959014422981446L; + + private static ColorSpaceCMYK THE_INSTANCE; + + public ColorSpaceCMYK() { + super(ColorSpace.TYPE_CMYK, 4); + } + + public float[] toRGB(float[] colorvalue) { + /* TODO: Implement this. */ + return null; + } + + public float[] fromRGB(float[] rgbvalue) { + /* TODO: Implement this. */ + return null; + } + + public float[] toCIEXYZ(float[] colorvalue) { + /* TODO: Implement this. */ + return null; + } + + public float[] fromCIEXYZ(float[] colorvalue) { + /* TODO: Implement this. */ + return null; + } + + public static ColorSpaceCMYK theInstance() { + if (THE_INSTANCE == null) { + THE_INSTANCE = new ColorSpaceCMYK(); + } + return THE_INSTANCE; + } + +} Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 15:57:14 UTC (rev 6968) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 16:37:15 UTC (rev 6969) @@ -24,12 +24,17 @@ package org.foray.pdf.object; +import org.foray.common.ColorSpaceCMYK; import org.foray.ps.PSReal; -import java.awt.color.ColorSpace; + import java.awt.Color; +import java.awt.color.ColorSpace; import java.util.ArrayList; public class PDFColor extends PDFPathPaint implements org.axsl.pdf.PDFColor { + + protected Color color; + protected static float blackFactor = 2.0f; // could be 3.0 as well. protected float red = -1.0f; protected float green = -1.0f; @@ -50,28 +55,16 @@ this.blue = theColor.getBlue() / 255f; } - public PDFColor(float theRed, float theGreen, float theBlue) { - // super(theNumber); - this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); - - this.red = theRed; - this.green = theGreen; - this.blue = theBlue; - } - // components from 0 to 255 public PDFColor(int theRed, int theGreen, int theBlue) { - this(theRed / 255f, theGreen / 255f, theBlue / 255f); + this.color = new Color(theRed, theGreen, theBlue); } public PDFColor(float theCyan, float theMagenta, float theYellow, float theBlack) { - // There does not seem to be a standard way to define a CMYK ColorSpace - this.colorSpace = null; - this.cyan = theCyan; - this.magenta = theMagenta; - this.yellow = theYellow; - this.black = theBlack; + float[] cmykArray = new float[] {theCyan, theMagenta, theYellow, + theBlack}; + this.color = new Color(ColorSpaceCMYK.theInstance(), cmykArray, 0); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 15:57:20
|
Revision: 6968 Author: victormote Date: 2006-03-15 07:57:14 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6968&view=rev Log Message: ----------- Remove unused code that can be replaced with methods from java.awt.ColorSpace. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 15:15:34 UTC (rev 6967) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 15:57:14 UTC (rev 6968) @@ -138,48 +138,6 @@ return (this.black); } - public void setColorSpace(int theColorSpace) { - int theOldColorSpace = this.colorSpace.getType(); - if (theOldColorSpace != theColorSpace) { - if (theOldColorSpace == ColorSpace.TYPE_RGB) { - if (theColorSpace == ColorSpace.TYPE_CMYK) { - this.convertRGBtoCMYK(); - } else // convert to Gray? - { - this.convertRGBtoGRAY(); - } - - } else if (theOldColorSpace == ColorSpace.TYPE_CMYK) { - if (theColorSpace == ColorSpace.TYPE_RGB) { - this.convertCMYKtoRGB(); - } else // convert to Gray? - { - this.convertCMYKtoGRAY(); - } - } else // used to be Gray - { - if (theColorSpace == ColorSpace.TYPE_RGB) { - this.convertGRAYtoRGB(); - } else // convert to CMYK? - { - this.convertGRAYtoCMYK(); - } - } - switch (theColorSpace) { - case ColorSpace.TYPE_CMYK: { - this.colorSpace = null; - return; - } - case ColorSpace.TYPE_RGB: { - this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); - } - case ColorSpace.TYPE_GRAY: { - this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); - } - } - } - } - public String getColorSpaceOut(boolean fillNotStroke) { StringBuffer p = new StringBuffer(""); @@ -241,89 +199,6 @@ return (p.toString()); } - protected void convertCMYKtoRGB() { - // convert CMYK to RGB - this.red = 1.0f - this.cyan; - this.green = 1.0f - this.green; - this.blue = 1.0f - this.yellow; - - this.red = (this.black / blackFactor) + this.red; - this.green = (this.black / blackFactor) + this.green; - this.blue = (this.black / blackFactor) + this.blue; - - } - - protected void convertRGBtoCMYK() { - // convert RGB to CMYK - this.cyan = 1.0f - this.red; - this.magenta = 1.0f - this.green; - this.yellow = 1.0f - this.blue; - - this.black = 0.0f; - /* - * If you want to calculate black, uncomment this - * //pick the lowest color - * tempDouble = this.red; - * - * if (this.green < tempDouble) - * tempDouble = this.green; - * - * if (this.blue < tempDouble) - * tempDouble = this.blue; - * - * this.black = tempDouble / this.blackFactor; - */ - } - - protected void convertGRAYtoRGB() { - this.red = 1.0f - this.black; - this.green = 1.0f - this.black; - this.blue = 1.0f - this.black; - } - - protected void convertGRAYtoCMYK() { - this.cyan = this.black; - this.magenta = this.black; - this.yellow = this.black; - // this.black=0.0;//? - } - - protected void convertCMYKtoGRAY() { - float temp = 0.0f; - - // pick the lowest color - temp = this.cyan; - - if (this.magenta < temp) { - temp = this.magenta; - } - - if (this.yellow < temp) { - temp = this.yellow; - } - - this.black = (temp / blackFactor); - - } - - protected void convertRGBtoGRAY() { - float temp = 0.0f; - - // pick the lowest color - temp = this.red; - - if (this.green < temp) { - temp = this.green; - } - - if (this.blue < temp) { - temp = this.blue; - } - - this.black = 1.0f - (temp / blackFactor); - - } - String toPDF() { String string = new String("[" + this.red() + " " + this.green() + " " + this.blue() + "]"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 15:15:41
|
Revision: 6967 Author: victormote Date: 2006-03-15 07:15:34 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6967&view=rev Log Message: ----------- Use floats instead of doubles in PDFColor. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 14:25:20 UTC (rev 6966) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 15:15:34 UTC (rev 6967) @@ -30,15 +30,15 @@ import java.util.ArrayList; public class PDFColor extends PDFPathPaint implements org.axsl.pdf.PDFColor { - protected static double blackFactor = 2.0; // could be 3.0 as well. - protected double red = -1.0; - protected double green = -1.0; - protected double blue = -1.0; + protected static float blackFactor = 2.0f; // could be 3.0 as well. + protected float red = -1.0f; + protected float green = -1.0f; + protected float blue = -1.0f; - protected double cyan = -1.0; - protected double magenta = -1.0; - protected double yellow = -1.0; - protected double black = -1.0; + protected float cyan = -1.0f; + protected float magenta = -1.0f; + protected float yellow = -1.0f; + protected float black = -1.0f; public static PDFColor PDF_RGB_BLACK = new PDFColor(Color.BLACK); @@ -50,7 +50,7 @@ this.blue = theColor.getBlue() / 255f; } - public PDFColor(double theRed, double theGreen, double theBlue) { + public PDFColor(float theRed, float theGreen, float theBlue) { // super(theNumber); this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); @@ -61,11 +61,11 @@ // components from 0 to 255 public PDFColor(int theRed, int theGreen, int theBlue) { - this(theRed / 255d, theGreen / 255d, theBlue / 255d); + this(theRed / 255f, theGreen / 255f, theBlue / 255f); } - public PDFColor(double theCyan, double theMagenta, double theYellow, - double theBlack) { + public PDFColor(float theCyan, float theMagenta, float theYellow, + float theBlack) { // There does not seem to be a standard way to define a CMYK ColorSpace this.colorSpace = null; this.cyan = theCyan; @@ -243,9 +243,9 @@ protected void convertCMYKtoRGB() { // convert CMYK to RGB - this.red = 1.0 - this.cyan; - this.green = 1.0 - this.green; - this.blue = 1.0 - this.yellow; + this.red = 1.0f - this.cyan; + this.green = 1.0f - this.green; + this.blue = 1.0f - this.yellow; this.red = (this.black / blackFactor) + this.red; this.green = (this.black / blackFactor) + this.green; @@ -255,11 +255,11 @@ protected void convertRGBtoCMYK() { // convert RGB to CMYK - this.cyan = 1.0 - this.red; - this.magenta = 1.0 - this.green; - this.yellow = 1.0 - this.blue; + this.cyan = 1.0f - this.red; + this.magenta = 1.0f - this.green; + this.yellow = 1.0f - this.blue; - this.black = 0.0; + this.black = 0.0f; /* * If you want to calculate black, uncomment this * //pick the lowest color @@ -276,9 +276,9 @@ } protected void convertGRAYtoRGB() { - this.red = 1.0 - this.black; - this.green = 1.0 - this.black; - this.blue = 1.0 - this.black; + this.red = 1.0f - this.black; + this.green = 1.0f - this.black; + this.blue = 1.0f - this.black; } protected void convertGRAYtoCMYK() { @@ -289,38 +289,38 @@ } protected void convertCMYKtoGRAY() { - double tempDouble = 0.0; + float temp = 0.0f; // pick the lowest color - tempDouble = this.cyan; + temp = this.cyan; - if (this.magenta < tempDouble) { - tempDouble = this.magenta; + if (this.magenta < temp) { + temp = this.magenta; } - if (this.yellow < tempDouble) { - tempDouble = this.yellow; + if (this.yellow < temp) { + temp = this.yellow; } - this.black = (tempDouble / blackFactor); + this.black = (temp / blackFactor); } protected void convertRGBtoGRAY() { - double tempDouble = 0.0; + float temp = 0.0f; // pick the lowest color - tempDouble = this.red; + temp = this.red; - if (this.green < tempDouble) { - tempDouble = this.green; + if (this.green < temp) { + temp = this.green; } - if (this.blue < tempDouble) { - tempDouble = this.blue; + if (this.blue < temp) { + temp = this.blue; } - this.black = 1.0 - (tempDouble / blackFactor); + this.black = 1.0f - (temp / blackFactor); } Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-03-15 14:25:20 UTC (rev 6966) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-03-15 15:15:34 UTC (rev 6967) @@ -586,7 +586,7 @@ } else if (c.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_CMYK) { float[] cComps = c.getColorComponents(new float[3]); - double[] cmyk = new double[3]; + float[] cmyk = new float[3]; for (int i = 0; i < 3; i++) { // convert the float elements to doubles for pdf cmyk[i] = cComps[i]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 14:25:25
|
Revision: 6966 Author: victormote Date: 2006-03-15 06:25:20 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6966&view=rev Log Message: ----------- Remove another dependency on FOrayPDF. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 14:18:58 UTC (rev 6965) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 14:25:20 UTC (rev 6966) @@ -473,12 +473,8 @@ ArrayList someColors = new ArrayList(); - PDFColor color1 = new PDFColor(c1.getRed(), c1.getGreen(), - c1.getBlue()); - someColors.add(color1); - PDFColor color2 = new PDFColor(c2.getRed(), c2.getGreen(), - c2.getBlue()); - someColors.add(color2); + someColors.add(c1); + someColors.add(c2); } else if (paint instanceof TexturePaint) {} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 14:19:20
|
Revision: 6965 Author: victormote Date: 2006-03-15 06:18:58 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6965&view=rev Log Message: ----------- 1. Move static methods from PDFNumber to PSReal. 2. Remove class PDFNumber. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFunction.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFShading.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java trunk/foray/foray-render/.classpath trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java Removed Paths: ------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumber.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -24,6 +24,7 @@ package org.foray.pdf.object; +import org.foray.ps.PSReal; import java.awt.color.ColorSpace; import java.awt.Color; import java.util.ArrayList; @@ -194,21 +195,21 @@ // fill if (fillNotStroke) { if (same) { - p.append(PDFNumber.doubleOut(this.red) + " g" + EOL); + p.append(PSReal.doubleOut(this.red) + " g" + EOL); } else { - p.append(PDFNumber.doubleOut(this.red) + " " - + PDFNumber.doubleOut(this.green) + " " - + PDFNumber.doubleOut(this.blue) + p.append(PSReal.doubleOut(this.red) + " " + + PSReal.doubleOut(this.green) + " " + + PSReal.doubleOut(this.blue) + " rg" + EOL); } // stroke/border } else { if (same) { - p.append(PDFNumber.doubleOut(this.red) + " G" + EOL); + p.append(PSReal.doubleOut(this.red) + " G" + EOL); } else { - p.append(PDFNumber.doubleOut(this.red) + " " - + PDFNumber.doubleOut(this.green) + " " - + PDFNumber.doubleOut(this.blue) + p.append(PSReal.doubleOut(this.red) + " " + + PSReal.doubleOut(this.green) + " " + + PSReal.doubleOut(this.blue) + " RG" + EOL); } } @@ -216,15 +217,15 @@ else if (this.colorSpace.getType() == ColorSpace.TYPE_CMYK) { // colorspace is CMYK if (fillNotStroke) { // fill - p.append(PDFNumber.doubleOut(this.cyan) + " " - + PDFNumber.doubleOut(this.magenta) + " " - + PDFNumber.doubleOut(this.yellow) + " " - + PDFNumber.doubleOut(this.black) + " k" + EOL); + p.append(PSReal.doubleOut(this.cyan) + " " + + PSReal.doubleOut(this.magenta) + " " + + PSReal.doubleOut(this.yellow) + " " + + PSReal.doubleOut(this.black) + " k" + EOL); } else { // fill - p.append(PDFNumber.doubleOut(this.cyan) + " " - + PDFNumber.doubleOut(this.magenta) + " " - + PDFNumber.doubleOut(this.yellow) + " " - + PDFNumber.doubleOut(this.black) + " K" + EOL); + p.append(PSReal.doubleOut(this.cyan) + " " + + PSReal.doubleOut(this.magenta) + " " + + PSReal.doubleOut(this.yellow) + " " + + PSReal.doubleOut(this.black) + " K" + EOL); } } // end of if CMYK @@ -232,9 +233,9 @@ // assume we're in DeviceGray, because otherwise we're screwed. else { if (fillNotStroke) { - p.append(PDFNumber.doubleOut(this.black) + " g" + EOL); + p.append(PSReal.doubleOut(this.black) + " g" + EOL); } else { - p.append(PDFNumber.doubleOut(this.black) + " G" + EOL); + p.append(PSReal.doubleOut(this.black) + " G" + EOL); } } return (p.toString()); Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFunction.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFunction.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFunction.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -24,6 +24,8 @@ package org.foray.pdf.object; +import org.foray.ps.PSReal; + import java.util.List; /** @@ -398,7 +400,7 @@ p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.domain.get(tempInt)) + " "); } @@ -412,7 +414,7 @@ p.append("/Size [ "); vectorSize = this.size.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.size.get(tempInt)) + p.append(PSReal.doubleOut((Double)this.size.get(tempInt)) + " "); } p.append("]" + EOL); @@ -422,7 +424,7 @@ p.append("/Encode [ "); vectorSize = this.encode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.encode.get(tempInt)) + " "); } p.append("]" + EOL); @@ -449,7 +451,7 @@ p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.range.get(tempInt)) + " "); } @@ -461,7 +463,7 @@ p.append("/Decode [ "); vectorSize = this.decode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.decode.get(tempInt)) + " "); } @@ -507,7 +509,7 @@ p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.domain.get(tempInt)) + " "); } @@ -522,7 +524,7 @@ p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.range.get(tempInt)) + " "); } @@ -536,7 +538,7 @@ p.append("/C0 [ "); vectorSize = this.cZero.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.cZero.get(tempInt)) + " "); } p.append("]" + EOL); @@ -547,7 +549,7 @@ p.append("/C1 [ "); vectorSize = this.cOne.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.cOne.get(tempInt)) + p.append(PSReal.doubleOut((Double)this.cOne.get(tempInt)) + " "); } p.append("]" + EOL); @@ -555,7 +557,7 @@ // N: The interpolation Exponent p.append("/N " - + PDFNumber.doubleOut(new Double + + PSReal.doubleOut(new Double (this.interpolationExponentN)) + EOL); @@ -569,7 +571,7 @@ p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.domain.get(tempInt)) + " "); } @@ -583,7 +585,7 @@ p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.range.get(tempInt)) + " "); } @@ -608,7 +610,7 @@ p.append("/Encode [ "); vectorSize = this.encode.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.encode.get(tempInt)) + " "); } @@ -630,7 +632,7 @@ vectorSize = this.bounds.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.bounds.get(tempInt)) + " "); } @@ -643,7 +645,7 @@ // [ 0.25 0.25 0.25 ] String functionsFraction - = PDFNumber.doubleOut(new Double(1.0 + = PSReal.doubleOut(new Double(1.0 / (numberOfFunctions))); for (tempInt = 0; tempInt + 1 < numberOfFunctions; @@ -668,7 +670,7 @@ p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.domain.get(tempInt)) + " "); } @@ -682,7 +684,7 @@ p.append("/Range [ "); vectorSize = this.range.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.range.get(tempInt)) + " "); } Deleted: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumber.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumber.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNumber.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -1,99 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.pdf.object; - -public class PDFNumber { - - /** Private constructor (should not be instantiated). */ - private PDFNumber() { - } - - public static String doubleOut(Double doubleDown) { - return doubleOut(doubleDown.doubleValue()); - } - - public static String doubleOut(double doubleDown) { - StringBuffer p = new StringBuffer(); - if (doubleDown < 0) { - doubleDown = -doubleDown; - p.append("-"); - } - double trouble = doubleDown % 1; - - if (trouble > 0.950) { - p.append((int)doubleDown + 1); - } else if (trouble < 0.050) { - p.append((int)doubleDown); - } else { - String doubleString = Double.toString(doubleDown); - int decimal = doubleString.indexOf("."); - if (decimal != -1) { - p.append(doubleString.substring(0, decimal)); - - if ((doubleString.length() - decimal) > 6) { - p.append(doubleString.substring(decimal, decimal + 6)); - } else { - p.append(doubleString.substring(decimal)); - } - } else { - p.append(doubleString); - } - } - return (p.toString()); - } - - public static String doubleOut(double doubleDown, int dec) { - - StringBuffer p = new StringBuffer(); - if (doubleDown < 0) { - doubleDown = -doubleDown; - p.append("-"); - } - double trouble = doubleDown % 1; - - if (trouble > (1.0 - (5.0 / (Math.pow(10.0, dec))))) { - p.append((int)doubleDown + 1); - } else if (trouble < (5.0 / (Math.pow(10.0, dec)))) { - p.append((int)doubleDown); - } else { - String doubleString = Double.toString(doubleDown); - int decimal = doubleString.indexOf("."); - if (decimal != -1) { - p.append(doubleString.substring(0, decimal)); - - if ((doubleString.length() - decimal) > dec) { - p.append(doubleString.substring(decimal, decimal + dec)); - } else { - p.append(doubleString.substring(decimal)); - } - } else { - p.append(doubleString); - } - } - return (p.toString()); - } - -} - Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -24,6 +24,8 @@ package org.foray.pdf.object; +import org.foray.ps.PSReal; + import java.awt.color.ColorSpace; import java.util.ArrayList; import java.util.List; @@ -306,22 +308,22 @@ vectorSize = this.bBox.size(); p.append("/BBox [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.bBox.get(tempInt))); p.append(" "); } p.append("]" + EOL); } - p.append("/XStep " + PDFNumber.doubleOut(new Double(this.xStep)) + p.append("/XStep " + PSReal.doubleOut(new Double(this.xStep)) + EOL); - p.append("/YStep " + PDFNumber.doubleOut(new Double(this.yStep)) + p.append("/YStep " + PSReal.doubleOut(new Double(this.yStep)) + EOL); if (this.matrix != null) { vectorSize = this.matrix.size(); p.append("/Matrix [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.matrix.get(tempInt))); p.append(" "); } @@ -367,7 +369,7 @@ vectorSize = this.matrix.size(); p.append("/Matrix [ "); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.matrix.get(tempInt))); p.append(" "); } Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFShading.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFShading.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFShading.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -24,6 +24,8 @@ package org.foray.pdf.object; +import org.foray.ps.PSReal; + import java.awt.color.ColorSpace; import java.util.List; @@ -342,7 +344,7 @@ p.append("/Background [ "); vectorSize = this.background.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.background.get(tempInt)) + " "); } p.append("]" + EOL); @@ -354,7 +356,7 @@ p.append("/BBox [ "); vectorSize = this.bBox.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut((Double)this.bBox.get(tempInt)) + p.append(PSReal.doubleOut((Double)this.bBox.get(tempInt)) + " "); } p.append("]" + EOL); @@ -370,7 +372,7 @@ p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.domain.get(tempInt)) + " "); } p.append("]" + EOL); @@ -382,7 +384,7 @@ p.append("/Matrix [ "); vectorSize = this.matrix.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.matrix.get(tempInt)) + " "); } p.append("]" + EOL); @@ -400,7 +402,7 @@ p.append("/Coords [ "); vectorSize = this.coords.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.coords.get(tempInt)) + " "); } p.append("]" + EOL); @@ -411,7 +413,7 @@ p.append("/Domain [ "); vectorSize = this.domain.size(); for (tempInt = 0; tempInt < vectorSize; tempInt++) { - p.append(PDFNumber.doubleOut + p.append(PSReal.doubleOut ((Double)this.domain.get(tempInt)) + " "); } p.append("]" + EOL); Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -27,9 +27,9 @@ import org.foray.pdf.object.PDFColor; import org.foray.pdf.object.PDFContentStream; import org.foray.pdf.object.PDFDocument; -import org.foray.pdf.object.PDFNumber; import org.foray.pdf.object.PDFPage; import org.foray.pdf.object.PDFResources; +import org.foray.ps.PSReal; import org.axsl.font.FontConsumer; import org.axsl.font.FontException; @@ -125,8 +125,8 @@ * The result is scaled so that the svg fits correctly inside the pdf document. */ public void setSVGDimension(float w, float h) { - currentStream.write("" + PDFNumber.doubleOut(width / w) + " 0 0 " - + PDFNumber.doubleOut(height / h) + " 0 0 cm\n"); + currentStream.write("" + PSReal.doubleOut(width / w) + " 0 0 " + + PSReal.doubleOut(height / h) + " 0 0 cm\n"); } /** Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -29,11 +29,11 @@ import org.foray.pdf.object.PDFDocument; import org.foray.pdf.object.PDFFont; import org.foray.pdf.object.PDFLink; -import org.foray.pdf.object.PDFNumber; import org.foray.pdf.object.PDFPage; import org.foray.pdf.object.PDFPattern; import org.foray.pdf.object.PDFString; import org.foray.pdf.object.PDFXObject; +import org.foray.ps.PSReal; import org.axsl.font.FontConsumer; import org.axsl.font.FontException; @@ -170,12 +170,12 @@ if (!at.isIdentity()) { double[] vals = new double[6]; at.getMatrix(vals); - currentStream.write(PDFNumber.doubleOut(vals[0], 8) + " " - + PDFNumber.doubleOut(vals[1], 8) + " " - + PDFNumber.doubleOut(vals[2], 8) + " " - + PDFNumber.doubleOut(vals[3], 8) + " " - + PDFNumber.doubleOut(vals[4], 8) + " " - + PDFNumber.doubleOut(vals[5], 8) + " cm\n"); + currentStream.write(PSReal.doubleOut(vals[0], 8) + " " + + PSReal.doubleOut(vals[1], 8) + " " + + PSReal.doubleOut(vals[2], 8) + " " + + PSReal.doubleOut(vals[3], 8) + " " + + PSReal.doubleOut(vals[4], 8) + " " + + PSReal.doubleOut(vals[5], 8) + " cm\n"); } } @@ -486,12 +486,12 @@ AffineTransform trans = getTransform(); double[] tranvals = new double[6]; trans.getMatrix(tranvals); - currentStream.write(PDFNumber.doubleOut(tranvals[0], 8) + " " - + PDFNumber.doubleOut(tranvals[1], 8) + " " - + PDFNumber.doubleOut(tranvals[2], 8) + " " - + PDFNumber.doubleOut(tranvals[3], 8) + " " - + PDFNumber.doubleOut(tranvals[4], 8) + " " - + PDFNumber.doubleOut(tranvals[5], 8) + " cm\n"); + currentStream.write(PSReal.doubleOut(tranvals[0], 8) + " " + + PSReal.doubleOut(tranvals[1], 8) + " " + + PSReal.doubleOut(tranvals[2], 8) + " " + + PSReal.doubleOut(tranvals[3], 8) + " " + + PSReal.doubleOut(tranvals[4], 8) + " " + + PSReal.doubleOut(tranvals[5], 8) + " cm\n"); PathIterator iter = s.getPathIterator(new AffineTransform()); while (!iter.isDone()) { @@ -499,26 +499,26 @@ int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " c\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " " + + PSReal.doubleOut(vals[4]) + " " + + PSReal.doubleOut(vals[5]) + " c\n"); break; case PathIterator.SEG_LINETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " l\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " l\n"); break; case PathIterator.SEG_MOVETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " m\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " m\n"); break; case PathIterator.SEG_QUADTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " y\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " y\n"); break; case PathIterator.SEG_CLOSE: currentStream.write("h\n"); @@ -542,26 +542,26 @@ int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " c\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " " + + PSReal.doubleOut(vals[4]) + " " + + PSReal.doubleOut(vals[5]) + " c\n"); break; case PathIterator.SEG_LINETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " l\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " l\n"); break; case PathIterator.SEG_MOVETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " m\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " m\n"); break; case PathIterator.SEG_QUADTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " y\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " y\n"); break; case PathIterator.SEG_CLOSE: currentStream.write("h\n"); @@ -706,10 +706,10 @@ break; } float lw = bs.getLineWidth(); - currentStream.write(PDFNumber.doubleOut(lw) + " w\n"); + currentStream.write(PSReal.doubleOut(lw) + " w\n"); float ml = bs.getMiterLimit(); - currentStream.write(PDFNumber.doubleOut(ml) + " M\n"); + currentStream.write(PSReal.doubleOut(ml) + " M\n"); } } @@ -829,12 +829,12 @@ double[] vals = new double[6]; trans.getMatrix(vals); - currentStream.write(PDFNumber.doubleOut(vals[0], 8) + " " - + PDFNumber.doubleOut(vals[1], 8) + " " - + PDFNumber.doubleOut(vals[2], 8) + " " - + PDFNumber.doubleOut(vals[3], 8) + " " - + PDFNumber.doubleOut(vals[4], 8) + " " - + PDFNumber.doubleOut(vals[5], 8) + " cm\n"); + currentStream.write(PSReal.doubleOut(vals[0], 8) + " " + + PSReal.doubleOut(vals[1], 8) + " " + + PSReal.doubleOut(vals[2], 8) + " " + + PSReal.doubleOut(vals[3], 8) + " " + + PSReal.doubleOut(vals[4], 8) + " " + + PSReal.doubleOut(vals[5], 8) + " cm\n"); currentStream.write("1 0 0 -1 0 0 Tm "); PDFFont pdfFont = new PDFFont(this.pdfDoc, font); @@ -935,12 +935,12 @@ } - currentStream.write(PDFNumber.doubleOut(vals[0], 8) + " " - + PDFNumber.doubleOut(vals[1], 8) + " " - + PDFNumber.doubleOut(vals[2], 8) + " " - + PDFNumber.doubleOut(vals[3], 8) + " " - + PDFNumber.doubleOut(vals[4], 8) + " " - + PDFNumber.doubleOut(vals[5], 8) + " Tm (" + ch + currentStream.write(PSReal.doubleOut(vals[0], 8) + " " + + PSReal.doubleOut(vals[1], 8) + " " + + PSReal.doubleOut(vals[2], 8) + " " + + PSReal.doubleOut(vals[3], 8) + " " + + PSReal.doubleOut(vals[4], 8) + " " + + PSReal.doubleOut(vals[5], 8) + " Tm (" + ch + ") Tj\n"); } @@ -986,26 +986,26 @@ int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " c\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " " + + PSReal.doubleOut(vals[4]) + " " + + PSReal.doubleOut(vals[5]) + " c\n"); break; case PathIterator.SEG_LINETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " l\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " l\n"); break; case PathIterator.SEG_MOVETO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " m\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " m\n"); break; case PathIterator.SEG_QUADTO: - currentStream.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " y\n"); + currentStream.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " y\n"); break; case PathIterator.SEG_CLOSE: currentStream.write("h\n"); Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java =================================================================== --- trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-ps/src/java/org/foray/ps/PSReal.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -147,4 +147,69 @@ return "Real: " + Double.toString(this.value); } + public static String doubleOut(Double doubleDown) { + return doubleOut(doubleDown.doubleValue()); + } + + public static String doubleOut(double doubleDown) { + StringBuffer p = new StringBuffer(); + if (doubleDown < 0) { + doubleDown = -doubleDown; + p.append("-"); + } + double trouble = doubleDown % 1; + + if (trouble > 0.950) { + p.append((int)doubleDown + 1); + } else if (trouble < 0.050) { + p.append((int)doubleDown); + } else { + String doubleString = Double.toString(doubleDown); + int decimal = doubleString.indexOf("."); + if (decimal != -1) { + p.append(doubleString.substring(0, decimal)); + + if ((doubleString.length() - decimal) > 6) { + p.append(doubleString.substring(decimal, decimal + 6)); + } else { + p.append(doubleString.substring(decimal)); + } + } else { + p.append(doubleString); + } + } + return (p.toString()); + } + + public static String doubleOut(double doubleDown, int dec) { + + StringBuffer p = new StringBuffer(); + if (doubleDown < 0) { + doubleDown = -doubleDown; + p.append("-"); + } + double trouble = doubleDown % 1; + + if (trouble > (1.0 - (5.0 / (Math.pow(10.0, dec))))) { + p.append((int)doubleDown + 1); + } else if (trouble < (5.0 / (Math.pow(10.0, dec)))) { + p.append((int)doubleDown); + } else { + String doubleString = Double.toString(doubleDown); + int decimal = doubleString.indexOf("."); + if (decimal != -1) { + p.append(doubleString.substring(0, decimal)); + + if ((doubleString.length() - decimal) > dec) { + p.append(doubleString.substring(decimal, decimal + dec)); + } else { + p.append(doubleString.substring(decimal)); + } + } else { + p.append(doubleString); + } + } + return (p.toString()); + } + } Modified: trunk/foray/foray-render/.classpath =================================================================== --- trunk/foray/foray-render/.classpath 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-render/.classpath 2006-03-15 14:18:58 UTC (rev 6965) @@ -4,7 +4,6 @@ <classpathentry kind="src" path="scripts"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="src" path="/FOrayCommon"/> - <classpathentry kind="src" path="/FOrayPDF"/> <classpathentry kind="src" path="/FOrayPS"/> <classpathentry kind="src" path="/axslFont"/> <classpathentry kind="src" path="/axslGraphic"/> @@ -16,5 +15,6 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/batik.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/axslPDF"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayPDF"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 13:59:32 UTC (rev 6964) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSGraphics2D.java 2006-03-15 14:18:58 UTC (rev 6965) @@ -24,16 +24,16 @@ package org.foray.render.ps; -import org.apache.batik.ext.awt.g2d.AbstractGraphics2D; -import org.apache.batik.ext.awt.g2d.GraphicContext; - import org.foray.pdf.object.PDFColor; -import org.foray.pdf.object.PDFNumber; +import org.foray.ps.PSReal; import org.foray.render.TempImage; import org.axsl.font.FontServer; import org.axsl.graphic.Graphic; +import org.apache.batik.ext.awt.g2d.AbstractGraphics2D; +import org.apache.batik.ext.awt.g2d.GraphicContext; + import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; @@ -359,22 +359,22 @@ int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + " " - + PDFNumber.doubleOut(1000 * vals[2]) + " " - + PDFNumber.doubleOut(1000 * vals[3]) + " " - + PDFNumber.doubleOut(1000 * vals[4]) + " " - + PDFNumber.doubleOut(1000 * vals[5]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " " + + PSReal.doubleOut(1000 * vals[2]) + " " + + PSReal.doubleOut(1000 * vals[3]) + " " + + PSReal.doubleOut(1000 * vals[4]) + " " + + PSReal.doubleOut(1000 * vals[5]) + " curveto"); break; case PathIterator.SEG_LINETO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " lineto"); break; case PathIterator.SEG_MOVETO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " M"); break; case PathIterator.SEG_QUADTO: @@ -403,22 +403,22 @@ int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + " " - + PDFNumber.doubleOut(1000 * vals[2]) + " " - + PDFNumber.doubleOut(1000 * vals[3]) + " " - + PDFNumber.doubleOut(1000 * vals[4]) + " " - + PDFNumber.doubleOut(1000 * vals[5]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " " + + PSReal.doubleOut(1000 * vals[2]) + " " + + PSReal.doubleOut(1000 * vals[3]) + " " + + PSReal.doubleOut(1000 * vals[4]) + " " + + PSReal.doubleOut(1000 * vals[5]) + " curveto"); break; case PathIterator.SEG_LINETO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " lineto"); break; case PathIterator.SEG_MOVETO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " M"); break; case PathIterator.SEG_QUADTO: @@ -526,11 +526,11 @@ break; } float lw = bs.getLineWidth(); - psRenderer.write(PDFNumber.doubleOut(1000 * lw) + psRenderer.write(PSReal.doubleOut(1000 * lw) + " setlinewidth"); float ml = bs.getMiterLimit(); - psRenderer.write(PDFNumber.doubleOut(1000 * ml) + psRenderer.write(PSReal.doubleOut(1000 * ml) + " setmiterlimit"); } } @@ -630,13 +630,13 @@ double[] vals = new double[6]; trans.getMatrix(vals); - psRenderer.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " " - + PDFNumber.doubleOut(vals[6]) + " Tm [" + s + "]"); + psRenderer.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " " + + PSReal.doubleOut(vals[4]) + " " + + PSReal.doubleOut(vals[5]) + " " + + PSReal.doubleOut(vals[6]) + " Tm [" + s + "]"); psRenderer.write("ET"); } @@ -685,13 +685,13 @@ for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator.next()) { - psRenderer.write(PDFNumber.doubleOut(vals[0]) + " " - + PDFNumber.doubleOut(vals[1]) + " " - + PDFNumber.doubleOut(vals[2]) + " " - + PDFNumber.doubleOut(vals[3]) + " " - + PDFNumber.doubleOut(vals[4]) + " " - + PDFNumber.doubleOut(vals[5]) + " " - + PDFNumber.doubleOut(vals[6]) + " Tm [" + ch + psRenderer.write(PSReal.doubleOut(vals[0]) + " " + + PSReal.doubleOut(vals[1]) + " " + + PSReal.doubleOut(vals[2]) + " " + + PSReal.doubleOut(vals[3]) + " " + + PSReal.doubleOut(vals[4]) + " " + + PSReal.doubleOut(vals[5]) + " " + + PSReal.doubleOut(vals[6]) + " Tm [" + ch + "]"); } @@ -729,22 +729,22 @@ int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + " " - + PDFNumber.doubleOut(1000 * vals[2]) + " " - + PDFNumber.doubleOut(1000 * vals[3]) + " " - + PDFNumber.doubleOut(1000 * vals[4]) + " " - + PDFNumber.doubleOut(1000 * vals[5]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " " + + PSReal.doubleOut(1000 * vals[2]) + " " + + PSReal.doubleOut(1000 * vals[3]) + " " + + PSReal.doubleOut(1000 * vals[4]) + " " + + PSReal.doubleOut(1000 * vals[5]) + " curveto"); break; case PathIterator.SEG_LINETO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " lineto"); break; case PathIterator.SEG_MOVETO: - psRenderer.write(PDFNumber.doubleOut(1000 * vals[0]) + " " - + PDFNumber.doubleOut(1000 * vals[1]) + psRenderer.write(PSReal.doubleOut(1000 * vals[0]) + " " + + PSReal.doubleOut(1000 * vals[1]) + " M"); break; case PathIterator.SEG_QUADTO: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 13:59:36
|
Revision: 6964 Author: victormote Date: 2006-03-15 05:59:32 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6964&view=rev Log Message: ----------- Remove another dependency on FOrayPDF. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java Modified: trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-03-15 02:40:02 UTC (rev 6963) +++ trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-03-15 13:59:32 UTC (rev 6964) @@ -32,8 +32,6 @@ package org.foray.render.pcl; -import org.foray.pdf.object.PDFColor; -import org.foray.pdf.object.PDFPathPaint; import org.foray.output.OutputConfig; import org.foray.render.PrintRenderer; @@ -99,7 +97,6 @@ */ protected void drawLine(int x1, int y1, int x2, int y2, int th, int rs, Color strokeColor) { - PDFColor pdfColor = new PDFColor(strokeColor); int dashon = 0; int dashoff = 0; // if ( rs != null && rs.length() > 5 && rs.charAt(0) == '[' && rs.charAt(1) != ']' && rs.charAt(4) == ']' ) @@ -124,11 +121,11 @@ while (start < y2) { if (start + len > y2) len = y2 - start; - addRect(x1 - (th / 2), start, th, len, pdfColor, pdfColor); + addRect(x1 - (th / 2), start, th, len, strokeColor, strokeColor); start += (len + dashoff * th); } } else - addRect(x1 - (th / 2), y1, th, y2 - y1 + 1, pdfColor, pdfColor); + addRect(x1 - (th / 2), y1, th, y2 - y1 + 1, strokeColor, strokeColor); } else if (y1 == y2) { if (dashon > 0 && dashoff > 0) { int start = x1; @@ -136,11 +133,11 @@ while (start < x2) { if (start + len > x2) len = x2 - start; - addRect(start, y1 + (th / 2), len, th, pdfColor, pdfColor); + addRect(start, y1 + (th / 2), len, th, strokeColor, strokeColor); start += (len + dashoff * th); } } else - addRect(x1, y1 + (th / 2), x2 - x1 + 1, th, pdfColor, pdfColor); + addRect(x1, y1 + (th / 2), x2 - x1 + 1, th, strokeColor, strokeColor); } } @@ -150,7 +147,6 @@ protected void drawRectangle(int x, int y, int w, int h, boolean stroke, Color strokeColor, boolean fill, Color fillColor) { - PDFColor strokePaint = new PDFColor(strokeColor); if ((h >= 0 && h < 720) || (h < 0 && h > -720) || w < 720) { if (w < 720) w = 720; @@ -158,12 +154,12 @@ h = 720; else if (h < 0 && h > -720) h = -720; - addRect(x, y, w, h, strokePaint, strokePaint); + addRect(x, y, w, h, strokeColor, strokeColor); } else { - addRect(x, y, w, 720, strokePaint, strokePaint); - addRect(x, y, 720, h, strokePaint, strokePaint); - addRect(x + w - 720, y, 720, h, strokePaint, strokePaint); - addRect(x, y - h + 720, w, 720, strokePaint, strokePaint); + addRect(x, y, w, 720, strokeColor, strokeColor); + addRect(x, y, 720, h, strokeColor, strokeColor); + addRect(x + w - 720, y, 720, h, strokeColor, strokeColor); + addRect(x, y - h + 720, w, 720, strokeColor, strokeColor); } } @@ -177,8 +173,7 @@ * @param fill the fill color/gradient * @param stroke the stroke color/gradient */ - protected void addRect(int x, int y, int w, int h, PDFPathPaint stroke, - PDFPathPaint fill) { + protected void addRect(int x, int y, int w, int h, Color stroke, Color fill) { if ((w == 0) || (h == 0)) return; if (h < 0) @@ -187,21 +182,13 @@ y += h; - PDFColor sc = (PDFColor)stroke; - PDFColor fc = (PDFColor)fill; + int lineshade = (int)(100 - ((0.3f * stroke.getRed() + + 0.59f * stroke.getGreen() + 0.11f * stroke.getBlue()) + * 100f)); + int fillshade = (int)(100 - ((0.3f * fill.getRed() + + 0.59f * fill.getGreen() + 0.11f * fill.getBlue()) + * 100f)); - sc.setColorSpace(ColorSpace.TYPE_RGB); - fc.setColorSpace(ColorSpace.TYPE_RGB); - - int lineshade = - (int)(100 - - ((0.3f * sc.red() + 0.59f * sc.green() + 0.11f * sc.blue()) - * 100f)); - int fillshade = - (int)(100 - - ((0.3f * fc.red() + 0.59f * fc.green() + 0.11f * fc.blue()) - * 100f)); - int xpos = xoffset + (x / 100); if (xpos < 0) { xpos = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 02:40:09
|
Revision: 6963 Author: victormote Date: 2006-03-14 18:40:02 -0800 (Tue, 14 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6963&view=rev Log Message: ----------- Remove another dependency on FOrayPDF. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-03-15 01:29:50 UTC (rev 6962) +++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-03-15 02:40:02 UTC (rev 6963) @@ -25,8 +25,6 @@ package org.foray.render.txt; import org.foray.output.OutputConfig; -import org.foray.pdf.object.PDFColor; -import org.foray.pdf.object.PDFPathPaint; import org.foray.render.PrintRenderer; import org.axsl.areaOut.Area; @@ -45,10 +43,8 @@ import java.awt.Color; import java.awt.Rectangle; -import java.awt.color.ColorSpace; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.util.List; /** * Renderer that renders areas to plain text. @@ -161,11 +157,11 @@ */ protected void drawLine(int x1, int y1, int x2, int y2, int th, int rs, Color strokeColor) { - PDFColor lstroke = null; + Color lstroke = null; if (rs == Constants.FOVAL_DOTTED) { - lstroke = new PDFColor(0.7f, 0.7f, 0.7f); + lstroke = new Color(0.7f, 0.7f, 0.7f); } else { - lstroke = new PDFColor(strokeColor); + lstroke = strokeColor; } if (x1 == x2) { addRect(x1, y1, th, y2 - y1 + 1, lstroke, lstroke); @@ -183,11 +179,6 @@ //TODO: Implement this. } - protected void addLine(float x1, float y1, float x2, float y2, - PDFColor sc, float sw) { - /* SVG - Not yet implemented */ - } - /** * add a rectangle to the current stream * @@ -197,7 +188,7 @@ * @param h the height in millipoints * @param stroke the stroke color/gradient */ - protected void drawRectangle(int x, int y, int w, int h, PDFPathPaint stroke) { + protected void drawRectangle(int x, int y, int w, int h, Color stroke) { if (h < 0) h *= -1; @@ -225,8 +216,8 @@ * @param fill the fill color/gradient * @param stroke the stroke color/gradient */ - protected void addRect(int x, int y, int w, int h, PDFPathPaint stroke, - PDFPathPaint fill) { + protected void addRect(int x, int y, int w, int h, Color stroke, + Color fill) { if ((w == 0) || (h == 0)) { return; } @@ -237,20 +228,11 @@ int row = (int)((pageHeight - (y / 100)) * 100 * yFactor); int col = (int)(x * xFactor); - PDFColor sc = (PDFColor)stroke; - PDFColor fc = (PDFColor)fill; - - sc.setColorSpace(ColorSpace.TYPE_RGB); - fc.setColorSpace(ColorSpace.TYPE_RGB); - - int lineshade = - (int)(100 - - ((0.3f * sc.red() + 0.59f * sc.green() + 0.11f * sc.blue()) - * 100f)); - int fillshade = - (int)(100 - - ((0.3f * fc.red() + 0.59f * fc.green() + 0.11f * fc.blue()) - * 100f)); + int lineshade = (int)(100 - ((0.3f * stroke.getRed() + + 0.59f * stroke.getGreen() + 0.11f * stroke.getBlue()) + * 100f)); + int fillshade = (int)(100 - ((0.3f * fill.getRed() + + 0.59f * fill.getGreen() + 0.11f * fill.getBlue()) * 100f)); getLogger().debug("TXTRenderer.addRect(" + x + ", " + y + ", " + w + ", " + h + ", " + stroke + ", " + fill + ") fillshade=" + fillshade); @@ -329,25 +311,7 @@ } } - /** - * add a filled rectangle to the current stream - * - * @param x the x position of left edge in millipoints - * @param y the y position of top edge in millipoints - * @param w the width in millipoints - * @param h the height in millipoints - */ - protected void addRect(float x, float y, float w, float h, float rx, - float ry, PDFColor fc, PDFColor sc, float sw) { - /* SVG - Not yet implemented */ - } - - // Add a polyline or polygon. Does not support fills yet!!! - protected void addPolyline(List points, int posx, int posy, PDFColor fc, - PDFColor sc, float sw, boolean close) {} - - /** * {@inheritDoc} */ protected void drawGraphic(Area area, Graphic image, @@ -359,8 +323,7 @@ int h) throws GraphicException { getLogger().debug("TXTRenderer.printBMP(" + img + ", " + x + ", " + y + ", " + w + ", " + h + ")"); - addRect(x, y, w, h, new PDFColor(1f, 1f, 1f), - new PDFColor(0f, 0f, 0f)); + addRect(x, y, w, h, new Color(1f, 1f, 1f), new Color(0f, 0f, 0f)); int nameh = (int)(h * yFactor / 2); if (nameh > 0) { int namew = (int)(w * xFactor); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 01:30:15
|
Revision: 6962 Author: victormote Date: 2006-03-14 17:29:50 -0800 (Tue, 14 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6962&view=rev Log Message: ----------- Require the PDFFactory in the PDFRenderer constructor. Modified Paths: -------------- trunk/foray/foray-app/.classpath trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java Modified: trunk/foray/foray-app/.classpath =================================================================== --- trunk/foray/foray-app/.classpath 2006-03-15 01:23:57 UTC (rev 6961) +++ trunk/foray/foray-app/.classpath 2006-03-15 01:29:50 UTC (rev 6962) @@ -25,5 +25,7 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/resolver.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/xml-apis-1.3.02.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslPDF"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayPDF"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-03-15 01:23:57 UTC (rev 6961) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-03-15 01:29:50 UTC (rev 6962) @@ -29,6 +29,7 @@ import org.foray.output.MIFConverter; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; +import org.foray.pdf.FOrayPDFFactory; import org.foray.render.awt.AWTRenderer; import org.foray.render.pcl.PCLRenderer; import org.foray.render.pdf.PDFRenderer; @@ -41,6 +42,7 @@ import org.axsl.font.FontServer; import org.axsl.fotree.FOTreeControl; import org.axsl.graphic.GraphicServer; +import org.axsl.pdf.PDFFactory; import org.axsl.text.TextServer; import org.apache.commons.logging.Log; @@ -468,7 +470,8 @@ break; } default: { - renderer = new PDFRenderer(outputOptions); + PDFFactory pdfFactory = new FOrayPDFFactory(getLogger()); + renderer = new PDFRenderer(outputOptions, pdfFactory); break; } } Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-03-15 01:23:57 UTC (rev 6961) +++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-03-15 01:29:50 UTC (rev 6962) @@ -32,7 +32,6 @@ import org.foray.common.FOrayException; import org.foray.common.StringUtilPre5; import org.foray.output.OutputConfig; -import org.foray.pdf.FOrayPDFFactory; import org.foray.render.PrintRenderer; import org.axsl.areaOut.Area; @@ -88,8 +87,9 @@ /** * Create a PDF renderer. */ - public PDFRenderer(OutputConfig renderConfig) { + public PDFRenderer(OutputConfig renderConfig, PDFFactory pdfFactory) { super(renderConfig); + this.pdfFactory = pdfFactory; } private void addEncryption() { @@ -133,7 +133,6 @@ * {@inheritDoc} */ public void startOutput() throws IOException { - this.pdfFactory = new FOrayPDFFactory(getLogger()); this.pdfDoc = this.pdfFactory.createPDFDocument(); String pdfVersion = this.options.optionPDFVersion(); if (pdfVersion != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-15 01:24:17
|
Revision: 6961 Author: victormote Date: 2006-03-14 17:23:57 -0800 (Tue, 14 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6961&view=rev Log Message: ----------- Remove need for a FontConsumer in the FOrayPDFFactory constructor. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java 2006-03-15 01:20:55 UTC (rev 6960) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java 2006-03-15 01:23:57 UTC (rev 6961) @@ -26,7 +26,6 @@ import org.foray.pdf.object.PDFResources; -import org.axsl.font.FontConsumer; import org.axsl.pdf.PDFColor; import org.axsl.pdf.PDFDocument; import org.axsl.pdf.PDFEncryption; @@ -46,11 +45,9 @@ public class FOrayPDFFactory implements PDFFactory { - FontConsumer fontConsumer; Log logger; - public FOrayPDFFactory(FontConsumer fontConsumer, Log logger) { - this.fontConsumer = fontConsumer; + public FOrayPDFFactory(Log logger) { this.logger = logger; } Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-03-15 01:20:55 UTC (rev 6960) +++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-03-15 01:23:57 UTC (rev 6961) @@ -133,7 +133,7 @@ * {@inheritDoc} */ public void startOutput() throws IOException { - this.pdfFactory = new FOrayPDFFactory(getFontConsumer(), getLogger()); + this.pdfFactory = new FOrayPDFFactory(getLogger()); this.pdfDoc = this.pdfFactory.createPDFDocument(); String pdfVersion = this.options.optionPDFVersion(); if (pdfVersion != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |