- 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 } );
- }
- }
- }
-
- 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;
- }
- }
-
- final public static Color calculateColorFromString( final String str, final boolean is_taxonomy ) {
- final String my_str = str.toUpperCase();
- char first = my_str.charAt( 0 );
- char second = ' ';
- char third = ' ';
- if ( my_str.length() > 1 ) {
- if ( is_taxonomy ) {
- second = my_str.charAt( 1 );
- }
- else {
- second = my_str.charAt( my_str.length() - 1 );
- }
- if ( is_taxonomy ) {
- if ( my_str.length() > 2 ) {
- if ( my_str.indexOf( " " ) > 0 ) {
- third = my_str.charAt( my_str.indexOf( " " ) + 1 );
+ final static Map<String, Integer> getRankCounts( final Phylogeny tree ) {
+ final Map<String, Integer> present_ranks = new HashMap<String, Integer>();
+ if ( ( tree != null ) && !tree.isEmpty() ) {
+ for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
+ final PhylogenyNode n = it.next();
+ if ( !n.isExternal() && n.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) && !n.isRoot() ) {
+ final String rank = n.getNodeData().getTaxonomy().getRank().toLowerCase();
+ if ( present_ranks.containsKey( rank ) ) {
+ present_ranks.put( rank, present_ranks.get( rank ) + 1 );