foray-commit Mailing List for FOray (Page 318)
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
(4) |
Dec
(23) |
| 2026 |
Jan
(119) |
Feb
(335) |
Mar
(103) |
Apr
(43) |
May
(154) |
Jun
(107) |
Jul
(187) |
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2006-04-14 19:42:50
|
Revision: 7014 Author: victormote Date: 2006-04-14 12:42:40 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7014&view=rev Log Message: ----------- Steps toward handling metrics files in jar files. 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-04-14 15:44:36 UTC (rev 7013) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-04-14 19:42:40 UTC (rev 7014) @@ -46,6 +46,7 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -305,11 +306,32 @@ return; } getLogger().info("Setting up fonts."); + registerBase14Fonts(); registerAWTFonts(); readFontConfig(fontConfigFile); setupCompleted = true; } + private void registerBase14Fonts() throws FontException { +// registerBase14Font("Base14-Courier", "Courier.afm"); + } + + private void registerBase14Font(String fontName, String fileName) { + URL metricURL; + try { + metricURL = new URL("jar", null, "org/foray/font/resource/base-14/" + + fileName); + } catch (MalformedURLException e) { + this.logger.warn(e); + return; + } + try { + registerFont(fontName, null, metricURL, null, "none", null); + } catch (FontException e) { + this.logger.warn(e); + } + } + private void registerAWTFonts() { if (! this.usingSystemFonts) { return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-14 15:44:44
|
Revision: 7013 Author: victormote Date: 2006-04-14 08:44:36 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7013&view=rev Log Message: ----------- Add base-14 fonts to jar file. Modified Paths: -------------- trunk/foray/foray-font/scripts/build.xml Modified: trunk/foray/foray-font/scripts/build.xml =================================================================== --- trunk/foray/foray-font/scripts/build.xml 2006-04-14 14:11:20 UTC (rev 7012) +++ trunk/foray/foray-font/scripts/build.xml 2006-04-14 15:44:36 UTC (rev 7013) @@ -97,6 +97,10 @@ > <classpath refid="libs-build-classpath"/> </javac> + <!-- Copy the base-14 files into the build directory. --> + <copy todir="${classes.dir}/org/foray/font/resources/base-14"> + <fileset dir="${module.dir}/resource/base-14" includes="**"/> + </copy> </target> <!-- =================================================================== --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-14 14:11:32
|
Revision: 7012 Author: victormote Date: 2006-04-14 07:11:20 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7012&view=rev Log Message: ----------- Rename Ant task class to FOrayAntTask. Added Paths: ----------- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/ant/FOray.java Deleted: trunk/foray/foray-app/src/java/org/foray/app/ant/FOray.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOray.java 2006-04-14 03:26:30 UTC (rev 7011) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOray.java 2006-04-14 14:11:20 UTC (rev 7012) @@ -1,503 +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.app.ant; - -import org.foray.app.FOInputHandler; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; -import org.foray.app.InputHandler; -import org.foray.app.Options; -import org.foray.app.SessionConfig; -import org.foray.app.Starter; -import org.foray.common.FOrayException; -import org.foray.common.Logging; -import org.foray.output.OutputConfig; -import org.foray.output.OutputTarget; - -import org.apache.commons.logging.Log; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.util.GlobPatternMapper; - -import org.xml.sax.XMLReader; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * Wrapper for FOray which allows it to be accessed from within an Ant task. - * Accepts the inputs: - * <ul> - * <li>fofile -> formatting objects file to be transformed</li> - * <li>format -> MIME type of the format to generate ex. "application/pdf"</li> - * <li>outfile -> output filename</li> - * <li>baseDir -> directory to work from</li> - * <li>userconfig -> file with user configuration (same as the "-c" command line option)</li> - * <li>messagelevel -> (error | warn | info | verbose | debug) level to output non-error messages</li> - * <li>logFiles -> Controls whether the names of the files that are processed are logged or not</li> - * </ul> - */ -public class FOray extends Task { - - File foFile; - List filesets = new ArrayList(); - File outFile; - File outDir; - String format; //MIME type - File baseDir; - File userConfig; - int messageType = Project.MSG_VERBOSE; - boolean logFiles = true; - private boolean force = false; - - /** - * Sets the user configuration file. - * @param userConfig File containing the user configuration. - */ - public void setUserconfig (File userConfig) { - this.userConfig = userConfig; - } - - /** - * Sets the input file. - * @param foFile The FO input file. - */ - public void setFofile(File foFile) { - this.foFile = foFile; - } - - /** - * Gets the input file - */ - public File getFofile() { - return foFile; - } - - /** - * Adds a set of fo files (nested fileset attribute). - */ - public void addFileset(FileSet set) { - filesets.add(set); - } - - /** - * Set whether to check dependencies, or to always generate; - * optional, default is false. - * - * @param force true if always generate. - */ - public void setForce(boolean force) { - this.force = force; - } - - /** - * Gets the force attribute - * @return the force attribute - */ - public boolean getForce() { - return force; - } - - /** - * Sets the output file - * @param outFile The File to which the output should be written. - */ - public void setOutfile(File outFile) { - this.outFile = outFile; - } - - /** - * Gets the output file - */ - public File getOutfile() { - return this.outFile; - } - - /** - * Sets the output directory - * @param outDir Directory to which the output should be written. - */ - public void setOutdir(File outDir) { - this.outDir = outDir; - } - - /** - * Gets the output directory - */ - public File getOutdir() { - return this.outDir; - } - - /** - * Sets output format (MIME type) - */ - public void setFormat(String format) { - this.format = format; - } - - /** - * Gets the output format (MIME type) - */ - public String getFormat() { - return this.format; - } - - /** - * Sets the message level to be used while processing. - * @param messageLevel String containing (info | verbose | debug). - */ - public void setMessagelevel(String messageLevel) { - if (messageLevel.equalsIgnoreCase("info")) { - messageType = Project.MSG_INFO; - } else if (messageLevel.equalsIgnoreCase("verbose")) { - messageType = Project.MSG_VERBOSE; - } else if (messageLevel.equalsIgnoreCase("debug")) { - messageType = Project.MSG_DEBUG; - } else if (messageLevel.equalsIgnoreCase("err") || messageLevel.equalsIgnoreCase("error")) { - messageType = Project.MSG_ERR; - } else if (messageLevel.equalsIgnoreCase("warn")) { - messageType = Project.MSG_WARN; - } else { - log("messagelevel set to unknown value \"" + messageLevel + - "\"", Project.MSG_ERR); - throw new BuildException("unknown messagelevel"); - } - } - - /** - * Returns the message type corresponding to Property.MSG_(INFO | VERBOSE | DEBUG) - * representing the current message level. - */ - public int getMessageType() { - return messageType; - } - - /** - * Sets the base directory. Currently ignored. - * @param baseDir File to use as a working directory. - */ - public void setBasedir(File baseDir) { - this.baseDir = baseDir; - } - - /** - * Gets the base directory - */ - public File getBasedir() { - return (baseDir != null) ? baseDir : getProject().resolveFile("."); - } - - /** - * Controls whether the filenames of the files that are processed are logged - * or not. - */ - public void setLogFiles(boolean aBoolean) { - logFiles = aBoolean; - } - - public boolean getLogFiles() { - return logFiles; - } - - /** - * Starts execution of this task - */ - public void execute() throws BuildException { - Log log = null; - switch (getMessageType()) { - case Project.MSG_INFO: { - log = Logging.makeDefaultLogger(); - break; - } - case Project.MSG_WARN: { - log = Logging.makeWarningLogger(); - break; - } - case Project.MSG_ERR: { - log = Logging.makeQuietLogger(); - break; - } - case Project.MSG_DEBUG: - case Project.MSG_VERBOSE: { - log = Logging.makeDebugLogger(); - break; - } - default: { - log = Logging.makeDefaultLogger(); - break; - } - } - try { - Starter starter = new FOrayTaskStarter(this, log, logFiles); - starter.run(); - } catch (FOrayException ex) { - throw new BuildException(ex); - } - } - -} - -class FOrayTaskStarter extends Starter { - FOray task; - Log log; - boolean logFiles; - - FOrayTaskStarter(FOray task, Log aLogger, boolean aLogFiles) - throws FOrayException { - super(aLogger, null, null); - this.task = task; - log = aLogger; - logFiles = aLogFiles; - } - - private int determineRenderer(String format) { - if ((format == null) || - format.equalsIgnoreCase("application/pdf") || - format.equalsIgnoreCase("pdf")) { - return FOrayTarget.RENDER_PDF; - } else if (format.equalsIgnoreCase("application/postscript") || - format.equalsIgnoreCase("ps")) { - return FOrayTarget.RENDER_PS; - } else if (format.equalsIgnoreCase("application/vnd.mif") || - format.equalsIgnoreCase("mif")) { - return FOrayTarget.RENDER_MIF; - } else if (format.equalsIgnoreCase("application/vnd.gp-PCL") || - format.equalsIgnoreCase("pcl")) { - return FOrayTarget.RENDER_PCL; - } else if (format.equalsIgnoreCase("text/plain") || - format.equalsIgnoreCase("txt")) { - return FOrayTarget.RENDER_TXT; - } else if (format.equalsIgnoreCase("text/xml") || - format.equalsIgnoreCase("at") || - format.equalsIgnoreCase("xml")) { - return FOrayTarget.RENDER_XML; - } else { - String err = "Couldn't determine renderer to use: "+format; - throw new BuildException(err); - } - } - - private String determineExtension(int renderer) { - switch (renderer) { - case FOrayTarget.RENDER_PDF: - return ".pdf"; - case FOrayTarget.RENDER_PS: - return ".ps"; - case FOrayTarget.RENDER_MIF: - return ".mif"; - case FOrayTarget.RENDER_PCL: - return ".pcl"; - case FOrayTarget.RENDER_TXT: - return ".txt"; - case FOrayTarget.RENDER_XML: - return ".xml"; - default: - String err = "Unknown renderer: "+renderer; - throw new BuildException(err); - } - } - - private File replaceExtension(File file, String expectedExt, - String newExt) { - String name = file.getName(); - if (name.toLowerCase().endsWith(expectedExt)) { - name = name.substring(0, name.length() - expectedExt.length()); - } - name = name.concat(newExt); - return new File(file.getParentFile(), name); - } - - public void run() throws FOrayException { - Log logger = Logging.makeDefaultLogger(); - SessionConfig configuration = new SessionConfig(logger); - if (task.userConfig != null) { - new Options (log, configuration, null, task.userConfig); - } - - try { - if (task.getFofile() != null) { - if (task.getBasedir() != null) { - configuration.parseOption("base-directory", - task.getBasedir().toURL().toExternalForm(), - SessionConfig.PRECEDENCE_DEFAULT); - } else { - configuration.parseOption("base-directory", - task.getFofile().getParentFile().toURL(). - toExternalForm(), - SessionConfig.PRECEDENCE_DEFAULT); - } - } - task.log("Using base directory: " + - configuration.optionBaseDirectory(), - Project.MSG_DEBUG); - } catch (Exception e) { - - task.log("Error setting base directory: " + e, Project.MSG_ERR); - } - - int rint = determineRenderer(task.getFormat()); - String newExtension = determineExtension(rint); - - // actioncount = # of fofiles actually processed through FOray - int actioncount = 0; - // skippedcount = # of fofiles which haven't changed (force = "false") - int skippedcount = 0; - - // deal with single source file - if (task.getFofile() != null) { - if (task.getFofile().exists()) { - File outf = task.getOutfile(); - if (outf == null) { - throw new BuildException("outfile is required when fofile is used"); - } - if (task.getOutdir() != null) { - outf = new File(task.getOutdir(), outf.getName()); - } - - // Render if "force" flag is set OR - // OR output file doesn't exist OR - // output file is older than input file - if (task.getForce() || !outf.exists() - || (task.getFofile().lastModified() > outf.lastModified() )) { - render(task.getFofile(), outf, rint, configuration); - actioncount++; - } else if (outf.exists() && (task.getFofile().lastModified() <= outf.lastModified() )) { - skippedcount++; - } - } - } - - GlobPatternMapper mapper = new GlobPatternMapper(); - mapper.setFrom("*.fo"); - mapper.setTo("*" + newExtension); - - // deal with the filesets - for (int i = 0; i < task.filesets.size(); i++) { - FileSet fs = (FileSet) task.filesets.get(i); - DirectoryScanner ds = fs.getDirectoryScanner(task.getProject()); - String[] files = ds.getIncludedFiles(); - - - for (int j = 0; j < files.length; j++) { - File f = new File(fs.getDir(task.getProject()), files[j]); - File outf = null; - if (task.getOutdir() != null && files[j].endsWith(".fo")) { - String[] sa = mapper.mapFileName(files[j]); - outf = new File(task.getOutdir(), sa[0]); - } else { - outf = replaceExtension(f, ".fo", newExtension); - if (task.getOutdir() != null) { - outf = new File(task.getOutdir(), outf.getName()); - } - } - try { - if (task.getBasedir() != null) { - configuration.parseOption("base-directory", - task.getBasedir().toURL().toExternalForm(), - SessionConfig.PRECEDENCE_DEFAULT); - } else { - configuration.parseOption("base-directory", - fs.getDir(task.getProject()).toURL(). - toExternalForm(), - SessionConfig.PRECEDENCE_DEFAULT); - } - task.log("Using base directory: " + - configuration.optionBaseDirectory(), - Project.MSG_DEBUG); - } catch (Exception e) { - task.log("Error setting base directory: " + e, Project.MSG_ERR); - } - - // Render if "force" flag is set OR - // OR output file doesn't exist OR - // output file is older than input file - if (task.getForce() || !outf.exists() - || (f.lastModified() > outf.lastModified() )) { - render(f, outf, rint, configuration); - actioncount++; - } else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) { - skippedcount++; - } - - } - } - - if (actioncount + skippedcount == 0) { - task.log("No files processed. No files were selected by the filesets " - + "and no fofile was set." , Project.MSG_WARN); - } else if (skippedcount > 0) { - task.log(skippedcount + " xslfo file(s) skipped (no change found" - + " since last generation; set force=\"true\" to override)." - , Project.MSG_INFO); - } - } - - private void render(File foFile, File outFile, int rendererType, - SessionConfig configuration) throws FOrayException { - InputHandler inputHandler = new FOInputHandler(logger, foFile); - XMLReader parser = inputHandler.getParser(); - - OutputStream out = null; - try { - File dir = outFile.getParentFile(); - dir.mkdirs(); - out = new FileOutputStream(outFile); - } catch (Exception ex) { - throw new BuildException(ex); - } - - if (logFiles) task.log(foFile + " -> " + outFile, Project.MSG_INFO); - - try { - FOraySession session = new FOraySession(log, configuration, null, - null, null, null); - FOrayDocument document = new FOrayDocument(session, - inputHandler.getInputSource(), parser); - - OutputConfig rendererOptions = null; - if (rendererType == FOrayTarget.RENDER_XML) { - rendererOptions = new OutputConfig(logger); - rendererOptions.parseOption("fineDetail", "true", - SessionConfig.PRECEDENCE_DEFAULT); - } - OutputTarget renderer = document.makeOutputTarget(rendererType, - rendererOptions); - new FOrayTarget(document, renderer, null, out); - - session.process(); - out.close(); - } catch (Exception ex) { - throw new BuildException(ex); - } - } - -} Copied: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java (from rev 6958, trunk/foray/foray-app/src/java/org/foray/app/ant/FOray.java) =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java (rev 0) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-04-14 14:11:20 UTC (rev 7012) @@ -0,0 +1,503 @@ +/* + * 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.app.ant; + +import org.foray.app.FOInputHandler; +import org.foray.app.FOrayDocument; +import org.foray.app.FOraySession; +import org.foray.app.FOrayTarget; +import org.foray.app.InputHandler; +import org.foray.app.Options; +import org.foray.app.SessionConfig; +import org.foray.app.Starter; +import org.foray.common.FOrayException; +import org.foray.common.Logging; +import org.foray.output.OutputConfig; +import org.foray.output.OutputTarget; + +import org.apache.commons.logging.Log; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.util.GlobPatternMapper; + +import org.xml.sax.XMLReader; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * Wrapper for FOray which allows it to be accessed from within an Ant task. + * Accepts the inputs: + * <ul> + * <li>fofile -> formatting objects file to be transformed</li> + * <li>format -> MIME type of the format to generate ex. "application/pdf"</li> + * <li>outfile -> output filename</li> + * <li>baseDir -> directory to work from</li> + * <li>userconfig -> file with user configuration (same as the "-c" command line option)</li> + * <li>messagelevel -> (error | warn | info | verbose | debug) level to output non-error messages</li> + * <li>logFiles -> Controls whether the names of the files that are processed are logged or not</li> + * </ul> + */ +public class FOrayAntTask extends Task { + + File foFile; + List filesets = new ArrayList(); + File outFile; + File outDir; + String format; //MIME type + File baseDir; + File userConfig; + int messageType = Project.MSG_VERBOSE; + boolean logFiles = true; + private boolean force = false; + + /** + * Sets the user configuration file. + * @param userConfig File containing the user configuration. + */ + public void setUserconfig (File userConfig) { + this.userConfig = userConfig; + } + + /** + * Sets the input file. + * @param foFile The FO input file. + */ + public void setFofile(File foFile) { + this.foFile = foFile; + } + + /** + * Gets the input file + */ + public File getFofile() { + return foFile; + } + + /** + * Adds a set of fo files (nested fileset attribute). + */ + public void addFileset(FileSet set) { + filesets.add(set); + } + + /** + * Set whether to check dependencies, or to always generate; + * optional, default is false. + * + * @param force true if always generate. + */ + public void setForce(boolean force) { + this.force = force; + } + + /** + * Gets the force attribute + * @return the force attribute + */ + public boolean getForce() { + return force; + } + + /** + * Sets the output file + * @param outFile The File to which the output should be written. + */ + public void setOutfile(File outFile) { + this.outFile = outFile; + } + + /** + * Gets the output file + */ + public File getOutfile() { + return this.outFile; + } + + /** + * Sets the output directory + * @param outDir Directory to which the output should be written. + */ + public void setOutdir(File outDir) { + this.outDir = outDir; + } + + /** + * Gets the output directory + */ + public File getOutdir() { + return this.outDir; + } + + /** + * Sets output format (MIME type) + */ + public void setFormat(String format) { + this.format = format; + } + + /** + * Gets the output format (MIME type) + */ + public String getFormat() { + return this.format; + } + + /** + * Sets the message level to be used while processing. + * @param messageLevel String containing (info | verbose | debug). + */ + public void setMessagelevel(String messageLevel) { + if (messageLevel.equalsIgnoreCase("info")) { + messageType = Project.MSG_INFO; + } else if (messageLevel.equalsIgnoreCase("verbose")) { + messageType = Project.MSG_VERBOSE; + } else if (messageLevel.equalsIgnoreCase("debug")) { + messageType = Project.MSG_DEBUG; + } else if (messageLevel.equalsIgnoreCase("err") || messageLevel.equalsIgnoreCase("error")) { + messageType = Project.MSG_ERR; + } else if (messageLevel.equalsIgnoreCase("warn")) { + messageType = Project.MSG_WARN; + } else { + log("messagelevel set to unknown value \"" + messageLevel + + "\"", Project.MSG_ERR); + throw new BuildException("unknown messagelevel"); + } + } + + /** + * Returns the message type corresponding to Property.MSG_(INFO | VERBOSE | DEBUG) + * representing the current message level. + */ + public int getMessageType() { + return messageType; + } + + /** + * Sets the base directory. Currently ignored. + * @param baseDir File to use as a working directory. + */ + public void setBasedir(File baseDir) { + this.baseDir = baseDir; + } + + /** + * Gets the base directory + */ + public File getBasedir() { + return (baseDir != null) ? baseDir : getProject().resolveFile("."); + } + + /** + * Controls whether the filenames of the files that are processed are logged + * or not. + */ + public void setLogFiles(boolean aBoolean) { + logFiles = aBoolean; + } + + public boolean getLogFiles() { + return logFiles; + } + + /** + * Starts execution of this task + */ + public void execute() throws BuildException { + Log log = null; + switch (getMessageType()) { + case Project.MSG_INFO: { + log = Logging.makeDefaultLogger(); + break; + } + case Project.MSG_WARN: { + log = Logging.makeWarningLogger(); + break; + } + case Project.MSG_ERR: { + log = Logging.makeQuietLogger(); + break; + } + case Project.MSG_DEBUG: + case Project.MSG_VERBOSE: { + log = Logging.makeDebugLogger(); + break; + } + default: { + log = Logging.makeDefaultLogger(); + break; + } + } + try { + Starter starter = new FOrayTaskStarter(this, log, logFiles); + starter.run(); + } catch (FOrayException ex) { + throw new BuildException(ex); + } + } + +} + +class FOrayTaskStarter extends Starter { + FOrayAntTask task; + Log log; + boolean logFiles; + + FOrayTaskStarter(FOrayAntTask task, Log aLogger, boolean aLogFiles) + throws FOrayException { + super(aLogger, null, null); + this.task = task; + log = aLogger; + logFiles = aLogFiles; + } + + private int determineRenderer(String format) { + if ((format == null) || + format.equalsIgnoreCase("application/pdf") || + format.equalsIgnoreCase("pdf")) { + return FOrayTarget.RENDER_PDF; + } else if (format.equalsIgnoreCase("application/postscript") || + format.equalsIgnoreCase("ps")) { + return FOrayTarget.RENDER_PS; + } else if (format.equalsIgnoreCase("application/vnd.mif") || + format.equalsIgnoreCase("mif")) { + return FOrayTarget.RENDER_MIF; + } else if (format.equalsIgnoreCase("application/vnd.gp-PCL") || + format.equalsIgnoreCase("pcl")) { + return FOrayTarget.RENDER_PCL; + } else if (format.equalsIgnoreCase("text/plain") || + format.equalsIgnoreCase("txt")) { + return FOrayTarget.RENDER_TXT; + } else if (format.equalsIgnoreCase("text/xml") || + format.equalsIgnoreCase("at") || + format.equalsIgnoreCase("xml")) { + return FOrayTarget.RENDER_XML; + } else { + String err = "Couldn't determine renderer to use: "+format; + throw new BuildException(err); + } + } + + private String determineExtension(int renderer) { + switch (renderer) { + case FOrayTarget.RENDER_PDF: + return ".pdf"; + case FOrayTarget.RENDER_PS: + return ".ps"; + case FOrayTarget.RENDER_MIF: + return ".mif"; + case FOrayTarget.RENDER_PCL: + return ".pcl"; + case FOrayTarget.RENDER_TXT: + return ".txt"; + case FOrayTarget.RENDER_XML: + return ".xml"; + default: + String err = "Unknown renderer: "+renderer; + throw new BuildException(err); + } + } + + private File replaceExtension(File file, String expectedExt, + String newExt) { + String name = file.getName(); + if (name.toLowerCase().endsWith(expectedExt)) { + name = name.substring(0, name.length() - expectedExt.length()); + } + name = name.concat(newExt); + return new File(file.getParentFile(), name); + } + + public void run() throws FOrayException { + Log logger = Logging.makeDefaultLogger(); + SessionConfig configuration = new SessionConfig(logger); + if (task.userConfig != null) { + new Options (log, configuration, null, task.userConfig); + } + + try { + if (task.getFofile() != null) { + if (task.getBasedir() != null) { + configuration.parseOption("base-directory", + task.getBasedir().toURL().toExternalForm(), + SessionConfig.PRECEDENCE_DEFAULT); + } else { + configuration.parseOption("base-directory", + task.getFofile().getParentFile().toURL(). + toExternalForm(), + SessionConfig.PRECEDENCE_DEFAULT); + } + } + task.log("Using base directory: " + + configuration.optionBaseDirectory(), + Project.MSG_DEBUG); + } catch (Exception e) { + + task.log("Error setting base directory: " + e, Project.MSG_ERR); + } + + int rint = determineRenderer(task.getFormat()); + String newExtension = determineExtension(rint); + + // actioncount = # of fofiles actually processed through FOray + int actioncount = 0; + // skippedcount = # of fofiles which haven't changed (force = "false") + int skippedcount = 0; + + // deal with single source file + if (task.getFofile() != null) { + if (task.getFofile().exists()) { + File outf = task.getOutfile(); + if (outf == null) { + throw new BuildException("outfile is required when fofile is used"); + } + if (task.getOutdir() != null) { + outf = new File(task.getOutdir(), outf.getName()); + } + + // Render if "force" flag is set OR + // OR output file doesn't exist OR + // output file is older than input file + if (task.getForce() || !outf.exists() + || (task.getFofile().lastModified() > outf.lastModified() )) { + render(task.getFofile(), outf, rint, configuration); + actioncount++; + } else if (outf.exists() && (task.getFofile().lastModified() <= outf.lastModified() )) { + skippedcount++; + } + } + } + + GlobPatternMapper mapper = new GlobPatternMapper(); + mapper.setFrom("*.fo"); + mapper.setTo("*" + newExtension); + + // deal with the filesets + for (int i = 0; i < task.filesets.size(); i++) { + FileSet fs = (FileSet) task.filesets.get(i); + DirectoryScanner ds = fs.getDirectoryScanner(task.getProject()); + String[] files = ds.getIncludedFiles(); + + + for (int j = 0; j < files.length; j++) { + File f = new File(fs.getDir(task.getProject()), files[j]); + File outf = null; + if (task.getOutdir() != null && files[j].endsWith(".fo")) { + String[] sa = mapper.mapFileName(files[j]); + outf = new File(task.getOutdir(), sa[0]); + } else { + outf = replaceExtension(f, ".fo", newExtension); + if (task.getOutdir() != null) { + outf = new File(task.getOutdir(), outf.getName()); + } + } + try { + if (task.getBasedir() != null) { + configuration.parseOption("base-directory", + task.getBasedir().toURL().toExternalForm(), + SessionConfig.PRECEDENCE_DEFAULT); + } else { + configuration.parseOption("base-directory", + fs.getDir(task.getProject()).toURL(). + toExternalForm(), + SessionConfig.PRECEDENCE_DEFAULT); + } + task.log("Using base directory: " + + configuration.optionBaseDirectory(), + Project.MSG_DEBUG); + } catch (Exception e) { + task.log("Error setting base directory: " + e, Project.MSG_ERR); + } + + // Render if "force" flag is set OR + // OR output file doesn't exist OR + // output file is older than input file + if (task.getForce() || !outf.exists() + || (f.lastModified() > outf.lastModified() )) { + render(f, outf, rint, configuration); + actioncount++; + } else if (outf.exists() && (f.lastModified() <= outf.lastModified() )) { + skippedcount++; + } + + } + } + + if (actioncount + skippedcount == 0) { + task.log("No files processed. No files were selected by the filesets " + + "and no fofile was set." , Project.MSG_WARN); + } else if (skippedcount > 0) { + task.log(skippedcount + " xslfo file(s) skipped (no change found" + + " since last generation; set force=\"true\" to override)." + , Project.MSG_INFO); + } + } + + private void render(File foFile, File outFile, int rendererType, + SessionConfig configuration) throws FOrayException { + InputHandler inputHandler = new FOInputHandler(logger, foFile); + XMLReader parser = inputHandler.getParser(); + + OutputStream out = null; + try { + File dir = outFile.getParentFile(); + dir.mkdirs(); + out = new FileOutputStream(outFile); + } catch (Exception ex) { + throw new BuildException(ex); + } + + if (logFiles) task.log(foFile + " -> " + outFile, Project.MSG_INFO); + + try { + FOraySession session = new FOraySession(log, configuration, null, + null, null, null); + FOrayDocument document = new FOrayDocument(session, + inputHandler.getInputSource(), parser); + + OutputConfig rendererOptions = null; + if (rendererType == FOrayTarget.RENDER_XML) { + rendererOptions = new OutputConfig(logger); + rendererOptions.parseOption("fineDetail", "true", + SessionConfig.PRECEDENCE_DEFAULT); + } + OutputTarget renderer = document.makeOutputTarget(rendererType, + rendererOptions); + new FOrayTarget(document, renderer, null, out); + + session.process(); + out.close(); + } catch (Exception ex) { + throw new BuildException(ex); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-14 03:26:41
|
Revision: 7011 Author: victormote Date: 2006-04-13 20:26:30 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7011&view=rev Log Message: ----------- Handle change in configuration DTD. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java Modified: trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-04-14 03:22:16 UTC (rev 7010) +++ trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-04-14 03:26:30 UTC (rev 7011) @@ -41,7 +41,8 @@ import javax.xml.parsers.SAXParserFactory; /** - * SAX2 Handler which retrieves the configuration information and stores them in Configuration. + * SAX2 Handler which retrieves the configuration information and stores them + * in Configuration. * Normally this class doesn't need to be accessed directly. */ public class ConfigurationParser extends DefaultHandler { @@ -153,16 +154,22 @@ Attributes attributes) { if (localName.equals("key")) { status += IN_KEY; - } else if (localName.equals("value")) { + return; + } + if (localName.equals("value")) { status += IN_VALUE; - } else if (localName.equals("entry")) { - } else if (localName.equals("configuration")) {} - else { - // to make sure that user knows about false tag - logger.error(getFormattedLocation() + "\nUnknown tag in " + return; + } + if (localName.equals("entry")) { + return; + } + if (localName.equals("foray-config")) { + return; + } + // to make sure that user knows about false tag + logger.error(getFormattedLocation() + "\nUnknown tag in " + "configuration file: " + localName); - } - } // end startElement + } // end startElement /** * stores subentries or entries into their hashes (map for subentries, configuration for entry) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-14 03:22:21
|
Revision: 7010 Author: victormote Date: 2006-04-13 20:22:16 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7010&view=rev Log Message: ----------- Fix some errors. Modified Paths: -------------- trunk/foray/doc/web/app/using/anttask.html Modified: trunk/foray/doc/web/app/using/anttask.html =================================================================== --- trunk/foray/doc/web/app/using/anttask.html 2006-04-14 03:17:45 UTC (rev 7009) +++ trunk/foray/doc/web/app/using/anttask.html 2006-04-14 03:22:16 UTC (rev 7010) @@ -29,8 +29,8 @@ <h2><a name="task">Define the Custom Ant Task</a></h2> <p>The first step toward using FOray from within your Ant scripts is to define the custom task within the Ant script. -It is generally desirable to set define the task in a common task that is -accessible to the remainder of the script, such as an "init" task. +It is generally desirable to define the task in a common target that is +accessible to the remainder of the script, such as an "init" target. Defining the task simply tells Ant how to find the FOray Ant task class, and the classes that are needed to run FOray. In the example below, note that your location for ${foray.home} and the @@ -121,8 +121,8 @@ <tr> <td>messagelevel</td> <td>Logging level. Possible values: <code>error</code>, <code>warn</code>, - <code>info</code>, <code>verbose</code>>, <code>debug</code>></td> - <td>No. Default is <code>verbose</code>></td> + <code>info</code>, <code>verbose</code>, <code>debug</code></td> + <td>No. Default is <code>verbose</code></td> </tr> <!--<tr> <td>logFiles</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-14 03:17:54
|
Revision: 7009 Author: victormote Date: 2006-04-13 20:17:45 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7009&view=rev Log Message: ----------- Add document for the Ant task. Modified Paths: -------------- trunk/foray/doc/web/00-rsrc/include/leftmenu.html Added Paths: ----------- trunk/foray/doc/web/app/using/anttask.html Modified: trunk/foray/doc/web/00-rsrc/include/leftmenu.html =================================================================== --- trunk/foray/doc/web/00-rsrc/include/leftmenu.html 2006-04-13 21:07:39 UTC (rev 7008) +++ trunk/foray/doc/web/00-rsrc/include/leftmenu.html 2006-04-14 03:17:45 UTC (rev 7009) @@ -81,6 +81,12 @@ <tr> <td class="Bullet1"> </td> <td class="Menu1"> + <a class="Menu" href="/app/using/anttask.html">Ant Task</a> + </td> + </tr> + <tr> + <td class="Bullet1"> </td> + <td class="Menu1"> <a class="Menu" href="/app/resources/other.html">Resources</a> </td> </tr> Added: trunk/foray/doc/web/app/using/anttask.html =================================================================== --- trunk/foray/doc/web/app/using/anttask.html (rev 0) +++ trunk/foray/doc/web/app/using/anttask.html 2006-04-14 03:17:45 UTC (rev 7009) @@ -0,0 +1,161 @@ +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + +<head> + <title>FOray - Using the FOray Ant Task</title> + <meta name="content-revised" + content="$Date$"/> + <!--#include virtual="/00-rsrc/include/standard-head.html" --> +</head> + +<body> +<!--#include virtual="/00-rsrc/include/leftmenu.html" --> + +<h1>Using the FOray Ant Task</h1> +<ul> + <li><a href="#intro">Introduction</a></li> + <li><a href="#task">Define the Custom Ant Task</a></li> + <li><a href="#params">Parameters</a></li> +</ul> + +<h2><a name="intro">Introduction</a></h2> +<p><a href="http://ant.apache.org/">Ant</a> is a powerful tool for automating +builds. FOray can be used from within Ant by using the custom FOray Ant +Task.</p> + +<h2><a name="task">Define the Custom Ant Task</a></h2> +<p>The first step toward using FOray from within your Ant scripts is to define +the custom task within the Ant script. +It is generally desirable to set define the task in a common task that is +accessible to the remainder of the script, such as an "init" task. +Defining the task simply tells Ant how to find the FOray Ant task class, and +the classes that are needed to run FOray. +In the example below, note that your location for ${foray.home} and the +classpath may be different.</p> + +<pre> + <property name="foray.home" location="D:/foray/trunk/foray/"/> + <taskdef name="foray" + classname="org.foray.app.ant.FOray"> + <classpath> + <fileset dir="${foray.home}/build" includes="*.jar"/> + <fileset dir="${foray.home}/lib" includes="*.jar"/> + </classpath> + </taskdef> +</pre> + +<h2><a name="params">Parameters</a></h2> +<p>After defining the task, you can use it within your script. +Simply use it like any other Ant task, giving it the parameters that it +needs to perform the desired processing.</p> + +<h3>Parameters specified as attributes</h3> +<table> +<tr> + <th>Attribute</th> + <th>Description</th> + <th>Required</th> +</tr> +<tr> + <td>fofile</td> + <td>The XSL-FO input file to be rendered</td> + <td>Yes<!--, if no fileset nested element is used--></td> +</tr> +<tr> + <td>outfile</td> + <td>Path to the output file.</td> + <td>Yes<!--, when fofile is used.--> + <!--(This attribute is not valid for filesets.)--></td> +</tr> +<tr> + <td>format</td> + <td>The mime-type of the desired output format. Possible values:<br/> +<code>application/pdf</code><br/> +<code>application/postscript</code><br/> +<code>application/vnd.mif</code><br/> +<code>application/rtf</code><br/> +<code>application/vnd.hp-PCL</code><br/> +<code>text/plain</code><br/> +<code>text/xml</code><br/> + </td> + <td>No, defaults to <code>application/pdf</code></td> +</tr> +<!--<tr> + <td>outdir</td> + <td>Output directory</td> + <td>Required if a fileset is used to specify the files to render; optional for fofile. (Can alternatively specify the full path in the fofile value.)</td> +</tr>--> +<!--<tr> + <td>force</td> + <td>Recreate target files, even if they are newer than their corresponding + source files. Note: This attribute is available in post-0.20.5 + versions (0.20.x nightly build and 1.0dev) only; target files are + always generated (i.e., force=true) in 0.20.5 release. + </td> + <td>No, default is <span class="codefrag">false</span></td> +</tr>--> +<!--<tr> + <td>basedir</td> + <td>Base directory to resolve relative references (e.g., graphics files) within the + FO document.</td> + <td>No, for single FO File entry, default is to use the location + of that FO file.</td> +</tr>--> +<!--<tr> + <td>relativebase</td> + <td>For fileset usage only. A value of <span class="codefrag">true</span> specifies using the location + of each .fo file as the base directory for resolving relative file references located + within that .fo file. A value of <span class="codefrag">false</span> specifies using the value of + basedir for all files within the fileset, or just the current working directory + if basedir is not specified.</td> + <td>No, default is <span class="codefrag">false</span>.</td> +</tr>--> +<tr> + <td>userconfig</td> + <td>User configuration file (same as the FOray "-c" command line option)</td> + <td>No</td> +</tr> +<tr> + <td>messagelevel</td> + <td>Logging level. Possible values: <code>error</code>, <code>warn</code>, + <code>info</code>, <code>verbose</code>>, <code>debug</code>></td> + <td>No. Default is <code>verbose</code>></td> +</tr> +<!--<tr> + <td>logFiles</td> + <td>Controls whether the names of the files that are processed are logged + (<span class="codefrag">true</span>) or not (<span class="codefrag">false</span>)</td> + <td>No, default is <span class="codefrag">true</span></td> +</tr>--> +</table> + +<!--<h3>Nested Elements</h3> +<table> +<tr> + <th>Attribute</th> + <th>Description</th> + <th>Required</th> +</tr> +<tr> + <td>fileset</td> + <td><a href="http://ant.apache.org/manual/CoreTypes/fileset.html">FileSets</a> + are used to specify multiple XSL-FO files to be rendered.</td> + <td>Yes, if no fofile attribute is supplied</td> +</tr> +</table>--> + +<h3>Examples</h3> +<p>The following example converts a single XSL-FO file to a PDF document:</p> +<pre> +<target name="generate-pdf" description="Generate a single PDF file"> + <foray format="application/pdf" + fofile="D:/fo/document.fo" + outfile="D:/pdf/document.pdf"/> +</target> +</pre> + +</body> +</html> Property changes on: trunk/foray/doc/web/app/using/anttask.html ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-13 21:07:44
|
Revision: 7008 Author: victormote Date: 2006-04-13 14:07:39 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7008&view=rev Log Message: ----------- Update sample config file to match new DTD location. Modified Paths: -------------- trunk/foray/config/sample-foray-config.xml Modified: trunk/foray/config/sample-foray-config.xml =================================================================== --- trunk/foray/config/sample-foray-config.xml 2006-04-13 20:57:17 UTC (rev 7007) +++ trunk/foray/config/sample-foray-config.xml 2006-04-13 21:07:39 UTC (rev 7008) @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE configuration SYSTEM "./schema/foray-config.dtd"> +<!DOCTYPE foray-config + PUBLIC "-//FOray//DTD FOray Configuration Book V0.1//EN" + "http://www.foray.org/dtds/0.1/en/foray-config.dtd"> <!-- This file is a sample FOray configuration file. For general information about FOray: @@ -8,7 +10,7 @@ http://www.foray.org/app/using/configuration.html --> -<configuration> +<foray-config> <!-- base-directory: Normally the base directory is the directory where the fo file is located. If you want to specify your own, uncomment this entry. @@ -108,6 +110,6 @@ </entry> --> -</configuration> +</foray-config> -<!-- Last Line of $RCSfile$ --> +<!-- Last Line of File. --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-13 20:57:27
|
Revision: 7007 Author: victormote Date: 2006-04-13 13:57:17 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7007&view=rev Log Message: ----------- Rename root element from "configuration" to "foray-config". Modified Paths: -------------- trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd Modified: trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd =================================================================== --- trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd 2006-04-13 20:36:43 UTC (rev 7006) +++ trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd 2006-04-13 20:57:17 UTC (rev 7007) @@ -8,7 +8,7 @@ http://www.foray.org/app/using/configuration.html --> -<!ELEMENT configuration (entry+) > +<!ELEMENT foray-config (entry+) > <!ELEMENT entry (key, value) > <!ELEMENT key (#PCDATA)> <!ELEMENT value (#PCDATA)> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-13 20:36:54
|
Revision: 7006 Author: victormote Date: 2006-04-13 13:36:43 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7006&view=rev Log Message: ----------- Move the configuration dtd from the config directory to the web site for availability. Added Paths: ----------- trunk/foray/doc/web/dtds/ trunk/foray/doc/web/dtds/0.1/ trunk/foray/doc/web/dtds/0.1/en/ trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd Removed Paths: ------------- trunk/foray/config/schema/foray-config.dtd Deleted: trunk/foray/config/schema/foray-config.dtd =================================================================== --- trunk/foray/config/schema/foray-config.dtd 2006-03-27 20:36:04 UTC (rev 7005) +++ trunk/foray/config/schema/foray-config.dtd 2006-04-13 20:36:43 UTC (rev 7006) @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- $Id$ --> - -<!-- This file is the XML DTD for a FOray configuration file. - For general information about FOray: - http://www.foray.org - For specific information about FOray configuration: - http://www.foray.org/app/using/configuration.html ---> - -<!ELEMENT configuration (entry+) > -<!ELEMENT entry (key, value) > -<!ELEMENT key (#PCDATA)> -<!ELEMENT value (#PCDATA)> - -<!-- Last Line of $RCSfile$ --> Copied: trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd (from rev 6864, trunk/foray/config/schema/foray-config.dtd) =================================================================== --- trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd (rev 0) +++ trunk/foray/doc/web/dtds/0.1/en/foray-config.dtd 2006-04-13 20:36:43 UTC (rev 7006) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- $Id$ --> + +<!-- This file is the XML DTD for a FOray configuration file. + For general information about FOray: + http://www.foray.org + For specific information about FOray configuration: + http://www.foray.org/app/using/configuration.html +--> + +<!ELEMENT configuration (entry+) > +<!ELEMENT entry (key, value) > +<!ELEMENT key (#PCDATA)> +<!ELEMENT value (#PCDATA)> + +<!-- Last Line of $RCSfile$ --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-27 20:36:21
|
Revision: 7005 Author: victormote Date: 2006-03-27 12:36:04 -0800 (Mon, 27 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7005&view=rev Log Message: ----------- Go ahead and get the new name fields. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 18:05:15 UTC (rev 7004) +++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-27 20:36:04 UTC (rev 7005) @@ -92,8 +92,8 @@ } fontComplexity = FOrayFont.FONT_SIMPLE; this.postscriptName = metricsFile.getPostscriptName(); - this.fontName = null; - this.fontName = null; + this.fontName = metricsFile.getFontName(); + this.familyName = metricsFile.getFontFamilyName(); capHeight = metricsFile.getCapHeight(); xHeight = metricsFile.getXHeight(); ascender = metricsFile.getLowerCaseAscent(); Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java 2006-03-26 18:05:15 UTC (rev 7004) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java 2006-03-27 20:36:04 UTC (rev 7005) @@ -96,15 +96,22 @@ public abstract void load() throws IOException ; /** - * Returns the Windows name of the font. - * - * @return The Windows name. + * Returns the name of the font. + * @return The name of this font. */ public String getFontName() { - return fontName; + return this.fontName; } /** + * Returns the name of the font's font-family. + * @return The name of the font's font-family. + */ + public String getFontFamilyName() { + return this.fontFamilyName; + } + + /** * Return the kerning table. */ public Kerning getKerning() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 18:05:22
|
Revision: 7004 Author: victormote Date: 2006-03-26 10:05:15 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7004&view=rev Log Message: ----------- Fix javadoc problems. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-26 17:54:34 UTC (rev 7003) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-26 18:05:15 UTC (rev 7004) @@ -99,79 +99,136 @@ return new RandomReaderArray(description, byteArray); } + /** + * {@inheritDoc} + */ public void seek(long pos) throws IOException { realReader.seek(pos); } + /** + * {@inheritDoc} + */ public long getFilePointer() throws IOException { return realReader.getFilePointer(); } + /** + * {@inheritDoc} + */ public long length() throws IOException { return realReader.length(); } + /** + * {@inheritDoc} + */ public void readFully(byte[] b) throws IOException { realReader.readFully(b); } + /** + * {@inheritDoc} + */ public void readFully(byte[] b, int off, int len) throws IOException { realReader.readFully(b, off, len); } + /** + * {@inheritDoc} + */ public int skipBytes(int n) throws IOException { return realReader.skipBytes(n); } + /** + * {@inheritDoc} + */ public boolean readBoolean() throws IOException { return realReader.readBoolean(); } + /** + * {@inheritDoc} + */ public byte readByte() throws IOException { return realReader.readByte(); } + /** + * {@inheritDoc} + */ public int readUnsignedByte() throws IOException { return realReader.readUnsignedByte(); } + /** + * {@inheritDoc} + */ public short readShort() throws IOException { return realReader.readShort(); } + /** + * {@inheritDoc} + */ public int readUnsignedShort() throws IOException { return realReader.readUnsignedShort(); } + /** + * {@inheritDoc} + */ public char readChar() throws IOException { return realReader.readChar(); } + /** + * {@inheritDoc} + */ public int readInt() throws IOException { return realReader.readInt(); } + /** + * {@inheritDoc} + */ public long readLong() throws IOException { return realReader.readLong(); } + /** + * {@inheritDoc} + */ public float readFloat() throws IOException { return realReader.readFloat(); } + /** + * {@inheritDoc} + */ public double readDouble() throws IOException { return realReader.readDouble(); } + /** + * {@inheritDoc} + */ public String readLine() throws IOException { this.lineNumber ++; return realReader.readLine(); } + /** + * {@inheritDoc} + */ public String readUTF() throws IOException { return realReader.readUTF(); } + /** + * {@inheritDoc} + */ public String getDescription() { return realReader.getDescription(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 17:54:47
|
Revision: 7003 Author: victormote Date: 2006-03-26 09:54:34 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7003&view=rev Log Message: ----------- Conform to aXSL changes suggested by Vincent Hennebert. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -74,6 +74,8 @@ */ fontComplexity = FOrayFont.FONT_COMPOSITE; this.postscriptName = stripWhiteSpace(ttf.getPostscriptName()); + this.fontName = ttf.getFontName(); + this.familyName = ttf.getFamilyName(); capHeight = ttf.getCapHeight(); xHeight = ttf.getXHeight(); ascender = ttf.getLowerCaseAscent(); Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -92,6 +92,8 @@ } fontComplexity = FOrayFont.FONT_SIMPLE; this.postscriptName = metricsFile.getPostscriptName(); + this.fontName = null; + this.fontName = null; capHeight = metricsFile.getCapHeight(); xHeight = metricsFile.getXHeight(); ascender = metricsFile.getLowerCaseAscent(); Modified: trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -49,6 +49,9 @@ * font-metrics file itself. */ protected String postscriptName = null; + protected String fontName = null; + protected String familyName = null; + protected Kerning kerning; /** expressed in 1/1000ths of a text space unit */ @@ -97,6 +100,20 @@ } /** + * {@inheritDoc} + */ + public String getFontName() { + return this.fontName; + } + + /** + * {@inheritDoc} + */ + public String getFamilyName() { + return this.familyName; + } + + /** * Returns the font's internal name, if given. Otherwise, returns * the configured name. * @return The name of the font. Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -192,7 +192,20 @@ /** * {@inheritDoc} */ + public String getFontName() { + if (this.lastMetrics == null) { + return null; + } + return this.lastMetrics.getFont().getFontName(); + } + + /** + * {@inheritDoc} + */ public String getPostscriptName() { + if (this.lastMetrics == null) { + return null; + } return this.lastMetrics.getFont().getPSName(); } @@ -240,7 +253,7 @@ } /** - * Returns the java name of the font's family. + * {@inheritDoc} */ public String getFamilyName() { if (this.lastMetrics == null) { Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFile.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -39,8 +39,9 @@ protected MetricsFileReader reader = null; // Header stuff - protected String windowsName; + protected String fontName; protected String postscriptName; + protected String fontFamilyName; /** Contains a 1 if the font is italic, otherwise a 0. */ protected short dfItalic; @@ -99,8 +100,8 @@ * * @return The Windows name. */ - public String getWindowsName() { - return windowsName; + public String getFontName() { + return fontName; } /** Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -728,11 +728,12 @@ } private void fullName() { - this.windowsName = getString(); + this.fontName = getString(); this.doneWithLine = true; } private void familyName() { + this.fontFamilyName = getString(); this.doneWithLine = true; } Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFilePFM.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -53,21 +53,83 @@ * Parses the header of the PFM file. */ private void loadHeader() throws IOException { - reader.seek(80); + reader.seek(0); + + /* Skip dfVersion. */ + reader.skipBytes(2); + + /* Skip dfSize. */ + reader.skipBytes(4); + + /* Skip dfCopyright. */ + reader.skipBytes(60); + + /* Skip dfType. */ + reader.skipBytes(2); + + /* Skip dfPoints. */ + reader.skipBytes(2); + + /* Skip dfVertRes. */ + reader.skipBytes(2); + + /* Skip dfHorizRes. */ + reader.skipBytes(2); + + /* Skip dfAscent. */ + reader.skipBytes(2); + + /* Skip dfInternalLeading. */ + reader.skipBytes(2); + + /* Skip dfExternalLeading. */ + reader.skipBytes(2); + dfItalic = (short) reader.readUnsignedByte(); - reader.skipBytes(2); + + /* Skip dfUnderline. */ + reader.skipBytes(1); + + /* Skip dfStrikeOut. */ + reader.skipBytes(1); + dfWeight = reader.readUnsignedShortLoHi(); + dfCharSet = reader.readUnsignedByte(); - reader.skipBytes(4); + + /* Skip dfPixWidth. */ + reader.skipBytes(2); + + /* Skip dfPixHeight. */ + reader.skipBytes(2); + dfPitchAndFamily = reader.readUnsignedByte(); + dfAvgWidth = reader.readUnsignedShortLoHi(); + dfMaxWidth = reader.readUnsignedShortLoHi(); + dfFirstChar = (char) reader.readUnsignedByte(); + dfLastChar = (char) reader.readUnsignedByte(); - reader.skipBytes(8); + + /* Skip dfDefaultChar. */ + reader.skipBytes(1); + + /* Skip dfBreakChar. */ + reader.skipBytes(1); + + /* Skip dfWidthBytes. */ + reader.skipBytes(2); + + /* Skip dfDevice. */ + reader.skipBytes(4); + long faceOffset = reader.readUnsignedIntLoHi(); + reader.seek(faceOffset); - windowsName = reader.readNullTerminatedString(); + + this.fontFamilyName = reader.readNullTerminatedString(); } /** Modified: trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java 2006-03-26 17:01:08 UTC (rev 7002) +++ trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java 2006-03-26 17:54:34 UTC (rev 7003) @@ -205,6 +205,10 @@ return nameTable.familyName; } + public String getFontName() { + return nameTable.fullName; + } + public int getCapHeight() { int capHeightToUse = 0; if (pcltTable == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 17:01:31
|
Revision: 7002 Author: victormote Date: 2006-03-26 09:01:08 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7002&view=rev Log Message: ----------- Conform to aXSL changes regarding method names, suggested by Vincent Hennebert. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontOutput.java trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPS.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFCIDFont.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFont.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -185,11 +185,6 @@ /** * {@inheritDoc} */ - public abstract String postscriptName() ; - - /** - * {@inheritDoc} - */ public abstract org.axsl.ps.Encoding getInternalEncoding() ; /** 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-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontUse.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -310,8 +310,8 @@ /** * {@inheritDoc} */ - public String postscriptName() { - String postScriptName = this.getFont().postscriptName(); + public String getPostscriptName() { + String postScriptName = this.getFont().getPostscriptName(); if (this.encoding == this.getFont().getInternalEncoding()) { return postScriptName; } Modified: trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -101,7 +101,7 @@ * the configured name. * @return The name of the font. */ - public String postscriptName() { + public String getPostscriptName() { if (postscriptName != null && ! postscriptName.equals("")) { return postscriptName; } @@ -289,7 +289,7 @@ FreeStandingFont anotherFSF = (FreeStandingFont) anotherObject; // Use the font name first - int compare = this.postscriptName().compareTo(anotherFSF.postscriptName()); + int compare = this.getPostscriptName().compareTo(anotherFSF.getPostscriptName()); if (compare != 0) { return compare; } Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -192,7 +192,7 @@ /** * {@inheritDoc} */ - public String postscriptName() { + public String getPostscriptName() { return this.lastMetrics.getFont().getPSName(); } @@ -317,8 +317,8 @@ } SystemFont anotherSystemFont = (SystemFont) anotherObject; // Use the font name first - int compare = this.postscriptName().compareTo(anotherSystemFont - .postscriptName()); + int compare = this.getPostscriptName().compareTo(anotherSystemFont + .getPostscriptName()); if (compare != 0) { return compare; } Modified: trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontOutput.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontOutput.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontOutput.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -103,7 +103,7 @@ embeddableFont = fsf.getRawFontFile(this.fontUse); } catch (IOException e) { this.getLogger().fatal("Failed to get contents for " - + fsf.postscriptName() + ": " + e.getMessage()); + + fsf.getPostscriptName() + ": " + e.getMessage()); } return embeddableFont; } Modified: trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPS.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPS.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-font/src/java/org/foray/font/output/FOrayFontPS.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -57,7 +57,7 @@ return pfb.getByteArray(PSFilter.PSDATA_ASCII_HEX); } catch (IOException e) { this.getLogger().fatal("Failed to get contents for " - + font.postscriptName() + ": " + e.getMessage()); + + font.getPostscriptName() + ": " + e.getMessage()); } return null; } Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFCIDFont.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFCIDFont.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFCIDFont.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -96,7 +96,7 @@ p.append(pdfID() + EOL); p.append("<< /Type /Font"); p.append(EOL + "/BaseFont /"); - p.append(font.postscriptName()); + p.append(font.getPostscriptName()); if (cidMap != null) { p.append(EOL + "/CIDToGIDMap "); p.append(cidMap.pdfReference()); Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -139,9 +139,10 @@ public String getBaseFont() { if (fsFont.getFont().isSubsettable()) { - return document.getNextFontSubsetTag() + "+" + fsFont.getFont().postscriptName(); + return document.getNextFontSubsetTag() + "+" + + fsFont.getFont().getPostscriptName(); } - return fsFont.getFont().postscriptName(); + return fsFont.getFont().getPostscriptName(); } /** Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -50,7 +50,8 @@ setData(fontFileStream); } catch (IOException ioe) { document.getLogger().error("Failed to embed font " - + font.getFont().postscriptName() + ": " + ioe.getMessage()); + + font.getFont().getPostscriptName() + ": " + + ioe.getMessage()); } } Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-03-26 16:32:54 UTC (rev 7001) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-03-26 17:01:08 UTC (rev 7002) @@ -332,7 +332,7 @@ continue; } PSFont psFont = getPSFont(fontUse); - write("/" + psFont.getName() + " /" + fontUse.postscriptName() + write("/" + psFont.getName() + " /" + fontUse.getPostscriptName() + " def"); } write("end def"); @@ -385,13 +385,13 @@ /* If using font's internal encoding, don't re-encode. */ continue; } - write("/" + font.postscriptName() + " findfont"); + write("/" + font.getPostscriptName() + " findfont"); write("dup length dict begin"); write(" {1 index /FID ne {def} {pop pop} ifelse} forall"); write(" /Encoding " + vector.getName() + " def"); write(" currentdict"); write("end"); - write("/" + fontUse.postscriptName() + " exch definefont pop"); + write("/" + fontUse.getPostscriptName() + " exch definefont pop"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 16:33:04
|
Revision: 7001 Author: victormote Date: 2006-03-26 08:32:54 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7001&view=rev Log Message: ----------- Conform to new aXSL requirements regarding new FontServer constructor allowing a font to be regisetered with byte arrays instead of URLs. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.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-26 16:13:53 UTC (rev 7000) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-26 16:32:54 UTC (rev 7001) @@ -695,22 +695,41 @@ metricsFileReader = new MetricsFileReader(this.getLogger(), metricsFileURL); } catch (IOException e) { - throw new FontException(e.getMessage()); + throw new FontException(e); } } new RegisteredFont(this, fontID, fontFileReader, metricsFileReader, collectionID, embed, systemName); } -// public void registerFont(String fontID, byte[] fontFileContents, -// byte[] metricsFileContents, String collectionID, String embed, -// String systemName) throws FontException { -// if (! isUsableFont(systemName, fontFileContents, metricsFileContents)) { -// return; -// } -// new RegisteredFont(this, fontID, fontFileURL, metricsFileURL, -// collectionID, embed, systemName); -// } + public void registerFont(String fontID, String fontFileDescription, + byte[] fontFileContents, String metricsFileDescription, + byte[] metricsFileContents, String collectionID, String embed, + String systemName) throws FontException { + if (! isUsableFont(systemName, fontFileContents, metricsFileContents)) { + return; + } + FontFileReader fontFileReader = null; + if (fontFileContents != null) { + try { + fontFileReader = new FontFileReader(this.logger, + fontFileDescription, fontFileContents); + } catch (IOException e) { + throw new FontException(e); + } + } + MetricsFileReader metricsFileReader = null; + if (metricsFileContents != null) { + try { + metricsFileReader = new MetricsFileReader(this.getLogger(), + metricsFileDescription, metricsFileContents); + } catch (IOException e) { + throw new FontException(e); + } + } + new RegisteredFont(this, fontID, fontFileReader, metricsFileReader, + collectionID, embed, systemName); + } private boolean isUsableFont(String systemName, Object fontFile, Object metricsFile) { Modified: trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java 2006-03-26 16:13:53 UTC (rev 7000) +++ trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java 2006-03-26 16:32:54 UTC (rev 7001) @@ -81,6 +81,13 @@ parseFontFileBasics(); } + public FontFileReader(Log logger, String description, byte[] byteArray) + throws IOException { + super(description, byteArray); + this.logger = logger; + parseFontFileBasics(); + } + /** * Parses the font file enough to find the font format and the file * format. This should only be run once. Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java 2006-03-26 16:13:53 UTC (rev 7000) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java 2006-03-26 16:32:54 UTC (rev 7001) @@ -68,6 +68,13 @@ parseMetricsFileBasics(); } + public MetricsFileReader(Log logger, String description, byte[] byteArray) + throws IOException { + super(description, byteArray); + this.logger = logger; + parseMetricsFileBasics(); + } + public MetricsFile metricsFileFactory() { switch (metricsFormat) { case METRICSFORMAT_PFM: { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 16:14:02
|
Revision: 7000 Author: victormote Date: 2006-03-26 08:13:53 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7000&view=rev Log Message: ----------- Store MetricsFileReader instead of URL in RegisteredFont, giving more flexibility on which implementation to use. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.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-26 16:05:32 UTC (rev 6999) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-26 16:13:53 UTC (rev 7000) @@ -26,6 +26,7 @@ import org.foray.common.Environment; import org.foray.font.format.FontFileReader; +import org.foray.font.format.MetricsFileReader; import org.foray.font.output.FOrayFontPDFFactory; import org.axsl.font.FontException; @@ -688,7 +689,16 @@ throw new FontException(e); } } - new RegisteredFont(this, fontID, fontFileReader, metricsFileURL, + MetricsFileReader metricsFileReader = null; + if (metricsFileURL != null) { + try { + metricsFileReader = new MetricsFileReader(this.getLogger(), + metricsFileURL); + } catch (IOException e) { + throw new FontException(e.getMessage()); + } + } + new RegisteredFont(this, fontID, fontFileReader, metricsFileReader, collectionID, embed, systemName); } Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 16:05:32 UTC (rev 6999) +++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 16:13:53 UTC (rev 7000) @@ -80,13 +80,7 @@ } public void parseFont() throws FontException { - MetricsFileReader reader = null; - try { - reader = new MetricsFileReader(this.getLogger(), - getRegisteredFont().getMetricsFile()); - } catch (IOException e) { - throw new FontException(e.getMessage()); - } + MetricsFileReader reader = this.getRegisteredFont().getMetricsFileReader(); metricsFile = reader.metricsFileFactory(); if (metricsFile == null) { throw new FontException("Unknown Metric Format: " 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-26 16:05:32 UTC (rev 6999) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2006-03-26 16:13:53 UTC (rev 7000) @@ -25,13 +25,12 @@ package org.foray.font; import org.foray.font.format.FontFileReader; +import org.foray.font.format.MetricsFileReader; import org.axsl.font.FontException; import org.apache.commons.logging.Log; -import java.net.URL; - /** * <p>Class representing a font that has been registered for use with FOray. * RegisteredFont is not really a Font, as it is not part of the Font hierarcy @@ -99,7 +98,7 @@ private int fontFormat = FOrayFont.FORMAT_UNKNOWN; /** URL to the font metrics file, if any. */ - private URL metricsFile = null; + private MetricsFileReader metricsFile = null; /** * Set to true if the configuration file has requested that this font be @@ -136,8 +135,9 @@ * Constructor useful for registering a Font that has not yet been created. */ public RegisteredFont(FOrayFontServer server, String fontName, - FontFileReader fontFileReader, URL metricsFileURL, String ttcName, - String embedding, String systemName) throws FontException { + FontFileReader fontFileReader, MetricsFileReader metricsFileURL, + String ttcName, String embedding, String systemName) + throws FontException { this.fontServer = server; this.configuredFontName = fontName; this.fontFileReader = fontFileReader; @@ -267,7 +267,7 @@ return this.systemName; } - protected URL getMetricsFile() { + protected MetricsFileReader getMetricsFileReader() { return metricsFile; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 16:05:40
|
Revision: 6999 Author: victormote Date: 2006-03-26 08:05:32 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6999&view=rev Log Message: ----------- Change MetricsFileReader constructor to take a logger instead of FontServer. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 16:00:45 UTC (rev 6998) +++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 16:05:32 UTC (rev 6999) @@ -82,7 +82,7 @@ public void parseFont() throws FontException { MetricsFileReader reader = null; try { - reader = new MetricsFileReader(getRegisteredFont().getFontServer(), + reader = new MetricsFileReader(this.getLogger(), getRegisteredFont().getMetricsFile()); } catch (IOException e) { throw new FontException(e.getMessage()); Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java 2006-03-26 16:00:45 UTC (rev 6998) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileReader.java 2006-03-26 16:05:32 UTC (rev 6999) @@ -25,7 +25,6 @@ package org.foray.font.format; import org.foray.common.RandomReader; -import org.foray.font.FOrayFontServer; import org.apache.commons.logging.Log; @@ -57,15 +56,15 @@ /** Set to one of the METRICSFORMAT... constants. */ private byte metricsFormat = METRICSFORMAT_UNKNOWN; - private FOrayFontServer fontServer; + private Log logger; /** * Constructor. * @param url The URL to the file for which this reader is created. */ - public MetricsFileReader(FOrayFontServer server, URL url) throws IOException { + public MetricsFileReader(Log logger, URL url) throws IOException { super(url); - this.fontServer = server; + this.logger = logger; parseMetricsFileBasics(); } @@ -123,12 +122,8 @@ return true; } - public FOrayFontServer getFontServer() { - return this.fontServer; - } - public Log getLogger() { - return getFontServer().getLogger(); + return this.logger; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 16:00:52
|
Revision: 6998 Author: victormote Date: 2006-03-26 08:00:45 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6998&view=rev Log Message: ----------- Rename instance variable for clarity. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java Modified: trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java 2006-03-26 15:57:36 UTC (rev 6997) +++ trunk/foray/foray-font/src/java/org/foray/font/FSTrueTypeFont.java 2006-03-26 16:00:45 UTC (rev 6998) @@ -60,7 +60,7 @@ } public void parseFont() { - TTFFile ttfFile = (TTFFile) getRegisteredFont().getReader().createFontFile(); + TTFFile ttfFile = (TTFFile) getRegisteredFont().getFontFileReader().createFontFile(); String fontName = getRegisteredFont().getTTCName(); try { this.ttf = ttfFile.getTTFFont(fontName); Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 15:57:36 UTC (rev 6997) +++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-26 16:00:45 UTC (rev 6998) @@ -65,12 +65,12 @@ if (this.type1File != null) { return this.type1File; } - FontFileReader reader = getRegisteredFont().getReader(); + FontFileReader reader = getRegisteredFont().getFontFileReader(); if (reader.getFileFormat() == FontFileReader.FILEFORMAT_TYPE1_PFB) { - this.type1File = new Type1PFBFile(getRegisteredFont().getReader()); + this.type1File = new Type1PFBFile(getRegisteredFont().getFontFileReader()); } else if (reader.getFileFormat() == FontFileReader.FILEFORMAT_TYPE1_PFA) { - this.type1File = new Type1PFAFile(getRegisteredFont().getReader()); + this.type1File = new Type1PFAFile(getRegisteredFont().getFontFileReader()); } else { String message = "Attempted to parse unknown Type1 font type.\n" + reader.getDescription(); 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-26 15:57:36 UTC (rev 6997) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2006-03-26 16:00:45 UTC (rev 6998) @@ -86,7 +86,7 @@ private String systemName = null; /** The FontFileReader used for parsing the actual font file. */ - private FontFileReader reader = null; + private FontFileReader fontFileReader = null; /** * For TrueType collections, ttcName specifies the name of the font within @@ -140,7 +140,7 @@ String embedding, String systemName) throws FontException { this.fontServer = server; this.configuredFontName = fontName; - this.reader = fontFileReader; + this.fontFileReader = fontFileReader; this.ttcName = ttcName; this.metricsFile = metricsFileURL; if (embedding == null) { @@ -217,12 +217,12 @@ } private FreeStandingFont createFSFont() throws FontException { - if (this.reader == null) { + if (this.fontFileReader == null) { /* The assumption here is that we have a metrics file for this * font, but not a font file, therefore it is Type 1. */ this.fontFormat = FOrayFont.FORMAT_TYPE1; } else { - this.fontFormat = reader.getFontFormat(); + this.fontFormat = fontFileReader.getFontFormat(); } switch (this.fontFormat) { case FOrayFont.FORMAT_TYPE1: { @@ -307,12 +307,12 @@ /** * @return Returns the reader. */ - public FontFileReader getReader() { - return reader; + public FontFileReader getFontFileReader() { + return fontFileReader; } public boolean hasFreeStandingFont() { - if (this.reader != null) { + if (this.fontFileReader != null) { return true; } if (this.metricsFile != null) { @@ -331,8 +331,4 @@ return true; } - public FontFileReader getFontFileReader() { - return this.reader; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 15:57:48
|
Revision: 6997 Author: victormote Date: 2006-03-26 07:57:36 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6997&view=rev Log Message: ----------- Change RegisteredFont constructor to take a FontFileReader instead of a URL, giving us flexibility to use other implementations. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java trunk/foray/foray-font/src/java/org/foray/font/SystemFont.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-26 15:37:36 UTC (rev 6996) +++ trunk/foray/foray-font/src/java/org/foray/font/FOrayFontServer.java 2006-03-26 15:57:36 UTC (rev 6997) @@ -25,6 +25,7 @@ package org.foray.font; import org.foray.common.Environment; +import org.foray.font.format.FontFileReader; import org.foray.font.output.FOrayFontPDFFactory; import org.axsl.font.FontException; @@ -676,24 +677,50 @@ public void registerFont(String fontID, URL fontFileURL, URL metricsFileURL, String collectionID, String embed, String systemName) throws FontException { + if (! isUsableFont(systemName, fontFileURL, metricsFileURL)) { + return; + } + FontFileReader fontFileReader = null; + if (fontFileURL != null) { + try { + fontFileReader = new FontFileReader(this.logger, fontFileURL); + } catch (IOException e) { + throw new FontException(e); + } + } + new RegisteredFont(this, fontID, fontFileReader, metricsFileURL, + collectionID, embed, systemName); + } + +// public void registerFont(String fontID, byte[] fontFileContents, +// byte[] metricsFileContents, String collectionID, String embed, +// String systemName) throws FontException { +// if (! isUsableFont(systemName, fontFileContents, metricsFileContents)) { +// return; +// } +// new RegisteredFont(this, fontID, fontFileURL, metricsFileURL, +// collectionID, embed, systemName); +// } + + private boolean isUsableFont(String systemName, Object fontFile, + Object metricsFile) { 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; + return false; } } 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; + if (fontFile == null + && metricsFile == null) { + return false; } } - new RegisteredFont(this, fontID, fontFileURL, metricsFileURL, - collectionID, embed, systemName); + return true; } public RegisteredFont getRegisteredFont(String name) { Modified: trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2006-03-26 15:37:36 UTC (rev 6996) +++ trunk/foray/foray-font/src/java/org/foray/font/FreeStandingFont.java 2006-03-26 15:57:36 UTC (rev 6997) @@ -25,6 +25,7 @@ package org.foray.font; import org.foray.font.charset.CharSet; +import org.foray.font.format.FontFileReader; import org.foray.font.format.Kerning; import org.foray.ps.encode.Encoding; @@ -32,7 +33,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URL; /** * Base class for all fonts that are registered independently of the operating @@ -194,7 +194,7 @@ return false; } /* If the fontFile exists, embed it. */ - if (getRegisteredFont().getFontFile() != null) { + if (getRegisteredFont().getFontFileReader() != null) { return true; } return false; @@ -220,17 +220,16 @@ } protected InputStream getFontInputStream() { - URL url = getRegisteredFont().getFontFile(); - if (url == null) { - this.getLogger().fatal("Unable to open font file or " - + "resource for embedding."); + FontFileReader fontFileReader = this.registeredFont.getFontFileReader(); + if ( fontFileReader == null) { return null; } InputStream instream = null; try { - instream = url.openStream(); + instream = fontFileReader.getInputStream(); } catch (IOException e1) { - this.getLogger().fatal("Unable to embed: " + url.getFile()); + this.getLogger().fatal("Unable to embed: " + + fontFileReader.getDescription()); } return instream; } 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-26 15:37:36 UTC (rev 6996) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2006-03-26 15:57:36 UTC (rev 6997) @@ -85,9 +85,6 @@ * configuration file. */ private String systemName = null; - /** URL to the actual font file, if any. */ - private URL fontFile = null; - /** The FontFileReader used for parsing the actual font file. */ private FontFileReader reader = null; @@ -137,14 +134,13 @@ /** * Constructor useful for registering a Font that has not yet been created. - * @param fontEmbedPath URL to the physical font file. */ public RegisteredFont(FOrayFontServer server, String fontName, - URL fontEmbedPath, URL metricsFileURL, String ttcName, + FontFileReader fontFileReader, URL metricsFileURL, String ttcName, String embedding, String systemName) throws FontException { this.fontServer = server; this.configuredFontName = fontName; - this.fontFile = fontEmbedPath; + this.reader = fontFileReader; this.ttcName = ttcName; this.metricsFile = metricsFileURL; if (embedding == null) { @@ -176,10 +172,6 @@ } try { - if (this.fontFile != null) { - this.reader = new FontFileReader(this.getLogger(), - this.fontFile); - } this.fsFont = createFSFont(); if (this.fsFont == null) { this.fsFont = getFontServer().getDefaultFreeStandingFont() @@ -279,10 +271,6 @@ return metricsFile; } - protected URL getFontFile() { - return fontFile; - } - protected String getTTCName() { return ttcName; } @@ -324,7 +312,7 @@ } public boolean hasFreeStandingFont() { - if (this.fontFile != null) { + if (this.reader != null) { return true; } if (this.metricsFile != null) { @@ -343,4 +331,8 @@ return true; } + public FontFileReader getFontFileReader() { + return this.reader; + } + } Modified: trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2006-03-26 15:37:36 UTC (rev 6996) +++ trunk/foray/foray-font/src/java/org/foray/font/SystemFont.java 2006-03-26 15:57:36 UTC (rev 6997) @@ -25,6 +25,7 @@ package org.foray.font; import org.foray.font.charset.CharSet; +import org.foray.font.format.FontFileReader; import org.foray.font.format.Kerning; import org.axsl.font.FontException; @@ -39,7 +40,6 @@ import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.InputStream; -import java.net.URL; /** * Handles interface of system (AWT) fonts to the client application. @@ -365,8 +365,8 @@ * create Font to draw. */ public java.awt.Font createFont() throws FontException { - if (this.registeredFont.getFontFile() != null) { - return createFontFromInput(this.registeredFont.getFontFile()); + if (this.registeredFont.getFontFileReader() != null) { + return createFontFromInput(); } /* Since we are using the font name instead of the font-family name, * the font-style should be PLAIN. */ @@ -376,11 +376,10 @@ /** * Creates a java.awt.Font instance from a URL. - * @param fontURL The URL containing the file from which the Font should be - * created. * @return The Font created from fontURL. */ - private Font createFontFromInput(URL fontURL) throws FontException { + private Font createFontFromInput() + throws FontException { FreeStandingFont fsf = this.getRegisteredFont().getFreeStandingFont(); if (fsf == null) { return null; @@ -390,23 +389,19 @@ /* An AWT font cannot be created from this font file. */ return null; } + FontFileReader fontFileReader = this.registeredFont.getFontFileReader(); Font newFont = null; if (getLogger().isDebugEnabled()) { - getLogger().debug("Create AWT font from URL: \n " - + fontURL.toExternalForm()); + getLogger().debug("Create AWT font from: \n " + + fontFileReader.getDescription()); } InputStream fontStream = null; try { - fontStream = fontURL.openStream(); - } catch (IOException e) { - throw new FontException("Error opening input stream for: \n " - + fontURL.toExternalForm(), e); - } - try { + fontStream = fontFileReader.getInputStream(); newFont = Font.createFont(fontFormat, fontStream); } catch (IOException e) { throw new FontException("Error reading input stream for: \n " - + fontURL.toExternalForm(), e); + + fontFileReader.getDescription(), e); } catch(FontFormatException ffe) { /* Ignore this. This just means that the fontFormat is not one that * java recognizes, probably because the runtime is lower than This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 15:37:42
|
Revision: 6996 Author: victormote Date: 2006-03-26 07:37:36 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6996&view=rev Log Message: ----------- Add method allowing RandomReader to return an InputStream. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java 2006-03-26 14:55:59 UTC (rev 6995) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java 2006-03-26 15:37:36 UTC (rev 6996) @@ -26,6 +26,7 @@ import java.io.DataInput; import java.io.IOException; +import java.io.InputStream; import java.io.RandomAccessFile; /** @@ -61,4 +62,10 @@ */ String getDescription(); + /** + * Return the input as an InputStream. + * @return An InputStream containing the input contents. + */ + InputStream getInputStream() throws IOException ; + } Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-26 14:55:59 UTC (rev 6995) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-26 15:37:36 UTC (rev 6996) @@ -27,6 +27,7 @@ import java.io.EOFException; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.net.URL; /** @@ -660,4 +661,11 @@ } + /** + * {@inheritDoc} + */ + public InputStream getInputStream() throws IOException { + return this.realReader.getInputStream(); + } + } Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2006-03-26 14:55:59 UTC (rev 6995) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2006-03-26 15:37:36 UTC (rev 6996) @@ -24,9 +24,11 @@ package org.foray.common; +import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.EOFException; import java.io.IOException; +import java.io.InputStream; /** * Implementation of RandomInput that uses a byte array. @@ -48,22 +50,37 @@ this.byteArray = byteArray; } + /** + * {@inheritDoc} + */ public void seek(long offset) throws IOException { arrayIndex = (int) offset; } + /** + * {@inheritDoc} + */ public int skipBytes(int add) throws IOException { return arrayIndex += add; } + /** + * {@inheritDoc} + */ public long length() throws IOException { return this.byteArray.length; } + /** + * {@inheritDoc} + */ public byte readByte() throws IOException { return this.byteArray[arrayIndex]; } + /** + * {@inheritDoc} + */ public final int readUnsignedByte() throws IOException { if (this.arrayIndex >= this.byteArray.length) { throw new EOFException(); @@ -73,31 +90,49 @@ return c; } + /** + * {@inheritDoc} + */ public final short readShort() throws IOException { int byte1 = readUnsignedByte(); int byte2 = readUnsignedByte(); return (short)((byte1 << 8) + (byte2 << 0)); } + /** + * {@inheritDoc} + */ public final int readUnsignedShort() throws IOException { int byte1 = readUnsignedByte(); int byte2 = readUnsignedByte(); return (byte1 << 8) + (byte2 << 0); } + /** + * {@inheritDoc} + */ public final double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); } + /** + * {@inheritDoc} + */ public final boolean readBoolean() throws IOException { int ch = readUnsignedByte(); return (ch != 0); } + /** + * {@inheritDoc} + */ public final void readFully(byte[] b) throws IOException { readFully(b, 0, b.length); } + /** + * {@inheritDoc} + */ public final void readFully(byte[] b, int off, int len) throws IOException { boolean eofDetected = false; if (this.arrayIndex + len >= this.byteArray.length) { @@ -111,24 +146,39 @@ } } + /** + * {@inheritDoc} + */ public final long readLong() throws IOException { return ((long) (readInt()) << 32) + (readInt() & 0xFFFFFFFFL); } + /** + * {@inheritDoc} + */ public final float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); } + /** + * {@inheritDoc} + */ public final char readChar() throws IOException { int byte1 = this.readUnsignedByte(); int byte2 = this.readUnsignedByte(); return (char)((byte1 << 8) + (byte2 << 0)); } + /** + * {@inheritDoc} + */ public final String readUTF() throws IOException { return DataInputStream.readUTF(this); } + /** + * {@inheritDoc} + */ public final int readInt() throws IOException { int byte1 = this.readUnsignedByte(); int byte2 = this.readUnsignedByte(); @@ -137,6 +187,9 @@ return ((byte1 << 24) + (byte2 << 16) + (byte3 << 8) + (byte4 << 0)); } + /** + * {@inheritDoc} + */ public final String readLine() throws IOException { StringBuffer input = new StringBuffer(); int byteRead = -1; @@ -169,12 +222,25 @@ return input.toString(); } + /** + * {@inheritDoc} + */ public long getFilePointer() throws IOException { return this.arrayIndex; } + /** + * {@inheritDoc} + */ public String getDescription() { return this.description; } + /** + * {@inheritDoc} + */ + public InputStream getInputStream() { + return new ByteArrayInputStream(this.byteArray); + } + } Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java 2006-03-26 14:55:59 UTC (rev 6995) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java 2006-03-26 15:37:36 UTC (rev 6996) @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.io.RandomAccessFile; import java.net.URL; @@ -37,6 +38,8 @@ * and used by RandomReader. */ class RandomReaderRAFile implements RandomInput { + + private URL url; private File file = null; private RandomAccessFile raFile = null; @@ -44,6 +47,7 @@ * Constructor. */ protected RandomReaderRAFile(URL url) throws IOException { + this.url = url; this.file = new File(url.getFile()); if (file == null) { return; @@ -128,4 +132,11 @@ return this.file.getPath(); } + /** + * {@inheritDoc} + */ + public InputStream getInputStream() throws IOException { + return this.url.openStream(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 14:56:05
|
Revision: 6995 Author: victormote Date: 2006-03-26 06:55:59 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6995&view=rev Log Message: ----------- Conform to FontFileReader changes. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 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-26 14:54:08 UTC (rev 6994) +++ trunk/foray/foray-font/src/java/org/foray/font/RegisteredFont.java 2006-03-26 14:55:59 UTC (rev 6995) @@ -177,7 +177,8 @@ try { if (this.fontFile != null) { - this.reader = new FontFileReader(fontServer, this.fontFile); + this.reader = new FontFileReader(this.getLogger(), + this.fontFile); } this.fsFont = createFSFont(); if (this.fsFont == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-26 14:54:14
|
Revision: 6994 Author: victormote Date: 2006-03-26 06:54:08 -0800 (Sun, 26 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6994&view=rev Log Message: ----------- Remove references to FontServer, just get a Log. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java Modified: trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java 2006-03-25 17:44:45 UTC (rev 6993) +++ trunk/foray/foray-font/src/java/org/foray/font/format/FontFileReader.java 2006-03-26 14:54:08 UTC (rev 6994) @@ -25,7 +25,6 @@ package org.foray.font.format; import org.foray.common.RandomReader; -import org.foray.font.FOrayFontServer; import org.foray.font.FOrayFont; import org.apache.commons.logging.Log; @@ -67,8 +66,6 @@ /** Set to one of the FILEFORMAT constants. */ private byte fileFormat = FILEFORMAT_UNKNOWN; - private FOrayFontServer fontServer; - private Log logger; /** The "child" FontFile instance that knows how to read this file. */ @@ -78,16 +75,6 @@ * instance for this. */ private boolean fontFileCreated = false; - /** - * Constructor - * @param url The URL to the file for which this reader is created. - */ - public FontFileReader(FOrayFontServer server, URL url) throws IOException { - super(url); - this.fontServer = server; - parseFontFileBasics(); - } - public FontFileReader(Log logger, URL url) throws IOException { super(url); this.logger = logger; @@ -173,10 +160,7 @@ } public Log getLogger() { - if (this.logger != null) { - return logger; - } - return this.fontServer.getLogger(); + return this.logger; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-25 17:44:50
|
Revision: 6993 Author: victormote Date: 2006-03-25 09:44:45 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6993&view=rev Log Message: ----------- Add constructor and logic that allows a RandomReader to be be created with a byte array. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-25 17:36:04 UTC (rev 6992) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-25 17:44:45 UTC (rev 6993) @@ -69,18 +69,35 @@ int lineNumber = 0; /** - * Basic constructor. + * Constructor suitable for a local file. * @param url The URL to the file that will be read. */ public RandomReader(URL url) throws IOException { this.realReader = randomInputFactory(url); } + /** + * Constructor suitable for a file or stream that has already been read + * into memory. + * @param description A description of the contents of + * <code>byteArray</code>. + * @param byteArray The byte array that should be read. + */ + public RandomReader(String description, byte[] byteArray) { + this.realReader = randomInputFactory(description, byteArray); + } + private RandomInput randomInputFactory(URL url) throws IOException{ /* Right now, there is only one available implementation. */ return new RandomReaderRAFile(url); } + private RandomInput randomInputFactory(String description, + byte[] byteArray) { + /* Right now, there is only one available implementation. */ + return new RandomReaderArray(description, byteArray); + } + public void seek(long pos) throws IOException { realReader.seek(pos); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-25 17:36:27
|
Revision: 6992 Author: victormote Date: 2006-03-25 09:36:04 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6992&view=rev Log Message: ----------- 1. Rename getURL to getDescription to make it more generic for the encapsulated item. 2. Remove URL from the wrapper. 3. Add a description instance variable to the RandomReaderArray class. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -55,4 +55,10 @@ */ long length() throws IOException; + /** + * Provides some kind of description of this item, useful in user messages. + * @return A description of the contents of this item. + */ + String getDescription(); + } Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReader.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -62,9 +62,6 @@ CHAR_ENCODE_UTF_16 }; - /** The URL of the underlying file */ - private URL url; - /** The RandomInput implementation that does the real work. */ RandomInput realReader; @@ -76,7 +73,6 @@ * @param url The URL to the file that will be read. */ public RandomReader(URL url) throws IOException { - this.url = url; this.realReader = randomInputFactory(url); } @@ -158,8 +154,8 @@ return realReader.readUTF(); } - public URL getURL() { - return url; + public String getDescription() { + return realReader.getDescription(); } /** Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -29,19 +29,22 @@ import java.io.IOException; /** - * Implementation of RandomInput that uses a RandomAccessFile to do the - * io work. Class has package-visibility only as it should only be instantiated - * and used by RandomReader. + * Implementation of RandomInput that uses a byte array. */ class RandomReaderArray implements RandomInput { - private byte[] byteArray = null; + private String description; + private byte[] byteArray; private int arrayIndex = 0; /** * Constructor. + * @param description A description of the source of this byte array, + * useful in user messages. + * @byteArray The byte array which will be "read" by this reader. */ - protected RandomReaderArray(byte[] byteArray) { + protected RandomReaderArray(String description, byte[] byteArray) { + this.description = description; this.byteArray = byteArray; } @@ -170,4 +173,8 @@ return this.arrayIndex; } + public String getDescription() { + return this.description; + } + } Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderRAFile.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -124,4 +124,8 @@ return raFile.getFilePointer(); } + public String getDescription() { + return this.file.getPath(); + } + } Modified: trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-font/src/java/org/foray/font/FSType1Font.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -73,7 +73,7 @@ this.type1File = new Type1PFAFile(getRegisteredFont().getReader()); } else { String message = "Attempted to parse unknown Type1 font type.\n" - + reader.getURL().getFile(); + + reader.getDescription(); this.getLogger().fatal(message); } return this.type1File; @@ -90,11 +90,11 @@ metricsFile = reader.metricsFileFactory(); if (metricsFile == null) { throw new FontException("Unknown Metric Format: " - + reader.getURL()); + + reader.getDescription()); } if (metricsFile.getInternalEncoding() == null) { throw new FontException("Unusable Internal Encoding: " - + reader.getURL()); + + reader.getDescription()); } fontComplexity = FOrayFont.FONT_SIMPLE; this.postscriptName = metricsFile.getPostscriptName(); Modified: trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-font/src/java/org/foray/font/format/MetricsFileAFM.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -1044,7 +1044,7 @@ } protected void logError(String message) { - getLogger().error(this.reader.getURL().getFile() + ": " + message); + getLogger().error(this.reader.getDescription() + ": " + message); } /** @@ -1080,7 +1080,7 @@ || charIndex > this.extentTable.length) { getLogger().error("Cannot encode glyph name: " + this.glyphName + "\n" - + " AFM: " + this.reader.getURL() + "\n" + + " AFM: " + this.reader.getDescription() + "\n" + " line: " + this.currentLineNumber); return; } Modified: trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2006-03-25 17:04:25 UTC (rev 6991) +++ trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2006-03-25 17:36:04 UTC (rev 6992) @@ -102,7 +102,7 @@ computeSegmentBoundaries(); } catch (IOException e) { reader.getLogger().error("Unable to parse basics of Type 1 file:\n" - + " " + reader.getURL().toString()); + + " " + reader.getDescription().toString()); } basicsParsed = true; } @@ -125,17 +125,17 @@ this.interpreter.process(); } catch (PSException e1) { this.reader.getLogger().error("PostScript interpreter failed:\n" - + " " + reader.getURL().toString()); + + " " + reader.getDescription().toString()); } this.fontBBox = parseFontBBox(); if (this.fontBBox == null) { this.reader.getLogger().error("Unable to parse Font BBox:\n" - + " " + reader.getURL().toString()); + + " " + reader.getDescription().toString()); } this.stemV = parseStemV(); if (this.stemV == 0) { this.reader.getLogger().error("Unable to parse StemV:\n" - + " " + reader.getURL().toString()); + + " " + reader.getDescription().toString()); } detailParsed = true; this.interpreter = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-25 17:04:34
|
Revision: 6991 Author: victormote Date: 2006-03-25 09:04:25 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6991&view=rev Log Message: ----------- Add RandomReader implementation that uses a byte array instead of a File. Added Paths: ----------- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java Added: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java (rev 0) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java 2006-03-25 17:04:25 UTC (rev 6991) @@ -0,0 +1,173 @@ +/* + * 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.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; + +/** + * Implementation of RandomInput that uses a RandomAccessFile to do the + * io work. Class has package-visibility only as it should only be instantiated + * and used by RandomReader. + */ +class RandomReaderArray implements RandomInput { + + private byte[] byteArray = null; + private int arrayIndex = 0; + + /** + * Constructor. + */ + protected RandomReaderArray(byte[] byteArray) { + this.byteArray = byteArray; + } + + public void seek(long offset) throws IOException { + arrayIndex = (int) offset; + } + + public int skipBytes(int add) throws IOException { + return arrayIndex += add; + } + + public long length() throws IOException { + return this.byteArray.length; + } + + public byte readByte() throws IOException { + return this.byteArray[arrayIndex]; + } + + public final int readUnsignedByte() throws IOException { + if (this.arrayIndex >= this.byteArray.length) { + throw new EOFException(); + } + char c = (char) this.byteArray[this.arrayIndex]; + this.arrayIndex ++; + return c; + } + + public final short readShort() throws IOException { + int byte1 = readUnsignedByte(); + int byte2 = readUnsignedByte(); + return (short)((byte1 << 8) + (byte2 << 0)); + } + + public final int readUnsignedShort() throws IOException { + int byte1 = readUnsignedByte(); + int byte2 = readUnsignedByte(); + return (byte1 << 8) + (byte2 << 0); + } + + public final double readDouble() throws IOException { + return Double.longBitsToDouble(readLong()); + } + + public final boolean readBoolean() throws IOException { + int ch = readUnsignedByte(); + return (ch != 0); + } + + public final void readFully(byte[] b) throws IOException { + readFully(b, 0, b.length); + } + + public final void readFully(byte[] b, int off, int len) throws IOException { + boolean eofDetected = false; + if (this.arrayIndex + len >= this.byteArray.length) { + eofDetected = true; + len = this.byteArray.length - this.arrayIndex; + } + System.arraycopy(this.byteArray, this.arrayIndex, b, off, len); + this.arrayIndex += len; + if (eofDetected) { + throw new EOFException(); + } + } + + public final long readLong() throws IOException { + return ((long) (readInt()) << 32) + (readInt() & 0xFFFFFFFFL); + } + + public final float readFloat() throws IOException { + return Float.intBitsToFloat(readInt()); + } + + public final char readChar() throws IOException { + int byte1 = this.readUnsignedByte(); + int byte2 = this.readUnsignedByte(); + return (char)((byte1 << 8) + (byte2 << 0)); + } + + public final String readUTF() throws IOException { + return DataInputStream.readUTF(this); + } + + public final int readInt() throws IOException { + int byte1 = this.readUnsignedByte(); + int byte2 = this.readUnsignedByte(); + int byte3 = this.readUnsignedByte(); + int byte4 = this.readUnsignedByte(); + return ((byte1 << 24) + (byte2 << 16) + (byte3 << 8) + (byte4 << 0)); + } + + public final String readLine() throws IOException { + StringBuffer input = new StringBuffer(); + int byteRead = -1; + boolean eol = false; + + while (!eol) { + switch (byteRead = this.readUnsignedByte()) { + case -1: + case '\n': { + eol = true; + break; + } + case '\r': { + eol = true; + long cur = getFilePointer(); + if ((this.readUnsignedByte()) != '\n') { + seek(cur); + } + break; + } + default: { + input.append((char)byteRead); + break; + } + } + } + if ((byteRead == -1) && (input.length() == 0)) { + return null; + } + return input.toString(); + } + + public long getFilePointer() throws IOException { + return this.arrayIndex; + } + +} Property changes on: trunk/foray/foray-common/src/java/org/foray/common/RandomReaderArray.java ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-25 17:03:42
|
Revision: 6990 Author: victormote Date: 2006-03-25 09:03:30 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6990&view=rev Log Message: ----------- Javadoc improvements. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java Modified: trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java 2006-03-25 14:54:55 UTC (rev 6989) +++ trunk/foray/foray-common/src/java/org/foray/common/RandomInput.java 2006-03-25 17:03:30 UTC (rev 6990) @@ -26,6 +26,7 @@ import java.io.DataInput; import java.io.IOException; +import java.io.RandomAccessFile; /** * This interface extends DataInput by adding methods for random access @@ -39,10 +40,19 @@ */ public interface RandomInput extends DataInput { + /** + * Same function as {@link RandomAccessFile#seek(long)}. + */ void seek(long pos) throws IOException; + /** + * Same function as {@link RandomAccessFile#getFilePointer()}. + */ long getFilePointer() throws IOException; + /** + * Same function as {@link RandomAccessFile#length()}. + */ long length() throws IOException; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |