Package eu.scape_project.planning.model.util

Examples of eu.scape_project.planning.model.util.FloatFormatter


   */
  private FloatFormatter formatter;
 
  @Before
  public void setup() {
    this.formatter = new FloatFormatter();
  }
View Full Code Here


    }

    @Override
    public String toString() {
        if (formatter == null) {
            formatter = new FloatFormatter();
        }
        return formatter.formatFloatPrecisly(value);
    }
View Full Code Here

    }

    @Override
    public String getFormattedValue() {
        if (formatter == null) {
            formatter = new FloatFormatter();
        }
        return formatter.formatFloat(value);
    }   
View Full Code Here

    }

    @Override
    public String toString() {
        if (formatter == null) {
            formatter = new FloatFormatter();
        }
        return formatter.formatFloatPrecisly(value);
    }
View Full Code Here

    }

    @Override
    public String getFormattedValue() {
        if (formatter == null) {
            formatter = new FloatFormatter();
        }
        return formatter.formatFloat(value);
    }
View Full Code Here

    }
   
    @Override
    public String toString() {
        if (formatter == null) {
            formatter = new FloatFormatter();
        }
        return formatter.formatFloatPrecisly(value);
    }
View Full Code Here

    }

    @Override
    public String getFormattedValue() {
        if (formatter == null) {
            formatter = new FloatFormatter();
        }
        return formatter.formatFloat(value);
    }
View Full Code Here

        if (result == null) {
            return results;
        }

        FloatFormatter formatter = new FloatFormatter();

        String fitsXMLResult = result.getFitsXMLString();
        String fitsXMLSample = sample.getFitsXMLString();

        XmlExtractor extractor = new XmlExtractor();
        extractor.setNamespaceContext(new FitsNamespaceContext());
        if ((fitsXMLResult != null) && (fitsXMLSample != null)) {
            // so we have a fits xml, lets analyse it:
            try {
                StringReader reader = new StringReader(fitsXMLResult);
                Document fitsDocResult = extractor.getDocument(new InputSource(reader));
                reader = new StringReader(fitsXMLSample);
                Document fitsDocSample = extractor.getDocument(new InputSource(reader));

                String sampleImageCompressionScheme = extractor.extractText(fitsDocSample,
                    "//fits:compressionScheme/text()");
                String resultImageCompressionScheme = extractor.extractText(fitsDocResult,
                    "//fits:compressionScheme/text()");

                for (String measureUri : measureUris) {
                    Value v = null;
                    if (MeasureConstants.FORMAT_CONFORMITY_WELL_FORMEDNESS.equals(measureUri)) {

                        v = extractor.extractValue(fitsDocResult, new BooleanScale(),
                            "//fits:well-formed[@status='SINGLE_RESULT']/text()",
                            "//fits:filestatus/fits:message/text()");
                    } else if (MeasureConstants.FORMAT_CONFORMITY_VALIDITY.equals(measureUri)) {
                        v = extractor.extractValue(fitsDocResult, new BooleanScale(),
                            "//fits:filestatus/fits:valid[@status='SINGLE_RESULT']/text()",
                            "//fits:filestatus/fits:message/text()");
                    }
                    if (MeasureConstants.COMPRESSION_ALGORITHM.equals(measureUri)) {
                        v = extractor.extractValue(fitsDocResult, new FreeStringScale(),
                            "//fits:compressionScheme/text()", null);
                    }

                    if ((v != null) && (v.getComment() == null || "".equals(v.getComment()))) {
                        v.setComment(SOURCE);
                        results.put(measureUri, v);
                        listener
                            .updateStatus(String.format("%s: measurement: %s = %s", NAME, measureUri, v.toString()));
                        // this leaf has been processed
                        continue;
                    }

                    if (MeasureConstants.FORMAT_CONFORMITY_CONFORMS.equals(measureUri)) {
                        if (alternative.getAction() != null) {
                            String puid = "UNDEFINED";
                            FormatInfo info = alternative.getAction().getTargetFormatInfo();
                            if (info != null) {
                                puid = info.getPuid();
                            }
                            String fitsText = extractor.extractText(fitsDocResult,
                                "//fits:externalIdentifier[@type='puid']/text()");
                            v = identicalValues(puid, fitsText, new BooleanScale());
                        }
                    } else if ((MeasureConstants.IMAGE_SIZE_IMAGE_WIDTH_EQUAL).equals(measureUri)) {
                        String sampleValue = extractor.extractText(fitsDocSample, "//fits:imageWidth/text()");
                        String resultValue = extractor.extractText(fitsDocResult, "//fits:imageWidth/text()");
                        v = identicalValues(sampleValue, resultValue, new BooleanScale());
                    } else if ((MeasureConstants.IMAGE_SIZE_IMAGE_HEIGHT_EQUAL).equals(measureUri)) {
                        String sampleValue = extractor.extractText(fitsDocSample, "//fits:imageHeight/text()");
                        String resultValue = extractor.extractText(fitsDocResult, "//fits:imageHeight/text()");
                        v = identicalValues(sampleValue, resultValue, new BooleanScale());
                    } else if ((MeasureConstants.IMAGE_ASPECT_RATIO_RETAINED).equals(measureUri)) {
                        try {
                            int sampleHeight = Integer.parseInt(extractor.extractText(fitsDocSample,
                                "//fits:imageHeight/text()"));
                            int resultHeight = Integer.parseInt(extractor.extractText(fitsDocResult,
                                "//fits:imageHeight/text()"));
                            int sampleWidth = Integer.parseInt(extractor.extractText(fitsDocSample,
                                "//fits:imageWidth/text()"));
                            int resultWidth = Integer.parseInt(extractor.extractText(fitsDocResult,
                                "//fits:imageWidth/text()"));

                            double sampleRatio = ((double) sampleWidth) / sampleHeight;
                            double resultRatio = ((double) resultWidth) / resultHeight;
                            v = new BooleanValue();
                            ((BooleanValue) v).bool(0 == Double.compare(sampleRatio, resultRatio));
                            v.setComment(String.format("Reference value: %s\nActual value: %s",
                                formatter.formatFloat(sampleRatio), formatter.formatFloat(resultRatio)));
                        } catch (NumberFormatException e) {
                            // not all values are available - aspectRatio cannot
                            // be calculated
                            v = new BooleanValue();
                            v.setComment("Image width and/or height are not available - aspectRatio cannot be calculated");
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.util.FloatFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.