X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FPhoto.java;h=7ffe35dec984511a6de8d7e522cb1aa25b4c7932;hb=140e9d165f85c3d4f0435a311e091209313faa2a;hp=2f230cc45dae35db740159724b7bd989002dbfae;hpb=da0b1f449260a0b4a94318006382a9039726ef3e;p=GpsPrune.git diff --git a/tim/prune/data/Photo.java b/tim/prune/data/Photo.java index 2f230cc..7ffe35d 100644 --- a/tim/prune/data/Photo.java +++ b/tim/prune/data/Photo.java @@ -19,13 +19,24 @@ public class Photo /** Size of original image */ private Dimension _size = null; /** Status of photo when loaded */ - private byte _originalStatus = PhotoStatus.NOT_CONNECTED; + private Status _originalStatus = Status.NOT_CONNECTED; /** Current photo status */ - private byte _currentStatus = PhotoStatus.NOT_CONNECTED; + private Status _currentStatus = Status.NOT_CONNECTED; + /** rotation flag (clockwise from 0 to 3) */ + private int _rotation = 0; // TODO: Need to store caption for image? // thumbnail for image (from exif) private byte[] _exifThumbnail = null; + /** Photo status */ + public enum Status { + /** Photo is not connected to any point */ + NOT_CONNECTED, + /** Photo has been connected to a point since it was loaded */ + TAGGED, + /** Photo is connected to a point */ + CONNECTED + }; /** * Constructor @@ -54,13 +65,11 @@ public class Photo { _dataPoint = inPoint; // set status according to point - if (inPoint == null) - { - setCurrentStatus(PhotoStatus.NOT_CONNECTED); + if (inPoint == null) { + setCurrentStatus(Status.NOT_CONNECTED); } - else - { - setCurrentStatus(PhotoStatus.CONNECTED); + else { + setCurrentStatus(Status.CONNECTED); } } @@ -143,7 +152,7 @@ public class Photo /** * @param inStatus status of photo when loaded */ - public void setOriginalStatus(byte inStatus) + public void setOriginalStatus(Status inStatus) { _originalStatus = inStatus; _currentStatus = inStatus; @@ -152,7 +161,7 @@ public class Photo /** * @return status of photo when it was loaded */ - public byte getOriginalStatus() + public Status getOriginalStatus() { return _originalStatus; } @@ -160,18 +169,26 @@ public class Photo /** * @return current status of photo */ - public byte getCurrentStatus() + public Status getCurrentStatus() { return _currentStatus; } /** * @param inStatus current status of photo */ - public void setCurrentStatus(byte inStatus) + public void setCurrentStatus(Status inStatus) { _currentStatus = inStatus; } + /** + * @return true if photo is connected to a point + */ + public boolean isConnected() + { + return _currentStatus != Status.NOT_CONNECTED; + } + /** * @return byte array of thumbnail data */ @@ -207,4 +224,32 @@ public class Photo return (inOther != null && inOther.getFile() != null && getFile() != null && inOther.getFile().equals(getFile())); } + + /** + * @param inRotation initial rotation value (from exif) + */ + public void setRotation(int inRotation) + { + if (inRotation >= 0 && inRotation <= 3) { + _rotation = inRotation; + } + } + + /** + * Rotate the image by 90 degrees + * @param inRight true to rotate right, false for left + */ + public void rotate(boolean inRight) + { + int dir = inRight?1:3; + _rotation = (_rotation + dir) % 4; + } + + /** + * @return rotation status + */ + public int getRotationDegrees() + { + return _rotation * 90; + } }