• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Rational类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.drew.lang.Rational的典型用法代码示例。如果您正苦于以下问题:Java Rational类的具体用法?Java Rational怎么用?Java Rational使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Rational类属于com.drew.lang包,在下文中一共展示了Rational类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDecimalCoordinatesAsFloat

import com.drew.lang.Rational; //导入依赖的package包/类
private static Float getDecimalCoordinatesAsFloat(String orientation, Rational[] coordinates) {
    if (orientation == null) {
        log.debug("GPS orientation is null, should be N, S, E, or W.");
        return null;
    }
    if (coordinates == null) {
        log.debug("GPS coordinates are null.");
        return null;
    }
    if (coordinates[0].getDenominator() == 0 || coordinates[1].getDenominator() == 0
            || coordinates[2].getDenominator() == 0) {
        log.debug("Invalid GPS coordinates (denominator should not be 0).");
        return null;
    }

    float m = 1;
    if (orientation.toUpperCase().charAt(0) == 'S' || orientation.toUpperCase().charAt(0) == 'W') {
        m = -1;
    }
    float deg = coordinates[0].getNumerator() / coordinates[0].getDenominator();
    float min = coordinates[1].getNumerator() * 60 * coordinates[2].getDenominator();
    float sec = coordinates[2].getNumerator();
    float den = 3600 * coordinates[1].getDenominator() * coordinates[2].getDenominator();
    return m * (deg + (min + sec) / den);
}
 
开发者ID:jgperrin,项目名称:net.jgp.labs.spark.datasources,代码行数:26,代码来源:ExifUtils.java


示例2: getGeoLocation

import com.drew.lang.Rational; //导入依赖的package包/类
/**
 * Parses various tags in an attempt to obtain a single object representing the latitude and longitude
 * at which this image was captured.
 *
 * @return The geographical location of this image, if possible, otherwise null
 */
@Nullable
public GeoLocation getGeoLocation()
{
    Rational[] latitudes = getRationalArray(TAG_LATITUDE);
    Rational[] longitudes = getRationalArray(TAG_LONGITUDE);
    String latitudeRef = getString(TAG_LATITUDE_REF);
    String longitudeRef = getString(TAG_LONGITUDE_REF);

    // Make sure we have the required values
    if (latitudes == null || latitudes.length != 3)
        return null;
    if (longitudes == null || longitudes.length != 3)
        return null;
    if (latitudeRef == null || longitudeRef == null)
        return null;

    Double lat = GeoLocation.degreesMinutesSecondsToDecimal(latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S"));
    Double lon = GeoLocation.degreesMinutesSecondsToDecimal(longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W"));

    // This can return null, in cases where the conversion was not possible
    if (lat == null || lon == null)
        return null;

    return new GeoLocation(lat, lon);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:32,代码来源:GpsDirectory.java


示例3: getFocusDistanceDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getFocusDistanceDescription()
{
    Rational value = _directory.getRational(TagFocusDistance);
    if (value == null)
        return "inf";
    if (value.getNumerator() == 0xFFFFFFFFL || value.getNumerator() == 0x00000000L)
        return "inf";

    return value.getNumerator() / 1000.0 + " m";
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:12,代码来源:OlympusFocusInfoMakernoteDescriptor.java


示例4: getAfPointSelectedDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getAfPointSelectedDescription()
{
    Rational[] values = _directory.getRationalArray(TagAfPointSelected);
    if (values == null)
        return "n/a";

    if (values.length < 4)
        return null;

    int index = 0;
    if (values.length == 5 && values[0].longValue() == 0)
        index = 1;

    int p1 = (int)(values[index].doubleValue() * 100);
    int p2 = (int)(values[index + 1].doubleValue() * 100);
    int p3 = (int)(values[index + 2].doubleValue() * 100);
    int p4 = (int)(values[index + 3].doubleValue() * 100);

    if(p1 + p2 + p3 + p4 == 0)
        return "n/a";

    return String.format("(%d%%,%d%%) (%d%%,%d%%)", p1, p2, p3, p4);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:25,代码来源:OlympusCameraSettingsMakernoteDescriptor.java


示例5: getManualFlashStrengthDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getManualFlashStrengthDescription()
{
    Rational[] values = _directory.getRationalArray(TagManualFlashStrength);
    if (values == null || values.length == 0)
        return "n/a";

    if (values.length == 3) {
        if (values[0].getDenominator() == 0 && values[1].getDenominator() == 0 && values[2].getDenominator() == 0)
            return "n/a";
    } else if (values.length == 4) {
        if (values[0].getDenominator() == 0 && values[1].getDenominator() == 0 && values[2].getDenominator() == 0 && values[3].getDenominator() == 0)
            return "n/a (x4)";
    }

    StringBuilder sb = new StringBuilder();
    for (Rational t : values)
        sb.append(t).append(", ");

    return sb.substring(0, sb.length() - 2);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:22,代码来源:OlympusCameraSettingsMakernoteDescriptor.java


示例6: getYCbCrCoefficientsDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getYCbCrCoefficientsDescription()
{
    int[] values = _directory.getIntArray(TagYCbCrCoefficients);
    if (values == null)
        return null;

    Rational[] ret = new Rational[values.length / 2];
    for(int i = 0; i < values.length / 2; i++)
    {
        ret[i] = new Rational((short)values[2*i], (short)values[2*i + 1]);
    }

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < ret.length; i++) {
        sb.append(ret[i].doubleValue());
        if (i < ret.length - 1)
            sb.append(" ");
    }
    return sb.length() == 0 ? null : sb.toString();
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:22,代码来源:OlympusRawInfoMakernoteDescriptor.java


示例7: getRational

import com.drew.lang.Rational; //导入依赖的package包/类
/** Returns the specified tag's value as a Rational.  If the value is unset or cannot be converted, <code>null</code> is returned. */
@Nullable
public Rational getRational(int tagType)
{
    Object o = getObject(tagType);

    if (o == null)
        return null;

    if (o instanceof Rational)
        return (Rational)o;
    if (o instanceof Integer)
        return new Rational((Integer)o, 1);
    if (o instanceof Long)
        return new Rational((Long)o, 1);

    // NOTE not doing conversions for real number types

    return null;
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:21,代码来源:Directory.java


示例8: testUnderlyingInt

import com.drew.lang.Rational; //导入依赖的package包/类
@Test
public void testUnderlyingInt() throws Exception
{
    int value = 123;
    int tagType = 321;
    _directory.setInt(tagType, value);

    assertEquals(value, _directory.getInt(tagType));
    assertEquals(Integer.valueOf(value), _directory.getInteger(tagType));
    assertEquals((float)value, _directory.getFloat(tagType), 0.00001);
    assertEquals((double)value, _directory.getDouble(tagType), 0.00001);
    assertEquals((long)value, _directory.getLong(tagType));
    assertEquals(Integer.toString(value), _directory.getString(tagType));
    assertEquals(new Rational(value, 1), _directory.getRational(tagType));
    assertArrayEquals(new int[]{value}, _directory.getIntArray(tagType));
    assertArrayEquals(new byte[]{(byte)value}, _directory.getByteArray(tagType));
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:18,代码来源:DirectoryTest.java


示例9: getFocalPlaneYResolutionDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getFocalPlaneYResolutionDescription()
{
    Rational rational = _directory.getRational(TAG_FOCAL_PLANE_Y_RESOLUTION);
    if (rational == null)
        return null;
    final String unit = getFocalPlaneResolutionUnitDescription();
    return rational.getReciprocal().toSimpleString(_allowDecimalRepresentationOfRationals)
        + (unit == null ? "" : " " + unit.toLowerCase());
}
 
开发者ID:ydanila,项目名称:j-metadata-extractor,代码行数:11,代码来源:ExifSubIFDDescriptor.java


示例10: addMetadata

import com.drew.lang.Rational; //导入依赖的package包/类
public void addMetadata(QuickTimeDirectory directory)
{
    // Get creation/modification times
    Calendar calendar = Calendar.getInstance();
    calendar.set(1904, 0, 1, 0, 0, 0);      // January 1, 1904  -  Macintosh Time Epoch
    Date date = calendar.getTime();
    long macToUnixEpochOffset = date.getTime();
    directory.setDate(TAG_CREATION_TIME, new Date((creationTime * 1000) + macToUnixEpochOffset));
    directory.setDate(TAG_MODIFICATION_TIME, new Date((modificationTime * 1000) + macToUnixEpochOffset));

    // Get duration and time scale
    directory.setLong(TAG_DURATION, duration);
    directory.setLong(TAG_TIME_SCALE, timescale);
    directory.setRational(QuickTimeDirectory.TAG_DURATION_SECONDS, new Rational(duration, timescale));

    // Calculate preferred rate fixed point
    double preferredRateInteger = (preferredRate & 0xFFFF0000) >> 16;
    double preferredRateFraction = (preferredRate & 0x0000FFFF) / Math.pow(2, 4);
    directory.setDouble(TAG_PREFERRED_RATE, preferredRateInteger + preferredRateFraction);

    // Calculate preferred volume fixed point
    double preferredVolumeInteger = (preferredVolume & 0xFF00) >> 8;
    double preferredVolumeFraction = (preferredVolume & 0x00FF) / Math.pow(2, 2);
    directory.setDouble(TAG_PREFERRED_VOLUME, preferredVolumeInteger + preferredVolumeFraction);

    directory.setLong(TAG_PREVIEW_TIME, previewTime);
    directory.setLong(TAG_PREVIEW_DURATION, previewDuration);
    directory.setLong(TAG_POSTER_TIME, posterTime);
    directory.setLong(TAG_SELECTION_TIME, selectionTime);
    directory.setLong(TAG_SELECTION_DURATION, selectionDuration);
    directory.setLong(TAG_CURRENT_TIME, currentTime);
    directory.setLong(TAG_NEXT_TRACK_ID, nextTrackID);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:34,代码来源:MovieHeaderAtom.java


示例11: getDistortionParam02Description

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getDistortionParam02Description()
{
    Integer value = _directory.getInteger(TagDistortionParam02);
    if (value == null)
        return null;

    return new Rational(value, 32678).toString();
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:10,代码来源:PanasonicRawDistortionDescriptor.java


示例12: getDistortionParam04Description

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getDistortionParam04Description()
{
    Integer value = _directory.getInteger(TagDistortionParam04);
    if (value == null)
        return null;

    return new Rational(value, 32678).toString();
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:10,代码来源:PanasonicRawDistortionDescriptor.java


示例13: getDistortionParam08Description

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getDistortionParam08Description()
{
    Integer value = _directory.getInteger(TagDistortionParam08);
    if (value == null)
        return null;

    return new Rational(value, 32678).toString();
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:10,代码来源:PanasonicRawDistortionDescriptor.java


示例14: getFNumberDescription

import com.drew.lang.Rational; //导入依赖的package包/类
/** Do a simple formatting like ExifSubIFDDescriptor.java */
@Nullable
public String getFNumberDescription()
{
    final Rational value = _directory.getRational(XmpDirectory.TAG_F_NUMBER);
    if (value==null)
        return null;
    return "F" + SimpleDecimalFormatter.format(value.doubleValue());
}
 
开发者ID:ydanila,项目名称:j-metadata-extractor,代码行数:10,代码来源:XmpDescriptor.java


示例15: getDistortionParam11Description

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getDistortionParam11Description()
{
    Integer value = _directory.getInteger(TagDistortionParam11);
    if (value == null)
        return null;

    return new Rational(value, 32678).toString();
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:10,代码来源:PanasonicRawDistortionDescriptor.java


示例16: getDigitalZoomRatioDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getDigitalZoomRatioDescription()
{
    Rational value = _directory.getRational(TAG_DIGITAL_ZOOM_RATIO);
    return value == null
        ? null
        : value.getNumerator() == 0
        ? "Digital zoom not used."
        : SimpleDecimalFormatter.format(value.doubleValue());
}
 
开发者ID:ydanila,项目名称:j-metadata-extractor,代码行数:11,代码来源:ExifSubIFDDescriptor.java


示例17: getGpsDirectionDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getGpsDirectionDescription(int tagType)
{
    Rational angle = _directory.getRational(tagType);
    // provide a decimal version of rational numbers in the description, to avoid strings like "35334/199 degrees"
    String value = angle != null
        ? new DecimalFormat("0.##").format(angle.doubleValue())
        : _directory.getString(tagType);
    return value == null || value.trim().length() == 0 ? null : value.trim() + " degrees";
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:11,代码来源:GpsDescriptor.java


示例18: getYResolutionDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getYResolutionDescription()
{
    Rational value = _directory.getRational(TAG_Y_RESOLUTION);
    if (value==null)
        return null;
    final String unit = getResolutionDescription();
    return String.format("%s dots per %s",
        value.toSimpleString(_allowDecimalRepresentationOfRationals),
        unit == null ? "unit" : unit.toLowerCase());
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:12,代码来源:ExifDescriptorBase.java


示例19: testYResolutionDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Test
public void testYResolutionDescription() throws Exception
{
    ExifIFD0Directory directory = new ExifIFD0Directory();
    directory.setRational(ExifIFD0Directory.TAG_Y_RESOLUTION, new Rational(50, 1));
    // 3 is for 'cm'
    directory.setInt(ExifIFD0Directory.TAG_RESOLUTION_UNIT, 3);
    ExifIFD0Descriptor descriptor = new ExifIFD0Descriptor(directory);
    assertEquals("50 dots per cm", descriptor.getDescription(ExifIFD0Directory.TAG_Y_RESOLUTION));
}
 
开发者ID:ydanila,项目名称:j-metadata-extractor,代码行数:11,代码来源:ExifIFD0DescriptorTest.java


示例20: getDigitalZoomRatioDescription

import com.drew.lang.Rational; //导入依赖的package包/类
@Nullable
public String getDigitalZoomRatioDescription()
{
    Rational value = _directory.getRational(TAG_DIGITAL_ZOOM_RATIO);
    return value == null
        ? null
        : value.getNumerator() == 0
            ? "Digital zoom not used"
            : new DecimalFormat("0.#").format(value.doubleValue());
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:11,代码来源:ExifDescriptorBase.java



注:本文中的com.drew.lang.Rational类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompiledScript类代码示例发布时间:2022-05-22
下一篇:
Java ObjectAdapterFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap