aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2012-02-22 03:36:18 +0100
committerSven Gothel <sgothel@jausoft.com>2012-02-22 03:36:18 +0100
commitd2d3720d940566608ea14b14cb4aeb5890ff21e1 (patch)
tree33053f481680040d626030585eda207f85d88149 /src/jogl/classes
parent4f175a49e682e0c98d137337a231617b5ae1f9dc (diff)
FontSet (graph): get*(..) throws IOException - Proper passing and handling of IOException
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/FontSet.java6
-rw-r--r--src/jogl/classes/jogamp/graph/font/JavaFontLoader.java10
-rw-r--r--src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java11
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java16
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java2
5 files changed, 26 insertions, 19 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/FontSet.java b/src/jogl/classes/com/jogamp/graph/font/FontSet.java
index 0cee81124..d376922ab 100644
--- a/src/jogl/classes/com/jogamp/graph/font/FontSet.java
+++ b/src/jogl/classes/com/jogamp/graph/font/FontSet.java
@@ -27,6 +27,8 @@
*/
package com.jogamp.graph.font;
+import java.io.IOException;
+
public interface FontSet {
@@ -54,7 +56,7 @@ public interface FontSet {
/** ITALIC style bit flag */
public static final int STYLE_ITALIC = 1 << 3;
- Font getDefault();
+ Font getDefault() throws IOException ;
- Font get(int family, int stylebits);
+ Font get(int family, int stylebits) throws IOException ;
}
diff --git a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
index 6b8260668..a00e9579c 100644
--- a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java
@@ -81,11 +81,11 @@ public class JavaFontLoader implements FontSet {
return 0 != ( bits & bit ) ;
}
- public Font getDefault() {
+ public Font getDefault() throws IOException {
return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular
}
- public Font get(int family, int style) {
+ public Font get(int family, int style) throws IOException {
Font font = (Font)fontMap.get( ( family << 8 ) | style );
if (font != null) {
return font;
@@ -135,7 +135,7 @@ public class JavaFontLoader implements FontSet {
return font;
}
- Font abspath(String fname, int family, int style) {
+ Font abspath(String fname, int family, int style) throws IOException {
if(null == javaFontPath) {
throw new GLException("java font path undefined");
}
@@ -147,9 +147,9 @@ public class JavaFontLoader implements FontSet {
fontMap.put( ( family << 8 ) | style, f );
return f;
}
- throw new GLException(err);
+ throw new IOException (err);
} catch (IOException ioe) {
- throw new GLException(err, ioe);
+ throw new IOException(err, ioe);
}
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
index 572955fd3..e2c79a5a8 100644
--- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
@@ -71,12 +71,11 @@ public class UbuntuFontLoader implements FontSet {
return 0 != ( bits & bit ) ;
}
- public Font getDefault() {
+ public Font getDefault() throws IOException {
return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular
}
- public Font get(int family, int style)
- {
+ public Font get(int family, int style) throws IOException {
Font font = (Font)fontMap.get( ( family << 8 ) | style );
if (font != null) {
return font;
@@ -119,7 +118,7 @@ public class UbuntuFontLoader implements FontSet {
return font;
}
- Font abspath(String fname, int family, int style) {
+ Font abspath(String fname, int family, int style) throws IOException {
final String err = "Problem loading font "+fname+", stream "+relPath+fname;
try {
URL url = IOUtil.getResource(UbuntuFontLoader.class, relPath+fname);
@@ -131,9 +130,9 @@ public class UbuntuFontLoader implements FontSet {
fontMap.put( ( family << 8 ) | style, f );
return f;
}
- throw new GLException(err);
+ throw new IOException(err);
} catch(IOException ioe) {
- throw new GLException(err, ioe);
+ throw new IOException(err, ioe);
}
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
index a9e5524c8..49e8a5826 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
@@ -44,18 +44,24 @@ import com.jogamp.graph.font.Font;
public class TypecastFontConstructor implements FontConstructor {
public Font create(final File ffile) throws IOException {
- return AccessController.doPrivileged(new PrivilegedAction<Font>() {
- public Font run() {
+ Object o = AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
OTFontCollection fontset;
try {
fontset = OTFontCollection.create(ffile);
return new TypecastFont(fontset);
} catch (IOException e) {
- e.printStackTrace();
+ return e;
}
- return null;
}
- });
+ });
+ if(o instanceof Font) {
+ return (Font)o;
+ }
+ if(o instanceof IOException) {
+ throw (IOException)o;
+ }
+ throw new InternalError("Unexpected Object: "+o);
}
public Font create(final URL furl) throws IOException {
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
index 53a8890bc..4a041604d 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java
@@ -107,7 +107,7 @@ public class OTFontCollection {
_fileName = file.getName();
if (!file.exists()) {
- throw new IOException();
+ throw new IOException("File <"+file.getName()+"> doesn't exist.");
}
// Do we need to modify the path name to deal with font resources