package org.forester.archaeopteryx;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
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 );
+ }
+ else {
+ third = my_str.charAt( 2 );
+ }
+ }
+ }
+ else if ( my_str.length() > 2 ) {
+ third = my_str.charAt( ( my_str.length() - 1 ) / 2 );
+ }
+ }
+ first = normalizeCharForRGB( first );
+ second = normalizeCharForRGB( second );
+ third = normalizeCharForRGB( third );
+ if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
+ first = 0;
+ }
+ else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) {
+ second = 255;
+ }
+ return new Color( first, second, third );
+ }
+
+ final private static char normalizeCharForRGB( char c ) {
+ c -= 65;
+ c *= 10.2;
+ c = c > 255 ? 255 : c;
+ c = c < 0 ? 0 : c;
+ return c;
+ }
}
private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
private SortedMap<String, Color> _display_colors = null;
private boolean _display_sequence_relations = false;
- private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
- private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
private boolean _editable = true;
private NODE_DATA _ext_desc_data_to_return = NODE_DATA.UNKNOWN;
private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
return _default_node_shape_size;
}
- public Color getDomainStructureBaseColor() {
- return _domain_structure_base_color;
- }
-
- public Color getDomainStructureFontColor() {
- return _domain_structure_font_color;
- }
-
public NODE_DATA getExtDescNodeDataToReturn() {
return _ext_desc_data_to_return;
}
else if ( key.equals( "gui_button_border_color" ) ) {
_gui_button_border_color = Color.decode( ( String ) st.nextElement() );
}
- else if ( key.equals( "domain_structure_font_color" ) ) {
- _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
- }
- else if ( key.equals( "domain_structure_base_color" ) ) {
- _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
- }
+
else if ( key.equals( "show_default_node_shapes" ) ) {
ForesterUtil
.printWarningMessage( Constants.PRG_NAME,
public final static boolean ALLOW_DDBJ_BLAST = false;
public final static String PRG_NAME = "Archaeopteryx";
final static String VERSION = "0.9894 beta";
- final static String PRG_DATE = "140811";
+ final static String PRG_DATE = "140815";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = { "Arial", "Helvetica",
"Verdana", "Tahoma", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" };
255 );
final static Color BUTTON_BORDER_COLOR_DEFAULT = new Color( 0, 0, 0 );
final static Color TAB_LABEL_FOREGROUND_COLOR_SELECTED = new Color( 0, 0, 0 );
- final static Color DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT = new Color( 32, 32, 32 );
- final static Color DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT = new Color( 144,
- 144,
- 144 );
final static String NCBI_ALL_DATABASE_SEARCH = "http://www.ncbi.nlm.nih.gov/gquery/?term=";
+ public final static Color DOMAIN_BASE_COLOR_FOR_PDF = new Color( 100,
+ 100,
+ 100 );
+ public final static Color DOMAIN_LABEL_COLOR_FOR_PDF = new Color( 150,
+ 150,
+ 150 );
final static short DEFAULT_NODE_SHAPE_SIZE_DEFAULT = 4;
}
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.SequenceRelation;
+import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.util.ForesterUtil;
private Map<Integer, String> _all_click_to_names;
private Map<String, Color> _annotation_colors;
private int _blast_item;
- private JComboBox _click_to_combobox;
+ private JComboBox<String> _click_to_combobox;
private JLabel _click_to_label;
private List<String> _click_to_names;
private int _collapse_cb_item;
private int _select_nodes_item;
private Sequence _selected_query_seq;
private JCheckBox _seq_relation_confidence_switch;
- private JComboBox _sequence_relation_type_box;
+ private JComboBox<SEQUENCE_RELATION_TYPE> _sequence_relation_type_box;
private JCheckBox _show_annotation;
private JCheckBox _show_binary_character_counts;
private JCheckBox _show_binary_characters;
private JCheckBox _show_seq_names;
private JCheckBox _show_seq_symbols;
private JCheckBox _show_sequence_acc;
- private JComboBox _show_sequence_relations;
+ private JComboBox<String> _show_sequence_relations;
private JCheckBox _show_taxo_code;
private JCheckBox _show_taxo_common_names;
private JCheckBox _show_taxo_images_cb;
search1();
displayedPhylogenyMightHaveChanged( true );
}
-
-
-
-
+ else if ( _dynamically_hide_data != null && e.getSource() == _dynamically_hide_data && !_dynamically_hide_data.isSelected() ) {
+ setDynamicHidingIsOn( false );
+ displayedPhylogenyMightHaveChanged( true );
+ }
else {
displayedPhylogenyMightHaveChanged( true );
}
return _selected_query_seq;
}
- public JComboBox getSequenceRelationBox() {
+ public JComboBox<String> getSequenceRelationBox() {
if ( _show_sequence_relations == null ) {
- _show_sequence_relations = new JComboBox();
+ _show_sequence_relations = new JComboBox<String>();
_show_sequence_relations.setFocusable( false );
_show_sequence_relations.setMaximumRowCount( 20 );
_show_sequence_relations.setFont( ControlPanel.js_font );
}
/* GUILHEM_BEG */
- public JComboBox getSequenceRelationTypeBox() {
+ public JComboBox<SEQUENCE_RELATION_TYPE> getSequenceRelationTypeBox() {
if ( _sequence_relation_type_box == null ) {
- _sequence_relation_type_box = new JComboBox();
+ _sequence_relation_type_box = new JComboBox<SEQUENCE_RELATION_TYPE>();
for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : SequenceRelation.SEQUENCE_RELATION_TYPE.values() ) {
_sequence_relation_type_box.addItem( type );
}
}
public void setSequenceRelationQueries( final Collection<Sequence> sequenceRelationQueries ) {
- final JComboBox box = getSequenceRelationBox();
+ final JComboBox<String> box = getSequenceRelationBox();
while ( box.getItemCount() > 1 ) {
box.removeItemAt( 1 );
}
break;
case Configuration.dynamically_hide_data:
_dynamically_hide_data = new JCheckBox( title );
- getDynamicallyHideData().setToolTipText( "To hide labels depending on likely visibility" );
+ getDynamicallyHideData().setToolTipText( "To hide labels depending on expected visibility" );
addJCheckBox( getDynamicallyHideData(), ch_panel );
add( ch_panel );
break;
}
void setDynamicHidingIsOn( final boolean is_on ) {
- // if ( !_configuration.isUseNativeUI() ) {
if ( is_on ) {
getDynamicallyHideData().setForeground( getConfiguration().getGuiCheckboxAndButtonActiveColor() );
}
getDynamicallyHideData().setForeground( Color.BLACK );
}
}
- // }
}
void setSearchFoundCountsOnLabel0( final int counts ) {
add( spacer );
_click_to_label = new JLabel( "Click on Node to:" );
add( customizeLabel( _click_to_label, getConfiguration() ) );
- _click_to_combobox = new JComboBox();
+ _click_to_combobox = new JComboBox<String>();
_click_to_combobox.setFocusable( false );
_click_to_combobox.setMaximumRowCount( 14 );
_click_to_combobox.setFont( ControlPanel.js_font );
_sequence_relation_type_box.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
_sequence_relation_type_box.setForeground( getConfiguration().getGuiButtonTextColor() );
}
- _sequence_relation_type_box.setRenderer( new ListCellRenderer() {
+ _sequence_relation_type_box.setRenderer( new ListCellRenderer<Object>() {
@Override
- public Component getListCellRendererComponent( final JList list,
+ public Component getListCellRendererComponent( final JList<?> list,
final Object value,
final int index,
final boolean isSelected,
case UNKNOWN:
s = "User Selected Data";
break;
+ default:
+ throw new IllegalStateException( "dont know how to deal with " + getConfiguration().getExtDescNodeDataToReturn() );
+
}
final String label = _configuration.getClickToTitle( Configuration.get_ext_desc_data ) + " " + s;
addClickToOption( Configuration.get_ext_desc_data, label );
|| ( o == _unrooted_type_cbmi ) || ( o == _circular_type_cbmi ) ) {\r
typeChanged( o );\r
}\r
+ \r
else if ( o == _about_item ) {\r
about();\r
}\r
}
_min_confidence_value = MIN_CONFIDENCE_DEFAULT;
_print_black_and_white = false;
- _print_using_actual_size = false;
+ _print_using_actual_size = true;
_graphics_export_using_actual_size = true;
_phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
_base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 );
import org.forester.util.ForesterUtil;
-/*
- * Maintains the color schemes and a set of colors for drawing a tree.
- */
+
public final class TreeColorSet {
public static final String ANNOTATION = "Annotation";
public static final String BRANCH_LENGTH = "Branch Length";
public static final String COLLAPSED = "Collapsed";
public static final String CONFIDENCE = "Confidence";
- public static final String DOMAINS = "Domains";
+ public static final String DOMAIN_LABEL = "Domain Label";
+ public static final String DOMAIN_BASE = "Domain Base";
public static final String DUPLICATION = "Duplication";
public static final String DUPLICATION_OR_SPECATION = "Duplication or Specation";
public static final String MATCHING_NODES_A = "Matching A";
public static final String TAXONOMY = "Taxonomy";
static final String[] COLOR_FIELDS = { BACKGROUND, BACKGROUND_GRADIENT_BOTTOM, SEQUENCE,
TAXONOMY, CONFIDENCE, BRANCH_LENGTH, BRANCH, NODE_BOX, COLLAPSED, MATCHING_NODES_A, MATCHING_NODES_B,
- MATCHING_NODES_A_AND_B, DUPLICATION, SPECIATION, DUPLICATION_OR_SPECATION, DOMAINS,
+ MATCHING_NODES_A_AND_B, DUPLICATION, SPECIATION, DUPLICATION_OR_SPECATION, DOMAIN_LABEL, DOMAIN_BASE,
BINARY_DOMAIN_COMBINATIONS, ANNOTATION, OVERVIEW };
static final String[] SCHEME_NAMES = { "Default", "Black", "Black & White", "Silver", "Green",
"White & Blue", "Cyan", "Orange", "Blue", "Blue & White", "Neon" };
- // Color schemes:
+
private int _color_scheme;
- // All the color sets; better be the same # of sets as there are names!
+
private final Color[][] _color_schemes = { { new Color( 0, 0, 0 ), // background_color
new Color( 0, 100, 100 ), // background_color_gradient_bottom
new Color( 230, 230, 230 ), // sequence __ Default (same as Black)
new Color( 180, 180, 180 ), // taxonomy
- new Color( 56, 176, 255 ), // support
+ new Color( 180, 180, 180 ), // support
new Color( 140, 140, 140 ), // branch_length_color
new Color( 255, 255, 255 ), // branch_color
new Color( 255, 255, 255 ), // box_color
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 123, 104, 238 ), // domains_color
+ new Color( 230, 230, 230 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 65, 105, 255 ), // binary_domain_combinations_color
new Color( 173, 255, 47 ) // annotation
, new Color( 130, 130, 130 ) // overview
new Color( 0, 255, 255 ), // background_color_gradient_bottom
new Color( 230, 230, 230 ), // sequence __ Black
new Color( 180, 180, 180 ), // taxonomy
- new Color( 56, 176, 255 ), // support
+ new Color( 180, 180, 180 ), // support
new Color( 140, 140, 140 ), // branch_length_color
new Color( 255, 255, 255 ), // branch_color
new Color( 255, 255, 255 ), // box_color
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 123, 104, 238 ), // domains_color
+ new Color( 230, 230, 230 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 65, 105, 255 ), // binary_domain_combinations_color
new Color( 173, 255, 47 ) // annotation
, new Color( 130, 130, 130 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 0, 0, 0 ), // domains_color
+ new Color( 0, 0, 0 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 0, 0, 0 ), // binary_domain_combinations_color
new Color( 0, 0, 0 ) // annotation
, new Color( 220, 220, 220 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 180, 180, 180 ), // domains_color
+ new Color( 230, 230, 230 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 180, 180, 180 ), // binary_domain_combinations_color
new Color( 140, 140, 140 ) // annotation
, new Color( 40, 40, 40 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 0, 235, 0 ), // domains_color
+ new Color( 230, 230, 230 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 0, 235, 0 ), // binary_domain_combinations_color
new Color( 0, 235, 0 ) // annotation
, new Color( 40, 40, 40 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 123, 104, 238 ), // domains_color
+ new Color( 0, 0, 0 ), // domain_label
+ new Color( 50, 50, 50 ), // domains_base
new Color( 65, 105, 225 ), // binary_domain_combinations_color
new Color( 173, 255, 47 ) // annotation
, new Color( 220, 220, 220 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 123, 104, 238 ), // domains_color
+ new Color( 230, 230, 230 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 65, 105, 225 ), // binary_domain_combinations_color
new Color( 173, 255, 47 ) // annotation
, new Color( 0, 120, 120 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 150, 150, 150 ), // domains_color
+ new Color( 255, 200, 0 ), // domain_label
+ new Color( 255, 200, 0 ), // domains_base
new Color( 150, 150, 150 ), // binary_domain_combinations_color
new Color( 150, 150, 150 ) // annotation
, new Color( 150, 150, 150 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 255, 255, 255 ), // domains_color
+ new Color(255, 255, 255 ), // domain_label
+ new Color( 100, 100, 100 ), // domains_base
new Color( 255, 255, 255 ), // binary_domain_combinations_color
new Color( 255, 255, 255 ) // annotation
, new Color( 77, 77, 255 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 255, 255, 255 ), // domains_color
+ new Color( 255, 255, 255 ), // domain_label
+ new Color( 150, 150, 150 ), // domains_base
new Color( 255, 255, 255 ), // binary_domain_combinations_color
new Color( 255, 255, 255 ) // annotation
, new Color( 170, 187, 204 ) // ov
new Color( 255, 0, 0 ), // duplication_box_color
new Color( 0, 255, 0 ), // speciation_box_color
new Color( 255, 255, 0 ), // duplication_speciation_color
- new Color( 27, 255, 0 ), // domains_color
+ new Color( 127, 255, 0 ), // domain_label
+ new Color( 234, 173, 234 ), // domains_base
new Color( 27, 255, 0 ), // binary_domain_combinations_color
new Color( 27, 255, 0 ) // annotation
, new Color( 77, 77, 255 ) // ov
private Color branch_color;
private Color branch_length_color;
private Color collapse_fill_color;
- private Color domains_color;
+ private Color domain_label_color;
+ private Color domain_base_color;
private Color dup_box_color;
private Color duplication_or_specation_color;
private Color found_color_0;
return SCHEME_NAMES[ getCurrentColorScheme() ];
}
- Color getDomainsColor() {
- return domains_color;
+ public Color getDomainBaseColor() {
+ return domain_base_color;
+ }
+
+ public Color getDomainLabelColor() {
+ return domain_label_color;
}
Color getDuplicationBoxColor() {
dup_box_color = _color_schemes[ scheme ][ 12 ];
spec_box_color = _color_schemes[ scheme ][ 13 ];
duplication_or_specation_color = _color_schemes[ scheme ][ 14 ];
- domains_color = _color_schemes[ scheme ][ 15 ];
- binary_domain_combinations_color = _color_schemes[ scheme ][ 16 ];
- annotation_color = _color_schemes[ scheme ][ 17 ];
- ov_color = _color_schemes[ scheme ][ 18 ];
+ domain_label_color = _color_schemes[ scheme ][ 15 ];
+ domain_base_color = _color_schemes[ scheme ][ 16 ];
+ binary_domain_combinations_color = _color_schemes[ scheme ][ 17 ];
+ annotation_color = _color_schemes[ scheme ][ 18 ];
+ ov_color = _color_schemes[ scheme ][ 19 ];
}
void setCurrentColorScheme( final int color_scheme ) {
void smallFonts() {
setDecreasedSizeBySystem( false );
- _small_font = _small_font.deriveFont( SMALL_FONTS_BASE - 1 );
+ _small_font = _small_font.deriveFont( SMALL_FONTS_BASE - 2 );
_large_font = _large_font.deriveFont( SMALL_FONTS_BASE );
setupFontMetrics();
}
void superTinyFonts() {
setDecreasedSizeBySystem( false );
_small_font = _small_font.deriveFont( 2f );
- _large_font = _large_font.deriveFont( 3f );
+ _large_font = _large_font.deriveFont( 4f );
setupFontMetrics();
}
void tinyFonts() {
setDecreasedSizeBySystem( false );
- _small_font = _small_font.deriveFont( 5f );
+ _small_font = _small_font.deriveFont( 4f );
_large_font = _large_font.deriveFont( 6f );
setupFontMetrics();
}
}
private void intializeFonts() {
- final int small_size = getBaseFont().getSize() - 1;
+ final int small_size = getBaseFont().getSize() - 2;
int italic = Font.ITALIC;
if ( getBaseFont().getStyle() == Font.BOLD ) {
italic = italic + Font.BOLD;
}
if ( c == null ) {
if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
- c = TreePanelUtil.calculateColorFromString( tax.getTaxonomyCode(), true );
+ c = AptxUtil.calculateColorFromString( tax.getTaxonomyCode(), true );
getControlPanel().getSpeciesColors().put( tax.getTaxonomyCode(), c );
}
else {
- c = TreePanelUtil.calculateColorFromString( tax.getScientificName(), true );
+ c = AptxUtil.calculateColorFromString( tax.getScientificName(), true );
getControlPanel().getSpeciesColors().put( tax.getScientificName(), c );
}
}
final String seq_name = seq.getName();
c = getControlPanel().getSequenceColors().get( seq_name );
if ( c == null ) {
- c = TreePanelUtil.calculateColorFromString( seq_name, false );
+ c = AptxUtil.calculateColorFromString( seq_name, false );
getControlPanel().getSequenceColors().put( seq_name, c );
}
return c;
return getTreeColorSet().getSequenceColor();
}
- /**
- * @return pointer to colorset for tree drawing
- */
- final TreeColorSet getTreeColorSet() {
+
+ public final TreeColorSet getTreeColorSet() {
return getMainPanel().getTreeColorSet();
}
&& ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {
RenderableDomainArchitecture rds = null;
if ( !( node.getNodeData().getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
- rds = new RenderableDomainArchitecture( node.getNodeData().getSequence().getDomainArchitecture(),
- getConfiguration() );
+ rds = new RenderableDomainArchitecture( node.getNodeData().getSequence().getDomainArchitecture() );
node.getNodeData().getSequence().setDomainArchitecture( rds );
}
else {
if ( !ForesterUtil.isEmpty( ann_str ) ) {
c = getControlPanel().getAnnotationColors().get( ann_str );
if ( c == null ) {
- c = TreePanelUtil.calculateColorFromString( ann_str, false );
+ c = AptxUtil.calculateColorFromString( ann_str, false );
getControlPanel().getAnnotationColors().put( ann_str, c );
}
if ( c == null ) {
final boolean disallow_shortcutting = ( dynamic_hiding_factor < 40 );
float min_dist = 1.5f;
if ( !disallow_shortcutting ) {
- // System.out.println( dynamic_hiding_factor );
if ( dynamic_hiding_factor > 4000 ) {
min_dist = 4;
}
cce.printStackTrace();
}
if ( rds != null ) {
- rds.setRenderingHeight( 6 );
+ final int default_height = 7;
+ float y = getYdistance();
+ if ( getControlPanel().isDynamicallyHideData() ) {
+ y = getTreeFontSet().getFontMetricsLarge().getHeight();
+ }
+ final int h = y < default_height ? ForesterUtil.roundToInt( y ) :default_height;
+ rds.setRenderingHeight( h > 1 ? h : 2 );
if ( getControlPanel().isDrawPhylogram() ) {
- rds.render( node.getXcoord() + x, node.getYcoord() - 3, g, this, to_pdf );
+ rds.render( node.getXcoord() + x, node.getYcoord() - ( h / 2 ), g, this, to_pdf );
}
else {
length_of_longest_text = calcLengthOfLongestText();
rds.render( getPhylogeny().getFirstExternalNode().getXcoord() + length_of_longest_text,
- node.getYcoord() - 3,
+ node.getYcoord() - ( h / 2 ),
g,
this,
to_pdf );
node.getYcoord() - 3,
g,
this,
- to_pdf );
+ to_pdf);
}
}
}
JOptionPane.showMessageDialog( parent, msg, title, JOptionPane.INFORMATION_MESSAGE );
}
- final 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 );
- }
- else {
- third = my_str.charAt( 2 );
- }
- }
- }
- else if ( my_str.length() > 2 ) {
- third = my_str.charAt( ( my_str.length() - 1 ) / 2 );
- }
- }
- first = TreePanelUtil.normalizeCharForRGB( first );
- second = TreePanelUtil.normalizeCharForRGB( second );
- third = TreePanelUtil.normalizeCharForRGB( third );
- if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
- first = 0;
- }
- else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) {
- second = 255;
- }
- return new Color( first, second, third );
- }
-
final static void collapseSpeciesSpecificSubtrees( final Phylogeny phy ) {
boolean inferred = false;
for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) {
return size;
}
- final static char normalizeCharForRGB( char c ) {
- c -= 65;
- c *= 10.2;
- c = c > 255 ? 255 : c;
- c = c < 0 ? 0 : c;
- return c;
- }
-
final static String pdbAccToString( final List<Accession> accs, final int i ) {
if ( ForesterUtil.isEmpty( accs.get( i ).getComment() ) ) {
return accs.get( i ).getValue();
import java.util.Map;
import java.util.SortedMap;
-import org.forester.archaeopteryx.Configuration;
+import org.forester.archaeopteryx.AptxUtil;
+import org.forester.archaeopteryx.Constants;
import org.forester.archaeopteryx.TreePanel;
import org.forester.phylogeny.data.DomainArchitecture;
import org.forester.phylogeny.data.PhylogenyData;
public final class RenderableDomainArchitecture extends DomainArchitecture implements RenderablePhylogenyData {
- static private Map<String, Color> Domain_colors;
final static private int BRIGHTEN_COLOR_BY = 200;
final static private int E_VALUE_THRESHOLD_EXP_DEFAULT = 0;
- private static int _Next_default_domain_color = 0;
- private final static String[] DEFAULT_DOMAINS_COLORS = { "0xFF0000", "0x0000FF", "0xAAAA00", "0xFF00FF",
- "0x00FFFF", "0x800000", "0x000080", "0x808000", "0x800080", "0x008080", "0xE1B694" };
- private int _e_value_threshold_exp = RenderableDomainArchitecture.E_VALUE_THRESHOLD_EXP_DEFAULT;
- private double _rendering_factor_width = 1.0;
- private double _rendering_height = 0;
+ final static private BasicStroke STROKE_1 = new BasicStroke( 1f );
+ private static Map<String, Color> _domain_colors;
private final DomainArchitecture _domain_structure;
+ private int _e_value_threshold_exp = E_VALUE_THRESHOLD_EXP_DEFAULT;
private final Rectangle2D _rectangle = new Rectangle2D.Float();
- private final Configuration _configuration;
- private static final BasicStroke STROKE_1 = new BasicStroke( 1f );
+ private double _rendering_factor_width = 1.0;
+ private double _rendering_height = 0;
- public RenderableDomainArchitecture( final DomainArchitecture domain_structure, final Configuration configuration ) {
+ public RenderableDomainArchitecture( final DomainArchitecture domain_structure ) {
_domain_structure = domain_structure;
- _configuration = configuration;
}
- private Configuration getConfiguration() {
- return _configuration;
+ public static void setColorMap( final Map<String, Color> domain_colors ) {
+ _domain_colors = domain_colors;
}
@Override
final Color color_two = getColorTwo( color_one );
double step = 1;
if ( to_pdf ) {
- step = 0.1;
+ step = 0.05;
}
for( double i = 0; i < heigth; i += step ) {
g.setColor( org.forester.util.ForesterUtil
}
}
- private Color getColorOne( final String name ) {
- Color c = getConfiguration().getDomainStructureBaseColor();
- if ( RenderableDomainArchitecture.Domain_colors != null ) {
- c = RenderableDomainArchitecture.Domain_colors.get( name );
+ private final Color getColorOne( final String name ) {
+ Color c = _domain_colors.get( name );
+ if ( c == null ) {
+ c = AptxUtil.calculateColorFromString( name, false );
if ( c == null ) {
- if ( RenderableDomainArchitecture._Next_default_domain_color < RenderableDomainArchitecture.DEFAULT_DOMAINS_COLORS.length ) {
- c = Color
- .decode( RenderableDomainArchitecture.DEFAULT_DOMAINS_COLORS[ RenderableDomainArchitecture._Next_default_domain_color++ ] );
- RenderableDomainArchitecture.Domain_colors.put( name, c );
- }
- else {
- c = getConfiguration().getDomainStructureBaseColor();
- }
+ throw new IllegalStateException();
}
+ _domain_colors.put( name, c );
}
return c;
}
final double start = x1 + 20.0;
final Stroke s = g.getStroke();
g.setStroke( STROKE_1 );
- g.setColor( getConfiguration().getDomainStructureFontColor() );
+ if ( !to_pdf ) {
+ g.setColor( tree_panel.getTreeColorSet().getDomainBaseColor() );
+ }
+ else {
+ g.setColor( Constants.DOMAIN_BASE_COLOR_FOR_PDF );
+ }
_rectangle.setFrame( start, y - 0.5, _domain_structure.getTotalLength() * f, 1 );
g.fill( _rectangle );
for( int i = 0; i < _domain_structure.getDomains().size(); ++i ) {
if ( d.getConfidence() <= Math.pow( 10, _e_value_threshold_exp ) ) {
final double xa = start + ( d.getFrom() * f );
final double xb = xa + ( d.getLength() * f );
- if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels() ) {
+ if ( tree_panel.getMainPanel().getOptions().isShowDomainLabels()
+ && ( tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getHeight() > 4 ) ) {
g.setFont( tree_panel.getMainPanel().getTreeFontSet().getSmallFont() );
- g.setColor( getConfiguration().getDomainStructureFontColor() );
+ if ( !to_pdf ) {
+ g.setColor( tree_panel.getTreeColorSet().getDomainLabelColor() );
+ }
+ else {
+ g.setColor( Constants.DOMAIN_LABEL_COLOR_FOR_PDF );
+ }
PhylogenyDataUtil.drawString( d.getName(), xa, y1
- + tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getAscent() + 6, g );
+ + tree_panel.getMainPanel().getTreeFontSet().getFontMetricsSmall().getAscent()
+ + _rendering_height, g );
}
drawDomain( xa, y1, xb - xa, _rendering_height, d.getName(), g, to_pdf );
}
public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
_domain_structure.toPhyloXML( writer, level, indentation );
}
-
- public static void setColorMap( final Map<String, Color> domain_colors ) {
- RenderableDomainArchitecture.Domain_colors = domain_colors;
- }
}
* @param g
* the Graphics to render to
*/
- public void render( final double x, final double y, final Graphics2D g, final TreePanel tree_panel, boolean to_pdf );
+ public void render( final double x, final double y, final Graphics2D g, final TreePanel tree_panel, boolean to_pdf );
public void setParameter( final double parameter );