import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import javax.swing.BorderFactory;
-import javax.swing.JApplet;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JMenuItem;
import org.forester.phylogeny.data.NodeVisualData.NodeFill;
import org.forester.phylogeny.data.NodeVisualData.NodeShape;
import org.forester.phylogeny.data.PhylogenyDataUtil;
-import org.forester.phylogeny.data.PropertiesMap;
-import org.forester.phylogeny.data.Property;
import org.forester.phylogeny.data.ProteinDomain;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.SequenceRelation;
import org.forester.phylogeny.data.Uri;
import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.phylogeny.iterators.PreorderTreeIterator;
-import org.forester.util.BasicDescriptiveStatistics;
import org.forester.util.DescriptiveStatistics;
import org.forester.util.ForesterConstants;
import org.forester.util.ForesterUtil;
private static final BasicStroke STROKE_075 = new BasicStroke( 0.75f );
private static final BasicStroke STROKE_1 = new BasicStroke( 1f );
private static final BasicStroke STROKE_2 = new BasicStroke( 2f );
+ private static final BasicStroke STROKE_01_DASHED = new BasicStroke( 0.1f,
+ BasicStroke.CAP_SQUARE,
+ BasicStroke.JOIN_ROUND,
+ 0,
+ new float[] {
+ 2.0f },
+ 0f );
+ private static final BasicStroke STROKE_005_DASHED = new BasicStroke( 0.05f,
+ BasicStroke.CAP_SQUARE,
+ BasicStroke.JOIN_ROUND,
+ 0,
+ new float[] {
+ 2.0f },
+ 0f );
+ private static final BasicStroke STROKE_001_DASHED = new BasicStroke( 0.01f,
+ BasicStroke.CAP_SQUARE,
+ BasicStroke.JOIN_ROUND,
+ 0,
+ new float[] {
+ 2.0f },
+ 0f );
private static final double TWO_PI = 2 * Math.PI;
- private final static int WIGGLE = 2;
+ private final static int WIGGLE = 3;
private static final String SHOW_ONLY_THIS_CONF_TYPE = null; //TODO remove me
HashMap<Long, Short> _nodeid_dist_to_leaf = new HashMap<Long, Short>();
final private Arc2D _arc = new Arc2D.Double();
private AffineTransform _at;
+ private int _clicked_x;
private int _circ_max_depth;
final private Set<Long> _collapsed_external_nodeid_set = new HashSet<Long>();
private JColorChooser _color_chooser = null;
private final FontRenderContext _frc = new FontRenderContext( null,
false,
false );
+ private float _furthest_node_x;
private PHYLOGENY_GRAPHICS_TYPE _graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
private PhylogenyNode _highlight_node = null;
private boolean _in_ov = false;
private float _ov_y_distance = 0;
private int _ov_y_position = 0;
private int _ov_y_start = 0;
+ private boolean _partition_tree = false;
private final boolean _phy_has_branch_lengths;
private Phylogeny _phylogeny = null;
private final Path2D.Float _polygon = new Path2D.Float();
RenderingHints.VALUE_RENDER_DEFAULT );
private JTextArea _rollover_popup;
private PhylogenyNode _root;
+ private float _root_x;
private final StringBuilder _sb = new StringBuilder();
private double _scale_distance = 0.0;
private String _scale_label = null;
private Map<String, AttributedString> _attributed_string_map = null;
private int _depth_collapse_level = -1;
private int _rank_collapse_level = -1;
+
+
+
static {
final DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator( '.' );
init();
// if ( !_phylogeny.isEmpty() ) {
_phylogeny.recalculateNumberOfExternalDescendants( true );
- checkForVectorProperties( _phylogeny );
// }
setBackground( getTreeColorSet().getBackgroundColor() );
final MouseListener mouse_listener = new MouseListener( this );
repaint();
}
}
- if ( e.isControlDown() ) {
+ if ( e.isControlDown() && e.isShiftDown() ) {
if ( notches < 0 ) {
getTreeFontSet().increaseFontSize();
}
updateOvSizes();
repaint();
}
+ else if ( e.isShiftDown() && e.isAltDown() ) {
+ if ( notches < 0 ) {
+ for( int i = 0; i < ( -notches ); ++i ) {
+ getControlPanel().zoomInX( AptxConstants.WHEEL_ZOOM_IN_FACTOR, AptxConstants.WHEEL_ZOOM_IN_FACTOR );
+ getControlPanel().displayedPhylogenyMightHaveChanged( false );
+ }
+ }
+ else {
+ for( int i = 0; i < notches; ++i ) {
+ getControlPanel().zoomOutX( AptxConstants.WHEEL_ZOOM_OUT_FACTOR,
+ AptxConstants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
+ getControlPanel().displayedPhylogenyMightHaveChanged( false );
+ }
+ }
+ }
else if ( e.isShiftDown() ) {
if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
|| ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
@Override
final public void paintComponent( final Graphics g ) {
- // Dimension currentSize = getSize();
- // if ( offscreenImage == null || !currentSize.equals( offscreenDimension ) ) {
- // call the 'java.awt.Component.createImage(...)' method to get an
- // image
- // offscreenImage = createImage( currentSize.width, currentSize.height );
- // offscreenGraphics = offscreenImage.getGraphics();
- // offscreenDimension = currentSize;
- // }
- // super.paintComponent( g ); //why?
- //final Graphics2D g2d = ( Graphics2D ) offscreenGraphics;
final Graphics2D g2d = ( Graphics2D ) g;
g2d.setRenderingHints( _rendering_hints );
paintPhylogeny( g2d, false, false, 0, 0, 0, 0 );
- //g.drawImage( offscreenImage, 0, 0, this );
}
@Override
type = 'n';
}
}
- JApplet applet = null;
- if ( isApplet() ) {
- applet = obtainApplet();
- }
try {
- Blast.openNcbiBlastWeb( query, type == 'n', applet, this );
+ Blast.openNcbiBlastWeb( query, type == 'n', this );
}
catch ( final Exception e ) {
e.printStackTrace();
return _last_drag_point_y;
}
- final private short getMaxBranchesToLeaf( final PhylogenyNode node ) {
- if ( !_nodeid_dist_to_leaf.containsKey( node.getId() ) ) {
- final short m = PhylogenyMethods.calculateMaxBranchesToLeaf( node );
- _nodeid_dist_to_leaf.put( node.getId(), m );
- return m;
- }
- else {
- return _nodeid_dist_to_leaf.get( node.getId() );
- }
- }
-
final private double getMaxDistanceToRoot() {
if ( _max_distance_to_root < 0 ) {
recalculateMaxDistanceToRoot();
sortDescendants( node );
break;
case GET_EXT_DESC_DATA:
- showExtDescNodeData( node );
+ showExtDescNodeData( node, '_' );
break;
case UNCOLLAPSE_ALL:
uncollapseAll( node );
setInOvRect( false );
}
}
- if ( e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK ) {
+ if ( e.isAltDown() ) {
if ( ( e.getKeyCode() == KeyEvent.VK_DELETE ) || ( e.getKeyCode() == KeyEvent.VK_HOME )
- || ( e.getKeyCode() == KeyEvent.VK_F ) ) {
- getMainPanel().getTreeFontSet().mediumFonts();
- getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
+ || ( e.getKeyCode() == KeyEvent.VK_C ) || ( e.getKeyCode() == KeyEvent.VK_BACK_SPACE ) ) {
+ getControlPanel().showWhole();
}
- else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
+ else if ( e.isShiftDown()
+ && ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) ) {
getMainPanel().getTreeFontSet().decreaseFontSize( 1, false );
getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
}
- else if ( plusPressed( e.getKeyCode() ) ) {
+ else if ( e.isShiftDown() && plusPressed( e.getKeyCode() ) ) {
getMainPanel().getTreeFontSet().increaseFontSize();
getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
}
- }
- else {
- if ( ( e.getKeyCode() == KeyEvent.VK_DELETE ) || ( e.getKeyCode() == KeyEvent.VK_HOME )
- || ( e.getKeyCode() == KeyEvent.VK_F ) ) {
- getControlPanel().showWhole();
+ else if ( e.getKeyCode() == KeyEvent.VK_O ) {
+ getControlPanel().orderPressed( this );
}
- else if ( ( e.getKeyCode() == KeyEvent.VK_UP ) || ( e.getKeyCode() == KeyEvent.VK_DOWN )
- || ( e.getKeyCode() == KeyEvent.VK_LEFT ) || ( e.getKeyCode() == KeyEvent.VK_RIGHT ) ) {
- if ( e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK ) {
- if ( e.getKeyCode() == KeyEvent.VK_UP ) {
- getMainPanel().getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR );
- getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
- }
- else if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
- getMainPanel().getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR );
- getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
- }
- else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
- getMainPanel().getControlPanel().zoomOutX( AptxConstants.WHEEL_ZOOM_OUT_FACTOR,
- AptxConstants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
- getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
- }
- else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
- getMainPanel().getControlPanel().zoomInX( AptxConstants.WHEEL_ZOOM_IN_FACTOR,
- AptxConstants.WHEEL_ZOOM_IN_FACTOR );
- getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
- }
- }
- else {
- final int d = 80;
- int dx = 0;
- int dy = -d;
- if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
- dy = d;
- }
- else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
- dx = -d;
- dy = 0;
- }
- else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
- dx = d;
- dy = 0;
- }
- final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
- scroll_position.x = scroll_position.x + dx;
- scroll_position.y = scroll_position.y + dy;
- if ( scroll_position.x <= 0 ) {
- scroll_position.x = 0;
- }
- else {
- final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
- - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
- if ( scroll_position.x >= max_x ) {
- scroll_position.x = max_x;
- }
- }
- if ( scroll_position.y <= 0 ) {
- scroll_position.y = 0;
- }
- else {
- final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
- - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
- if ( scroll_position.y >= max_y ) {
- scroll_position.y = max_y;
- }
- }
- repaint();
- getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
- }
+ else if ( e.getKeyCode() == KeyEvent.VK_R ) {
+ getControlPanel().returnedToSuperTreePressed();
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_U ) {
+ getControlPanel().uncollapseAll( this );
+ getControlPanel().displayedPhylogenyMightHaveChanged( false );
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_UP ) {
+ getMainPanel().getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR );
+ getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
+ getMainPanel().getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR );
+ getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
+ getMainPanel().getControlPanel().zoomOutX( AptxConstants.WHEEL_ZOOM_OUT_FACTOR,
+ AptxConstants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR );
+ getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
+ getMainPanel().getControlPanel().zoomInX( AptxConstants.WHEEL_ZOOM_IN_FACTOR,
+ AptxConstants.WHEEL_ZOOM_IN_FACTOR );
+ getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
}
else if ( ( e.getKeyCode() == KeyEvent.VK_SUBTRACT ) || ( e.getKeyCode() == KeyEvent.VK_MINUS ) ) {
getMainPanel().getControlPanel().zoomOutY( AptxConstants.WHEEL_ZOOM_OUT_FACTOR );
getMainPanel().getControlPanel().zoomInY( AptxConstants.WHEEL_ZOOM_IN_FACTOR );
getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( false );
}
+ }
+ else {
+ if ( ( e.getKeyCode() == KeyEvent.VK_UP ) || ( e.getKeyCode() == KeyEvent.VK_DOWN )
+ || ( e.getKeyCode() == KeyEvent.VK_LEFT ) || ( e.getKeyCode() == KeyEvent.VK_RIGHT ) ) {
+ final int d = 80;
+ int dx = 0;
+ int dy = -d;
+ if ( e.getKeyCode() == KeyEvent.VK_DOWN ) {
+ dy = d;
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_LEFT ) {
+ dx = -d;
+ dy = 0;
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_RIGHT ) {
+ dx = d;
+ dy = 0;
+ }
+ final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport().getViewPosition();
+ scroll_position.x = scroll_position.x + dx;
+ scroll_position.y = scroll_position.y + dy;
+ if ( scroll_position.x <= 0 ) {
+ scroll_position.x = 0;
+ }
+ else {
+ final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getMaximum()
+ - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
+ if ( scroll_position.x >= max_x ) {
+ scroll_position.x = max_x;
+ }
+ }
+ if ( scroll_position.y <= 0 ) {
+ scroll_position.y = 0;
+ }
+ else {
+ final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
+ - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
+ if ( scroll_position.y >= max_y ) {
+ scroll_position.y = max_y;
+ }
+ }
+ repaint();
+ getMainPanel().getCurrentScrollPane().getViewport().setViewPosition( scroll_position );
+ }
else if ( e.getKeyCode() == KeyEvent.VK_S ) {
if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED )
|| ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR ) ) {
else {
getOptions().setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
}
- if ( getMainPanel().getMainFrame() == null ) {
- // Must be "E" applet version.
- final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
- if ( ae.getlabelDirectionCbmi() != null ) {
- ae.getlabelDirectionCbmi().setSelected( selected );
- }
- }
- else {
- getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected( selected );
- }
+ getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected( selected );
repaint();
}
else if ( e.getKeyCode() == KeyEvent.VK_X ) {
else if ( getOptions().isShowOverview() && isOvOn() && ( e.getKeyCode() == KeyEvent.VK_U ) ) {
decreaseOvSize();
}
- e.consume();
}
+ if ( e.getKeyCode() == KeyEvent.VK_HOME || e.getKeyCode() == KeyEvent.VK_ESCAPE ) {
+ getControlPanel().showWhole();
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_PAGE_UP ) {
+ getMainPanel().getTreeFontSet().increaseFontSize();
+ getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
+ }
+ else if ( e.getKeyCode() == KeyEvent.VK_PAGE_DOWN ) {
+ getMainPanel().getTreeFontSet().decreaseFontSize( 1, false );
+ getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged( true );
+ }
+ e.consume();
}
final private void makePopupMenus( final PhylogenyNode node ) {
if ( !ForesterUtil.isEmpty( uri_strs ) ) {
for( final String uri_str : uri_strs ) {
try {
- AptxUtil.launchWebBrowser( new URI( uri_str ),
- isApplet(),
- isApplet() ? obtainApplet() : null,
- "_aptx_seq" );
+ AptxUtil.launchWebBrowser( new URI( uri_str ), "_aptx_seq" );
}
catch ( final IOException e ) {
AptxUtil.showErrorMessage( this, e.toString() );
final String uri_str = TreePanelUtil.createUriForSeqWeb( node, getConfiguration(), this );
if ( !ForesterUtil.isEmpty( uri_str ) ) {
try {
- AptxUtil.launchWebBrowser( new URI( uri_str ),
- isApplet(),
- isApplet() ? obtainApplet() : null,
- "_aptx_seq" );
+ AptxUtil.launchWebBrowser( new URI( uri_str ), "_aptx_seq" );
}
catch ( final IOException e ) {
AptxUtil.showErrorMessage( this, e.toString() );
}
if ( !ForesterUtil.isEmpty( uri_str ) ) {
try {
- AptxUtil.launchWebBrowser( new URI( uri_str ),
- isApplet(),
- isApplet() ? obtainApplet() : null,
- "_aptx_tax" );
+ AptxUtil.launchWebBrowser( new URI( uri_str ), "_aptx_tax" );
}
catch ( final IOException e ) {
AptxUtil.showErrorMessage( this, e.toString() );
final boolean to_pdf,
final boolean to_graphics_file ) {
g.setFont( getTreeFontSet().getSmallFont() );
- if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+ if ( to_pdf || ( to_graphics_file && getOptions().isPrintBlackAndWhite() ) ) {
g.setColor( Color.BLACK );
}
else {
final boolean to_graphics_file,
final boolean to_pdf,
final boolean is_in_found_nodes ) {
+ ////
+ //// TODO
+ ////
Color c = null;
+ int res[] = null;
+ if ( _found_nodes_0 != null || _found_nodes_1 != null ) {
+ res = calcFoundNodesInSubtree( node );
+ }
if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
c = Color.BLACK;
}
- else if ( is_in_found_nodes ) {
- c = getColorForFoundNode( node );
- }
- else if ( getControlPanel().isColorAccordingToSequence() ) {
- c = getSequenceBasedColor( node );
- }
- else if ( getControlPanel().isColorAccordingToTaxonomy() ) {
- c = getTaxonomyBasedColor( node );
- }
+ //TODO
+ //FIXME
+ // else if ( is_in_found_nodes ) {
+ // c = getColorForFoundNode( node );
+ // }
+ // else if ( getControlPanel().isColorAccordingToSequence() ) {
+ // c = getSequenceBasedColor( node );
+ // }
+ // else if ( getControlPanel().isColorAccordingToTaxonomy() ) {
+ // c = getTaxonomyBasedColor( node );
+ // }
else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles()
&& ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) {
c = PhylogenyMethods.getBranchColorValue( node );
}
+ else if ( to_pdf ) {
+ g.setColor( getTreeColorSet().getBranchColorForPdf() );
+ }
else {
c = getTreeColorSet().getCollapseFillColor();
}
else if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.ROUNDED ) {
x += ROUNDED_D;
}
- if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
+ if ( to_pdf || ( to_graphics_file && getOptions().isPrintBlackAndWhite() ) ) {
g.setColor( Color.BLACK );
}
else {
( node.getYcoord() - getFontMetricsForLargeDefaultFont().getMaxDescent() ),
g );
g.setColor( getTreeColorSet().getLostCharactersColor() );
- TreePanel.drawString( lost,
- parent_x + ( ( x - parent_x
- - getFontMetricsForLargeDefaultFont().stringWidth( lost ) ) / 2 ),
- ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ),
- g );
+ TreePanel
+ .drawString( lost,
+ parent_x + ( ( x - parent_x - getFontMetricsForLargeDefaultFont().stringWidth( lost ) )
+ / 2 ),
+ ( node.getYcoord() + getFontMetricsForLargeDefaultFont().getMaxAscent() ),
+ g );
}
}
|| ( getOptions().isShowDefaultNodeShapesForMarkedNodes()
&& ( node.getNodeData().getNodeVisualData() != null )
&& ( !node.getNodeData().getNodeVisualData().isEmpty() ) )
- || ( getControlPanel().isUseVisualStyles()
- && ( ( node.getNodeData().getNodeVisualData() != null )
- && ( ( node.getNodeData().getNodeVisualData().getNodeColor() != null )
- || ( node.getNodeData().getNodeVisualData()
- .getSize() != NodeVisualData.DEFAULT_SIZE )
- || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT )
- || ( node.getNodeData().getNodeVisualData()
- .getShape() != NodeShape.DEFAULT ) ) ) )
+ || ( getControlPanel().isUseVisualStyles() && ( ( node.getNodeData().getNodeVisualData() != null )
+ && ( ( node.getNodeData().getNodeVisualData().getNodeColor() != null )
+ || ( node.getNodeData().getNodeVisualData().getSize() != NodeVisualData.DEFAULT_SIZE )
+ || ( node.getNodeData().getNodeVisualData().getFillType() != NodeFill.DEFAULT )
+ || ( node.getNodeData().getNodeVisualData().getShape() != NodeShape.DEFAULT ) ) ) )
|| ( getControlPanel().isEvents() && node.isHasAssignedEvent()
&& ( node.getNodeData().getEvent().isDuplication()
|| node.getNodeData().getEvent().isSpeciation()
if ( !getControlPanel().isShowInternalData() && !node.isExternal() && !node.isCollapse() ) {
return 0;
}
+ if ( !getControlPanel().isShowExternalData() && ( node.isExternal() || node.isCollapse() ) ) {
+ return 0;
+ }
_sb.setLength( 0 );
int x = 0;
if ( add > 0 ) {
x += paintTaxonomy( g, node, is_in_found_nodes, to_pdf, to_graphics_file, x );
}
setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getSequenceColor() );
+ final boolean saw_species = _sb.length() > 0;
+ _sb.setLength( 0 );
+ nodeDataAsSB( node, _sb );
if ( node.isCollapse() && ( ( !node.isRoot() && !node.getParent().isCollapse() ) || node.isRoot() ) ) {
- if ( _sb.length() > 0 ) {
- _sb.setLength( 0 );
- _sb.append( " (" );
+ if ( ( _sb.length() == 0 ) && !saw_species ) {
+ if ( getOptions().isShowAbbreviatedLabelsForCollapsedNodes()
+ && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames()
+ || getControlPanel().isShowSeqNames() || getControlPanel().isShowNodeNames() ) ) {
+ final PhylogenyNode first = PhylogenyMethods.getFirstExternalNode( node );
+ final PhylogenyNode last = PhylogenyMethods.getLastExternalNode( node );
+ if ( getControlPanel().isShowTaxonomyCode() && first.getNodeData().isHasTaxonomy()
+ && last.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( first.getNodeData().getTaxonomy().getTaxonomyCode() )
+ && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+ addLabelForCollapsed( first.getNodeData().getTaxonomy().getTaxonomyCode(),
+ last.getNodeData().getTaxonomy().getTaxonomyCode(),
+ node.getAllExternalDescendants().size(),
+ node );
+ }
+ else if ( getControlPanel().isShowTaxonomyScientificNames() && first.getNodeData().isHasTaxonomy()
+ && last.getNodeData().isHasTaxonomy()
+ && !ForesterUtil.isEmpty( first.getNodeData().getTaxonomy().getScientificName() )
+ && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getScientificName() ) ) {
+ addLabelForCollapsed( first.getNodeData().getTaxonomy().getScientificName(),
+ last.getNodeData().getTaxonomy().getScientificName(),
+ node.getAllExternalDescendants().size(),
+ node );
+ }
+ else if ( getControlPanel().isShowSeqNames() && first.getNodeData().isHasSequence()
+ && last.getNodeData().isHasSequence()
+ && !ForesterUtil.isEmpty( first.getNodeData().getSequence().getName() )
+ && !ForesterUtil.isEmpty( last.getNodeData().getSequence().getName() ) ) {
+ addLabelForCollapsed( first.getNodeData().getSequence().getName(),
+ last.getNodeData().getSequence().getName(),
+ node.getAllExternalDescendants().size(),
+ node );
+ }
+ else if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( first.getName() )
+ && !ForesterUtil.isEmpty( last.getName() ) ) {
+ addLabelForCollapsed( first.getName(),
+ last.getName(),
+ node.getAllExternalDescendants().size(),
+ node );
+ }
+ }
+ }
+ else if ( ( _sb.length() > 0 ) || saw_species ) {
+ // _sb.setLength( 0 );
+ _sb.append( " [" );
_sb.append( node.getAllExternalDescendants().size() );
- _sb.append( ")" );
+ _sb.append( "]" );
+ if ( _found_nodes_0 != null || _found_nodes_1 != null ) {
+ int[] res = calcFoundNodesInSubtree( node );
+ if ( res[ 0 ] > 0 ) {
+ _sb.append( " [" );
+ _sb.append( res[ 0 ] );
+ _sb.append( "/" );
+ _sb.append( res[ 1 ] );
+ _sb.append( "]" );
+ }
+ }
}
}
else {
- _sb.setLength( 0 );
+ // _sb.setLength( 0 );
}
- nodeDataAsSB( node, _sb );
+ // nodeDataAsSB( node, _sb );
final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
float down_shift_factor = 3.0f;
if ( !node.isExternal() && ( node.getNumberOfDescendants() == 1 ) ) {
down_shift_factor = 1;
}
- final float pos_x = node.getXcoord() + x + 2 + half_box_size;
+ float pos_x;
+ if ( getControlPanel().getTreeDisplayType() == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM
+ && ( node.isExternal() || node.isCollapse() ) ) {
+ pos_x = ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
+ + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x + ( 2 * TreePanel.MOVE ) + getXdistance()
+ + 3 );
+ }
+ else {
+ pos_x = node.getXcoord() + x + 2 + half_box_size;
+ }
float pos_y;
if ( !using_visual_font ) {
pos_y = ( node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent() / down_shift_factor ) );
else {
pos_y = ( node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / down_shift_factor ) );
}
+ if ( getControlPanel().getTreeDisplayType() == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM
+ && ( node.isExternal() || node.isCollapse() ) ) {
+ drawConnection( node.getXcoord(), pos_x - x, node.getYcoord(), 5, 20, g, to_pdf );
+ if ( node.isCollapse() ) {
+ pos_x -= add;
+ }
+ }
final String sb_str = _sb.toString();
// GUILHEM_BEG ______________
if ( _control_panel.isShowSequenceRelations() && node.getNodeData().isHasSequence()
&& ( _query_sequence != null ) ) {
- int nodeTextBoundsWidth = 0;
- if ( sb_str.length() > 0 ) {
- final Rectangle2D node_text_bounds = new TextLayout( sb_str, g.getFont(), _frc ).getBounds(); //would like to remove this 'new', but how...
- nodeTextBoundsWidth = ( int ) node_text_bounds.getWidth();
- }
- if ( node.getNodeData().getSequence().equals( _query_sequence ) ) {
- if ( nodeTextBoundsWidth > 0 ) { // invert font color and background color to show that this is the query sequence
- g.fillRect( ( int ) pos_x - 1, ( int ) pos_y - 8, nodeTextBoundsWidth + 5, 11 );
- g.setColor( getTreeColorSet().getBackgroundColor() );
- }
- }
- else {
- final List<SequenceRelation> seqRelations = node.getNodeData().getSequence().getSequenceRelations();
- for( final SequenceRelation seqRelation : seqRelations ) {
- final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence )
- || seqRelation.getRef1().isEqual( _query_sequence ) )
- && seqRelation.getType()
- .equals( getControlPanel().getSequenceRelationTypeBox().getSelectedItem() );
- if ( fGotRelationWithQuery ) { // we will underline the text to show that this sequence is ortholog to the query
- final double linePosX = node.getXcoord() + 2 + half_box_size;
- final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence()
- || ( seqRelation.getConfidence() == null ) ) ? null
- : " (" + seqRelation.getConfidence().getValue() + ")";
- if ( sConfidence != null ) {
- float confidenceX = pos_x;
- if ( sb_str.length() > 0 ) {
- confidenceX += new TextLayout( sb_str, g.getFont(), _frc ).getBounds().getWidth()
- + CONFIDENCE_LEFT_MARGIN;
- }
- if ( confidenceX > linePosX ) { // let's only display confidence value if we are already displaying at least one of Prot/Gene Name and Taxonomy Code
- final int confidenceWidth = ( int ) new TextLayout( sConfidence, g.getFont(), _frc )
- .getBounds().getWidth();
- TreePanel.drawString( sConfidence, confidenceX, pos_y, g );
- x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
- }
- }
- if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
- {
- if ( nodeTextBoundsWidth == 0 ) {
- nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
- }
- else {
- nodeTextBoundsWidth += 2;
- }
- g.drawLine( ( int ) linePosX + 1,
- 3 + ( int ) pos_y,
- ( int ) linePosX + x + nodeTextBoundsWidth,
- 3 + ( int ) pos_y );
- break;
- }
- }
- }
- }
+ x = paintSequenceRelation( g, node, x, half_box_size, pos_x, pos_y, sb_str );
}
+ // GUILHEM_END _____________
if ( sb_str.length() > 0 ) {
if ( !isAllowAttributedStrings() ) {
TreePanel.drawString( sb_str, pos_x, pos_y, g );
drawStringX( sb_str, pos_x, pos_y, g );
}
}
- // GUILHEM_END _____________
if ( _sb.length() > 0 ) {
if ( !using_visual_font && !is_in_found_nodes ) {
x += getFontMetricsForLargeDefaultFont().stringWidth( _sb.toString() ) + 5;
return x;
}
+ private final int paintSequenceRelation( final Graphics2D g,
+ final PhylogenyNode node,
+ int x,
+ final int half_box_size,
+ final float pos_x,
+ final float pos_y,
+ final String sb_str ) {
+ int nodeTextBoundsWidth = 0;
+ if ( sb_str.length() > 0 ) {
+ final Rectangle2D node_text_bounds = new TextLayout( sb_str, g.getFont(), _frc ).getBounds(); //would like to remove this 'new', but how...
+ nodeTextBoundsWidth = ( int ) node_text_bounds.getWidth();
+ }
+ if ( node.getNodeData().getSequence().equals( _query_sequence ) ) {
+ if ( nodeTextBoundsWidth > 0 ) { // invert font color and background color to show that this is the query sequence
+ g.fillRect( ( int ) pos_x - 1, ( int ) pos_y - 8, nodeTextBoundsWidth + 5, 11 );
+ g.setColor( getTreeColorSet().getBackgroundColor() );
+ }
+ }
+ else {
+ final List<SequenceRelation> seqRelations = node.getNodeData().getSequence().getSequenceRelations();
+ for( final SequenceRelation seqRelation : seqRelations ) {
+ final boolean fGotRelationWithQuery = ( seqRelation.getRef0().isEqual( _query_sequence )
+ || seqRelation.getRef1().isEqual( _query_sequence ) )
+ && seqRelation.getType()
+ .equals( getControlPanel().getSequenceRelationTypeBox().getSelectedItem() );
+ if ( fGotRelationWithQuery ) { // we will underline the text to show that this sequence is ortholog to the query
+ final double linePosX = node.getXcoord() + 2 + half_box_size;
+ final String sConfidence = ( !getControlPanel().isShowSequenceRelationConfidence()
+ || ( seqRelation.getConfidence() == null ) ) ? null
+ : " (" + seqRelation.getConfidence().getValue() + ")";
+ if ( sConfidence != null ) {
+ float confidenceX = pos_x;
+ if ( sb_str.length() > 0 ) {
+ confidenceX += new TextLayout( sb_str, g.getFont(), _frc ).getBounds().getWidth()
+ + CONFIDENCE_LEFT_MARGIN;
+ }
+ if ( confidenceX > linePosX ) { // let's only display confidence value if we are already displaying at least one of Prot/Gene Name and Taxonomy Code
+ final int confidenceWidth = ( int ) new TextLayout( sConfidence, g.getFont(), _frc )
+ .getBounds().getWidth();
+ TreePanel.drawString( sConfidence, confidenceX, pos_y, g );
+ x += CONFIDENCE_LEFT_MARGIN + confidenceWidth;
+ }
+ }
+ if ( ( x + nodeTextBoundsWidth ) > 0 ) /* we only underline if there is something displayed */
+ {
+ if ( nodeTextBoundsWidth == 0 ) {
+ nodeTextBoundsWidth -= 3; /* the gap between taxonomy code and node name should not be underlined if nothing comes after it */
+ }
+ else {
+ nodeTextBoundsWidth += 2;
+ }
+ g.drawLine( ( int ) linePosX + 1,
+ 3 + ( int ) pos_y,
+ ( int ) linePosX + x + nodeTextBoundsWidth,
+ 3 + ( int ) pos_y );
+ break;
+ }
+ }
+ }
+ }
+ return x;
+ }
+
+ private final void drawConnection( final float x1,
+ final float x2,
+ final float y,
+ final int dist_left,
+ final int dist_right,
+ final Graphics2D g,
+ final boolean pdf ) {
+ if ( ( ( x1 + dist_left ) < ( x2 - dist_right ) ) ) {
+ final Stroke strok = g.getStroke();
+ Color col = null;
+ if ( strok == STROKE_005 ) {
+ g.setStroke( STROKE_001_DASHED );
+ }
+ else if ( strok == STROKE_01 ) {
+ g.setStroke( STROKE_005_DASHED );
+ }
+ else {
+ g.setStroke( STROKE_01_DASHED );
+ }
+ if ( pdf ) {
+ col = g.getColor();
+ g.setColor( lighter( col ) );
+ }
+ drawLine( x1 + dist_left, y, x2 - dist_right, y, g );
+ g.setStroke( strok );
+ if ( pdf ) {
+ g.setColor( col );
+ }
+ }
+ }
+
+ public static Color lighter( final Color color ) {
+ if ( ( color.getRed() == 0 ) && ( color.getGreen() == 0 ) && ( color.getBlue() == 0 ) ) {
+ return new Color( 200, 200, 200 );
+ }
+ else {
+ return color;
+ }
+ }
+
+ private final void addLabelForCollapsed( final String first,
+ final String last,
+ final int size,
+ final PhylogenyNode node ) {
+ _sb.append( first.length() < AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME ? first
+ : first.substring( 0, AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME - 1 ) );
+ _sb.append( " ... " );
+ _sb.append( last.length() < AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME ? last
+ : last.substring( 0, AptxConstants.MAX_LENGTH_FOR_COLLAPSED_NAME - 1 ) );
+ _sb.append( " (" + size + ")" );
+ if ( _found_nodes_0 != null || _found_nodes_1 != null ) {
+ /////
+ /////
+ int[] res = calcFoundNodesInSubtree( node );
+ if ( res[ 0 ] > 0 ) {
+ _sb.append( " [" );
+ _sb.append( res[ 0 ] );
+ _sb.append( "/" );
+ _sb.append( res[ 1 ] );
+ _sb.append( "]" );
+ }
+ }
+ }
+
+ private final int[] calcFoundNodesInSubtree( final PhylogenyNode node ) {
+ final List<PhylogenyNode> all_descs = PhylogenyMethods.getAllDescendants( node );
+ int res[] = new int[ 2 ];
+ int found = 0;
+ int total = 0;
+ for( final PhylogenyNode desc : all_descs ) {
+ if ( desc.isHasNodeData() ) {
+ if ( ( _found_nodes_0 != null && _found_nodes_0.contains( desc.getId() ) )
+ || ( _found_nodes_1 != null && _found_nodes_1.contains( desc.getId() ) ) ) {
+ ++found;
+ }
+ ++total;
+ }
+ }
+ res[ 0 ] = found;
+ res[ 1 ] = total;
+ return res;
+ }
+
private final boolean isAllowAttributedStrings() {
return false;
}
if ( !node.isExternal() && !node.isCollapse() ) {
boolean first_child = true;
float y2 = 0.0f;
- final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
+ //final int parent_max_branch_to_leaf = getMaxBranchesToLeaf( node );
for( int i = 0; i < node.getNumberOfDescendants(); ++i ) {
final PhylogenyNode child_node = node.getChildNode( i );
final int factor_x = node.getNumberOfExternalNodes() - child_node.getNumberOfExternalNodes();
&& ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
paintMolecularSequences( g, node, to_pdf );
}
- if ( dynamically_hide && !is_in_found_nodes && ( ( node.isExternal()
- && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) )
+ if ( dynamically_hide && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) )
|| ( !node.isExternal() && ( ( new_x_min < 20 )
|| ( ( _y_distance * node.getNumberOfExternalNodes() ) < getFontMetricsForLargeDefaultFont()
.getHeight() ) ) ) ) ) {
if ( ( !getControlPanel().isShowInternalData() && !node.isExternal() ) ) {
return;
}
+ if ( ( !getControlPanel().isShowExternalData() && node.isExternal() ) ) {
+ return;
+ }
if ( getControlPanel().isShowDomainArchitectures() && node.getNodeData().isHasSequence()
&& ( node.getNodeData().getSequence().getDomainArchitecture() != null ) && ( node.getNodeData()
.getSequence().getDomainArchitecture() instanceof RenderableDomainArchitecture ) ) {
if ( getOptions().isLineUpRendarableNodeData() ) {
if ( getOptions().isRightLineUpDomains() ) {
rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
- + _length_of_longest_text
+ + _length_of_longest_text + 50 //TODO why plus 50?
+ ( ( _longest_domain - rds.getTotalLength() ) * rds.getRenderingFactorWidth() ) ),
node.getYcoord() - ( h / 2.0f ),
g,
}
else {
rds.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
- + _length_of_longest_text ), node.getYcoord() - ( h / 2.0f ), g, this, to_pdf );
+ + _length_of_longest_text + 50 ),
+ node.getYcoord() - ( h / 2.0f ),
+ g,
+ this,
+ to_pdf );
}
}
else {
//if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() )
// && ( node.getNodeData().getSequence().isMolecularSequenceAligned() )
// && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) {
- // paintMolecularSequences( g, node, to_pdf );
+ // paintMolecularSequences( g, node, to_pdf );
//}
}
final Taxonomy taxonomy = node.getNodeData().getTaxonomy();
final boolean using_visual_font = setFont( g, node, is_in_found_nodes );
setColor( g, node, to_graphics_file, to_pdf, is_in_found_nodes, getTreeColorSet().getTaxonomyColor() );
- final float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift;
+ float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift;
+ if ( getControlPanel().getTreeDisplayType() == Options.PHYLOGENY_DISPLAY_TYPE.ALIGNED_PHYLOGRAM
+ && node.isExternal() ) {
+ start_x = ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() )
+ + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift + ( 2 * TreePanel.MOVE ) + getXdistance()
+ + 3 );
+ }
float start_y;
if ( !using_visual_font ) {
start_y = node.getYcoord() + ( getFontMetricsForLargeDefaultFont().getAscent()
}
private final StringBuffer propertiesToString( final PhylogenyNode node ) {
- final PropertiesMap properties = node.getNodeData().getProperties();
- final StringBuffer sb = new StringBuffer();
- boolean first = true;
- for( final String ref : properties.getPropertyRefs() ) {
- if ( first ) {
- first = false;
- }
- else {
- sb.append( " " );
- }
- final Property p = properties.getProperty( ref );
- sb.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
- sb.append( "=" );
- sb.append( p.getValue() );
- if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
- sb.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
- }
- }
- return sb;
+ return node.getNodeData().getProperties().asText();
}
private void setColor( final Graphics2D g,
_urt_factor_ov = urt_factor_ov;
}
- private void showExtDescNodeData( final PhylogenyNode node ) {
+ private void showExtDescNodeData( final PhylogenyNode node, final char separator ) {
final List<String> data = new ArrayList<String>();
final List<PhylogenyNode> nodes = node.getAllExternalDescendants();
if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) {
if ( n.getNodeData().isHasSequence()
&& !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
final StringBuilder ann = new StringBuilder();
- if ( !ForesterUtil.isEmpty( n.getName() ) ) {
+ if ( getControlPanel().isShowNodeNames() && !ForesterUtil.isEmpty( n.getName() ) ) {
ann.append( n.getName() );
- ann.append( "|" );
+ ann.append( separator );
}
- if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
- ann.append( "SYM=" );
+ if ( n.getNodeData().isHasTaxonomy() ) {
+ if ( getControlPanel().isShowTaxonomyCode()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
+ ann.append( n.getNodeData().getTaxonomy().getTaxonomyCode() );
+ ann.append( separator );
+ }
+ if ( getControlPanel().isShowTaxonomyScientificNames()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
+ ann.append( n.getNodeData().getTaxonomy().getScientificName() );
+ ann.append( separator );
+ }
+ if ( getControlPanel().isShowTaxonomyCommonNames()
+ && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) ) {
+ ann.append( n.getNodeData().getTaxonomy().getCommonName() );
+ ann.append( separator );
+ }
+ }
+ if ( getControlPanel().isShowSeqSymbols()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getSymbol() ) ) {
ann.append( n.getNodeData().getSequence().getSymbol() );
- ann.append( "|" );
+ ann.append( separator );
}
- if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
- ann.append( "NAME=" );
+ if ( getControlPanel().isShowSeqNames()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
ann.append( n.getNodeData().getSequence().getName() );
- ann.append( "|" );
+ ann.append( separator );
}
- if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
- ann.append( "GN=" );
+ if ( getControlPanel().isShowGeneNames()
+ && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getGeneName() ) ) {
ann.append( n.getNodeData().getSequence().getGeneName() );
- ann.append( "|" );
+ ann.append( separator );
}
- if ( n.getNodeData().getSequence().getAccession() != null ) {
- ann.append( "ACC=" );
+ if ( getControlPanel().isShowSequenceAcc()
+ && n.getNodeData().getSequence().getAccession() != null ) {
ann.append( n.getNodeData().getSequence().getAccession().asText() );
- ann.append( "|" );
+ ann.append( separator );
}
- if ( n.getNodeData().isHasTaxonomy() ) {
- if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) {
- ann.append( "TAXID=" );
- ann.append( n.getNodeData().getTaxonomy().getTaxonomyCode() );
- ann.append( "|" );
- }
- if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
- ann.append( "SN=" );
- ann.append( n.getNodeData().getTaxonomy().getScientificName() );
- ann.append( "|" );
- }
- }
- String ann_str;
- if ( ann.charAt( ann.length() - 1 ) == '|' ) {
+
+ final String ann_str;
+ if ( ann.length() > 0 && ann.charAt( ann.length() - 1 ) == separator ) {
ann_str = ann.substring( 0, ann.length() - 1 );
}
else {
+ ", unique entries: " + size;
}
final String s = sb.toString().trim();
- if ( getMainPanel().getMainFrame() == null ) {
- // Must be "E" applet version.
- final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
- ae.showTextFrame( s, title );
- }
- else {
- getMainPanel().getMainFrame().showTextFrame( s, title );
- }
+ getMainPanel().getMainFrame().showTextFrame( s, title );
}
}
}
}
}
if ( node.getNodeData().isHasProperties() ) {
- final PropertiesMap properties = node.getNodeData().getProperties();
- for( final String ref : properties.getPropertyRefs() ) {
+ if ( _popup_buffer.length() > 0 ) {
_popup_buffer.append( "\n" );
- final Property p = properties.getProperty( ref );
- _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getRef() ) );
- _popup_buffer.append( "=" );
- _popup_buffer.append( p.getValue() );
- if ( !ForesterUtil.isEmpty( p.getUnit() ) ) {
- _popup_buffer.append( TreePanelUtil.getPartAfterColon( p.getUnit() ) );
- }
}
+ _popup_buffer.append( node.getNodeData().getProperties().asText() );
}
if ( _popup_buffer.length() > 0 ) {
if ( !getConfiguration().isUseNativeUI() ) {
else {
getControlPanel().setDrawPhylogramEnabled( false );
}
- if ( getMainPanel().getMainFrame() == null ) {
- // Must be "E" applet version.
- ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
- .setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
- }
- else {
- getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
- }
+ getMainPanel().getMainFrame().setSelectedTypeInTypeMenu( getPhylogenyGraphicsType() );
}
final void calcMaxDepth() {
setYdistance( ydist );
setOvXDistance( ov_xdist );
final double height = _phylogeny.calculateHeight( !_options.isCollapsedWithAverageHeigh() );
+ //final double height = PhylogenyMethods.calculateMaxDepth( _phylogeny );
if ( height > 0 ) {
final float corr = ( float ) ( ( x - ( 2.0 * TreePanel.MOVE ) - getLongestExtNodeInfo()
- getXdistance() ) / height );
}
boolean use_vis = false;
final Graphics2D g = ( Graphics2D ) getGraphics();
- if ( getControlPanel().isUseVisualStyles() ) {
+ if ( g != null && getControlPanel().isUseVisualStyles() ) {
use_vis = setFont( g, node, false );
}
if ( !use_vis ) {
}
}
- void checkForVectorProperties( final Phylogeny phy ) {
- final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
- for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
- final PhylogenyNode node = iter.next();
- if ( node.getNodeData().getProperties() != null ) {
- final PropertiesMap pm = node.getNodeData().getProperties();
- final double[] vector = new double[ pm.getProperties().size() ];
- int counter = 0;
- for( final String ref : pm.getProperties().keySet() ) {
- if ( ref.startsWith( PhyloXmlUtil.VECTOR_PROPERTY_REF ) ) {
- final Property p = pm.getProperty( ref );
- final String value_str = p.getValue();
- final String index_str = ref.substring( PhyloXmlUtil.VECTOR_PROPERTY_REF.length(),
- ref.length() );
- double d = -100;
- try {
- d = Double.parseDouble( value_str );
- }
- catch ( final NumberFormatException e ) {
- JOptionPane.showMessageDialog( this,
- "Could not parse \"" + value_str + "\" into a decimal value",
- "Problem with Vector Data",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- int i = -1;
- try {
- i = Integer.parseInt( index_str );
- }
- catch ( final NumberFormatException e ) {
- JOptionPane.showMessageDialog( this,
- "Could not parse \"" + index_str
- + "\" into index for vector data",
- "Problem with Vector Data",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( i < 0 ) {
- JOptionPane.showMessageDialog( this,
- "Attempt to use negative index for vector data",
- "Problem with Vector Data",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- vector[ i ] = d;
- ++counter;
- stats.addValue( d );
- }
- }
- final List<Double> vector_l = new ArrayList<Double>( counter );
- for( int i = 0; i < counter; ++i ) {
- vector_l.add( vector[ i ] );
- }
- node.getNodeData().setVector( vector_l );
- }
- }
- if ( stats.getN() > 0 ) {
- _statistics_for_vector_data = stats;
- }
- }
-
void clearCurrentExternalNodesDataBuffer() {
setCurrentExternalNodesDataBuffer( new StringBuilder() );
}
setArrowCursor();
}
-
-
final void colorRank( final String rank ) {
if ( ( _phylogeny == null ) || ( _phylogeny.getNumberOfExternalNodes() < 2 ) ) {
return;
* @param y
* @return pointer to the node at x,y, null if not found
*/
- final PhylogenyNode findNode( final int x, final int y ) {
+ public final PhylogenyNode findNode( final int x, final int y ) {
if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return null;
}
return _domain_structure_e_value_thr_exp;
}
- final Set<Long> getFoundNodes0() {
+ public final Set<Long> getFoundNodes0() {
return _found_nodes_0;
}
- final Set<Long> getFoundNodes1() {
+ public final Set<Long> getFoundNodes1() {
return _found_nodes_1;
}
- List<PhylogenyNode> getFoundNodesAsListOfPhylogenyNodes() {
+ public List<PhylogenyNode> getFoundNodesAsListOfPhylogenyNodes() {
final List<PhylogenyNode> additional_nodes = new ArrayList<PhylogenyNode>();
if ( getFoundNodes0() != null ) {
for( final Long id : getFoundNodes0() ) {
return getTreeColorSet().getTaxonomyColor();
}
- final File getTreeFile() {
+ public final File getTreeFile() {
return _treefile;
}
&& ( e.getY() <= ( getOvRectangle().getY() + getOvRectangle().getHeight() + 1 ) ) );
}
- final boolean isApplet() {
- return getMainPanel() instanceof MainPanelApplets;
- }
-
final boolean isCanCollapse() {
return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
}
}
}
else {
- // no node was clicked
+ // no node was clicked so partition tree instead
_highlight_node = null;
- }
+
+ _clicked_x = e.getX();
+ if (!getPhylogeny().isEmpty()) {
+ // should be calculated on each partition as the tree can theoretically
+ // change in the meantime
+ PhylogenyNode furthestNode = PhylogenyMethods.calculateNodeWithMaxDistanceToRoot( _phylogeny );
+ _furthest_node_x = furthestNode.getXcoord();
+ _root_x = _phylogeny.getRoot().getXcoord();
+
+ // don't bother if 0 distance tree or clicked x lies outside of tree
+ if (_furthest_node_x != _root_x && !(_clicked_x < _root_x || _clicked_x > _furthest_node_x))
+ {
+ _partition_tree = true;
+
+ }
+
+
}
+ }
+ }
repaint();
}
_urt_factor *= f;
}
- final JApplet obtainApplet() {
- return ( ( MainPanelApplets ) getMainPanel() ).getApplet();
- }
-
final void paintBranchCircular( final PhylogenyNode p,
final PhylogenyNode c,
final Graphics2D g,
final int graphics_file_height,
final int graphics_file_x,
final int graphics_file_y ) {
+ if (_partition_tree) {
+// float threshold = (_clicked_x - _root_x) / (_furthest_node_x - _root_x);
+// drawLine( _clicked_x, 0, _clicked_x, getHeight(),g);
+
+ _partition_tree = false;
+ }
+
if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return;
}
}
}
final boolean disallow_shortcutting = ( dynamic_hiding_factor < 40 )
- || getControlPanel().isUseVisualStyles() || getOptions().isShowDefaultNodeShapesForMarkedNodes()
- || ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() )
- || ( ( getFoundNodes1() != null ) && !getFoundNodes1().isEmpty() )
- || ( ( getCurrentExternalNodes() != null ) && !getCurrentExternalNodes().isEmpty() )
+ /* || getControlPanel().isUseVisualStyles() || getOptions().isShowDefaultNodeShapesForMarkedNodes()*/ //TODO check if this is really not needed.
|| to_graphics_file || to_pdf;
for( final PhylogenyNode element : _nodes_in_preorder ) {
paintNodeRectangular( g,
final void recalculateMaxDistanceToRoot() {
_max_distance_to_root = PhylogenyMethods.calculateMaxDistanceToRoot( getPhylogeny() );
+ if ( getPhylogeny().getRoot().getDistanceToParent() > 0 ) {
+ _max_distance_to_root += getPhylogeny().getRoot().getDistanceToParent();
+ }
}
/**
_current_external_nodes_data_buffer = sb;
}
- final void setFoundNodes0( final Set<Long> found_nodes ) {
+ public final void setFoundNodes0( final Set<Long> found_nodes ) {
_found_nodes_0 = found_nodes;
}
- final void setFoundNodes1( final Set<Long> found_nodes ) {
+ public final void setFoundNodes1( final Set<Long> found_nodes ) {
_found_nodes_1 = found_nodes;
}
getTreeFontSet().tinyFonts();
}
- final void setTreeFile( final File treefile ) {
+ public final void setTreeFile( final File treefile ) {
_treefile = treefile;
}
_sub_phylogenies_temp_roots[ _subtree_index ] = node;
++_subtree_index;
_phylogeny = TreePanelUtil.subTree( node, _phylogeny );
+ if ( _phylogeny.getRoot().isCollapse() ) {
+ _phylogeny.getRoot().setCollapse( false );
+ }
+ _phylogeny.externalNodesHaveChanged();
+ _phylogeny.clearHashIdToNodeMap();
+ _phylogeny.recalculateNumberOfExternalDescendants( true );
updateSubSuperTreeButton();
+ getMainPanel().getControlPanel().search0();
+ getMainPanel().getControlPanel().search1();
+ resetRankCollapseRankValue();
+ resetDepthCollapseDepthValue();
+ getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
+ getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
+ getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
}
else if ( node.isRoot() && isCurrentTreeIsSubtree() ) {
superTree();
_sub_phylogenies[ _subtree_index ] = null;
_sub_phylogenies_temp_roots[ _subtree_index ] = null;
_phylogeny = _sub_phylogenies[ --_subtree_index ];
+ _phylogeny.externalNodesHaveChanged();
+ _phylogeny.clearHashIdToNodeMap();
+ _phylogeny.recalculateNumberOfExternalDescendants( true );
+ getMainPanel().getControlPanel().search0();
+ getMainPanel().getControlPanel().search1();
+ resetRankCollapseRankValue();
+ resetDepthCollapseDepthValue();
+ getMainPanel().getControlPanel().updateDomainStructureEvaluethresholdDisplay();
+ getMainPanel().getControlPanel().updateDepthCollapseDepthDisplay();
+ getMainPanel().getControlPanel().updateRankCollapseRankDisplay();
updateSubSuperTreeButton();
}
}
}
+ final void updateButtonToUncollapseAll() {
+ if ( PhylogenyMethods.isHasCollapsedNodes( _phylogeny ) ) {
+ getControlPanel().activateButtonToUncollapseAll();
+ }
+ else {
+ getControlPanel().deactivateButtonToUncollapseAll();
+ }
+ }
+
final void zoomInDomainStructure() {
if ( _domain_structure_width < 2000 ) {
_domain_structure_width *= 1.2;
--_depth_collapse_level;
PhylogenyMethods.collapseToDepth( _phylogeny, _depth_collapse_level );
}
-
}
}
}
else {
--_rank_collapse_level;
- PhylogenyMethods.collapseToRank( _phylogeny, mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+ PhylogenyMethods.collapseToRank( _phylogeny,
+ mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
}
}
}
}
-
public void increaseRankCollapseLevel() {
if ( ( _phylogeny != null ) && ( _phylogeny.getNumberOfExternalNodes() > 2 ) ) {
final String ranks[] = PhylogenyMethods.obtainPresentRanksSorted( _phylogeny );
if ( ranks.length > 1 ) {
- if ( _rank_collapse_level >= (ranks.length - 1 ) ) {
+ if ( _rank_collapse_level >= ( ranks.length - 1 ) ) {
_rank_collapse_level = 0;
- PhylogenyMethods.collapseToRank( _phylogeny,mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+ PhylogenyMethods.collapseToRank( _phylogeny,
+ mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
}
- else if ( _rank_collapse_level == (ranks.length - 2 ) ) {
+ else if ( _rank_collapse_level == ( ranks.length - 2 ) ) {
++_rank_collapse_level;
uncollapseAll();
}
else {
++_rank_collapse_level;
- PhylogenyMethods.collapseToRank( _phylogeny,mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
+ PhylogenyMethods.collapseToRank( _phylogeny,
+ mapToAbsoluteRankLevel( ranks, _rank_collapse_level ) );
}
}
}
}
-
private final static int mapToAbsoluteRankLevel( final String present_ranks_sorted[],
final int rank_collapse_level ) {
final String rank_str = present_ranks_sorted[ rank_collapse_level ];
}
return TaxonomyUtil.RANK_TO_INT.get( rank_str );
}
-
+
private final void uncollapseAll() {
- final PhylogenyNodeIterator it = new PreorderTreeIterator(_phylogeny );
+ final PhylogenyNodeIterator it = new PreorderTreeIterator( _phylogeny );
while ( it.hasNext() ) {
it.next().setCollapse( false );
}
}
-
+
final int resetDepthCollapseDepthValue() {
return _depth_collapse_level = -1;
}
final void setDepthCollapseDepthValue( final int depth_collapse_level ) {
_depth_collapse_level = depth_collapse_level;
}
-
+
final int resetRankCollapseRankValue() {
return _rank_collapse_level = -1;
}