Home | History | Annotate | Download | only in imageshow
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.gallery3d.filtershow.imageshow;
     18 
     19 public class ControlPoint implements Comparable {
     20     public float x;
     21     public float y;
     22 
     23     public ControlPoint(float px, float py) {
     24         x = px;
     25         y = py;
     26     }
     27 
     28     public ControlPoint(ControlPoint point) {
     29         x = point.x;
     30         y = point.y;
     31     }
     32 
     33     public boolean sameValues(ControlPoint other) {
     34         if (this == other) {
     35             return true;
     36         }
     37         if (other == null) {
     38             return false;
     39         }
     40 
     41         if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x)) {
     42             return false;
     43         }
     44         if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y)) {
     45             return false;
     46         }
     47         return true;
     48     }
     49 
     50     public ControlPoint copy() {
     51         return new ControlPoint(x, y);
     52     }
     53 
     54     @Override
     55     public int compareTo(Object another) {
     56         ControlPoint p = (ControlPoint) another;
     57         if (p.x < x) {
     58             return 1;
     59         } else if (p.x > x) {
     60             return -1;
     61         }
     62         return 0;
     63     }
     64 }
     65