本文整理汇总了Java中android.util.SizeF类的典型用法代码示例。如果您正苦于以下问题:Java SizeF类的具体用法?Java SizeF怎么用?Java SizeF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SizeF类属于android.util包,在下文中一共展示了SizeF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTransact
import android.util.SizeF; //导入依赖的package包/类
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
switch(code) {
case TRANSACT_methodWithNotNullSizeArrayParameter: {
data.enforceInterface(this.getInterfaceDescriptor());
final SizeF[] sizeArrayParamArray;
final int sizeArrayParamLength = data.readInt();
if (sizeArrayParamLength < 0) {
sizeArrayParamArray = null;
} else {
sizeArrayParamArray = new SizeF[sizeArrayParamLength];
for (int i = 0; i < sizeArrayParamArray.length; i++) {
sizeArrayParamArray[i] = data.readSizeF();
}
}
delegate.methodWithNotNullSizeArrayParameter(sizeArrayParamArray);
reply.writeNoException();
return true;
}
}
return super.onTransact(code, data, reply, flags);
}
示例2: methodWithNotNullSizeArrayParameter
import android.util.SizeF; //导入依赖的package包/类
@Override
public void methodWithNotNullSizeArrayParameter(@NotNull SizeF[] sizeArrayParam) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
try {
data.writeInterfaceToken(NotNullSizeArrayParameter$$AidlServerImpl.DESCRIPTOR);
if (sizeArrayParam == null) {
data.writeInt(-1);
} else {
data.writeInt(sizeArrayParam.length);
for (SizeF sizeArrayParamComponent : sizeArrayParam) {
data.writeSizeF(sizeArrayParamComponent);
}
}
delegate.transact(NotNullSizeArrayParameter$$AidlServerImpl.TRANSACT_methodWithNotNullSizeArrayParameter, data, reply, 0);
reply.readException();
} finally {
data.recycle();
reply.recycle();
}
}
示例3: getAngle
import android.util.SizeF; //导入依赖的package包/类
public float[] getAngle() {
// 物理センサのサイズを取得(単位はミリメートル)
// SizeFクラス float型の幅widthと高さheightの情報を持つ
SizeF physicalSize = mCameraCharacteristics.get( mCameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE );
Log.d( "CameraCharacteristics", "物理サイズ : " + physicalSize.getWidth() + ", " + physicalSize.getHeight() );
// 焦点距離取得
float[] focalLength = mCameraCharacteristics.get( mCameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS );
// 画素配列の画素数取得
// Sizeクラス int型の幅widthと高さheightの情報を持つ
Size fullArraySize = mCameraCharacteristics.get( mCameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE );
Log.d( "CameraCharacteristics", "画素配列幅 : " + fullArraySize.getWidth() + ", " + fullArraySize.getHeight() );
// 有効な配列領域取得( = 切り取り領域[ 0, 0, activeRect.width, activeRect.height ])
Rect activeRect = mCameraCharacteristics.get( mCameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE );
Log.d( "CameraCharacteristics", "有効配列幅 : " + activeRect.width() + ", " + activeRect.height() );
// 出力ストリームのサイズ取得
Size outputStreamSize = new Size( mTextureView.getWidth(), mTextureView.getHeight() );
Log.d( "CameraCharacteristics", "出力ストリーム : " + outputStreamSize.getWidth() + ", " + outputStreamSize.getHeight() );
//
// 縦方向を切り取る場合(出力アスペクト比 > 切り取り領域のアスペクト比)
// 横方向を切り取る場合(出力アスペクト比 < 切り取り領域のアスペクト比)
/*
* 【FOVを求める式】 angle = 2 * arctan( d / (2 * f) )
* f = 焦点距離, d = 縦または横のセンサ物理サイズ
*/
// 実際に画面に表示している領域と取得したセンサ全体の物理サイズは異なる
// その辺の計算がよくわからないので全体で考えます
float[] angle = new float[2];
angle[0] = 2f * (float)Math.toDegrees( Math.atan( physicalSize.getWidth() / ( 2 * focalLength[0] ) ) ); // 横
angle[1] = 2f * (float)Math.toDegrees( Math.atan( physicalSize.getHeight() / ( 2 * focalLength[0] ) ) ); // 縦
Log.d("getAngle", angle[0] + ", " + angle[1] + ", " );
return angle;
}
示例4: testSerializeSizeF
import android.util.SizeF; //导入依赖的package包/类
@Test
public void testSerializeSizeF() {
SizeF expectedValue = new SizeF(9, 5);
mCoder.serialize(bundle(), randomKey(), expectedValue);
assertEquals(expectedValue, bundle().getSizeF(randomKey()));
}
示例5: testCoderApi21NotNullAbove21
import android.util.SizeF; //导入依赖的package包/类
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Test
public void testCoderApi21NotNullAbove21() throws CoderNotFoundException {
assertCoderNotNull(Size.class);
assertCoderNotNull(SizeF.class);
}
示例6: testCoderApi21ThrowsBelowApi21
import android.util.SizeF; //导入依赖的package包/类
@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);
}
示例7: onTransact
import android.util.SizeF; //导入依赖的package包/类
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
switch(code) {
case TRANSACT_methodWithCollectionReturn: {
data.enforceInterface(this.getInterfaceDescriptor());
final ArrayList<SizeF> abstrListCollection;
final int abstrListSize = data.readInt();
if (abstrListSize < 0) {
abstrListCollection = null;
} else {
abstrListCollection = new ArrayList<>(abstrListSize);
for (int j = 0; j < abstrListSize; j++) {
final SizeF abstrListTmp;
if (data.readByte() == -1) {
abstrListTmp = null;
} else {
abstrListTmp = data.readSizeF();
}
abstrListCollection.add(abstrListTmp);
}
}
final Collection<AbstractListTest> returnValue = delegate.methodWithCollectionReturn(abstrListCollection);
reply.writeNoException();
if (returnValue == null) {
reply.writeInt(-1);
} else {
reply.writeInt(returnValue.size());
for (AbstractListTest returnValueElement : returnValue) {
reply.writeStrongBinder(returnValueElement == null ? null : returnValueElement.asBinder());
}
}
return true;
}
}
return super.onTransact(code, data, reply, flags);
}
示例8: testGetSizeF
import android.util.SizeF; //导入依赖的package包/类
@TargetApi(21)
public void testGetSizeF() {
Key<SizeF> key = new Key<>("key");
Bundle bundle = new Bundle();
SizeF testSize = new SizeF(1, 2);
bundle.putSizeF("key", testSize);
TypedBundle typedBundle = runThroughParcel(new TypedBundle(bundle));
assertThat(typedBundle.get(key)).isEqualTo(testSize);
}
示例9: testPutSizeF
import android.util.SizeF; //导入依赖的package包/类
@TargetApi(21)
public void testPutSizeF() {
Key<SizeF> key = new Key<>("key");
SizeF testSize = new SizeF(1, 2);
TypedBundle typedBundle = new TypedBundle();
typedBundle.put(key, testSize);
assertThat(runThroughParcel(typedBundle).getBundle().getSizeF("key")).isEqualTo(testSize);
}
示例10: getSizeF
import android.util.SizeF; //导入依赖的package包/类
@TargetApi(21)
public SizeF getSizeF(String key){
if(bundle != null){
return bundle.getSizeF(key);
}
try{
return (SizeF) stub.get(key);
} catch(Exception e){
return null;
}
}
示例11: putSizeF
import android.util.SizeF; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void putSizeF(String key, SizeF value){
if(bundle != null) {
bundle.putSizeF(key, value);
} else {
stub.put(key, value);
}
}
示例12: shouldSaveSizeFValueType
import android.util.SizeF; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Test
public void shouldSaveSizeFValueType() {
Bundle bundle = mock(Bundle.class);
SizeF value = new SizeF(42, 42);
ValueSaver<SizeF> valueSaver = mValueSaverFactory.build(value);
valueSaver.save(bundle, SOME_KEY, value);
verify(bundle).putSizeF(SOME_KEY, value);
}
示例13: sizeFIsCorrectlyParcelled
import android.util.SizeF; //导入依赖的package包/类
@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);
}
示例14: testDeserializeSizeF
import android.util.SizeF; //导入依赖的package包/类
@Test
public void testDeserializeSizeF() {
SizeF expectedValue = new SizeF(9, 5);
bundle().putSizeF(randomKey(), expectedValue);
assertEquals(expectedValue, mCoder.deserialize(bundle(), randomKey()));
}
示例15: write
import android.util.SizeF; //导入依赖的package包/类
@Override
public void write(Bundle bundle, Object to, StateField field) throws IllegalAccessException {
Field propertyField = field.getField();
propertyField.setAccessible(true);
bundle.putSizeF(field.getBundleKey(), (SizeF) propertyField.get(to));
}