Changeset 10862 in josm for trunk/src/com/drew/metadata/exif/makernotes/OlympusMakernoteDescriptor.java
- Timestamp:
- 2016-08-20T20:58:03+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/makernotes/OlympusMakernoteDescriptor.java
r8132 r10862 1 1 /* 2 * Copyright 2002-201 5Drew Noakes2 * Copyright 2002-2016 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 21 21 package com.drew.metadata.exif.makernotes; 22 22 23 import com.drew.lang.DateUtil; 23 24 import com.drew.lang.annotations.NotNull; 24 25 import com.drew.lang.annotations.Nullable; 25 26 import com.drew.metadata.TagDescriptor; 26 27 27 import java.util.GregorianCalendar; 28 import java.math.RoundingMode; 29 import java.text.DecimalFormat; 28 30 29 31 import static com.drew.metadata.exif.makernotes.OlympusMakernoteDirectory.*; … … 115 117 return getFocusDistanceDescription(); 116 118 case CameraSettings.TAG_FLASH_FIRED: 117 return getFlas tFiredDescription();119 return getFlashFiredDescription(); 118 120 case CameraSettings.TAG_DATE: 119 121 return getDateDescription(); … … 142 144 return getSubjectProgramDescription(); 143 145 case CameraSettings.TAG_FLASH_COMPENSATION: 144 return getFlas tCompensationDescription();146 return getFlashCompensationDescription(); 145 147 case CameraSettings.TAG_ISO_SETTING: 146 148 return getIsoSettingDescription(); … … 258 260 259 261 double iso = Math.pow((value / 8d) - 1, 2) * 3.125; 260 return Double.toString(iso); 262 DecimalFormat format = new DecimalFormat("0.##"); 263 format.setRoundingMode(RoundingMode.HALF_UP); 264 return format.format(iso); 261 265 } 262 266 … … 274 278 275 279 double shutterSpeed = Math.pow((49-value) / 8d, 2); 276 return Double.toString(shutterSpeed) + " sec"; 280 DecimalFormat format = new DecimalFormat("0.###"); 281 format.setRoundingMode(RoundingMode.HALF_UP); 282 return format.format(shutterSpeed) + " sec"; 277 283 } 278 284 … … 289 295 290 296 double fStop = Math.pow((value/16d) - 0.5, 2); 291 return "F" + Double.toString(fStop);297 return getFStopDescription(fStop); 292 298 } 293 299 … … 308 314 { 309 315 Long value = _directory.getLongObject(CameraSettings.TAG_EXPOSURE_COMPENSATION); 310 return value == null ? null : ((value / 3d) - 2) + " EV"; 316 DecimalFormat format = new DecimalFormat("0.##"); 317 return value == null ? null : format.format((value / 3d) - 2) + " EV"; 311 318 } 312 319 … … 341 348 { 342 349 Long value = _directory.getLongObject(CameraSettings.TAG_FOCAL_LENGTH); 343 return value == null ? null : Double.toString(value/256d) + " mm";350 return value == null ? null : getFocalLengthDescription(value/256d); 344 351 } 345 352 … … 356 363 357 364 @Nullable 358 public String getFlas tFiredDescription()365 public String getFlashFiredDescription() 359 366 { 360 367 return getIndexedDescription(CameraSettings.TAG_FLASH_FIRED, "No", "Yes"); … … 370 377 if (value == null) 371 378 return null; 372 long day = value & 0xFF; 373 long month = (value >> 16) & 0xFF; 374 long year = (value >> 8) & 0xFF; 375 return new GregorianCalendar((int)year + 1970, (int)month, (int)day).getTime().toString(); 379 380 int day = (int) (value & 0xFF); 381 int month = (int) ((value >> 16) & 0xFF); 382 int year = (int) ((value >> 8) & 0xFF) + 1970; 383 384 if (!DateUtil.isValidDate(year, month, day)) 385 return "Invalid date"; 386 387 return String.format("%04d-%02d-%02d", year, month + 1, day); 376 388 } 377 389 … … 385 397 if (value == null) 386 398 return null; 387 long hours = (value >> 8) & 0xFF; 388 long minutes = (value >> 16) & 0xFF; 389 long seconds = value & 0xFF; 399 400 int hours = (int) ((value >> 8) & 0xFF); 401 int minutes = (int) ((value >> 16) & 0xFF); 402 int seconds = (int) (value & 0xFF); 403 404 if (!DateUtil.isValidTime(hours, minutes, seconds)) 405 return "Invalid time"; 390 406 391 407 return String.format("%02d:%02d:%02d", hours, minutes, seconds); … … 400 416 return null; 401 417 double fStop = Math.pow((value/16d) - 0.5, 2); 402 return "F" + fStop;418 return getFStopDescription(fStop); 403 419 } 404 420 … … 424 440 { 425 441 Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_RED); 426 return value == null ? null : Double.toString(value/256d); 442 DecimalFormat format = new DecimalFormat("0.##"); 443 return value == null ? null : format.format(value/256d); 427 444 } 428 445 … … 431 448 { 432 449 Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_GREEN); 433 return value == null ? null : Double.toString(value/256d); 450 DecimalFormat format = new DecimalFormat("0.##"); 451 return value == null ? null : format.format(value/256d); 434 452 } 435 453 … … 438 456 { 439 457 Long value = _directory.getLongObject(CameraSettings.TAG_WHITE_BALANCE_BLUE); 440 return value == null ? null : Double.toString(value/256d); 458 DecimalFormat format = new DecimalFormat("0.##"); 459 return value == null ? null : format.format(value / 256d); 441 460 } 442 461 … … 468 487 469 488 @Nullable 470 public String getFlas tCompensationDescription()489 public String getFlashCompensationDescription() 471 490 { 472 491 Long value = _directory.getLongObject(CameraSettings.TAG_FLASH_COMPENSATION); 473 return value == null ? null : ((value-6)/3d) + " EV"; 492 DecimalFormat format = new DecimalFormat("0.##"); 493 return value == null ? null : format.format((value-6)/3d) + " EV"; 474 494 } 475 495 … … 535 555 { 536 556 Long value = _directory.getLongObject(CameraSettings.TAG_APEX_BRIGHTNESS_VALUE); 537 return value == null ? null : Double.toString((value/8d)-6); 557 DecimalFormat format = new DecimalFormat("0.##"); 558 return value == null ? null : format.format((value/8d)-6); 538 559 } 539 560
Note:
See TracChangeset
for help on using the changeset viewer.