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.inputmethod.latin.utils; 18 19 public final class CoordinateUtils { 20 private static final int INDEX_X = 0; 21 private static final int INDEX_Y = 1; 22 private static final int ARRAY_SIZE = INDEX_Y + 1; 23 24 private CoordinateUtils() { 25 // This utility class is not publicly instantiable. 26 } 27 28 public static int[] newInstance() { 29 return new int[ARRAY_SIZE]; 30 } 31 32 public static int x(final int[] coords) { 33 return coords[INDEX_X]; 34 } 35 36 public static int y(final int[] coords) { 37 return coords[INDEX_Y]; 38 } 39 40 public static void set(final int[] coords, final int x, final int y) { 41 coords[INDEX_X] = x; 42 coords[INDEX_Y] = y; 43 } 44 45 public static void copy(final int[] destination, final int[] source) { 46 destination[INDEX_X] = source[INDEX_X]; 47 destination[INDEX_Y] = source[INDEX_Y]; 48 } 49 } 50