import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
+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;
"",
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 ) {
category = new DefaultMutableTreeNode( name );
top.add( category );
addSubelementEditable( category, NodePanel.DATE_DESCRIPTION, date.getDesc(), PHYLOXML_TAG.DATE_DESCRIPTION );
- addSubelementEditable( category, NodePanel.DATE_VALUE, String.valueOf( date.getValue() != null ? date
- .getValue() : "" ), PHYLOXML_TAG.DATE_VALUE );
- addSubelementEditable( category, NodePanel.DATE_MIN, String
- .valueOf( date.getMin() != null ? date.getMin() : "" ), PHYLOXML_TAG.DATE_MIN );
- addSubelementEditable( category, NodePanel.DATE_MAX, String
- .valueOf( date.getMax() != null ? date.getMax() : "" ), PHYLOXML_TAG.DATE_MAX );
+ addSubelementEditable( category,
+ NodePanel.DATE_VALUE,
+ String.valueOf( date.getValue() != null ? date.getValue() : "" ),
+ PHYLOXML_TAG.DATE_VALUE );
+ addSubelementEditable( category,
+ NodePanel.DATE_MIN,
+ String.valueOf( date.getMin() != null ? date.getMin() : "" ),
+ PHYLOXML_TAG.DATE_MIN );
+ addSubelementEditable( category,
+ NodePanel.DATE_MAX,
+ String.valueOf( date.getMax() != null ? date.getMax() : "" ),
+ PHYLOXML_TAG.DATE_MAX );
addSubelementEditable( category, NodePanel.DATE_UNIT, date.getUnit(), PHYLOXML_TAG.DATE_UNIT );
}
NodePanel.DIST_GEODETIC_DATUM,
p0.getGeodeticDatum(),
PHYLOXML_TAG.DIST_GEODETIC );
- addSubelementEditable( category, NodePanel.DIST_LATITUDE, String.valueOf( p0.getLatitude() != null ? p0
- .getLatitude() : "" ), PHYLOXML_TAG.DIST_LAT );
- addSubelementEditable( category, NodePanel.DIST_LONGITUDE, String.valueOf( p0.getLongitude() != null ? p0
- .getLongitude() : "" ), PHYLOXML_TAG.DIST_LONG );
- addSubelementEditable( category, NodePanel.DIST_ALTITUDE, String.valueOf( p0.getAltitude() != null ? p0
- .getAltitude() : "" ), PHYLOXML_TAG.DIST_ALT );
- addSubelementEditable( category, NodePanel.DIST_ALT_UNIT, String.valueOf( p0.getAltiudeUnit() != null ? p0
- .getAltiudeUnit() : "" ), PHYLOXML_TAG.DIST_ALT_UNIT );
+ addSubelementEditable( category,
+ NodePanel.DIST_LATITUDE,
+ String.valueOf( p0.getLatitude() != null ? p0.getLatitude() : "" ),
+ PHYLOXML_TAG.DIST_LAT );
+ addSubelementEditable( category,
+ NodePanel.DIST_LONGITUDE,
+ String.valueOf( p0.getLongitude() != null ? p0.getLongitude() : "" ),
+ PHYLOXML_TAG.DIST_LONG );
+ addSubelementEditable( category,
+ NodePanel.DIST_ALTITUDE,
+ String.valueOf( p0.getAltitude() != null ? p0.getAltitude() : "" ),
+ PHYLOXML_TAG.DIST_ALT );
+ addSubelementEditable( category,
+ NodePanel.DIST_ALT_UNIT,
+ String.valueOf( p0.getAltiudeUnit() != null ? p0.getAltiudeUnit() : "" ),
+ PHYLOXML_TAG.DIST_ALT_UNIT );
}
private void addEvents( final DefaultMutableTreeNode top, Event events, final String name ) {
PHYLOXML_TAG.EVENTS_SPECIATIONS );
addSubelementEditable( category,
NodePanel.EVENTS_GENE_LOSSES,
- String
- .valueOf( events.getNumberOfGeneLosses() >= 0 ? events.getNumberOfGeneLosses()
- : 0 ),
+ String.valueOf( events.getNumberOfGeneLosses() >= 0 ? events.getNumberOfGeneLosses() : 0 ),
PHYLOXML_TAG.EVENTS_GENE_LOSSES );
}
}
private List<Point> obtainPoints() {
- ForesterUtil.ensurePresenceOfDistribution( getMyNode() );
+ Util.ensurePresenceOfDistribution( getMyNode() );
Distribution d = getMyNode().getNodeData().getDistribution();
if ( d.getPoints() == null ) {
d = new Distribution( d.getDesc(), new ArrayList<Point>(), d.getPolygons() );
}
}
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 ) ) {
}
break;
case TAXONOMY_CODE:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
try {
getMyNode().getNodeData().getTaxonomy().setTaxonomyCode( value );
}
}
break;
case TAXONOMY_SCIENTIFIC_NAME:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().setScientificName( value );
break;
case TAXONOMY_COMMON_NAME:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().setCommonName( value );
break;
case TAXONOMY_RANK:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
try {
getMyNode().getNodeData().getTaxonomy().setRank( value.toLowerCase() );
}
}
break;
case TAXONOMY_AUTHORITY:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().setAuthority( value );
break;
case TAXONOMY_URI: {
}
}
if ( uri != null ) {
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
}
addUri( mtn, uri, number, getMyNode().getNodeData().getTaxonomy() );
break;
}
else if ( getMyNode().getNodeData().getTaxonomy().getSynonyms().size() == number ) {
if ( !ForesterUtil.isEmpty( value ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().getSynonyms().add( value );
}
}
}
break;
case TAXONOMY_ID_VALUE:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
if ( getMyNode().getNodeData().getTaxonomy().getIdentifier() == null ) {
getMyNode().getNodeData().getTaxonomy().setIdentifier( new Identifier( value ) );
}
}
break;
case TAXONOMY_ID_PROVIDER:
- ForesterUtil.ensurePresenceOfTaxonomy( getMyNode() );
+ Util.ensurePresenceOfTaxonomy( getMyNode() );
if ( getMyNode().getNodeData().getTaxonomy().getIdentifier() == null ) {
getMyNode().getNodeData().getTaxonomy().setIdentifier( new Identifier( "", value ) );
}
}
break;
case SEQ_LOCATION:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
getMyNode().getNodeData().getSequence().setLocation( value );
break;
case SEQ_MOL_SEQ:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
getMyNode().getNodeData().getSequence().setMolecularSequence( value );
break;
case SEQ_NAME:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
getMyNode().getNodeData().getSequence().setName( value );
break;
case SEQ_SYMBOL:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
try {
getMyNode().getNodeData().getSequence().setSymbol( value );
}
}
break;
case SEQ_TYPE:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
try {
getMyNode().getNodeData().getSequence().setType( value.toLowerCase() );
}
}
break;
case SEQ_ACC_SOURCE:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
if ( getMyNode().getNodeData().getSequence().getAccession() == null ) {
getMyNode().getNodeData().getSequence().setAccession( new Accession( "", value ) );
}
}
break;
case SEQ_ACC_VALUE:
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
if ( getMyNode().getNodeData().getSequence().getAccession() == null ) {
getMyNode().getNodeData().getSequence().setAccession( new Accession( value, "" ) );
}
}
}
if ( uri != null ) {
- ForesterUtil.ensurePresenceOfSequence( getMyNode() );
+ Util.ensurePresenceOfSequence( getMyNode() );
}
addUri( mtn, uri, number, getMyNode().getNodeData().getSequence() );
break;
getMyNode().getNodeData().getEvent().setGeneLosses( parsePositiveInt( mtn, value ) );
break;
case DATE_DESCRIPTION:
- ForesterUtil.ensurePresenceOfDate( getMyNode() );
+ Util.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setDesc( value );
break;
case DATE_MAX:
- ForesterUtil.ensurePresenceOfDate( getMyNode() );
+ Util.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setMax( parseBigDecimal( mtn, value ) );
break;
case DATE_MIN:
- ForesterUtil.ensurePresenceOfDate( getMyNode() );
+ Util.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setMin( parseBigDecimal( mtn, value ) );
break;
case DATE_UNIT:
- ForesterUtil.ensurePresenceOfDate( getMyNode() );
+ Util.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setUnit( value );
break;
case DATE_VALUE:
- ForesterUtil.ensurePresenceOfDate( getMyNode() );
+ Util.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setValue( parseBigDecimal( mtn, value ) );
break;
case DIST_ALT: {
p.getLatitude(),
p.getLongitude(),
new_value,
- ForesterUtil.isEmpty( p.getAltiudeUnit() ) ? "?" : p
- .getAltiudeUnit() );
+ ForesterUtil.isEmpty( p.getAltiudeUnit() ) ? "?"
+ : p.getAltiudeUnit() );
ps.set( 0, p_new );
}
break;
}
case DIST_DESC: {
- ForesterUtil.ensurePresenceOfDistribution( getMyNode() );
+ Util.ensurePresenceOfDistribution( getMyNode() );
final Distribution d = getMyNode().getNodeData().getDistribution();
getMyNode().getNodeData().setDistribution( new Distribution( value, d.getPoints(), d.getPolygons() ) );
break;
if ( !ForesterUtil.isEmpty( value ) ) {
final List<Point> ps = obtainPoints();
final Point p = ps.get( 0 );
- final Point p_new = new Point( value, p.getLatitude(), p.getLongitude(), p.getAltitude(), p
- .getAltiudeUnit() );
+ final Point p_new = new Point( value,
+ p.getLatitude(),
+ p.getLongitude(),
+ p.getAltitude(),
+ p.getAltiudeUnit() );
ps.set( 0, p_new );
}
break;
if ( !ForesterUtil.isEmpty( value ) ) {
final List<Point> ps = obtainPoints();
final Point p = ps.get( 0 );
- final Point p_new = new Point( p.getGeodeticDatum(), p.getLatitude(), p.getLongitude(), p
- .getAltitude(), value );
+ final Point p_new = new Point( p.getGeodeticDatum(),
+ p.getLatitude(),
+ p.getLongitude(),
+ p.getAltitude(),
+ value );
ps.set( 0, p_new );
}
break;
if ( new_value != null ) {
final List<Point> ps = obtainPoints();
final Point p = ps.get( 0 );
- final Point p_new = new Point( p.getGeodeticDatum(), p.getLatitude(), new_value, p.getAltitude(), p
- .getAltiudeUnit() );
+ final Point p_new = new Point( p.getGeodeticDatum(),
+ p.getLatitude(),
+ new_value,
+ p.getAltitude(),
+ p.getAltiudeUnit() );
ps.set( 0, p_new );
}
break;
private enum PHYLOXML_TAG {
NODE_NAME,
NODE_BRANCH_LENGTH,
+ NODE_BRANCH_WIDTH,
TAXONOMY_CODE,
TAXONOMY_SCIENTIFIC_NAME,
TAXONOMY_AUTHORITY,