List of usage examples for android.graphics Point Point
public Point()
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static Point getDisplaySize(Context ctx) { Display display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); size.x = display.getWidth();/*from www . j a v a2s.c o m*/ size.y = display.getHeight(); return size; }
From source file:com.example.SmartBoard.DrawingView.java
public void onTouchCircleMode(MotionEvent event) { int eventaction = event.getAction(); int X = (int) event.getX(); int Y = (int) event.getY(); switch (eventaction) { case MotionEvent.ACTION_DOWN: // touch down so check if the finger is on // a ball finished = false;/*from ww w .j av a2s . c o m*/ if (points[0] == null) { //initialize rectangle. points[0] = new Point(); points[0].x = X; points[0].y = Y; points[1] = new Point(); points[1].x = X; points[1].y = Y + 30; points[2] = new Point(); points[2].x = X + 30; points[2].y = Y + 30; points[3] = new Point(); points[3].x = X + 30; points[3].y = Y; balID = 2; groupId = 1; // declare each ball with the ColorBall class for (Point pt : points) { colorballs.add(new ColorBall(getContext(), R.drawable.dot_drag_handle, pt)); } } invalidate(); break; case MotionEvent.ACTION_MOVE: // touch drag with the ball if (balID > -1) { // move the balls the same as the finger colorballs.get(balID).setX(X); colorballs.get(balID).setY(Y); if (groupId == 1) { colorballs.get(1).setX(colorballs.get(0).getX()); colorballs.get(1).setY(colorballs.get(2).getY()); colorballs.get(3).setX(colorballs.get(2).getX()); colorballs.get(3).setY(colorballs.get(0).getY()); } else { colorballs.get(0).setX(colorballs.get(1).getX()); colorballs.get(0).setY(colorballs.get(3).getY()); colorballs.get(2).setX(colorballs.get(3).getX()); colorballs.get(2).setY(colorballs.get(1).getY()); } invalidate(); } break; case MotionEvent.ACTION_UP: // touch drop - just do things here after dropping finished = true; break; } // redraw the canvas invalidate(); return; }
From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private void lockOrientation() { Display display = POIMapActivity.this.getWindowManager().getDefaultDisplay(); int rotation = display.getRotation(); int height;/* w w w . ja v a 2s .co m*/ int width; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) { height = display.getHeight(); width = display.getWidth(); } else { Point size = new Point(); display.getSize(size); height = size.y; width = size.x; } switch (rotation) { case Surface.ROTATION_90: if (width > height) POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else POIMapActivity.this.setRequestedOrientation(9/* reversePortait */); break; case Surface.ROTATION_180: if (height > width) POIMapActivity.this.setRequestedOrientation(9/* reversePortait */); else POIMapActivity.this.setRequestedOrientation(8/* reverseLandscape */); break; case Surface.ROTATION_270: if (width > height) POIMapActivity.this.setRequestedOrientation(8/* reverseLandscape */); else POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; default: if (height > width) POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); else POIMapActivity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } }
From source file:com.homeworkreminder.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); registerReceiver(dateReceiver, intentFilter); setContentView(R.layout.home);/* w w w.j a v a 2s. c o m*/ inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); context = this; prefs = PreferenceManager.getDefaultSharedPreferences(context); theme = new ThemeManager(this) { @Override public void setColor(ColorScheme scheme) { // TODO Auto-generated method stub mDrawerList.setBackgroundColor(scheme.getUltraDarkColor()); mDrawerList.setSelector(new ColorDrawable(scheme.getNormalColor())); actionBar.setBackgroundDrawable(new ColorDrawable(scheme.getSuperDarkColor())); actionBarExtension.setBackgroundColor(scheme.getSuperDarkColor()); actionBarExtension.getChildAt(0).setBackgroundColor(scheme.getSuperDarkColor()); setColorComboForActionBar(scheme.getColorName()); if (Build.VERSION.SDK_INT >= 11) { VersionHelper.refreshActionBarMenu(activity); } } }; main_content = (RelativeLayout) findViewById(R.id.main_content_screen); actionBarExtension = (RelativeLayout) findViewById(R.id.actionbar_extension); main_container = (RelativeLayout) findViewById(R.id.main_container); notask_notify = (RelativeLayout) findViewById(R.id.notask_notify); notask = (TextView) findViewById(R.id.tv_notask); actionBarExtension.setVisibility(View.VISIBLE); caldroidFragment = new CaldroidFragment(); if (savedInstanceState != null) { caldroidFragment.restoreStatesFromKey(savedInstanceState, "CALDROID_SAVED_STATE"); } else { Bundle args = new Bundle(); Calendar cal = Calendar.getInstance(); args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1); args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR)); args.putBoolean(CaldroidFragment.ENABLE_SWIPE, true); args.putBoolean(CaldroidFragment.SIX_WEEKS_IN_CALENDAR, true); caldroidFragment.setArguments(args); } actionBar = getActionBar(); getActionBar().setHomeButtonEnabled(true); getActionBar().setIcon(R.drawable.ic_drawer); prevScreen = 0; firstStart = true; drawerAdapter = new DrawerListAdapter(this); DrawerItems = getResources().getStringArray(R.array.home_drawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.home_drawer); mDrawerList = (ListView) findViewById(R.id.nav_drawer); mDrawerList.setAdapter(drawerAdapter); SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(this); int startupscreen = Integer.parseInt(getPrefs.getString("Startup_screen", "0")); UpcomingDate = Integer.parseInt(getPrefs.getString("Upcoming_date", "7")); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.home, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); getActionBar().setTitle(mTitle); invalidateOptionsMenu(); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); Database = new CoreDatabase(this); swipelistview = (SwipeListView) findViewById(R.id.example_swipe_lv_list); swipelistview.setVisibility(View.GONE); subjectlistview = (ExpandableListView) findViewById(R.id.subject_listview); // add_subject_btn = (ImageButton) findViewById(R.id.add_subject_btn); subjectlistview.setVisibility(View.GONE); // add_subject_btn.setVisibility(View.GONE); notask.setText("Loading"); TaskHolder = Database.getAllTask("Pending"); Collections.sort(TaskHolder, new Comparator<Task>() { public int compare(Task o1, Task o2) { return o1.getDue().compareTo(o2.getDue()); } }); generateTaskMap(TaskHolder); // get subjects subjectArray = Database.querySubjectList(); subjectArray.add(0, DEFAULT_SUBJECT); generateSubjectMap(); Completed = Database.getAllTask("Completed"); adapter = new ItemAdapter(this, R.layout.custom_row, TaskHolder, swipelistview, prefs.getString("Color_scheme", "Default")); subject_adapter = new SubjectListAdapter(this, subjectArray, SubjectMap, subjectlistview); swipelistview.setSwipeListViewListener(new BaseSwipeListViewListener() { @Override public void onOpened(int position, boolean toRight) { } @Override public void onClosed(int position, boolean fromRight) { } @Override public void onListChanged() { } @Override public void onMove(int position, float x) { } @Override public void onStartOpen(int position, int action, boolean right) { } @Override public void onStartClose(int position, boolean right) { } @Override public void onClickFrontView(int position) { if (swipelistview.isOpen(position)) { swipelistview.openAnimate(position); } } @Override public void onClickBackView(int position) { } @Override public void onDismiss(int[] reverseSortedPositions) { } }); // These are the swipe listview settings. you can change these // setting as your requirement Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = getResources().getDisplayMetrics().density; dpWidth = outMetrics.widthPixels / density; swipelistview.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT); // modes swipelistview.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL); swipelistview.setOffsetLeft(Util.convertDpToPixel(dpWidth - 180 + 10, this)); // left side offset swipelistview.setOffsetRight(0); // right side offset swipelistview.setAnimationTime(300); // animation time swipelistview.setSwipeOpenOnLongPress(false); swipelistview.setAdapter(adapter); main_container.setBackgroundColor(context.getResources().getColor(R.color.pure_white)); if (startupscreen == 0) { mDrawerList.performItemClick(mDrawerList.getChildAt(0), 0, mDrawerList.getItemIdAtPosition(0)); } else if (startupscreen == 1) { mDrawerList.performItemClick(mDrawerList.getChildAt(1), 1, mDrawerList.getItemIdAtPosition(1)); } else if (startupscreen == 2) { mDrawerList.performItemClick(mDrawerList.getChildAt(2), 2, mDrawerList.getItemIdAtPosition(2)); } else if (startupscreen == 3) { mDrawerList.performItemClick(mDrawerList.getChildAt(3), 3, mDrawerList.getItemIdAtPosition(3)); } else if (startupscreen == 4) { mDrawerList.performItemClick(mDrawerList.getChildAt(4), 4, mDrawerList.getItemIdAtPosition(4)); } else { mDrawerList.performItemClick(mDrawerList.getChildAt(0), 0, mDrawerList.getItemIdAtPosition(0)); } firstStart = false; alarmHandler = new AlarmHandler(this); scheduleClient = new ScheduleClient(this.getApplicationContext()); scheduleClient.doBindService(); this.initActionBarExtension(); theme.loadColorScheme(PreferenceManager.getDefaultSharedPreferences(this)); }
From source file:com.miz.functions.MizLib.java
public static String getImageUrlSize(Context c) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);//from w w w . j a v a 2s .c om final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; if (columnWidth > 300) return "w500"; else if (columnWidth > 185) return "w300"; } return "w185"; }
From source file:com.miz.functions.MizLib.java
public static String getBackdropUrlSize(Context c) { WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);// w w w. j a v a 2 s .c o m final int width = Math.max(size.x, size.y); if (width > 1280 && isTablet(c)) // We only want to download full size images on tablets, as these are the only devices where you can see the difference return "original"; else if (width > 780) return "w1280"; return "w780"; }
From source file:com.dahl.brendan.wordsearch.view.WordSearchActivity.java
/** * creates a grid of textViews from layout files based on the gridSize * and sets the new textViews to use the controller as their listener * //from w w w . j a v a 2 s.co m * @param gridSize square size of the new grid to make * @param controller the onkeyListener used for the grid's textViews, also holds the gridView an array of the new textView's in the grid */ public void setupViewGrid() { control.setLetter(null); int gridSize = control.getGridSize(); TextViewGridController controller = control.getGridManager(); ViewGroup gridTable = (ViewGroup) this.findViewById(R.id.gridTable); if (gridTable.getChildCount() != gridSize) { if (gridTable.getChildCount() == 0) { gridTable.setKeepScreenOn(true); gridTable.setOnTouchListener(controller); } controller.clearPointDemension(); gridTable.removeAllViews(); Point point = new Point(); controller.setGridView(new TextView[gridSize][]); TextView[][] gridView = controller.getGridView(); for (point.y = 0; point.y < gridSize; point.y++) { this.getLayoutInflater().inflate(R.layout.grid_row, gridTable, true); ViewGroup row = (ViewGroup) gridTable.getChildAt(point.y); TextView[] rowText = new TextView[gridSize]; for (point.x = 0; point.x < gridSize; point.x++) { this.getLayoutInflater().inflate(R.layout.grid_text_view, row, true); TextView view = (TextView) row.getChildAt(point.x); view.setId(ConversionUtil.convertPointToID(point, control.getGridSize())); view.setOnKeyListener(controller); rowText[point.x] = view; } gridView[point.y] = rowText; } gridTable.requestLayout(); } }
From source file:com.miz.functions.MizLib.java
public static String getBackdropThumbUrlSize(Context c) { WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);/*from w w w. j a va2s . c o m*/ final int width = Math.min(size.x, size.y); if (width >= 780) return "w780"; if (width >= 400) return "w500"; return "w300"; }
From source file:ws.crandell.newspaperpuzzles.wordsearch.view.WordSearchActivity.java
/** * creates a grid of textViews from layout files based on the gridSize * and sets the new textViews to use the controller as their listener * /*from w w w . j a v a 2 s.c o m*/ * @param gridSize square size of the new grid to make * @param controller the onkeyListener used for the grid's textViews, also holds the gridView an array of the new textView's in the grid */ public void setupViewGrid() { control.setLetter(null); int gridSize = control.getGridSize(); TextViewGridController controller = control.getGridManager(); ViewGroup gridTable = (ViewGroup) this.findViewById(R.id.gridTable); if (gridTable.getChildCount() != gridSize) { if (gridTable.getChildCount() == 0) { gridTable.setKeepScreenOn(true); gridTable.setOnTouchListener(controller); } controller.clearPointDemension(); gridTable.removeAllViews(); Point point = new Point(); controller.setGridView(new TextView[gridSize][]); TextView[][] gridView = controller.getGridView(); for (point.y = 0; point.y < gridSize; point.y++) { this.getLayoutInflater().inflate(R.layout.ws_grid_row, gridTable, true); ViewGroup row = (ViewGroup) gridTable.getChildAt(point.y); TextView[] rowText = new TextView[gridSize]; for (point.x = 0; point.x < gridSize; point.x++) { this.getLayoutInflater().inflate(R.layout.ws_grid_text_view, row, true); TextView view = (TextView) row.getChildAt(point.x); view.setId(ConversionUtil.convertPointToID(point, control.getGridSize())); view.setOnKeyListener(controller); rowText[point.x] = view; } gridView[point.y] = rowText; } gridTable.requestLayout(); } }
From source file:com.miz.functions.MizLib.java
public static String getActorUrlSize(Context c) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size);/*from w w w. java2s . co m*/ final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; if (columnWidth > 400) return "h632"; if (columnWidth >= 300) return "w300"; } return "w185"; }