MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / convertUnit

Method convertUnit

CodenameOne/src/com/codename1/ui/plaf/Style.java:2250–2280  ·  view source on GitHub ↗
(byte[] unitType, float v, int orientation)

Source from the content-addressed store, hash-verified

2248 }
2249
2250 private int convertUnit(byte[] unitType, float v, int orientation) {
2251 if (unitType != null) {
2252 switch (unitType[orientation]) {
2253 case UNIT_TYPE_REM:
2254 return Math.round(v * Font.getDefaultFont().getHeight());
2255 case UNIT_TYPE_VH:
2256 return Math.round(v / 100f * CN.getDisplayHeight());
2257 case UNIT_TYPE_VW:
2258 return Math.round(v / 100f * CN.getDisplayWidth());
2259 case UNIT_TYPE_VMIN:
2260 return Math.round(v / 100f * Math.min(CN.getDisplayWidth(), CN.getDisplayHeight()));
2261 case UNIT_TYPE_VMAX:
2262 return Math.round(v / 100f * Math.max(CN.getDisplayWidth(), CN.getDisplayHeight()));
2263 case UNIT_TYPE_DIPS:
2264 return Display.getInstance().convertToPixels(v);
2265 case UNIT_TYPE_SCREEN_PERCENTAGE:
2266 if (orientation == Component.TOP || orientation == Component.BOTTOM) {
2267 float h = Display.getInstance().getDisplayHeight();
2268 h = h / 100.0f * v;
2269 return (int) h;
2270 } else {
2271 float w = Display.getInstance().getDisplayWidth();
2272 w = w / 100.0f * v;
2273 return (int) w;
2274 }
2275 default:
2276 return (int) v;
2277 }
2278 }
2279 return (int) v;
2280 }
2281
2282 /// Returns the Padding
2283 ///

Callers 15

getPaddingLeftMethod · 0.95
getPaddingRightMethod · 0.95
getPaddingTopMethod · 0.95
getPaddingBottomMethod · 0.95
getHorizontalMarginsMethod · 0.95
getVerticalMarginsMethod · 0.95
getHorizontalPaddingMethod · 0.95
getVerticalPaddingMethod · 0.95
getMarginRightNoRTLMethod · 0.95
getMarginLeftNoRTLMethod · 0.95
getPaddingRightNoRTLMethod · 0.95
getPaddingLeftNoRTLMethod · 0.95

Calls 9

roundMethod · 0.95
getDefaultFontMethod · 0.95
getDisplayHeightMethod · 0.95
getDisplayWidthMethod · 0.95
minMethod · 0.95
maxMethod · 0.95
getInstanceMethod · 0.95
getHeightMethod · 0.65
convertToPixelsMethod · 0.65

Tested by

no test coverage detected