Debian Codegraph @

layoutlib-api/src/main/java/com/android/ide/common/rendering/api/HardwareConfig.java

raw
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.ide.common.rendering.api;
18
19 import com.android.annotations.Nullable;
20 import com.android.resources.Density;
21 import com.android.resources.ScreenOrientation;
22 import com.android.resources.ScreenRound;
23 import com.android.resources.ScreenSize;
24
25 /**
26 * Hardware configuration for the rendering.
27 * This is immutable.
28 *
29 * @since 9
30 */
31 public class HardwareConfig {
32
33 private final int mScreenWidth;
34 private final int mScreenHeight;
35 private final Density mDensity;
36 private final float mXdpi;
37 private final float mYdpi;
38 private final ScreenOrientation mOrientation;
39 private final ScreenSize mScreenSize;
40 private final ScreenRound mScreenRound;
41
42 private final boolean mSoftwareButtons;
43
44 public HardwareConfig(
45 int screenWidth,
46 int screenHeight,
47 Density density,
48 float xdpi,
49 float ydpi,
50 ScreenSize screenSize,
51 ScreenOrientation orientation,
52 ScreenRound screenRoundness,
53 boolean softwareButtons) {
54 mScreenWidth = screenWidth;
55 mScreenHeight = screenHeight;
56 mDensity = density;
57 mXdpi = xdpi;
58 mYdpi = ydpi;
59 mScreenSize = screenSize;
60 mOrientation = orientation;
61 mScreenRound = screenRoundness;
62 mSoftwareButtons = softwareButtons;
63 }
64
65 public int getScreenWidth() {
66 return mScreenWidth;
67 }
68
69 public int getScreenHeight() {
70 return mScreenHeight;
71 }
72
73 public Density getDensity() {
74 return mDensity;
75 }
76
77 public float getXdpi() {
78 return mXdpi;
79 }
80
81 public float getYdpi() {
82 return mYdpi;
83 }
84
85 public ScreenSize getScreenSize() {
86 return mScreenSize;
87 }
88
89 public ScreenOrientation getOrientation() {
90 return mOrientation;
91 }
92
93 public boolean hasSoftwareButtons() {
94 return mSoftwareButtons;
95 }
96
97 /**
98 * @since 15
99 */
100 @Nullable
101 public ScreenRound getScreenRoundness() {
102 return mScreenRound;
103 }
104
105 /**
106 * @since 15
107 */
108 @SuppressWarnings({"MethodMayBeStatic", "unused"})
109 public int getDensityDpi() {
110 throw new UnsupportedOperationException();
111 }
112 }