• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
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.ide.eclipse.adt.internal.editors.layout.gle2;
18 
19 public interface ICanvasTransform {
20     /**
21      * Margin around the rendered image.
22      * Should be enough space to display the layout width and height pseudo widgets.
23      */
24     public static final int IMAGE_MARGIN = 25;
25 
26     /**
27      * Computes the transformation from a X/Y canvas image coordinate
28      * to client pixel coordinate.
29      * <p/>
30      * This takes into account the {@link #IMAGE_MARGIN},
31      * the current scaling and the current translation.
32      *
33      * @param canvasX A canvas image coordinate (X or Y).
34      * @return The transformed coordinate in client pixel space.
35      */
translate(int canvasX)36     public int translate(int canvasX);
37 
38     /**
39      * Computes the transformation from a canvas image size (width or height) to
40      * client pixel coordinates.
41      *
42      * @param canwasW A canvas image size (W or H).
43      * @return The transformed coordinate in client pixel space.
44      */
scale(int canwasW)45     public int scale(int canwasW);
46 
47     /**
48      * Computes the transformation from a X/Y client pixel coordinate
49      * to canvas image coordinate.
50      * <p/>
51      * This takes into account the {@link #IMAGE_MARGIN},
52      * the current scaling and the current translation.
53      * <p/>
54      * This is the inverse of {@link #translate(int)}.
55      *
56      * @param screenX A client pixel space coordinate (X or Y).
57      * @return The transformed coordinate in canvas image space.
58      */
inverseTranslate(int screenX)59     public int inverseTranslate(int screenX);
60 }
61