List of usage examples for android.graphics Point Point
public Point(int x, int y)
From source file:cc.softwarefactory.lokki.android.fragments.MapViewFragment.java
private void setupAddPlacesOverlay() { // todo these should probably be initialized once... Button cancelButton = (Button) getView().findViewById(R.id.cancel_add_place_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override/*from w ww . j a v a 2 s. c o m*/ public void onClick(View v) { setAddPlacesVisible(false); } }); Button addPlaceButton = (Button) getView().findViewById(R.id.add_place_button); addPlaceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int mapWidth = fragment.getView().getWidth(); int mapHeight = fragment.getView().getHeight() - getView().findViewById(R.id.add_place_buttons).getHeight(); Location middleSideLocation; if (mapWidth > mapHeight) { middleSideLocation = MapUtils.convertToLocation( map.getProjection().fromScreenLocation(new Point(mapWidth / 2, 0)), "middleSide"); } else { middleSideLocation = MapUtils.convertToLocation( map.getProjection().fromScreenLocation(new Point(0, mapHeight / 2)), "middleSide"); } LatLng centerLatLng = map.getProjection().fromScreenLocation(getAddPlaceCircleCenter()); int radius = (int) middleSideLocation .distanceTo(MapUtils.convertToLocation(centerLatLng, "center")); DialogUtils.addPlace(getActivity(), centerLatLng, (int) (radius * radiusMultiplier)); } }); }
From source file:com.pseudosudostudios.jdd.views.Grid.java
/** * @return the Point of the parameter in the gird *//*from w ww . j a va 2 s .c om*/ private Point getPointFirstPatch(Tile clicked) { for (int row = 0; row < tiles.length; row++) for (int col = 0; col < tiles[row].length; col++) if (tiles[row][col] == clicked) return new Point(row, col); return null; }
From source file:io.github.data4all.util.Gallery.java
/** * Decodes the informations of an image from the given JSON. * /* w w w. j a v a 2s . co m*/ * @param json * @return * @throws JSONException */ private static Informations decodeInformations(JSONObject json) throws JSONException { final TransformationParamBean parameters = TransformationParamBean .fromJSON(json.getJSONArray(JSON_PARAMETER)); final DeviceOrientation oriantation = DeviceOrientation .fromJSON((JSONArray) json.getJSONArray(JSON_ORIENTATION)); final JSONArray dimension = json.getJSONArray(JSON_DIMENSION); return new Informations(parameters, oriantation, new Point(dimension.getInt(0), dimension.getInt(1))); }
From source file:com.askjeffreyliu.camera2barcode.CameraActivity.java
@Subscribe //(threadMode = ThreadMode.MAIN) public void onMessageEvent(MultiResultEvent event) { if (event != null && event.results != null && event.results.length > 0) { mGraphicOverlay.clear();//from w w w . j ava 2 s .c om handler.removeCallbacks(runnable); for (int i = 0; i < event.results.length; i++) { final Result r = event.results[i]; ArrayList<Point> pointArrayList = new ArrayList<>(); for (int j = 0; j < r.getResultPoints().length; j++) { float x, y; try { x = r.getResultPoints()[j].getX(); y = r.getResultPoints()[j].getY(); } catch (NullPointerException e) { return; } final float scaledX = x / event.width * mGraphicOverlay.getWidth(); final float scaledY = y / event.height * mGraphicOverlay.getHeight(); pointArrayList.add(new Point((int) scaledX, (int) scaledY)); } final Rect rect = Utils.createRect(pointArrayList, r.getBarcodeFormat() == BarcodeFormat.QR_CODE); mGraphicOverlay.add(new GraphicOverlay.Graphic(mGraphicOverlay) { @Override public void draw(Canvas canvas) { canvas.drawRect(rect, paint); canvas.drawText(r.getText(), rect.left, rect.bottom, textPaint); } }); CameraActivity.this.runOnUiThread(new Runnable() { @Override public void run() { getPageSetOverlay(false); } }); handler.postDelayed(runnable, 100); } } }
From source file:com.pseudosudostudios.jdd.activities.GameActivity.java
private void loadGame(Bundle saved) { Log.i("Load game", "Loading game"); if (bg == null) bg = new Grid(this); File dataFile = new File(getFilesDir(), saveDataFileName); try {/*from w ww . j av a 2 s. c om*/ BufferedReader read = new BufferedReader(new FileReader(dataFile)); String input = ""; while (read.ready()) input += read.readLine(); read.close(); JSONObject master = new JSONObject(input); JSONArray tilesFromFile = master.getJSONArray(arrayKey); Tile[][] loadedTile = new Tile[3][3]; Tile[][] solution = new Tile[3][3]; int jsonIndex = 0; for (int row = 0; row < loadedTile.length; row++) { for (int col = 0; col < loadedTile[row].length; col++) { JSONObject currTile = tilesFromFile.getJSONObject(jsonIndex); Point center = new Point(currTile.getInt(pointX), currTile.getInt(pointY)); int north = currTile.getInt(northKey); int east = currTile.getInt(eastKey); int south = currTile.getInt(southKey); int west = currTile.getInt(westKey); loadedTile[row][col] = new Tile(this, center, north, east, south, west); jsonIndex++; } } jsonIndex = 0; JSONArray solJSon = master.getJSONArray(onSaveSolution); for (int row = 0; row < solution.length; row++) { for (int col = 0; col < solution[row].length; col++) { JSONObject currTile = solJSon.getJSONObject(jsonIndex); Point center = new Point(currTile.getInt(pointX), currTile.getInt(pointY)); int north = currTile.getInt(northKey); int east = currTile.getInt(eastKey); int south = currTile.getInt(southKey); int west = currTile.getInt(westKey); solution[row][col] = new Tile(this, center, north, east, south, west); jsonIndex++; } } bg.moves = master.getInt(moveKey); bg.setTileArray(loadedTile, solution, master.getInt(moveKey), master.getLong(onSaveTime), master.getInt(jsonTileSize)); bg.setDifficulty(master.getString(levelKey)); Grid.numberOfColors = master.getInt(numColorsKey); Tile.initPaints(); Log.i("Load game", "Game Loaded"); } catch (Exception e) { Log.i("Load game", "Error loading game"); if (dataFile != null) dataFile.delete(); e.printStackTrace(); showInstructions(); } bg.invalidate(); }
From source file:cc.softwarefactory.lokki.android.fragments.MapViewFragment.java
private Point getAddPlaceCircleCenter() { int mapCenterX = fragment.getView().getWidth() / 2; int mapCenterY = (fragment.getView().getHeight() - getView().findViewById(R.id.add_place_buttons).getHeight()) / 2; return new Point(mapCenterX, mapCenterY); }
From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java
private void onImageChange() { boolean isCurrentOriginal = ((mOriginalRefineImage == null) || (mMasterImage.getUri().equals(mOriginalRefineImage))); if (mImageShowBackground != null) { mMasterImage.setTranslation(new Point(0, 0)); mMasterImage.setScaleFactor(1);/*from w w w . ja va 2 s .c om*/ mImageShowBackground.invalidate(); mImageShowBackground.setZoomPanSupported(!isCurrentOriginal); } if (mSaveButton != null) { if (isCurrentOriginal) { mSaveButton.setVisibility(View.INVISIBLE); } else { mSaveButton.setVisibility(View.VISIBLE); } } }
From source file:com.uzmap.pkg.uzmodules.uzBMap.methods.MapOpen.java
public void setScaleBar(UZModuleContext moduleContext) { boolean show = moduleContext.optBoolean("show", false); mMapView.showScaleControl(show);//from w w w. j a v a 2 s .co m mMapView.setScaleControlPosition( new Point(mJsParamsUtil.controlX(moduleContext), mJsParamsUtil.controlY(moduleContext))); }
From source file:com.example.mapsv2.ClustersAreListsActivity.java
private Point getZoneCenter(final Marker marker) { final int orientation = getResources().getConfiguration().orientation; final int w = fullScreenOverlay.getWidth(); // this is full screen width final int h = fullScreenOverlay.getHeight(); // this is full screen height final int cx, cy; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { // Left Zone: Leftmost 1/4 of screen cx = (w / 4) / 2;// ww w . j a va 2 s . co m cy = h / 2; } else { // Top Zone: Upper 1/4 of screen cx = w / 2; cy = (h / 4) / 2; } return new Point(cx, cy); }
From source file:com.uzmap.pkg.uzmodules.uzBMap.methods.MapOpen.java
public void getRegion(UZModuleContext moduleContext) { LatLng pointLeft = mBaiduMap.getProjection().fromScreenLocation(new Point(0, mMapView.getHeight())); LatLng pointRight = mBaiduMap.getProjection().fromScreenLocation(new Point(mMapView.getWidth(), 0)); new CallBackUtil().getRegionCallBack(moduleContext, pointLeft, pointRight); }