-
- final private static void openUrlInWebBrowser( final String url ) throws IOException, ClassNotFoundException,
- SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
- InvocationTargetException, InterruptedException {
- final String os = System.getProperty( "os.name" );
- final Runtime runtime = Runtime.getRuntime();
- if ( os.toLowerCase().startsWith( "win" ) ) {
- Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url );
- }
- else if ( ForesterUtil.isMac() ) {
- final Class<?> file_mgr = Class.forName( "com.apple.eio.FileManager" );
- final Method open_url = file_mgr.getDeclaredMethod( "openURL", new Class[] { String.class } );
- open_url.invoke( null, new Object[] { url } );
- }
- else {
- final String[] browsers = { "firefox", "opera", "konqueror", "mozilla", "netscape", "epiphany" };
- String browser = null;
- for( int i = 0; ( i < browsers.length ) && ( browser == null ); ++i ) {
- if ( runtime.exec( new String[] { "which", browsers[ i ] } ).waitFor() == 0 ) {
- browser = browsers[ i ];
- }
- }
- if ( browser == null ) {
- throw new IOException( "could not find a web browser to open [" + url + "] in" );
- }
- else {
- runtime.exec( new String[] { browser, url } );
- }
- }
- }
-
- // See: http://www.xml.nig.ac.jp/tutorial/rest/index.html#2.2
- // static void openDDBJRest() throws IOException {
- // //set URL
- // URL url = new URL( "http://xml.nig.ac.jp/rest/Invoke" );
- // //set parameter
- // String query = "service=GetEntry&method=getDDBJEntry&accession=AB000100";
- // //make connection
- // URLConnection urlc = url.openConnection();
- // //use post mode
- // urlc.setDoOutput( true );
- // urlc.setAllowUserInteraction( false );
- // //send query
- // PrintStream ps = new PrintStream( urlc.getOutputStream() );
- // ps.print( query );
- // ps.close();
- // //get result
- // BufferedReader br = new BufferedReader( new InputStreamReader(
- // urlc.getInputStream() ) );
- // String l = null;
- // while ( ( l = br.readLine() ) != null ) {
- // System.out.println( l );
- // }
- // br.close();
- // }
- public static enum GraphicsExportType {
- BMP( "bmp" ), GIF( "gif" ), JPG( "jpg" ), PDF( "pdf" ), PNG( "png" ), TIFF( "tif" );
-
- private final String _suffix;
-
- private GraphicsExportType( final String suffix ) {
- _suffix = suffix;
- }
-
- @Override
- public String toString() {
- return _suffix;
- }
- }