OSDN Git Service

Remove stale temporary ASEC containers
[android-x86/frameworks-base.git] / tools / layoutlib / bridge / src / com / android / layoutlib / bridge / LayoutResult.java
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.bridge;
18
19 import com.android.layoutlib.api.ILayoutResult;
20
21 import java.awt.image.BufferedImage;
22
23 /**
24  * Implementation of {@link ILayoutResult}
25  */
26 public final class LayoutResult implements ILayoutResult {
27
28     private final ILayoutViewInfo mRootView;
29     private final BufferedImage mImage;
30     private final int mSuccess;
31     private final String mErrorMessage;
32
33     /**
34      * Creates a {@link #SUCCESS} {@link ILayoutResult} with the specified params
35      * @param rootView
36      * @param image
37      */
38     public LayoutResult(ILayoutViewInfo rootView, BufferedImage image) {
39         mSuccess = SUCCESS;
40         mErrorMessage = null;
41         mRootView = rootView;
42         mImage = image;
43     }
44     
45     /**
46      * Creates a LayoutResult with a specific success code and associated message
47      * @param code
48      * @param message
49      */
50     public LayoutResult(int code, String message) {
51         mSuccess = code;
52         mErrorMessage = message;
53         mRootView = null;
54         mImage = null;
55     }
56
57     public int getSuccess() {
58         return mSuccess;
59     }
60
61     public String getErrorMessage() {
62         return mErrorMessage;
63     }
64
65     public BufferedImage getImage() {
66         return mImage;
67     }
68
69     public ILayoutViewInfo getRootView() {
70         return mRootView;
71     }
72     
73     /**
74      * Implementation of {@link ILayoutResult.ILayoutViewInfo}
75      */
76     public static final class LayoutViewInfo implements ILayoutViewInfo {
77         private final Object mKey;
78         private final String mName;
79         private final int mLeft;
80         private final int mRight;
81         private final int mTop;
82         private final int mBottom;
83         private ILayoutViewInfo[] mChildren;
84
85         public LayoutViewInfo(String name, Object key, int left, int top, int right, int bottom) {
86             mName = name;
87             mKey = key;
88             mLeft = left;
89             mRight = right;
90             mTop = top;
91             mBottom = bottom;
92         }
93         
94         public void setChildren(ILayoutViewInfo[] children) {
95             mChildren = children;
96         }
97
98         public ILayoutViewInfo[] getChildren() {
99             return mChildren;
100         }
101
102         public Object getViewKey() {
103             return mKey;
104         }
105
106         public String getName() {
107             return mName;
108         }
109
110         public int getLeft() {
111             return mLeft;
112         }
113
114         public int getTop() {
115             return mTop;
116         }
117
118         public int getRight() {
119             return mRight;
120         }
121
122         public int getBottom() {
123             return mBottom;
124         }
125     }
126 }