1 /*
2  * Copyright (C) 2011 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.data;
18 
19 import android.graphics.Rect;
20 
21 import com.android.gallery3d.common.Utils;
22 
23 import java.util.StringTokenizer;
24 
25 public class Face implements Comparable<Face> {
26     private String mName;
27     private String mPersonId;
28     private Rect mPosition;
29 
Face(String name, String personId, String rect)30     public Face(String name, String personId, String rect) {
31         mName = name;
32         mPersonId = personId;
33         Utils.assertTrue(mName != null && mPersonId != null && rect != null);
34         StringTokenizer tokenizer = new StringTokenizer(rect);
35         mPosition = new Rect();
36         while (tokenizer.hasMoreElements()) {
37             mPosition.left = Integer.parseInt(tokenizer.nextToken());
38             mPosition.top = Integer.parseInt(tokenizer.nextToken());
39             mPosition.right = Integer.parseInt(tokenizer.nextToken());
40             mPosition.bottom = Integer.parseInt(tokenizer.nextToken());
41         }
42     }
43 
getPosition()44     public Rect getPosition() {
45         return mPosition;
46     }
47 
getName()48     public String getName() {
49         return mName;
50     }
51 
52     @Override
equals(Object obj)53     public boolean equals(Object obj) {
54         if (obj instanceof Face) {
55             Face face = (Face) obj;
56             return mPersonId.equals(face.mPersonId);
57         }
58         return false;
59     }
60 
61     @Override
compareTo(Face another)62     public int compareTo(Face another) {
63         return mName.compareTo(another.mName);
64     }
65 }
66