+
+ /**
+ * Helper method for calcColor methods.
+ *
+ * @param smallercolor_component_x
+ * color component the smaller color
+ * @param largercolor_component_x
+ * color component the larger color
+ * @param x
+ * factor
+ * @return an int representing a color component
+ */
+ final private static int calculateColorComponent( final double smallercolor_component_x,
+ final double largercolor_component_x,
+ final double x ) {
+ return ( int ) ( smallercolor_component_x + ( ( x * ( largercolor_component_x - smallercolor_component_x ) ) / 255.0 ) );
+ }
+
+ /**
+ * Helper method for calcColor methods.
+ *
+ *
+ * @param value
+ * the value
+ * @param larger
+ * the largest value
+ * @param smaller
+ * the smallest value
+ * @return a normalized value between larger and smaller
+ */
+ final private static double calculateColorFactor( final double value, final double larger, final double smaller ) {
+ return ( 255.0 * ( value - smaller ) ) / ( larger - smaller );
+ }
+
+ final private static String[] splitString( final String str ) {
+ final String regex = "[\\s;,]+";
+ return str.split( regex );
+ }
+
+ public final static void outOfMemoryError( final OutOfMemoryError e ) {
+ System.err.println();
+ System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" );
+ System.err.println();
+ e.printStackTrace( System.err );
+ System.err.println();
+ System.exit( -1 );
+ }
+
+ public final static Color obtainColorDependingOnTaxonomyGroup( final String tax ) {
+ if ( tax.equalsIgnoreCase( "deuterostomia" ) ) {
+ return DEUTEROSTOMIA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "protostomia" ) ) {
+ return PROTOSTOMIA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "metazoa" ) ) {
+ return METAZOA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "holozoa" ) ) {
+ return HOLOZOA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "fungi" ) ) {
+ return FUNGI_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "holomycota" ) ) {
+ return HOLOMYCOTA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "amoebozoa" ) ) {
+ return AMOEBOZOA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "viridiplantae" ) ) {
+ return VIRIDPLANTAE_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "rhodophyta" ) ) {
+ return RHODOPHYTA_COLOR;
+ }
+ else if ( tax.toLowerCase().startsWith( "hacrobia" ) ) {
+ return HACROBIA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "glaucocystophyceae" ) || tax.equalsIgnoreCase( "glaucophyta" ) ) {
+ return GLAUCOPHYTA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "stramenopiles" ) ) {
+ return STRAMENOPILES_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "alveolata" ) ) {
+ return ALVEOLATA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "rhizaria" ) ) {
+ return RHIZARIA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "excavata" ) ) {
+ return EXCAVATA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "apusozoa" ) ) {
+ return APUSOZOA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "archaea" ) ) {
+ return ARCHAEA_COLOR;
+ }
+ else if ( tax.equalsIgnoreCase( "bacteria" ) ) {
+ return BACTERIA_COLOR;
+ }
+ return null;
+ }