Examples of Rational


Examples of com.lightcrafts.utils.Rational

            case META_SRATIONAL:
            case META_URATIONAL:
                //
                // Print rational numbers better.
                //
                final Rational r =
                    ((RationalMetaValue)value).getRationalValue();
                if ( r.isInteger() )
                    return Integer.toString( r.intValue() );
                if ( r.numerator() > r.denominator() )
                    return TextUtil.tenths( r );
            default:
                return null;
        }
    }
View Full Code Here

Examples of com.lightcrafts.utils.Rational

                    EXIF_FIELD_SIZE[ EXIF_FIELD_TYPE_SRATIONAL ];
                final int longSize = EXIF_FIELD_SIZE[ EXIF_FIELD_TYPE_SLONG ];
                for ( int i = 0; i < numValues; ++i )
                    try {
                        final int pos = offset + i * valueSize;
                        values[i] = new Rational(
                            m_buf.getInt( pos ), m_buf.getInt( pos + longSize )
                        );
                    }
                    catch ( IllegalArgumentException e ) {
                        m_handler.gotBadMetadata( e );
                        return null;
                    }
                return new RationalMetaValue( values );
            }

            case EXIF_FIELD_TYPE_URATIONAL: {
                final Rational[] values = new Rational[ numValues ];
                final int valueSize =
                    EXIF_FIELD_SIZE[ EXIF_FIELD_TYPE_URATIONAL ];
                final int longSize = EXIF_FIELD_SIZE[ EXIF_FIELD_TYPE_ULONG ];
                for ( int i = 0; i < numValues; ++i )
                    try {
                        final int pos = offset + i * valueSize;
                        values[i] = new Rational(
                            m_buf.getInt( pos ), m_buf.getInt( pos + longSize )
                        );
                    }
                    catch ( IllegalArgumentException e ) {
                        m_handler.gotBadMetadata( e );
View Full Code Here

Examples of com.lightcrafts.utils.Rational

    public float getShutterSpeed() {
        final ImageMetaValue value = getValue( CIFF_SI_SHUTTER_SPEED );
        if ( value == null )
            return 0;
        final int apex = value.getIntValue();
        final Rational speed = MetadataUtil.convertShutterSpeedFromAPEX( apex );
        return speed.floatValue();
    }
View Full Code Here

Examples of com.lightcrafts.utils.Rational

                    MetadataUtil.convertISOFromAPEX( apex )
                );
            }
            case CIFF_SI_SHUTTER_SPEED: {
                final int apex = value.getIntValue();
                final Rational speed =
                    MetadataUtil.convertShutterSpeedFromAPEX( apex );
                return MetadataUtil.shutterSpeedString( speed.doubleValue() );
            }
            default:
                return super.valueToString( value );
        }
    }
View Full Code Here

Examples of com.lightcrafts.utils.Rational

                    TIFF_FIELD_SIZE[ TIFF_FIELD_TYPE_SRATIONAL ];
                final int longSize = TIFF_FIELD_SIZE[ TIFF_FIELD_TYPE_SLONG ];
                for ( int i = 0; i < numValues; ++i )
                    try {
                        final int pos = offset + i * valueSize;
                        values[i] = new Rational(
                            m_buf.getInt( pos ), m_buf.getInt( pos + longSize )
                        );
                    }
                    catch ( IllegalArgumentException e ) {
                        logBadImageMetadata();
                        return null;
                    }
                return new RationalMetaValue( values );
            }

            case TIFF_FIELD_TYPE_URATIONAL: {
                final Rational[] values = new Rational[ numValues ];
                final int valueSize =
                    TIFF_FIELD_SIZE[ TIFF_FIELD_TYPE_URATIONAL ];
                final int longSize = TIFF_FIELD_SIZE[ TIFF_FIELD_TYPE_ULONG ];
                for ( int i = 0; i < numValues; ++i )
                    try {
                        final int pos = offset + i * valueSize;
                        values[i] = new Rational(
                            m_buf.getInt( pos ), m_buf.getInt( pos + longSize )
                        );
                    }
                    catch ( IllegalArgumentException e ) {
                        logBadImageMetadata();
View Full Code Here

Examples of com.lightcrafts.utils.Rational

     * @return Returns the shutter speed as a {@link Rational} value.
     */
    public static Rational convertShutterSpeedFromAPEX( int apex ) {
        final double n = Math.exp( - convertAPEXToEV( apex ) * LN_2 );
        return n > 0 && n < 1 ?
            new Rational( 1, (int)fixShutterSpeed( 1/n ) ) :
            //new Rational( 1, (int)(1/n + 0.5) ) :
            new Rational( (int)(n * 10), 10 );
    }
View Full Code Here

Examples of com.sun.media.jai.util.Rational

        // Represent the scale factors as Rational numbers.
        // Since a value of 1.2 is represented as 1.200001 which
        // throws the forward/backward mapping in certain situations.
  // Convert the scale and translation factors to Rational numbers
        Rational scaleXRational =
      Rational.approximate(scaleX, rationalTolerance);

        Rational scaleYRational =
      Rational.approximate(scaleY, rationalTolerance);

  long scaleXRationalNum = (long)scaleXRational.num;
  long scaleXRationalDenom = (long)scaleXRational.denom;
  long scaleYRationalNum = (long)scaleYRational.num;
  long scaleYRationalDenom = (long)scaleYRational.denom;

        Rational transXRational =
      Rational.approximate(transX, rationalTolerance);

        Rational transYRational =
      Rational.approximate(transY, rationalTolerance);

  long transXRationalNum = (long)transXRational.num;
  long transXRationalDenom = (long)transXRational.denom;
  long transYRationalNum = (long)transYRational.num;
View Full Code Here

Examples of core.Rational

    @Override
    public Rational getRandomElement() {
      // Java's random number generator
      Random randomGenerator = new Random();
     
      return new Rational(randomGenerator.nextInt(Integer.MAX_VALUE));
    }
View Full Code Here

Examples of edu.harvard.hul.ois.ots.schemas.XmlContent.Rational

        }
        YCbCrCoefficients ycbcrc = new YCbCrCoefficients ();
        try {
            ycbcr.setYCbCrCoefficients(ycbcrc);
            phi.setYCbCr (ycbcr);
            ycbcrc.setLumaRed(new Rational ((int) (red * 100), 100));
            ycbcrc.setLumaGreen(new Rational ((int) (green * 100), 100));
            ycbcrc.setLumaBlue(new Rational ((int) (blue * 100), 100));
        }
        catch (XmlContentException e) {}
    }
View Full Code Here

Examples of edu.harvard.hul.ois.ots.schemas.XmlContent.Rational

                    else
                        interp = "Cr";
                    break;
                }
                comp.setComponentPhotometricInterpretation(interp);
                comp.setHeadroom (new Rational ((int) (rbwVal[i] * 100), 100));
                comp.setFootroom (new Rational ((int) (rbwVal[i+1] * 100), 100));
            }
        }
        catch (XmlContentException e) {}
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.