List of usage examples for android.graphics Point toString
@Override
public String toString()
From source file:com.williammora.mapsexample.StreetViewPanoramaEventsDemoActivity.java
@Override public void onStreetViewPanoramaClick(StreetViewPanoramaOrientation orientation) { Point point = svp.orientationToPoint(orientation); if (point != null) { mPanoClickTextView.setText("Times clicked=" + ++mPanoClickTimes + " :" + point.toString()); svp.animateTo(new StreetViewPanoramaCamera.Builder().orientation(orientation) .zoom(svp.getPanoramaCamera().zoom).build(), 1000); }/*www . java 2 s . com*/ }
From source file:com.example.camera2.Camera2BasicFragment.java
/** * Sets up member variables related to camera. * * @param width The width of available size for camera preview * @param height The height of available size for camera preview *//* w w w. java2 s .co m*/ private void setUpCameraOutputs(int width, int height) { Activity activity = getActivity(); CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { for (String cameraId : manager.getCameraIdList()) { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_BACK) { continue; } StreamConfigurationMap map = characteristics .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } for (Size s : map.getOutputSizes(ImageFormat.JPEG)) { Log.i("tag", "Size in map for JPEG:" + s.getWidth() + "x" + s.getHeight()); } for (Size s : map.getOutputSizes(SurfaceTexture.class)) { Log.i("tag", "Size in map for SurfaceTexture:" + s.getWidth() + "x" + s.getHeight()); } // For still image captures, we use the largest available size. Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/2); mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, mBackgroundHandler); // Find out if we need to swap dimension to get the preview size relative to sensor // coordinate. int displayRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); //noinspection ConstantConditions mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); boolean swappedDimensions = false; switch (displayRotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: if (mSensorOrientation == 90 || mSensorOrientation == 270) { swappedDimensions = true; } break; case Surface.ROTATION_90: case Surface.ROTATION_270: if (mSensorOrientation == 0 || mSensorOrientation == 180) { swappedDimensions = true; } break; default: Log.e(TAG, "Display rotation is invalid: " + displayRotation); } Point displaySize = new Point(); activity.getWindowManager().getDefaultDisplay().getSize(displaySize); Log.i("tag", "Point :" + displaySize.toString()); int rotatedPreviewWidth = width; int rotatedPreviewHeight = height; int maxPreviewWidth = displaySize.x; int maxPreviewHeight = displaySize.y; if (swappedDimensions) { rotatedPreviewWidth = height; rotatedPreviewHeight = width; maxPreviewWidth = displaySize.y; maxPreviewHeight = displaySize.x; } if (maxPreviewWidth > MAX_PREVIEW_WIDTH) { maxPreviewWidth = MAX_PREVIEW_WIDTH; } if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) { maxPreviewHeight = MAX_PREVIEW_HEIGHT; } // Danger, W.R.! Attempting to use too large a preview size could exceed the camera // bus' bandwidth limitation, resulting in gorgeous previews but the storage of // garbage capture data. mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest); Log.i("tag", "mPreviewSize:" + mPreviewSize.getWidth() + "x" + mPreviewSize.getHeight()); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } else { mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth()); } // Check if the flash is supported. Boolean available = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE); mFlashSupported = available == null ? false : available; mCameraId = cameraId; return; } } catch (CameraAccessException e) { e.printStackTrace(); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. ErrorDialog.newInstance(getString(R.string.camera_error)).show(getChildFragmentManager(), FRAGMENT_DIALOG); } }
From source file:com.example.pyo.edit.MapsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); mDeviceListView = (ListView) findViewById(R.id.deviceListView); mDeviceList = new ArrayList<String>(); mDeviceList.add("Device1 10m"); mDeviceList.add("Device2 15m"); mDeviceList.add("Device3 20m"); mDeviceList.add("Device4 25m"); ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mDeviceList); mDeviceListView.setAdapter(adapter); mDeviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from w w w .j av a 2s . c om*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mDeviceRange = 10 + 5 * position; mDeviceListView.setVisibility(View.INVISIBLE); } }); mDeviceListView.setVisibility(View.INVISIBLE); // REGISTER DRAW MAP TOUCH LISENTER mDrawMap = (FrameLayout) findViewById(R.id.draw_map); IS_MAP_MOVEABLE = false; mDrawPoints = new Vector<Vector<Point>>(); mDrawMap.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Point point = new Point(Math.round(event.getX()), Math.round(event.getY())); if (IS_MAP_MOVEABLE) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mDrawPoints.add(new Vector<Point>()); mDrawPoints.lastElement().add(point); break; case MotionEvent.ACTION_MOVE: mDrawPoints.lastElement().add(point); break; case MotionEvent.ACTION_UP: //mDrawPoints.clear(); break; } } System.out.println("[!] drag event : " + point.toString()); return IS_MAP_MOVEABLE; } }); mDrawCanvas = new DrawCanvas(this); mDrawMap.addView(mDrawCanvas); }