X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FPhoto.java;h=c9046743a704ca2629e8341ebef1d4497f878384;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=3646cb5201ba706d3d2aae30fa021d8407a41adf;hpb=5625a1abadb5f2ca5f017fe7dbda1d5141cb637b;p=GpsPrune.git diff --git a/tim/prune/data/Photo.java b/tim/prune/data/Photo.java index 3646cb5..c904674 100644 --- a/tim/prune/data/Photo.java +++ b/tim/prune/data/Photo.java @@ -8,23 +8,15 @@ import javax.swing.ImageIcon; /** * Class to represent a photo and link to DataPoint */ -public class Photo +public class Photo extends MediaFile { - /** File where photo is stored */ - private File _file = null; - /** Timestamp, if any */ - private Timestamp _timestamp = null; - /** Associated DataPoint if correlated */ - private DataPoint _dataPoint = null; /** Size of original image */ private Dimension _size = null; - /** Status of photo when loaded */ - private byte _originalStatus = PhotoStatus.NOT_CONNECTED; - /** Current photo status */ - private byte _currentStatus = PhotoStatus.NOT_CONNECTED; + /** rotation flag (clockwise from 0 to 3) */ + private int _rotation = 0; // TODO: Need to store caption for image? - // TODO: Need to store thumbnail for image? - + // thumbnail for image (from exif) + private byte[] _exifThumbnail = null; /** * Constructor @@ -32,59 +24,7 @@ public class Photo */ public Photo(File inFile) { - _file = inFile; - } - - - /** - * @return File object where photo resides - */ - public File getFile() - { - return _file; - } - - - /** - * Set the data point associated with the photo - * @param inPoint DataPoint with coordinates etc - */ - public void setDataPoint(DataPoint inPoint) - { - _dataPoint = inPoint; - // set status according to point - if (inPoint == null) - { - setCurrentStatus(PhotoStatus.NOT_CONNECTED); - } - else - { - setCurrentStatus(PhotoStatus.CONNECTED); - } - } - - /** - * @return the DataPoint object - */ - public DataPoint getDataPoint() - { - return _dataPoint; - } - - /** - * @param inTimestamp Timestamp of photo - */ - public void setTimestamp(Timestamp inTimestamp) - { - _timestamp = inTimestamp; - } - - /** - * @return timestamp of photo - */ - public Timestamp getTimestamp() - { - return _timestamp; + super(inFile, null); } /** @@ -106,8 +46,7 @@ public class Photo */ public Dimension getSize() { - if (_size == null) - { + if (_size == null) { calculateSize(); } return _size; @@ -140,55 +79,55 @@ public class Photo } /** - * @param inStatus status of photo when loaded + * @return byte array of thumbnail data */ - public void setOriginalStatus(byte inStatus) + public byte[] getExifThumbnail() { - _originalStatus = inStatus; - _currentStatus = inStatus; + return _exifThumbnail; } /** - * @return status of photo when it was loaded + * @param inBytes byte array from exif */ - public byte getOriginalStatus() + public void setExifThumbnail(byte[] inBytes) { - return _originalStatus; + _exifThumbnail = inBytes; } /** - * @return current status of photo + * Delete the cached data when the Photo is no longer needed */ - public byte getCurrentStatus() + public void resetCachedData() { - return _currentStatus; + _size = null; + // remove thumbnail too } + /** - * @param inStatus current status of photo + * @param inRotation initial rotation value (from exif) */ - public void setCurrentStatus(byte inStatus) + public void setRotation(int inRotation) { - _currentStatus = inStatus; + if (inRotation >= 0 && inRotation <= 3) { + _rotation = inRotation; + } } - /** - * Delete the cached data when the Photo is no longer needed + * Rotate the image by 90 degrees + * @param inRight true to rotate right, false for left */ - public void resetCachedData() + public void rotate(boolean inRight) { - _size = null; - // remove thumbnail too + int dir = inRight?1:3; + _rotation = (_rotation + dir) % 4; } /** - * Check if a Photo object refers to the same File as another - * @param inOther other Photo object - * @return true if the Files are the same + * @return rotation status */ - public boolean equals(Photo inOther) + public int getRotationDegrees() { - return (inOther != null && inOther.getFile() != null && getFile() != null - && inOther.getFile().equals(getFile())); + return _rotation * 90; } }