Package eu.planets_project.pp.plato.model.scales

Examples of eu.planets_project.pp.plato.model.scales.Scale


    public MeasurementInfoUri toMeasurementInfoUri(){
        MeasurementInfoUri uri = new MeasurementInfoUri(getUri());
        return uri;
    }
    public Scale getScale() {
        Scale s = null;
        if ((metric != null)&& (metric.getScale() != null)) {
            s = metric.getScale();
        } else if ((property != null) &&(property.getScale() != null)) {
            s = property.getScale();
        }
View Full Code Here


            s = property.getScale();
        }
        return s;
    }
    public String getUnit() {
        Scale s = getScale();
        if (s != null) {
            return s.getUnit();
        } else {
            return null;
        }
    }
View Full Code Here

    @Test
    public void testScaleBooleanValue(){
        Leaf leaf = new Leaf();
        leaf.changeScale(booleanScale);
        // test as parent Scale - this is the way it is used within the application
        Scale scale = leaf.getScale();
        assert("Yes/No".equals(((BooleanScale)scale).getRestriction()));
        ((RestrictedScale)scale).setRestriction("meine/eigene");
        assert("Yes/No".equals(((RestrictedScale)scale).getRestriction()));
        Scale cloned = scale.clone();
        assert(cloned instanceof BooleanScale);
        assert("Yes/No".equals(((RestrictedScale)cloned).getRestriction()));
    }
View Full Code Here

   
    @Test
    public void testScaleIntRangeValue(){
        Leaf leaf = new Leaf();
        leaf.changeScale(intRangeScale);
        Scale scale = leaf.getScale();
        assert("0/5".equals(((RestrictedScale)scale).getRestriction()));
        ((RestrictedScale)scale).setRestriction("-5/-1");
        assert("-5/-1".equals(((RestrictedScale)scale).getRestriction()));
        ((RestrictedScale)scale).setRestriction("aa/bbb");
        assert("-5/-1".equals(((RestrictedScale)scale).getRestriction()));
        scale.setUnit(null);
        assert(scale.getUnit() == null);
        scale.setUnit("mm");
        assert("mm".equals(scale.getUnit()));
       
        Scale cloned = scale.clone();
        assert(cloned instanceof IntRangeScale);
        assert("-5/-1".equals(((RestrictedScale)cloned).getRestriction()));
        assert("mm".equals(cloned.getUnit()));
    }
View Full Code Here

    @Test
    public void testChangeScaleType(){
        Leaf leaf = new Leaf();
        leaf.changeScale(booleanScale);
        leaf.changeScale(intRangeScale);
        Scale scale = leaf.getScale();
       
        assert(scale instanceof IntRangeScale);
        assert("0/5".equals(((RestrictedScale)scale).getRestriction()));
       
        leaf.changeScale(yanScale);
View Full Code Here

     * resets property mappings, if present.
     *
     * @param className canonical class name of the new scale
     */
    public void setScaleByClassName(String className) {
        Scale scaleType = null;
        try {
            if (className != null && !"".equals(className)) {
                scaleType = (Scale) Class.forName(className).newInstance();
            }
        } catch (InstantiationException e) {
View Full Code Here

     */
    public void adjustScalesToMeasurements(MeasurementsDescriptor descriptor) {
        for (Leaf l : getRoot().getAllLeaves()) {
            MeasurementInfoUri mInfo = l.getMeasurementInfo().toMeasurementInfoUri();
            if (mInfo.getAsURI() != null) {
                Scale s = descriptor.getMeasurementScale(mInfo);
                if (s != null) {
                    l.adjustScale(s);
                }
            }
        }
View Full Code Here

                XmlExtractor xmlExtractor = new XmlExtractor();
                Document doc = xmlExtractor.getDocument(new InputSource(pcdlStream));
               
                for(MeasurementInfoUri measurementInfoUri: measurementInfoUris) {
                    String propertyURI = measurementInfoUri.getAsURI();
                    Scale scale = descriptor.getMeasurementScale(measurementInfoUri);
                    if (scale == null)  {
                        // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
                        continue;
                    }
                    if (ACTION_RETAIN_FILENAME.equals(propertyURI)) {
                        // for all wrapped minimee migrators the output filename can be determined by -o <filename> or something similar 
                        Value v = scale.createValue();
                        v.setComment("obtained from PCDL descriptor");
                        v.parse("Yes");
                        results.put(measurementInfoUri, v);
                    }
                   
View Full Code Here

                 String resultImageCompressionScheme = extractor.extractText(fitsDocResult, "//fits:compressionScheme/text()");
                
                 for (MeasurementInfoUri measurementInfoUri : measurementInfoUris) {
                     Value v = null;
                     String propertyURI = measurementInfoUri.getAsURI();
                     Scale scale = descriptor.getMeasurementScale(measurementInfoUri);
                     if (scale == null)  {
                         // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
                         continue;
                     }
                     if(OBJECT_FORMAT_CORRECT_WELLFORMED.equals(propertyURI)) {
                         v = extractor.extractValue(fitsDocResult, scale,
                             "//fits:well-formed[@status='SINGLE_RESULT']/text()",
                             "//fits:filestatus/fits:message/text()");
                     } else if(OBJECT_FORMAT_CORRECT_VALID.equals(propertyURI)) {
                         v = extractor.extractValue(fitsDocResult, scale,
                                 "//fits:filestatus/fits:valid[@status='SINGLE_RESULT']/text()",
                                 "//fits:filestatus/fits:message/text()");
                     } if(OBJECT_COMPRESSION_SCHEME.equals(propertyURI)) {
                         v = extractor.extractValue(fitsDocResult, scale,
                                 "//fits:compressionScheme/text()",
                                 null);
                     }
                    
                     if ((v!= null) && (v.getComment() == null || "".equals(v.getComment()))) {
                         v.setComment(SOURCE);
                         results.put(measurementInfoUri, v);
                         listener.updateStatus(String.format("%s: measurement: %s = %s", NAME, measurementInfoUri.getAsURI(), v.toString()));
                         // this leaf has been processed
                         continue;
                     }                             

                     if(OBJECT_FORMAT_CORRECT_CONFORMS.equals(propertyURI)) {
                         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, scale);
                         }
                     }  else if((OBJECT_IMAGE_DIMENSION_WIDTH + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample, "//fits:imageWidth/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:imageWidth/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     else if((OBJECT_IMAGE_DIMENSION_HEIGHT + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:imageHeight/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:imageHeight/text()");
                         v = identicalValues(sampleValue, resultValue, scale);
                     else if((OBJECT_IMAGE_DIMENSION_ASPECTRATIO + "#equal").equals(propertyURI)) {
                         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 = scale.createValue();
                            ((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 = scale.createValue();
                            v.setComment("Image width and/or height are not available - aspectRatio cannot be calculated");
                        }
                     }  else if((OBJECT_COMPRESSION_SCHEME + "#equal").equals(propertyURI)) {
                         v = identicalValues(sampleImageCompressionScheme, resultImageCompressionScheme, scale);
                     else if(OBJECT_COMPRESSION_LOSSLESS.equals(propertyURI)) {
                         // At the moment we only handle compression schemes of images
                         if ((resultImageCompressionScheme != null) && (!"".equals(resultImageCompressionScheme))) {
                             v = scale.createValue();
                             ((BooleanValue)v).bool(FITS_COMPRESSIONSCHEME_UNCOMPRESSED.equals(resultImageCompressionScheme));
                         }
                     }  else if(OBJECT_COMPRESSION_LOSSY.equals(propertyURI)) {
                         // At the moment we only handle compression schemes of images
                         if ((resultImageCompressionScheme != null) && (!"".equals(resultImageCompressionScheme))) {
                             v = scale.createValue();
                             ((BooleanValue)v).bool(! FITS_COMPRESSIONSCHEME_UNCOMPRESSED.equals(resultImageCompressionScheme));
                         }
                     }  else if((OBJECT_IMAGE_COLORENCODING_BITSPERSAMPLE + "#equal").equals(propertyURI)) {
                         String sampleValue = extractor.extractText(fitsDocSample,"//fits:bitsPerSample/text()");
                         String resultValue = extractor.extractText(fitsDocResult,"//fits:bitsPerSample/text()");
View Full Code Here

       
        HashMap<MeasurementInfoUri, Value> results = new HashMap<MeasurementInfoUri, Value>();
       
        for(MeasurementInfoUri measurementInfoUri: measurementInfoUris) {
            String propertyURI = measurementInfoUri.getAsURI();
            Scale scale = descriptor.getMeasurementScale(measurementInfoUri);
            if (scale == null)  {
                // This means that I am not entitled to evaluate this measurementInfo and therefore supposed to skip it:
                continue;
            }
            if (OBJECT_FORMAT_RELATIVEFILESIZE.equals(propertyURI)) {
                // evaluate here
                PositiveFloatValue v = (PositiveFloatValue) scale.createValue();
                double d = ((double)result.getData().getSize())/sample.getData().getSize()*100;
                long l = Math.round(d);
                d = ((double)l)/100;
                v.setValue(d);
                results.put(measurementInfoUri, v);
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.scales.Scale

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.