• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.ide.common.rendering;
18 
19 import com.android.ide.common.rendering.api.RenderSession;
20 import com.android.ide.common.rendering.api.Result;
21 import com.android.ide.common.rendering.api.ViewInfo;
22 
23 import java.awt.image.BufferedImage;
24 import java.util.Collections;
25 import java.util.List;
26 
27 /**
28  * Static {@link RenderSession} returning a given {@link Result}, {@link ViewInfo} and
29  * {@link BufferedImage}.
30  * <p/>
31  * All other methods are untouched from the base implementation provided by the API.
32  * <p/>
33  * This is meant to be used as a wrapper around the static results. No further operations are
34  * possible.
35  *
36  */
37 public class StaticRenderSession extends RenderSession {
38 
39     private final Result mResult;
40     private final List<ViewInfo> mRootViewInfo;
41     private final BufferedImage mImage;
42 
StaticRenderSession(Result result, ViewInfo rootViewInfo, BufferedImage image)43     public StaticRenderSession(Result result, ViewInfo rootViewInfo, BufferedImage image) {
44         mResult = result;
45         mRootViewInfo = Collections.singletonList(rootViewInfo);
46         mImage = image;
47     }
48 
49     @Override
getResult()50     public Result getResult() {
51         return mResult;
52     }
53 
54     @Override
getRootViews()55     public List<ViewInfo> getRootViews() {
56         return mRootViewInfo;
57     }
58 
59     @Override
getImage()60     public BufferedImage getImage() {
61         return mImage;
62     }
63 }
64