private static final double readDistanceCutoffAttribute( final Element element ) { double val = 0; try { val = element.getChild( TRACKER_SETTINGS_DISTANCE_CUTOFF_ELEMENT ) .getAttribute( TRACKER_SETTINGS_DISTANCE_CUTOFF_ATTNAME_v12 ).getDoubleValue(); } catch ( final DataConversionException e ) {} return val; }
private static final double readTimeCutoffAttribute( final Element element ) { double val = 0; try { val = element.getChild( TRACKER_SETTINGS_TIME_CUTOFF_ELEMENT ) .getAttribute( TRACKER_SETTINGS_TIME_CUTOFF_ATTNAME_v12 ).getDoubleValue(); } catch ( final DataConversionException e ) {} return val; }
private static final double readDistanceCutoffAttribute( final Element element ) { double val = 0; try { val = element.getChild( TRACKER_SETTINGS_DISTANCE_CUTOFF_ELEMENT ) .getAttribute( TRACKER_SETTINGS_DISTANCE_CUTOFF_ATTNAME_v12 ).getDoubleValue(); } catch ( final DataConversionException e ) {} return val; }
private static final double readTimeCutoffAttribute( final Element element ) { double val = 0; try { val = element.getChild( TRACKER_SETTINGS_TIME_CUTOFF_ELEMENT ) .getAttribute( TRACKER_SETTINGS_TIME_CUTOFF_ATTNAME_v12 ).getDoubleValue(); } catch ( final DataConversionException e ) {} return val; }
private static double[] readCalibration( final File source ) throws JDOMException, IOException { final SAXBuilder sb = new SAXBuilder(); final Document document = sb.build( source ); final Element root = document.getRootElement(); final double[] calibration = new double[ 3 ]; final Element settings = root.getChild( "Settings" ); final Element imageData = settings.getChild( "ImageData" ); calibration[ 0 ] = imageData.getAttribute( "pixelwidth" ).getDoubleValue(); calibration[ 1 ] = imageData.getAttribute( "pixelheight" ).getDoubleValue(); calibration[ 2 ] = imageData.getAttribute( "voxeldepth" ).getDoubleValue(); return calibration; }
private static double[] readCalibration( final File source ) throws JDOMException, IOException { final SAXBuilder sb = new SAXBuilder(); final Document document = sb.build( source ); final Element root = document.getRootElement(); final double[] calibration = new double[ 3 ]; final Element settings = root.getChild( "Settings" ); final Element imageData = settings.getChild( "ImageData" ); calibration[ 0 ] = imageData.getAttribute( "pixelwidth" ).getDoubleValue(); calibration[ 1 ] = imageData.getAttribute( "pixelheight" ).getDoubleValue(); calibration[ 2 ] = imageData.getAttribute( "voxeldepth" ).getDoubleValue(); return calibration; }
/** * Unmarshall the attributes of a JDom element in a map of doubles. Mappings * are <b>added</b> to the specified map. If a value is found not to be a * double, an error is returned. * * @return <code>true</code> if all values were found and mapped as doubles, * <code>false</code> otherwise and the error holder is updated. */ public static boolean unmarshallMap( final Element element, final Map< String, Double > map, final StringBuilder errorHolder ) { boolean ok = true; final List< Attribute > attributes = element.getAttributes(); for ( final Attribute att : attributes ) { final String key = att.getName(); try { final double val = att.getDoubleValue(); map.put( key, val ); } catch ( final DataConversionException e ) { errorHolder.append( "Could not convert the " + key + " attribute to double. Got " + att.getValue() + ".\n" ); ok = false; } } return ok; }
/** * Look for all the sub-elements of <code>element</code> with the name * TRACKER_SETTINGS_FEATURE_ELEMENT, fetch the feature attributes from them, * and returns them in a map. */ private static final Map< String, Double > readTrackerFeatureMap( final Element element ) { final Map< String, Double > map = new HashMap< >(); final List< Element > featurelinkingElements = element.getChildren( TRACKER_SETTINGS_FEATURE_ELEMENT ); for ( final Element el : featurelinkingElements ) { final List< Attribute > atts = el.getAttributes(); for ( final Attribute att : atts ) { final String feature = att.getName(); Double cutoff; try { cutoff = att.getDoubleValue(); } catch ( final DataConversionException e ) { cutoff = 0d; } map.put( feature, cutoff ); } } return map; }
/** * Unmarshall the attributes of a JDom element in a map of doubles. Mappings * are <b>added</b> to the specified map. If a value is found not to be a * double, an error is returned. * * @return <code>true</code> if all values were found and mapped as doubles, * <code>false</code> otherwise and the error holder is updated. */ public static boolean unmarshallMap( final Element element, final Map< String, Double > map, final StringBuilder errorHolder ) { boolean ok = true; final List< Attribute > attributes = element.getAttributes(); for ( final Attribute att : attributes ) { final String key = att.getName(); try { final double val = att.getDoubleValue(); map.put( key, val ); } catch ( final DataConversionException e ) { errorHolder.append( "Could not convert the " + key + " attribute to double. Got " + att.getValue() + ".\n" ); ok = false; } } return ok; }
/** * Look for all the sub-elements of <code>element</code> with the name * TRACKER_SETTINGS_FEATURE_ELEMENT, fetch the feature attributes from them, * and returns them in a map. */ private static final Map< String, Double > readTrackerFeatureMap( final Element element ) { final Map< String, Double > map = new HashMap< >(); final List< Element > featurelinkingElements = element.getChildren( TRACKER_SETTINGS_FEATURE_ELEMENT ); for ( final Element el : featurelinkingElements ) { final List< Attribute > atts = el.getAttributes(); for ( final Attribute att : atts ) { final String feature = att.getName(); Double cutoff; try { cutoff = att.getDoubleValue(); } catch ( final DataConversionException e ) { cutoff = 0d; } map.put( feature, cutoff ); } } return map; }
try attVal = attribute.getDoubleValue();
try attVal = attribute.getDoubleValue();
try attVal = attribute.getDoubleValue();
public static final double readDoubleAttribute(final Element element, final String name, final Logger logger) { double val = 0; final Attribute att = element.getAttribute(name); if (null == att) { logger.error("Could not find attribute "+name+" for element "+element.getName()+", substituting default value.\n"); return val; } try { val = att.getDoubleValue(); } catch (final DataConversionException e) { logger.error("Cannot read the attribute "+name+" of the element "+element.getName()+", substituting default value.\n"); } return val; }
public static final double readDoubleAttribute(final Element element, final String name, final Logger logger) { double val = 0; final Attribute att = element.getAttribute(name); if (null == att) { logger.error("Could not find attribute "+name+" for element "+element.getName()+", substituting default value.\n"); return val; } try { val = att.getDoubleValue(); } catch (final DataConversionException e) { logger.error("Cannot read the attribute "+name+" of the element "+element.getName()+", substituting default value.\n"); } return val; }
private PrecisionModel createPrecisionModel(Element precisionModelElement) throws TestParseException { Attribute scaleAttribute = precisionModelElement.getAttribute("scale"); if (scaleAttribute == null) { throw new TestParseException( "Missing scale attribute in <precisionModel>"); } double scale; try { scale = scaleAttribute.getDoubleValue(); } catch (DataConversionException e) { throw new TestParseException( "Could not convert scale attribute to double: " + scaleAttribute.getValue()); } return new PrecisionModel(scale); }
private Spot createSpotFrom( final Element spotEl ) { final int ID = readIntAttribute( spotEl, SPOT_ID_ATTRIBUTE_NAME, logger ); final Spot spot = new Spot( ID ); final List< Attribute > atts = spotEl.getAttributes(); atts.remove( SPOT_ID_ATTRIBUTE_NAME ); String name = spotEl.getAttributeValue( SPOT_NAME_ATTRIBUTE_NAME ); if ( null == name || name.equals( "" ) ) { name = "ID" + ID; } spot.setName( name ); atts.remove( SPOT_NAME_ATTRIBUTE_NAME ); for ( final Attribute att : atts ) { if ( att.getName().equals( SPOT_NAME_ATTRIBUTE_NAME ) || att.getName().equals( SPOT_ID_ATTRIBUTE_NAME ) ) { continue; } try { spot.putFeature( att.getName(), att.getDoubleValue() ); } catch ( final DataConversionException e ) { logger.error( "Cannot read the feature " + att.getName() + " value. Skipping.\n" ); } } return spot; }
private Spot createSpotFrom( final Element spotEl ) { final int ID = readIntAttribute( spotEl, SPOT_ID_ATTRIBUTE_NAME, logger ); final Spot spot = new Spot( ID ); final List< Attribute > atts = spotEl.getAttributes(); atts.remove( SPOT_ID_ATTRIBUTE_NAME ); String name = spotEl.getAttributeValue( SPOT_NAME_ATTRIBUTE_NAME ); if ( null == name || name.equals( "" ) ) { name = "ID" + ID; } spot.setName( name ); atts.remove( SPOT_NAME_ATTRIBUTE_NAME ); for ( final Attribute att : atts ) { if ( att.getName().equals( SPOT_NAME_ATTRIBUTE_NAME ) || att.getName().equals( SPOT_ID_ATTRIBUTE_NAME ) ) { continue; } try { spot.putFeature( att.getName(), att.getDoubleValue() ); } catch ( final DataConversionException e ) { logger.error( "Cannot read the feature " + att.getName() + " value. Skipping.\n" ); } } return spot; }
try attVal = attribute.getDoubleValue();
try attVal = attribute.getDoubleValue();