X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=75ef09b0a8d4783b426cdf9f29db0f0381ac59ad;hb=c0439ed8b088887ffea2faf11bc7897333287cb3;hp=496157993cc156c6fd7a136b091da4bbf1ec62e4;hpb=6035dd06c322b649ac5a0c4df39abbf4503d3ad1;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 4961579..75ef09b 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -84,7 +84,6 @@ 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; @@ -122,8 +121,6 @@ import org.forester.phylogeny.data.NodeVisualData; 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; @@ -131,7 +128,6 @@ import org.forester.phylogeny.data.Taxonomy; 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; @@ -239,15 +235,13 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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, + private static final BasicStroke STROKE_01_DASHED = new BasicStroke( 0.1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 0, new float[] { - 2.0f }, 0f ); - - - + 2.0f }, + 0f ); private static final BasicStroke STROKE_005_DASHED = new BasicStroke( 0.05f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, @@ -385,7 +379,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee init(); // if ( !_phylogeny.isEmpty() ) { _phylogeny.recalculateNumberOfExternalDescendants( true ); - checkForVectorProperties( _phylogeny ); // } setBackground( getTreeColorSet().getBackgroundColor() ); final MouseListener mouse_listener = new MouseListener( this ); @@ -454,7 +447,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee repaint(); } } - if ( e.isControlDown() ) { + if ( e.isControlDown() && e.isShiftDown() ) { if ( notches < 0 ) { getTreeFontSet().increaseFontSize(); } @@ -466,6 +459,21 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) ) { @@ -727,12 +735,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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(); @@ -1293,16 +1297,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) { @@ -1584,89 +1578,47 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ); @@ -1680,6 +1632,50 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) ) { @@ -1706,16 +1702,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) { @@ -1736,8 +1723,19 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) { @@ -1986,10 +1984,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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() ); @@ -2014,10 +2009,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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() ); @@ -2096,10 +2088,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } 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() ); @@ -2577,11 +2566,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee ( 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 ); } } @@ -2642,14 +2632,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee || ( 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() @@ -2833,6 +2820,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) { @@ -2850,11 +2840,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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() ); - boolean saw_species = _sb.length() > 0; + 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 && !saw_species ) { + if ( ( _sb.length() == 0 ) && !saw_species ) { if ( getOptions().isShowAbbreviatedLabelsForCollapsedNodes() && ( getControlPanel().isShowTaxonomyCode() || getControlPanel().isShowTaxonomyScientificNames() || getControlPanel().isShowSeqNames() || getControlPanel().isShowNodeNames() ) ) { @@ -2864,7 +2854,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && 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() ); @@ -2873,7 +2862,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && last.getNodeData().isHasTaxonomy() && !ForesterUtil.isEmpty( first.getNodeData().getTaxonomy().getScientificName() ) && !ForesterUtil.isEmpty( last.getNodeData().getTaxonomy().getScientificName() ) ) { - addLabelForCollapsed( first.getNodeData().getTaxonomy().getScientificName(), + addLabelForCollapsed( first.getNodeData().getTaxonomy().getScientificName(), last.getNodeData().getTaxonomy().getScientificName(), node.getAllExternalDescendants().size() ); } @@ -2893,31 +2882,28 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } } - else if ( _sb.length() > 0 || saw_species ) { - // _sb.setLength( 0 ); - _sb.append( " (" ); + else if ( ( _sb.length() > 0 ) || saw_species ) { + // _sb.setLength( 0 ); + _sb.append( " [" ); _sb.append( node.getAllExternalDescendants().size() ); - _sb.append( ")" ); - + _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; } float pos_x; - if ( getControlPanel().isDrawPhylogram() && getOptions().isAlignExtLabelsInPhylogram() && (node.isExternal() || node.isCollapse() ) ) { + 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; @@ -2929,9 +2915,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { pos_y = ( node.getYcoord() + ( getFontMetrics( g.getFont() ).getAscent() / down_shift_factor ) ); } - if ( getControlPanel().isDrawPhylogram() && getOptions().isAlignExtLabelsInPhylogram() && (node.isExternal() || node.isCollapse() ) ) { + 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()) { + if ( node.isCollapse() ) { pos_x -= add; } } @@ -2950,7 +2937,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee drawStringX( sb_str, pos_x, pos_y, g ); } } - if ( _sb.length() > 0 ) { if ( !using_visual_font && !is_in_found_nodes ) { x += getFontMetricsForLargeDefaultFont().stringWidth( _sb.toString() ) + 5; @@ -3029,12 +3015,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } private final int paintSequenceRelation( final Graphics2D g, - final PhylogenyNode node, - int x, - final int half_box_size, - float pos_x, - float pos_y, - final String sb_str ) { + 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... @@ -3301,7 +3287,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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(); @@ -3413,8 +3399,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && ( !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() ) ) ) ) ) { @@ -3435,6 +3420,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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 ) ) { @@ -3636,7 +3624,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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() ); float start_x = node.getXcoord() + 3 + ( getOptions().getDefaultNodeShapeSize() / 2 ) + x_shift; - if ( getControlPanel().isDrawPhylogram() && getOptions().isAlignExtLabelsInPhylogram() && node.isExternal() ) { + 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 ); @@ -3876,25 +3865,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } 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, @@ -4254,14 +4225,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee + ", 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 ); } } } @@ -4452,17 +4416,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } 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() ) { @@ -4573,14 +4530,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee 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() { @@ -4863,67 +4813,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - 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 vector_l = new ArrayList( 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() ); } @@ -5287,10 +5176,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && ( e.getY() <= ( getOvRectangle().getY() + getOvRectangle().getHeight() + 1 ) ) ); } - final boolean isApplet() { - return getMainPanel() instanceof MainPanelApplets; - } - final boolean isCanCollapse() { return ( getPhylogenyGraphicsType() != PHYLOGENY_GRAPHICS_TYPE.UNROOTED ); } @@ -5592,10 +5477,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _urt_factor *= f; } - final JApplet obtainApplet() { - return ( ( MainPanelApplets ) getMainPanel() ).getApplet(); - } - final void paintBranchCircular( final PhylogenyNode p, final PhylogenyNode c, final Graphics2D g, @@ -5802,10 +5683,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } 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, @@ -6400,9 +6278,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee getControlPanel().activateButtonToReturnToSuperTree( _subtree_index ); } } - + final void updateButtonToUncollapseAll() { - if ( PhylogenyMethods.isHasCollapsedNodes(_phylogeny) ) { + if ( PhylogenyMethods.isHasCollapsedNodes( _phylogeny ) ) { getControlPanel().activateButtonToUncollapseAll(); } else {