diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2013-07-18 16:37:30 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2013-08-01 09:46:44 -0700 |
commit | 203eb404a7cd6a80397535e63d22b3772939f03d (patch) | |
tree | c6cc970ad5bf9fc710cb3a8a2a667729b2439623 /src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java | |
parent | 3a5bc6b23096365e1a814f8999937028bc12b401 (diff) | |
download | android_packages_apps_Snap-203eb404a7cd6a80397535e63d22b3772939f03d.tar.gz android_packages_apps_Snap-203eb404a7cd6a80397535e63d22b3772939f03d.tar.bz2 android_packages_apps_Snap-203eb404a7cd6a80397535e63d22b3772939f03d.zip |
Refactoring Geometry handling.
Bug: 9170644
Bug: 9366654
Bug: 9366263
- Consolidates all the geometry transforms in GeometryMathUtils and
significantly reduces complexity.
- Removes GeometryMetadata object and dependent code.
- Removes ImageGeometry and geometry update callbacks.
Change-Id: I59add51907459593244c9ebaadef585efc7486d5
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java index 890f1cfd6..94c9497fc 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterStraightenRepresentation.java @@ -29,6 +29,8 @@ public class FilterStraightenRepresentation extends FilterRepresentation { public static final String SERIALIZATION_NAME = "STRAIGHTEN"; public static final String SERIALIZATION_STRAIGHTEN_VALUE = "value"; private static final String TAG = FilterStraightenRepresentation.class.getSimpleName(); + public static final int MAX_STRAIGHTEN_ANGLE = 45; + public static final int MIN_STRAIGHTEN_ANGLE = -45; float mStraighten; @@ -48,7 +50,7 @@ public class FilterStraightenRepresentation extends FilterRepresentation { } public FilterStraightenRepresentation() { - this(0); + this(getNil()); } public void set(FilterStraightenRepresentation r) { @@ -73,7 +75,7 @@ public class FilterStraightenRepresentation extends FilterRepresentation { public void setStraighten(float straighten) { if (!rangeCheck(straighten)) { - straighten = Math.min(Math.max(straighten, -45), 45); + straighten = Math.min(Math.max(straighten, MIN_STRAIGHTEN_ANGLE), MAX_STRAIGHTEN_ANGLE); } mStraighten = straighten; } @@ -107,7 +109,11 @@ public class FilterStraightenRepresentation extends FilterRepresentation { @Override public boolean isNil() { - return mStraighten == 0; + return mStraighten == getNil(); + } + + public static float getNil() { + return 0; } @Override @@ -124,7 +130,7 @@ public class FilterStraightenRepresentation extends FilterRepresentation { while (reader.hasNext()) { String name = reader.nextName(); if (SERIALIZATION_STRAIGHTEN_VALUE.equals(name)) { - int s = reader.nextInt(); + float s = (float) reader.nextDouble(); if (rangeCheck(s)) { setStraighten(s); unset = false; @@ -139,7 +145,7 @@ public class FilterStraightenRepresentation extends FilterRepresentation { reader.endObject(); } - private boolean rangeCheck(float s) { + private boolean rangeCheck(double s) { if (s < -45 || s > 45) { return false; } |