org.faceless.pdf2.viewer2
Class Util

java.lang.Object
  extended by org.faceless.pdf2.viewer2.Util

public final class Util
extends Object

A utility class that handles localized Strings, display of error messages and so on. Developers extending the viewer are welcome to use this class

This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

Since:
2.11 - created from the SuperJOptionPane class

Field Summary
static BFOLogger LOGGER
           
 
Method Summary
static void displayThrowable(Throwable throwable, Component parent)
          Display an Error message, including the stack trace
static String encodeColor(Color c)
          Return the standard #RRGGBB representation of a Color
static void fixScrollPaneKeyBindings(JScrollPane scrollpane)
          Remove the pageup/pagedown key bindings from ScrollPanes - they're clashing with the pageup/pagedown we're mapping on the DocumentPanel
static int getScreenResolution(Component comp)
          Get the screen resolution.
static String getUIString(String key, String field1)
          Return a UIManager string field with the specified fields replaced
static String getUIString(String key, String field1, String field2)
          Return a UIManager string field with the specified fields replaced
static boolean hasFilePermission()
          Return true if the viewer can access the local filesystem
static boolean isBrowserApplet(Component c)
          Return true if the viewer is running as an Applet inside a web browser, false otherwise
static boolean isJNLP(Component c)
          Return true if the specified component is running in a JNLP environment, false otherwise
static boolean isLAFAqua()
          Return true if the LAF uses the Aqua toolkit (OS X)
static boolean isLAFGTK()
          Return true if the LAF uses the GTK+ toolkit (UNIX)
static boolean isLAFMetal()
          Return true if the LAF uses the Metal toolkit
static boolean isLAFNimbus()
          Return true if the LAF uses the Nimbus toolkit
static boolean isLAFWindows()
          Return true if the LAF uses the Window toolkit
static boolean isStandaloneApplet(Component c)
          Return true if the viewer is running as an Applet that has been dragged outside of the web browser, false otherwise.
static boolean openURL(URL url, Component c)
          Display a URL in a web browser, if possible
static URL toURL(DocumentPanel docpanel, String path)
          Attempt to convert a relative URL to an absolute one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

public static final BFOLogger LOGGER
Method Detail

displayThrowable

public static void displayThrowable(Throwable throwable,
                                    Component parent)
Display an Error message, including the stack trace

Parameters:
throwable - the Throwable object this error relates to
parent - the parent component (not used)

isLAFAqua

public static boolean isLAFAqua()
Return true if the LAF uses the Aqua toolkit (OS X)


isLAFGTK

public static boolean isLAFGTK()
Return true if the LAF uses the GTK+ toolkit (UNIX)


isLAFNimbus

public static boolean isLAFNimbus()
Return true if the LAF uses the Nimbus toolkit


isLAFWindows

public static boolean isLAFWindows()
Return true if the LAF uses the Window toolkit


isLAFMetal

public static boolean isLAFMetal()
Return true if the LAF uses the Metal toolkit


isBrowserApplet

public static boolean isBrowserApplet(Component c)
Return true if the viewer is running as an Applet inside a web browser, false otherwise

Parameters:
c - the Component
Since:
2.11.1

isStandaloneApplet

public static boolean isStandaloneApplet(Component c)
Return true if the viewer is running as an Applet that has been dragged outside of the web browser, false otherwise.

Parameters:
c - the Component
Since:
2.11.1

isJNLP

public static boolean isJNLP(Component c)
Return true if the specified component is running in a JNLP environment, false otherwise

Parameters:
c - the Component
Since:
2.11.1

openURL

public static boolean openURL(URL url,
                              Component c)
Display a URL in a web browser, if possible

Parameters:
url - the URL to open
c - the Component
Returns:
true if the URL could be opened, false otherwise
Since:
2.11.1

getUIString

public static String getUIString(String key,
                                 String field1)
Return a UIManager string field with the specified fields replaced

Parameters:
key - the message key,
field1 - the field to be substituted for {1}
Returns:
the modified string

getUIString

public static String getUIString(String key,
                                 String field1,
                                 String field2)
Return a UIManager string field with the specified fields replaced

Parameters:
key - the message key,
field1 - the field to be substituted for {1}
field2 - the field to be substituted for {2}
Returns:
the modified string

fixScrollPaneKeyBindings

public static void fixScrollPaneKeyBindings(JScrollPane scrollpane)
Remove the pageup/pagedown key bindings from ScrollPanes - they're clashing with the pageup/pagedown we're mapping on the DocumentPanel


toURL

public static URL toURL(DocumentPanel docpanel,
                        String path)
Attempt to convert a relative URL to an absolute one. URL is assumed to be relative to the file. If we don't have that info but we're loaded from an applet, then attempt to load URL relative to the applet base. Otherwise, take your best shot.


hasFilePermission

public static boolean hasFilePermission()
Return true if the viewer can access the local filesystem


encodeColor

public static String encodeColor(Color c)
Return the standard #RRGGBB representation of a Color


getScreenResolution

public static int getScreenResolution(Component comp)
Get the screen resolution. Same as Toolkit.getScreenResolution, except it allows us to override it using the PDFViewer "dpi" property



Copyright © 2001-2013 Big Faceless Organization