• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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.layoutlib.api;
18 
19 import java.awt.image.BufferedImage;
20 
21 /**
22  * The result of a layout computation through
23  * {@link ILayoutLibBridge#computeLayout(IXmlPullParser, int, int, String, java.util.Map, java.util.Map, java.util.Map, IFontLoader, ILayoutLibLog, ICustomViewLoader)}
24  */
25 public interface ILayoutResult {
26     /**
27      * Success return code
28      */
29     final static int SUCCESS = 0;
30 
31     /**
32      * Error return code, in which case an error message is guaranteed to be defined.
33      * @See {@link #getErrorMessage()}
34      */
35     final static int ERROR = 1;
36 
37     /**
38      * Returns the result code.
39      * @see #SUCCESS
40      * @see #ERROR
41      */
getSuccess()42     int getSuccess();
43 
44     /**
45      * Returns the {@link ILayoutViewInfo} object for the top level view.
46      */
getRootView()47     ILayoutViewInfo getRootView();
48 
49     /**
50      * Returns the rendering of the full layout.
51      */
getImage()52     BufferedImage getImage();
53 
54     /**
55      * Returns the error message.
56      * <p/>Only valid when {@link #getSuccess()} returns {@link #ERROR}
57      */
getErrorMessage()58     String getErrorMessage();
59 
60     /**
61      * Layout information for a specific view.
62      */
63     public interface ILayoutViewInfo {
64 
65         /**
66          * Returns the list of children views.
67          */
getChildren()68         ILayoutViewInfo[] getChildren();
69 
70         /**
71          * Returns the key associated with the node.
72          * @see IXmlPullParser#getViewKey()
73          */
getViewKey()74         Object getViewKey();
75 
76         /**
77          * Returns the name of the view.
78          */
getName()79         String getName();
80 
81         /**
82          * Returns the left of the view bounds.
83          */
getLeft()84         int getLeft();
85 
86         /**
87          * Returns the top of the view bounds.
88          */
getTop()89         int getTop();
90 
91         /**
92          * Returns the right of the view bounds.
93          */
getRight()94         int getRight();
95 
96         /**
97          * Returns the bottom of the view bounds.
98          */
getBottom()99         int getBottom();
100     }
101 }
102