X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FNodeEditPanel.java;h=2392620e6635e238f4febdd4443c99165d968ff7;hb=c4dc9d9c84ce985a3f65c07f818df8e7d9054dd8;hp=81e869d42c0e2868439170b2d87c848183c6f58d;hpb=0f295917c869b17a9322af3e738e3527ba9b31d4;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java b/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java index 81e869d..2392620 100644 --- a/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/NodeEditPanel.java @@ -52,6 +52,7 @@ import org.forester.archaeopteryx.tools.ImageLoader; import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Accession; +import org.forester.phylogeny.data.BranchWidth; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.Date; import org.forester.phylogeny.data.Distribution; @@ -59,6 +60,7 @@ import org.forester.phylogeny.data.Event; import org.forester.phylogeny.data.Identifier; import org.forester.phylogeny.data.MultipleUris; import org.forester.phylogeny.data.PhylogenyData; +import org.forester.phylogeny.data.PhylogenyDataUtil; import org.forester.phylogeny.data.Point; import org.forester.phylogeny.data.Reference; import org.forester.phylogeny.data.Sequence; @@ -152,7 +154,7 @@ class NodeEditPanel extends JPanel { top.add( category ); addSubelementEditable( category, NodePanel.NODE_NAME, phylogeny_node.getName(), PHYLOXML_TAG.NODE_NAME ); String bl = ""; - if ( phylogeny_node.getDistanceToParent() != PhylogenyNode.DISTANCE_DEFAULT ) { + if ( phylogeny_node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) { bl = ForesterUtil.FORMATTER_6.format( phylogeny_node.getDistanceToParent() ); } addSubelementEditable( category, NodePanel.NODE_BRANCH_LENGTH, bl, PHYLOXML_TAG.NODE_BRANCH_LENGTH ); @@ -183,6 +185,12 @@ class NodeEditPanel extends JPanel { "", PHYLOXML_TAG.CONFIDENCE_TYPE, counter ); + String bw = "1"; + if ( ( phylogeny_node.getBranchData().getBranchWidth() != null ) + && ( phylogeny_node.getBranchData().getBranchWidth().getValue() != BranchWidth.BRANCH_WIDTH_DEFAULT_VALUE ) ) { + bw = ForesterUtil.FORMATTER_3.format( phylogeny_node.getBranchData().getBranchWidth().getValue() ); + } + addSubelementEditable( category, NodePanel.NODE_BRANCH_WIDTH, bw, PHYLOXML_TAG.NODE_BRANCH_WIDTH ); } // private void addAnnotation( final DefaultMutableTreeNode top, final Annotation ann, final String name ) { @@ -644,7 +652,7 @@ class NodeEditPanel extends JPanel { break; case NODE_BRANCH_LENGTH: if ( ForesterUtil.isEmpty( value ) ) { - getMyNode().setDistanceToParent( PhylogenyNode.DISTANCE_DEFAULT ); + getMyNode().setDistanceToParent( PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ); } else { try { @@ -659,6 +667,28 @@ class NodeEditPanel extends JPanel { } } break; + case NODE_BRANCH_WIDTH: + if ( ForesterUtil.isEmpty( value ) || value.equals( "1" ) ) { + if ( getMyNode().getBranchData().getBranchWidth() != null ) { + getMyNode().getBranchData().setBranchWidth( new BranchWidth() ); + } + } + else { + try { + final double bw = ForesterUtil.parseDouble( value ); + if ( bw >= 0 ) { + getMyNode().getBranchData().setBranchWidth( new BranchWidth( bw ) ); + } + } + catch ( final ParseException e ) { + JOptionPane.showMessageDialog( this, + "failed to parse branch width from: " + value, + "Error", + JOptionPane.ERROR_MESSAGE ); + mtn.setUserObject( "" ); + } + } + break; case CONFIDENCE_VALUE: double confidence = Confidence.CONFIDENCE_DEFAULT_VALUE; if ( !ForesterUtil.isEmpty( value ) ) { @@ -684,7 +714,8 @@ class NodeEditPanel extends JPanel { } else { final String type = getMyNode().getBranchData().getConfidences().get( number ).getType(); - getMyNode().getBranchData().getConfidences().set( number, new Confidence( confidence, type ) ); + final double sd = getMyNode().getBranchData().getConfidences().get( number ).getStandardDeviation(); + getMyNode().getBranchData().getConfidences().set( number, new Confidence( confidence, type, sd ) ); } break; case CONFIDENCE_TYPE: @@ -698,7 +729,8 @@ class NodeEditPanel extends JPanel { } else { final double v = getMyNode().getBranchData().getConfidences().get( number ).getValue(); - getMyNode().getBranchData().getConfidences().set( number, new Confidence( v, value ) ); + final double sd = getMyNode().getBranchData().getConfidences().get( number ).getStandardDeviation(); + getMyNode().getBranchData().getConfidences().set( number, new Confidence( v, value, sd ) ); } break; case TAXONOMY_CODE: @@ -793,7 +825,7 @@ class NodeEditPanel extends JPanel { break; case SEQ_MOL_SEQ: ForesterUtil.ensurePresenceOfSequence( getMyNode() ); - getMyNode().getNodeData().getSequence().setMolecularSequence( value ); + getMyNode().getNodeData().getSequence().setMolecularSequence( value.replaceAll( "[^a-zA-Z-]", "" ) ); break; case SEQ_NAME: ForesterUtil.ensurePresenceOfSequence( getMyNode() ); @@ -1020,6 +1052,7 @@ class NodeEditPanel extends JPanel { private enum PHYLOXML_TAG { NODE_NAME, NODE_BRANCH_LENGTH, + NODE_BRANCH_WIDTH, TAXONOMY_CODE, TAXONOMY_SCIENTIFIC_NAME, TAXONOMY_AUTHORITY,