android.util.SizeF Java Examples
The following examples show how to use
android.util.SizeF.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeAdapterTest.java From paperparcel with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Test public void sizeFIsCorrectlyParcelled() { TypeAdapter<SizeF> adapter = StaticAdapters.SIZE_F_ADAPTER; SizeF expected = new SizeF(10.f, 10.f); SizeF result = writeThenRead(adapter, expected); assertThat(result).isEqualTo(expected); }
Example #2
Source File: Bundle.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Returns the value associated with the given key, or null if * no mapping of the desired type exists for the given key or a null * value is explicitly associated with the key. * * @param key a String, or null * @return a Size value, or null */ @Nullable public SizeF getSizeF(@Nullable String key) { unparcel(); final Object o = mMap.get(key); try { return (SizeF) o; } catch (ClassCastException e) { typeWarning(key, o, "SizeF", e); return null; } }
Example #3
Source File: StateCoderUtilsTest.java From lyra with Apache License 2.0 | 5 votes |
@Config(maxSdk = Build.VERSION_CODES.KITKAT) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Test(expected = CoderNotFoundException.class) public void testCoderApi21ThrowsBelowApi21() throws CoderNotFoundException { assertCoderNotNull(Size.class); assertCoderNotNull(SizeF.class); }
Example #4
Source File: MarshalQueryableSizeF.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public SizeF unmarshal(ByteBuffer buffer) { float width = buffer.getFloat(); float height = buffer.getFloat(); return new SizeF(width, height); }
Example #5
Source File: StateCoderUtilsTest.java From lyra with Apache License 2.0 | 5 votes |
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Test public void testCoderApi21NotNullAbove21() throws CoderNotFoundException { assertCoderNotNull(Size.class); assertCoderNotNull(SizeF.class); }
Example #6
Source File: SizeFCoderTest.java From lyra with Apache License 2.0 | 5 votes |
@Test public void testSerializeSizeF() { SizeF expectedValue = new SizeF(9, 5); mCoder.serialize(bundle(), randomKey(), expectedValue); assertEquals(expectedValue, bundle().getSizeF(randomKey())); }
Example #7
Source File: BcmRouterIntent.java From bcm-android with GNU General Public License v3.0 | 4 votes |
public BcmRouterIntent putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }
Example #8
Source File: StaticAdapters.java From paperparcel with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void writeToParcel(@NonNull SizeF value, @NonNull Parcel dest, int flags) { dest.writeSizeF(value); }
Example #9
Source File: StaticAdapters.java From paperparcel with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @NonNull @Override public SizeF readFromParcel(@NonNull Parcel source) { return source.readSizeF(); }
Example #10
Source File: Bundle.java From Akatsuki with Apache License 2.0 | 4 votes |
public SizeF getSizeF(java.lang.String key){ throw new RuntimeException("Stub!"); }
Example #11
Source File: Bundle.java From Akatsuki with Apache License 2.0 | 4 votes |
public void putSizeF(java.lang.String key, SizeF value){ throw new RuntimeException("Stub!"); }
Example #12
Source File: BundleHelper.java From OpenHub with GNU General Public License v3.0 | 4 votes |
public BundleHelper put(@NonNull String key, @Nullable SizeF value){ bundle.putSizeF(key, value); return this; }
Example #13
Source File: MeepoUtils.java From Meepo with Apache License 2.0 | 4 votes |
public static void putValueToBundle( @NonNull Bundle bundle, @NonNull String key, @NonNull Object value) { if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof Integer) { bundle.putInt(key, (int) value); } else if (value instanceof Boolean) { bundle.putBoolean(key, (boolean) value); } else if (value instanceof Long) { bundle.putLong(key, (long) value); } else if (value instanceof Short) { bundle.putShort(key, (short) value); } else if (value instanceof Double) { bundle.putDouble(key, (double) value); } else if (value instanceof Float) { bundle.putFloat(key, (float) value); } else if (value instanceof Character) { bundle.putChar(key, (char) value); } else if (value instanceof Byte) { bundle.putByte(key, (byte) value); } else if (value instanceof CharSequence) { bundle.putCharSequence(key, (CharSequence) value); } else if (value instanceof Bundle) { bundle.putBundle(key, (Bundle) value); } else if (value instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) value); } else if (value instanceof String[]) { bundle.putStringArray(key, (String[]) value); } else if (value instanceof int[]) { bundle.putIntArray(key, (int[]) value); } else if (value instanceof boolean[]) { bundle.putBooleanArray(key, (boolean[]) value); } else if (value instanceof long[]) { bundle.putLongArray(key, (long[]) value); } else if (value instanceof short[]) { bundle.putShortArray(key, (short[]) value); } else if (value instanceof double[]) { bundle.putDoubleArray(key, (double[]) value); } else if (value instanceof float[]) { bundle.putFloatArray(key, (float[]) value); } else if (value instanceof char[]) { bundle.putCharArray(key, (char[]) value); } else if (value instanceof byte[]) { bundle.putByteArray(key, (byte[]) value); } else if (value instanceof CharSequence[]) { bundle.putCharSequenceArray(key, (CharSequence[]) value); } else if (value instanceof Parcelable[]) { bundle.putParcelableArray(key, (Parcelable[]) value); } else if (value instanceof ArrayList) { bundle.putIntegerArrayList(key, (ArrayList<Integer>) value); } else if (value instanceof SparseArray) { bundle.putSparseParcelableArray(key, (SparseArray<? extends Parcelable>) value); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (value instanceof IBinder) { bundle.putBinder(key, (IBinder) value); return; } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (value instanceof Size) { bundle.putSize(key, (Size) value); return; } else if (value instanceof SizeF) { bundle.putSizeF(key, (SizeF) value); return; } } if (value instanceof Serializable) { bundle.putSerializable(key, (Serializable) value); return; } throw new RuntimeException(String.format(Locale.getDefault(), "Arguments extra %s has wrong type %s.", key, value.getClass().getName())); } }
Example #14
Source File: SizeFCoderTest.java From lyra with Apache License 2.0 | 4 votes |
@Test public void testDeserializeSizeF() { SizeF expectedValue = new SizeF(9, 5); bundle().putSizeF(randomKey(), expectedValue); assertEquals(expectedValue, mCoder.deserialize(bundle(), randomKey())); }
Example #15
Source File: MarshalQueryableSizeF.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public boolean isTypeMappingSupported(TypeReference<SizeF> managedType, int nativeType) { return nativeType == TYPE_FLOAT && (SizeF.class.equals(managedType.getType())); }
Example #16
Source File: MarshalQueryableSizeF.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public Marshaler<SizeF> createMarshaler( TypeReference<SizeF> managedType, int nativeType) { return new MarshalerSizeF(managedType, nativeType); }
Example #17
Source File: MarshalQueryableSizeF.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void marshal(SizeF value, ByteBuffer buffer) { buffer.putFloat(value.getWidth()); buffer.putFloat(value.getHeight()); }
Example #18
Source File: Camera2Proxy.java From mobile-ar-sensor-logger with GNU General Public License v3.0 | 4 votes |
@Override public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { Long timestamp = result.get(CaptureResult.SENSOR_TIMESTAMP); Long number = result.getFrameNumber(); Long exposureTimeNs = result.get(CaptureResult.SENSOR_EXPOSURE_TIME); Long frmDurationNs = result.get(CaptureResult.SENSOR_FRAME_DURATION); Long frmReadoutNs = result.get(CaptureResult.SENSOR_ROLLING_SHUTTER_SKEW); Integer iso = result.get(CaptureResult.SENSOR_SENSITIVITY); if (expoStats.size() > kMaxExpoSamples) { expoStats.subList(0, kMaxExpoSamples / 2).clear(); } expoStats.add(new NumExpoIso(number, exposureTimeNs, iso)); Float fl = result.get(CaptureResult.LENS_FOCAL_LENGTH); Float fd = result.get(CaptureResult.LENS_FOCUS_DISTANCE); Integer afMode = result.get(CaptureResult.CONTROL_AF_MODE); Rect rect = result.get(CaptureResult.SCALER_CROP_REGION); mFocalLengthHelper.setmFocalLength(fl); mFocalLengthHelper.setmFocusDistance(fd); mFocalLengthHelper.setmCropRegion(rect); SizeF sz_focal_length = mFocalLengthHelper.getFocalLengthPixel(); String delimiter = ","; StringBuilder sb = new StringBuilder(); sb.append(timestamp); sb.append(delimiter + sz_focal_length.getWidth()); sb.append(delimiter + sz_focal_length.getHeight()); sb.append(delimiter + number); sb.append(delimiter + exposureTimeNs); sb.append(delimiter + frmDurationNs); sb.append(delimiter + frmReadoutNs); sb.append(delimiter + iso); sb.append(delimiter + fl); sb.append(delimiter + fd); sb.append(delimiter + afMode); String frame_info = sb.toString(); if (mRecordingMetadata) { try { mFrameMetadataWriter.write(frame_info + "\n"); } catch (IOException err) { System.err.println("Error writing captureResult: " + err.getMessage()); } } ((CameraCaptureActivity) mActivity).updateCaptureResultPanel( sz_focal_length.getWidth(), exposureTimeNs, afMode); }
Example #19
Source File: Parcel.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Flatten a SizeF into the parcel at the current dataPosition(), * growing dataCapacity() if needed. */ public final void writeSizeF(SizeF val) { writeFloat(val.getWidth()); writeFloat(val.getHeight()); }
Example #20
Source File: MarshalQueryableSizeF.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
protected MarshalerSizeF(TypeReference<SizeF> typeReference, int nativeType) { super(MarshalQueryableSizeF.this, typeReference, nativeType); }
Example #21
Source File: StateCoderUtils.java From lyra with Apache License 2.0 | 4 votes |
/** * Get the default {@link StateCoder} from a class. * If the class is equal to the coder class or the coder class extends/implements the class * passed as parameter, the class is supported. * In the other cases, you have to implement your own {@link StateCoder}. * * @param cls class that can be serialized/deserialized with a {@link StateCoder} * @return coder related to the class passed as parameter * @throws CoderNotFoundException if the coder wasn't found */ @NonNull public static StateCoder getBasicCoderForClass(@NonNull Class<?> cls) throws CoderNotFoundException { if (boolean.class == cls || Boolean.class == cls) return new BooleanCoder(); if (boolean[].class == cls) return new BooleanArrayCoder(); if (byte.class == cls || Byte.class == cls) return new ByteCoder(); if (byte[].class == cls) return new ByteArrayCoder(); if (char.class == cls || Character.class == cls) return new CharCoder(); if (char[].class == cls) return new CharArrayCoder(); if (CharSequence.class == cls) return new CharSequenceCoder(); if (CharSequence[].class == cls) return new CharSequenceArrayCoder(); if (double.class == cls || Double.class == cls) return new DoubleCoder(); if (double[].class == cls) return new DoubleArrayCoder(); if (float.class == cls || Float.class == cls) return new FloatCoder(); if (float[].class == cls) return new FloatArrayCoder(); if (IBinder.class == cls) return new IBinderCoder(); if (int.class == cls || Integer.class == cls) return new IntCoder(); if (int[].class == cls) return new IntArrayCoder(); if (long.class == cls || Long.class == cls) return new LongCoder(); if (long[].class == cls) return new LongArrayCoder(); if (Parcelable.class == cls) return new ParcelableCoder(); if (Parcelable[].class == cls) return new ParcelableArrayCoder(); if (Serializable.class == cls) return new SerializableCoder(); if (short.class == cls || Short.class == cls) return new ShortCoder(); if (short[].class == cls) return new ShortArrayCoder(); if (String.class == cls) return new StringCoder(); if (String[].class == cls) return new StringArrayCoder(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Size.class == cls) return new SizeCoder(); if (SizeF.class == cls) return new SizeFCoder(); } return getBasicCoderForInheritedClass(cls); }
Example #22
Source File: Parcel.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Read a SizeF from the parcel at the current dataPosition(). */ public final SizeF readSizeF() { final float width = readFloat(); final float height = readFloat(); return new SizeF(width, height); }
Example #23
Source File: LegacyMetadataMapper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private static void mapSensor(CameraMetadataNative m, Parameters p) { // Use the largest jpeg size (by area) for both active array and pixel array Size largestJpegSize = getLargestSupportedJpegSizeByArea(p); /* * sensor.info.activeArraySize */ { Rect activeArrayRect = ParamsUtils.createRect(largestJpegSize); m.set(SENSOR_INFO_ACTIVE_ARRAY_SIZE, activeArrayRect); } /* * sensor.availableTestPatternModes */ { // Only "OFF" test pattern mode is available m.set(SENSOR_AVAILABLE_TEST_PATTERN_MODES, new int[] { SENSOR_TEST_PATTERN_MODE_OFF }); } /* * sensor.info.pixelArraySize */ m.set(SENSOR_INFO_PIXEL_ARRAY_SIZE, largestJpegSize); /* * sensor.info.physicalSize */ { /* * Assume focal length is at infinity focus and that the lens is rectilinear. */ float focalLength = p.getFocalLength(); // in mm double angleHor = p.getHorizontalViewAngle() * Math.PI / 180; // to radians double angleVer = p.getVerticalViewAngle() * Math.PI / 180; // to radians float height = (float)Math.abs(2 * focalLength * Math.tan(angleVer / 2)); float width = (float)Math.abs(2 * focalLength * Math.tan(angleHor / 2)); m.set(SENSOR_INFO_PHYSICAL_SIZE, new SizeF(width, height)); // in mm } /* * sensor.info.timestampSource */ { m.set(SENSOR_INFO_TIMESTAMP_SOURCE, SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN); } }
Example #24
Source File: ParameterUtils.java From android_9.0.0_r45 with Apache License 2.0 | 3 votes |
/** * Returns the component-wise zoom ratio (each greater or equal than {@code 1.0}); * largest values means more zoom. * * @param activeArraySize active array size of the sensor (e.g. max jpeg size) * @param cropSize size of the crop/zoom * * @return {@link SizeF} with width/height being the component-wise zoom ratio * * @throws NullPointerException if any of the args were {@code null} * @throws IllegalArgumentException if any component of {@code cropSize} was {@code 0} */ private static SizeF getZoomRatio(Size activeArraySize, Size cropSize) { checkNotNull(activeArraySize, "activeArraySize must not be null"); checkNotNull(cropSize, "cropSize must not be null"); checkArgumentPositive(cropSize.getWidth(), "cropSize.width must be positive"); checkArgumentPositive(cropSize.getHeight(), "cropSize.height must be positive"); float zoomRatioWidth = activeArraySize.getWidth() * 1.0f / cropSize.getWidth(); float zoomRatioHeight = activeArraySize.getHeight() * 1.0f / cropSize.getHeight(); return new SizeF(zoomRatioWidth, zoomRatioHeight); }
Example #25
Source File: Bundler.java From KUtils-master with Apache License 2.0 | 2 votes |
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ @TargetApi(21) public Bundler putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }
Example #26
Source File: Bundler.java From SmartTabLayout with Apache License 2.0 | 2 votes |
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null * @return this */ @TargetApi(21) public Bundler putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }
Example #27
Source File: Bundle.java From android_9.0.0_r45 with Apache License 2.0 | 2 votes |
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ public void putSizeF(@Nullable String key, @Nullable SizeF value) { unparcel(); mMap.put(key, value); }
Example #28
Source File: Bundler.java From SmartTablayout with Apache License 2.0 | 2 votes |
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ @TargetApi(21) public Bundler putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }
Example #29
Source File: Bundler.java From SmartTablayout with Apache License 2.0 | 2 votes |
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ @TargetApi(21) public Bundler putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }
Example #30
Source File: Bundler.java From KUtils-master with Apache License 2.0 | 2 votes |
/** * Inserts a SizeF value into the mapping of this Bundle, replacing * any existing value for the given key. Either key or value may be null. * * @param key a String, or null * @param value a SizeF object, or null */ @TargetApi(21) public Bundler putSizeF(String key, SizeF value) { bundle.putSizeF(key, value); return this; }