X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fjpeg%2FExifGateway.java;fp=tim%2Fprune%2Fjpeg%2FExifGateway.java;h=0000000000000000000000000000000000000000;hp=c11ba2e69ec7c3f1d7ead5bd7a549ec3ea6ce318;hb=92dad5df664287acb51728e9ea599f150765d34a;hpb=81843c3d8d0771bf00d0f26034a13aa515465c78 diff --git a/tim/prune/jpeg/ExifGateway.java b/tim/prune/jpeg/ExifGateway.java deleted file mode 100644 index c11ba2e..0000000 --- a/tim/prune/jpeg/ExifGateway.java +++ /dev/null @@ -1,108 +0,0 @@ -package tim.prune.jpeg; - -import java.io.File; -import javax.swing.JOptionPane; -import tim.prune.I18nManager; - -/** - * Skeleton gateway to the Exif functions. - * This is required by Debian to divert Exif handling - * to the external libmetadata-extractor-java library - * instead of the included modified routines. - * - * Switching between internal and external libraries is - * handled by the ExifLibrarySwitch - */ -public abstract class ExifGateway -{ - /** Library object to call */ - private static ExifLibrary _exifLibrary = null; - /** Flag to set whether failure warning has already been shown */ - private static boolean _exifFailWarned = false; - - /** Static block to initialise library */ - static - { - String libraryClass = ExifLibrarySwitch.USE_INTERNAL_LIBRARY?"InternalExifLibrary":"ExternalExifLibrary"; - try - { - _exifLibrary = (ExifLibrary) Class.forName("tim.prune.jpeg." + libraryClass).newInstance(); - } - catch (Throwable nolib) {_exifLibrary = null;} - } - - - /** - * Get the Jpeg data from the given file - * @param inFile file to read - * @return jpeg data, or null if none found - */ - public static JpegData getJpegData(File inFile) - { - try - { - // Call library (if found) - if (_exifLibrary != null) { - JpegData data = _exifLibrary.getJpegData(inFile); - return data; - } - } - catch (LinkageError nolib) { - System.err.println("Link: " + nolib.getMessage()); - nolib.printStackTrace(); - } - // Not successful - warn if necessary - if (!_exifFailWarned) - { - JOptionPane.showMessageDialog(null, I18nManager.getText("error.jpegload.exifreadfailed"), - I18nManager.getText("error.jpegload.dialogtitle"), JOptionPane.WARNING_MESSAGE); - _exifFailWarned = true; - } - return null; - } - - /** - * @return key to use to describe library, matching key for about dialog - */ - public static String getDescriptionKey() - { - String key = ExifLibrarySwitch.USE_INTERNAL_LIBRARY?"internal":"external"; - if (_exifLibrary == null || !_exifLibrary.looksOK()) {key = key + ".failed";} - return key; - } - - - /** - * @param inNumerator numerator from Rational - * @param inDenominator denominator from Rational - * @return the value of the specified number as a positive double. - * Prevents interpretation of 32 bit numbers as negative, and forces a positive answer - */ - public static final double convertToPositiveValue(int inNumerator, int inDenominator) - { - if (inDenominator == 0) return 0.0; - double numeratorDbl = inNumerator; - double denomDbl = inDenominator; - if (inNumerator >= 0) - return numeratorDbl / denomDbl; - final double correction = Math.pow(2.0, 32); - numeratorDbl += correction; - if (inDenominator < 0) denomDbl += correction; - return numeratorDbl / denomDbl; - } - - - /** - * @param inNumerator numerator from Rational - * @param inDenominator denominator from Rational - * @return the value of the specified number as a positive double. - * Forces a positive answer - */ - public static final double convertToPositiveValue(long inNumerator, long inDenominator) - { - if (inDenominator == 0L) return 0.0; - final double numeratorDbl = inNumerator; - final double denomDbl = inDenominator; - return numeratorDbl / denomDbl; - } -}