nicolasroard | 0d7cdf8 | 2012-09-25 14:27:56 -0700 | [diff] [blame] | 1 | |
| 2 | package com.android.gallery3d.filtershow.ui; |
| 3 | |
John Hoford | c7b2c28 | 2012-10-02 18:12:03 -0700 | [diff] [blame^] | 4 | public class ControlPoint implements Comparable { |
nicolasroard | 0d7cdf8 | 2012-09-25 14:27:56 -0700 | [diff] [blame] | 5 | public ControlPoint(float px, float py) { |
| 6 | x = px; |
| 7 | y = py; |
| 8 | } |
| 9 | |
| 10 | public ControlPoint multiply(float m) { |
| 11 | return new ControlPoint(x * m, y * m); |
| 12 | } |
| 13 | |
| 14 | public ControlPoint add(ControlPoint v) { |
| 15 | return new ControlPoint(x + v.x, y + v.y); |
| 16 | } |
| 17 | |
| 18 | public ControlPoint sub(ControlPoint v) { |
| 19 | return new ControlPoint(x - v.x, y - v.y); |
| 20 | } |
| 21 | |
| 22 | public float x; |
| 23 | public float y; |
| 24 | |
| 25 | public ControlPoint copy() { |
| 26 | return new ControlPoint(x, y); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public int compareTo(Object another) { |
| 31 | ControlPoint p = (ControlPoint) another; |
| 32 | if (p.x < x) { |
| 33 | return 1; |
| 34 | } else if (p.x > x) { |
| 35 | return -1; |
| 36 | } |
| 37 | return 0; |
| 38 | } |
| 39 | } |