[FOray-commit] SF.net SVN: foray:[10789] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2009-04-27 16:25:06
|
Revision: 10789
http://foray.svn.sourceforge.net/foray/?rev=10789&view=rev
Author: victormote
Date: 2009-04-27 16:24:56 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
Use new aXSL interfaces to reduce a dependency on FOrayPS.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsInterpreter4a.java
Added Paths:
-----------
trunk/foray/foray-ps/src/java/org/foray/ps/PsFontDirectory4a.java
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 2009-04-27 15:50:00 UTC (rev 10788)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2009-04-27 16:24:56 UTC (rev 10789)
@@ -29,12 +29,10 @@
package org.foray.font.format;
import org.foray.common.WKConstants;
-import org.foray.ps.PsDictionary;
import org.foray.ps.PsInterpreter4a;
-import org.foray.ps.PsObject;
-import org.foray.ps.type1.PsFontDictionary;
import org.axsl.ps.PsFilterType;
+import org.axsl.ps.PsFontDirectory;
import org.axsl.ps.PsInput;
import org.axsl.ps.PsInterpreterException;
import org.axsl.ps.Type1FontDictionary;
@@ -44,8 +42,7 @@
import org.apache.commons.logging.Log;
import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.List;
/**
* Abstract superclass for the various Postscript Type 1 font file formats.
@@ -149,17 +146,12 @@
+ "\n " + this.getReader().getDescription().toString());
}
- final PsDictionary fontDirectory = interpreter.getFontDirectory();
+ final PsFontDirectory fontDirectory = interpreter.getFontDirectory();
if (fontDirectory != null) {
- final Map<PsObject, PsObject> fontMap = fontDirectory.getMap();
- final Iterator<PsObject> iter = fontMap.keySet().iterator();
+ final List<? extends Type1FontDictionary> fonts = fontDirectory.getFonts();
// There should only be one font in the font directory
- if (iter.hasNext()) {
- final PsObject psObject = fontMap.get(iter.next());
- if (psObject instanceof PsDictionary) {
- final PsDictionary dictionary = (PsDictionary) psObject;
- this.fontDictionary = new PsFontDictionary(dictionary);
- }
+ if (fonts.size() > 0) {
+ this.fontDictionary = fonts.get(0);
}
}
Added: trunk/foray/foray-ps/src/java/org/foray/ps/PsFontDirectory4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsFontDirectory4a.java (rev 0)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsFontDirectory4a.java 2009-04-27 16:24:56 UTC (rev 10789)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2009 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps;
+
+import org.foray.ps.type1.PsFontDictionary;
+
+import org.axsl.ps.PsFontDirectory;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A /FontDirectory dictionary.
+ */
+public class PsFontDirectory4a extends PsDictionaryWrapper implements PsFontDirectory {
+
+ /**
+ * Constructor.
+ * @param dictionary The wrapped dictionary instance.
+ */
+ public PsFontDirectory4a(final PsDictionary dictionary) {
+ super(dictionary);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PsFontDictionary> getFonts() {
+ final List<PsFontDictionary> returnList = new ArrayList<PsFontDictionary>();
+ final Map<PsObject, PsObject> fontMap = getWrappedDictionary().getMap();
+ final Iterator<PsObject> iter = fontMap.keySet().iterator();
+ if (iter.hasNext()) {
+ final PsObject psObject = fontMap.get(iter.next());
+ if (psObject instanceof PsDictionary) {
+ final PsDictionary dictionary = (PsDictionary) psObject;
+ final PsFontDictionary fontDictionary = new PsFontDictionary(dictionary);
+ returnList.add(fontDictionary);
+ }
+ }
+ return returnList;
+ }
+
+}
Property changes on: trunk/foray/foray-ps/src/java/org/foray/ps/PsFontDirectory4a.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsInterpreter4a.java 2009-04-27 15:50:00 UTC (rev 10788)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsInterpreter4a.java 2009-04-27 16:24:56 UTC (rev 10789)
@@ -815,12 +815,13 @@
* Returns the font dictionary.
* @return The font dictionary.
*/
- public PsDictionary getFontDirectory() {
+ public PsFontDirectory4a getFontDirectory() {
final PsDictionary systemDict = getSystemDict();
if (systemDict == null) {
return null;
}
- return (PsDictionary) systemDict.getItem("FontDirectory");
+ final PsDictionary dictionary = (PsDictionary) systemDict.getItem("FontDirectory");
+ return new PsFontDirectory4a(dictionary);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|