List of usage examples for android.util DisplayMetrics DENSITY_XXHIGH
int DENSITY_XXHIGH
To view the source code for android.util DisplayMetrics DENSITY_XXHIGH.
Click Source Link
From source file:ly.count.android.api.DeviceInfoTests.java
public void testGetDensity() { Context mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_LOW); assertEquals("LDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_MEDIUM); assertEquals("MDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_TV); assertEquals("TVDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_HIGH); assertEquals("HDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XHIGH); assertEquals("XHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXHIGH); assertEquals("XXHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_XXXHIGH); assertEquals("XXXHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(DisplayMetrics.DENSITY_400); assertEquals("XMHDPI", DeviceInfo.getDensity(mockContext)); mockContext = mockContextForTestingDensity(0); assertEquals("", DeviceInfo.getDensity(mockContext)); }
From source file:ly.count.android.sdk.DeviceInfo.java
/** * Maps the current display density to a string constant. * @param context context to use to retrieve the current display metrics * @return a string constant representing the current display density, or the * empty string if the density is unknown *///w w w. j av a 2 s. c o m static String getDensity(final Context context) { String densityStr = ""; final int density = context.getResources().getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: densityStr = "LDPI"; break; case DisplayMetrics.DENSITY_MEDIUM: densityStr = "MDPI"; break; case DisplayMetrics.DENSITY_TV: densityStr = "TVDPI"; break; case DisplayMetrics.DENSITY_HIGH: densityStr = "HDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_260: // densityStr = "XHDPI"; // break; case DisplayMetrics.DENSITY_280: densityStr = "XHDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_300: // densityStr = "XHDPI"; // break; case DisplayMetrics.DENSITY_XHIGH: densityStr = "XHDPI"; break; //todo uncomment in android sdk 25 //case DisplayMetrics.DENSITY_340: // densityStr = "XXHDPI"; // break; case DisplayMetrics.DENSITY_360: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_400: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_420: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_XXHIGH: densityStr = "XXHDPI"; break; case DisplayMetrics.DENSITY_560: densityStr = "XXXHDPI"; break; case DisplayMetrics.DENSITY_XXXHIGH: densityStr = "XXXHDPI"; break; default: densityStr = "other"; break; } return densityStr; }
From source file:com.lendingtree.view.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(mTitleRes);/*w w w. j ava 2 s . co m*/ // set the Behind View setBehindContentView(R.layout.menu_frame); if (savedInstanceState == null) { FragmentTransaction t = this.getSupportFragmentManager().beginTransaction(); mFrag = new SlidingMenuFragment(); t.replace(R.id.menu_frame, mFrag); t.commit(); } else { mFrag = (Fragment) this.getSupportFragmentManager().findFragmentById(R.id.menu_frame); } // Ramesh Gundala for Menu Icon showing ActionBar ab = getSupportActionBar(); ab.setHomeButtonEnabled(true); // ab.setDisplayHomeAsUpEnabled(true); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setFadeDegree(Constants.ZERO_POINT_THREE_FIVE); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: break; case DisplayMetrics.DENSITY_MEDIUM: sm.setTouchmodeMarginThreshold(Constants.SIXTY); break; case DisplayMetrics.DENSITY_HIGH: sm.setTouchmodeMarginThreshold(Constants.SIXTY); break; case DisplayMetrics.DENSITY_XHIGH: sm.setTouchmodeMarginThreshold(Constants.EIGHTY); break; case DisplayMetrics.DENSITY_XXHIGH: sm.setTouchmodeMarginThreshold(Constants.HUNDRED); break; default: sm.setTouchmodeMarginThreshold(Constants.SIXTY); } onStartCount = 1; if (savedInstanceState == null) // 1st time { if (sliding) { this.overridePendingTransition(0, 0); } else { this.overridePendingTransition(R.anim.anim_slide_in_left, R.anim.anim_slide_out_left); } } else // already created so reverse animation { onStartCount = 2; } // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // getSupportActionBar().setDisplayShowHomeEnabled(false); }
From source file:com.dm.material.dashboard.candybar.helpers.DrawableHelper.java
@Nullable public static Bitmap getHighQualityIcon(@NonNull Context context, String packageName) { try {//from ww w . ja v a 2 s.co m PackageManager packageManager = context.getPackageManager(); ApplicationInfo info = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Resources resources = packageManager.getResourcesForApplication(packageName); int density = DisplayMetrics.DENSITY_XXHIGH; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { density = DisplayMetrics.DENSITY_XXXHIGH; } Drawable drawable = ResourcesCompat.getDrawableForDensity(resources, info.icon, density, null); if (drawable != null) return ((BitmapDrawable) drawable).getBitmap(); } catch (Exception | OutOfMemoryError e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }
From source file:com.landenlabs.all_devtool.ScreenFragment.java
void updateView() { m_displayMetrics = Utils.getDisplayMetrics(m_context); m_layout = Ui.viewById(m_rootView, R.id.screen_layout); m_screenDevice = Ui.viewById(m_rootView, R.id.screen_device); TextView screenSizeText = Ui.viewById(m_rootView, R.id.screen_size); TextView screenDensityText = Ui.viewById(m_rootView, R.id.screen_density); m_screenDevice.setText(Build.MODEL); int widthPx = m_displayMetrics.widthPixels; int heightPx = m_displayMetrics.heightPixels; String sizeStr = String.format(Locale.getDefault(), "%.0f dp x %.0f dp\n%d px x %d px\n%.1f in x %.1f in", Utils.pxToDp(widthPx), Utils.pxToDp(heightPx), widthPx, heightPx, (float) widthPx / m_displayMetrics.densityDpi, (float) heightPx / m_displayMetrics.densityDpi); screenSizeText.setText(sizeStr);/* ww w. j a v a2s . co m*/ String densityStr = "Low"; if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_MEDIUM) densityStr = "Medium"; else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) densityStr = "High"; else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_XHIGH) densityStr = "x-High"; else if (m_displayMetrics.densityDpi <= DisplayMetrics.DENSITY_XXHIGH) densityStr = "xx-High"; else if (m_displayMetrics.densityDpi > DisplayMetrics.DENSITY_XXHIGH) densityStr = "xxx-High"; screenDensityText.setText(String.format("Density %s(%d) px/dp=%.2f", densityStr, m_displayMetrics.densityDpi, m_displayMetrics.density)); m_horzWindowArrow = Ui.viewById(m_rootView, R.id.horz_arrow); m_vertPanelArrow = Ui.viewById(m_rootView, R.id.vert_panel_arrow); m_horzWindowText = Ui.viewById(m_rootView, R.id.horz_arrow_text); m_vertPanelText = Ui.viewById(m_rootView, R.id.vert_panel_text); TextView themeTv = Ui.viewById(m_rootView, R.id.theme); // themeTv.setRotation(-90); String themeName = GlobalInfo.s_globalInfo.themeName; if (!themeName.equals("Theme.Holo")) themeName = themeName + "\nBest with Theme.Halo"; themeTv.setText(themeName); /* * Dynamically get theme - always returns 'AppTheme' which is set in style try { PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(GlobalInfo.s_globalInfo.pkgName, 0); int themeResId = packageInfo.applicationInfo.theme; String themeName = getResources().getResourceEntryName(themeResId); themeTv.setText(themeName); } catch (Exception ex) { themeTv.setVisibility(View.GONE); } */ Message msgObj = m_handler.obtainMessage(MSG_GET_UI_SIZE); m_handler.sendMessageDelayed(msgObj, 1000); final TextView touchPos = Ui.viewById(m_rootView, R.id.touch_pos); m_drawPoints = Ui.viewById(m_rootView, R.id.drawPoints); m_drawPoints.setOnTouchInfo(new DrawView.TouchInfo() { public void onTouchInfo(MotionEvent event) { touchPos.setText(String.format("%.0f,%.0f", event.getX(), event.getY())); } }); }
From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java
private static String getDensityString(DisplayMetrics displayMetrics) { switch (displayMetrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: return "ldpi"; case DisplayMetrics.DENSITY_MEDIUM: return "mdpi"; case DisplayMetrics.DENSITY_HIGH: return "hdpi"; case DisplayMetrics.DENSITY_XHIGH: return "xhdpi"; case DisplayMetrics.DENSITY_XXHIGH: return "xxhdpi"; case DisplayMetrics.DENSITY_XXXHIGH: return "xxxhdpi"; case DisplayMetrics.DENSITY_TV: return "tvdpi"; default:/* w w w .j ava 2 s. c o m*/ return "unknown"; } }
From source file:jahirfiquitiva.iconshowcase.tasks.LoadAppsToRequest.java
@SuppressWarnings("deprecation") public Drawable getAppIcon(Resources resources, int iconId) { Drawable d;//ww w .j a va 2s.c o m try { int iconDpi; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { iconDpi = DisplayMetrics.DENSITY_XXXHIGH; } else { iconDpi = DisplayMetrics.DENSITY_XXHIGH; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { d = resources.getDrawableForDensity(iconId, iconDpi, null); } else { d = resources.getDrawableForDensity(iconId, iconDpi); } } catch (Resources.NotFoundException e) { try { d = ContextCompat.getDrawable(context.get(), R.drawable.ic_na_launcher); } catch (Resources.NotFoundException e1) { d = null; } } return (d != null) ? d : getAppDefaultActivityIcon(); }
From source file:uni.oulu.mentor.TeacherVisionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //DO NOT USE THIS SERVICE YET, DOES NOT WORK //Intent intent = new Intent(this, TeacherVisionService.class); //startService(intent); /*Idea from http://stackoverflow.com/questions/2902640/android-get-the-screen-resolution-pixels-as-integer-values */ @SuppressWarnings("deprecation") int screenWidthPix = getWindowManager().getDefaultDisplay().getWidth(); @SuppressWarnings("deprecation") int screenHeightPix = getWindowManager().getDefaultDisplay().getHeight(); /*Idea from http://stackoverflow.com/questions/5015094/determine-device-screen-category-small-normal-large-xlarge-using-code*/ if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) screenType = 3;/* w w w .ja va 2s . c o m*/ else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) screenType = 4; else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) screenType = 1; else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) screenType = 2; //screen density is investigated here DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int density = metrics.densityDpi; if (density == DisplayMetrics.DENSITY_HIGH) { //400 dpi is 600px if (screenType == 1) translationX = 240; //240 / 1.5 = 160 else if (screenType == 2) translationX = 315; //315 / 1.5 = 210 in dpi, screen 800 pix wide screen, needs about 1024/400 = 800/x => 312,5, 2.56 else if (screenType == 3) translationX = 540; //540 / 1.5 = 360 in dpi else if (screenType == 4) translationX = 600; //600 / 1.5 = 400 in dpi } else if (density == DisplayMetrics.DENSITY_MEDIUM) { //400 dpi is 400px if (screenType == 1) translationX = 160; //160 / 1 = 160 in dpi else if (screenType == 2) translationX = 210; //210 / 1 = 210 in dpi else if (screenType == 3) translationX = 360; //360 / 1 = 360 in dpi else if (screenType == 4) translationX = 400; //400 / 1 = 400 in dpi } else if (density == DisplayMetrics.DENSITY_LOW) { //400 dpi is 300px if (screenType == 1) translationX = 120; //120 / 0.75 = 160 in dpi else if (screenType == 2) translationX = 158; //158 / 0.75 = 210 in dpi else if (screenType == 3) translationX = 270; //270 / 0.75 = 360 in dpi else if (screenType == 4) translationX = 300; //300 / 0.75 = 400 in dpi } else if (density == DisplayMetrics.DENSITY_XHIGH || density == DisplayMetrics.DENSITY_XXHIGH) { //400 dpi is 800px if (screenType == 1) translationX = 320; //320 / 2 = 160 in dpi else if (screenType == 2) translationX = 420; // 420 / 2 = 210 in dpi else if (screenType == 3) translationX = 720; // 720 / 2 = 360 in dpi else if (screenType == 4) translationX = 800; // 800 / 2 = 400 in dpi } else { //not supported } int offsetX = ((int) screenWidthPix / 20); int offsetY = ((int) screenHeightPix / 10); maxPosOpenX = screenWidthPix; //boundary for minimum amount of width on x-axis, where the touch is seen as panel open touch minPosOpenX = screenWidthPix - offsetX; //boundary for maximum amount of width on x-axis, where the touch is seen as panel close touch maxPosCloseX = screenWidthPix - translationX + offsetX; //boundary for minimum amount of width on x-axis, where the touch is seen as panel close touch minPosCloseX = screenWidthPix - translationX - offsetX; //boundary for maximum amount of height on y-axis, where the touch is seen as panel open or close touch maxPosY = (screenHeightPix / 2) + offsetY; //boundary for minimum amount of height on y-axis, where the touch is seen as panel open or close touch minPosY = (screenHeightPix / 2) - offsetY; //instantiation of lists onlineStudentsList = new ArrayList<Student>(); feedbacksList = new ArrayList<Feedback>(); questionsList = new ArrayList<Question>(); answersList = new ArrayList<Answer>(); ownQuestionsList = new ArrayList<Question>(); //data stored for this user is fetched here, from the previous activity, and stored into the teacher instance Intent intent2 = getIntent(); teacher = (Teacher) intent2.getParcelableExtra("teacherObj"); ipStr = getResources().getString(R.string.IP); usersUrl = "http://" + ipStr + "/mentor/users"; coursesUrl = "http://" + ipStr + "/mentor/courses"; //default preferences are fetched, and listener is set to listen for preference changes PreferenceManager.setDefaultValues(this, R.xml.preferences, false); sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sp.registerOnSharedPreferenceChangeListener(this); //SharedPreferences.Editor editor = sp.edit(); //editor.putString("flaretimePref", "5"); //editor.clear(); //editor.commit(); // In case of notifications are added later /*String ns = Context.NOTIFICATION_SERVICE; mNotificationManager = (NotificationManager) getSystemService(ns); icon = R.drawable.mlogo2;*/ //AndAR preview renderer = new CustomRenderer();//optional, may be set to null super.setNonARRenderer(renderer);//or might be omitted try { //register an object for each marker type artoolkit = super.getArtoolkit(); oneObject = new CustomObject("onePatt", "onePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter, customColor twoObject = new CustomObject("twoPatt", "twoPatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter threeObject = new CustomObject("threePatt", "threePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter artoolkit.registerARObject(oneObject); artoolkit.registerARObject(twoObject); artoolkit.registerARObject(threeObject); } catch (AndARException ex) { Log.e("AndARException ", ex.getMessage()); } LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View vv = inflater.inflate(R.layout.activity_teacher_vision, null); //screen width and height in pixels screenWidth = (float) this.getApplicationContext().getResources().getDisplayMetrics().widthPixels; screenHeight = (float) this.getApplicationContext().getResources().getDisplayMetrics().heightPixels; inflater.inflate(R.layout.fragment_teacher_vision, null); //UI elements are added on top of AndAR by calling this addContentView-method instead of setContentView super.addContentView(vv, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))); //create a layout for settings button. add it over video frames LinearLayout lil = new LinearLayout(this); Button settingsButton = new Button(this); settingsButton.setText("Settings"); settingsButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); settingsButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment()) .addToBackStack("settings").commit(); } }); lil.addView(settingsButton); super.addContentView(lil, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT))); //starts the AndAR startPreview(); //mDetector is instantiated here for detecting gestures mDetector = new GestureDetectorCompat(this, new SwipeGestureListener()); //view pager instantiation, also mAdapter instantiated and set as adapter for view pager mPager = (ViewPager) findViewById(R.id.pager); mAdapter = new TabAdapter(getFragmentManager(), mPager); mPager.setAdapter(mAdapter); //begin to poll online users pollUsersCancelled = false; pollUsersTask = new PollUsersTask(this); pollUsersTask.execute(); //begin to poll feedbacks pollFeedbacksCancelled = false; pollFeedbacksTask = new PollFeedbacksTask(this); pollFeedbacksTask.execute(); //begin to poll questions pollQuestionsCancelled = false; pollQuestionsTask = new PollQuestionsTask(this); pollQuestionsTask.execute(); //begin to poll answers pollAnswersCancelled = false; pollAnswersTask = new PollAnswersTask(this); pollAnswersTask.execute(); //initialize tab buttons button = (Button) findViewById(R.id.goto_first); //first one is not enabled at the beginning, because the user is in first tab at first button.setEnabled(false); button2 = (Button) findViewById(R.id.goto_second); button3 = (Button) findViewById(R.id.goto_last); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mPager.setCurrentItem(0); button.setEnabled(false); button2.setEnabled(true); button3.setEnabled(true); } }); button2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mPager.setCurrentItem(1); button.setEnabled(true); button2.setEnabled(false); button3.setEnabled(true); } }); button3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mPager.setCurrentItem(2); button.setEnabled(true); button2.setEnabled(true); button3.setEnabled(false); } }); }
From source file:com.cypress.cysmart.BLEServiceFragments.HealthTemperatureService.java
/** * Setting up the aChart Third party library * @param parent/*from w w w. jav a2 s.c o m*/ */ private void setupChart(View parent) { /** * Setting graph titles */ String graphTitle = getResources().getString(R.string.health_temperature_graph); String graphXAxis = getResources().getString(R.string.health_temperature_time); String graphYAxis = getResources().getString(R.string.health_temperature_temperature); // Creating an XYSeries for temperature mTempEratureDataSeries = new XYSeries(graphTitle); // Creating a dataset to hold each series XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset(); // Adding temperature Series to the dataset mDataset.addSeries(mTempEratureDataSeries); // Creating XYSeriesRenderer to customize XYSeriesRenderer mRenderer = new XYSeriesRenderer(); mRenderer.setColor(getResources().getColor(R.color.main_bg_color)); mRenderer.setPointStyle(PointStyle.CIRCLE); mRenderer.setFillPoints(true); mRenderer.setLineWidth(5); int deviceDPi = getResources().getDisplayMetrics().densityDpi; switch (getResources().getDisplayMetrics().densityDpi) { case DisplayMetrics.DENSITY_XHIGH: mMultiRenderer.setMargins(new int[] { 40, 90, 25, 10 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XHDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_XHDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_XHDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_XHDPI); break; case DisplayMetrics.DENSITY_HIGH: mMultiRenderer.setMargins(new int[] { 30, 50, 25, 10 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_HDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_HDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_HDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_HDPI); break; case DisplayMetrics.DENSITY_XXHIGH: mMultiRenderer.setMargins(new int[] { 50, 100, 35, 20 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_XXHDPI); break; default: if (deviceDPi > DisplayMetrics.DENSITY_XXHIGH && deviceDPi < DisplayMetrics.DENSITY_XXXHIGH) { mMultiRenderer.setMargins(new int[] { 50, 100, 35, 20 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_XXHDPI); } else { mMultiRenderer.setMargins(new int[] { 30, 50, 25, 10 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_LDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_LDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_LDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_LDPI); } break; } mMultiRenderer.setXTitle(graphXAxis); mMultiRenderer.setLabelsColor(Color.BLACK); mMultiRenderer.setYTitle(graphYAxis); mMultiRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00)); mMultiRenderer.setPanEnabled(true, true); mMultiRenderer.setYLabelsColor(0, Color.BLACK); mMultiRenderer.setXLabelsColor(Color.BLACK); mMultiRenderer.setApplyBackgroundColor(true); mMultiRenderer.setBackgroundColor(Color.WHITE); mMultiRenderer.setGridColor(Color.BLACK); mMultiRenderer.setShowGrid(true); mMultiRenderer.setShowLegend(false); // Adding mRenderer to multipleRenderer mMultiRenderer.addSeriesRenderer(mRenderer); // Getting a reference to LinearLayout of the MainActivity Layout mGraphLayoutParent = (LinearLayout) parent.findViewById(R.id.chart_container); mChart = ChartFactory.getLineChartView(getActivity(), mDataset, mMultiRenderer); // Adding the Line Chart to the LinearLayout mGraphLayoutParent.addView(mChart); }
From source file:com.cypress.cysmart.BLEServiceFragments.HeartRateService.java
/** * Setting up the aChart Third party library * @param parent// w w w . jav a2 s.c om */ private void setupChart(View parent) { /** * Setting graph titles */ String graphTitle = getResources().getString(R.string.hrm_graph_label); String graphXAxis = getResources().getString(R.string.health_temperature_time); String graphYAxis = getResources().getString(R.string.hrm_graph_label); // Creating an XYSeries for temperature mDataSeries = new XYSeries(graphTitle); // Creating a dataset to hold each series XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset(); // Adding temperature Series to the dataset mDataset.addSeries(mDataSeries); // Creating XYSeriesRenderer to customize XYSeriesRenderer mRenderer = new XYSeriesRenderer(); mRenderer.setColor(getResources().getColor(R.color.main_bg_color)); mRenderer.setPointStyle(PointStyle.CIRCLE); mRenderer.setFillPoints(true); mRenderer.setLineWidth(3); // Creating a XYMultipleSeriesRenderer to customize the whole chart XYMultipleSeriesRenderer mMultiRenderer = new XYMultipleSeriesRenderer(); int deviceDPi = getResources().getDisplayMetrics().densityDpi; switch (deviceDPi) { case DisplayMetrics.DENSITY_XHIGH: mMultiRenderer.setMargins(new int[] { 40, 90, 25, 10 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XHDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_XHDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_XHDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_XHDPI); break; case DisplayMetrics.DENSITY_HIGH: mMultiRenderer.setMargins(new int[] { 30, 50, 25, 10 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_HDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_HDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_HDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_HDPI); break; case DisplayMetrics.DENSITY_XXHIGH: mMultiRenderer.setMargins(new int[] { 50, 100, 35, 20 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_XXHDPI); break; default: if (deviceDPi > DisplayMetrics.DENSITY_XXHIGH && deviceDPi < DisplayMetrics.DENSITY_XXXHIGH) { mMultiRenderer.setMargins(new int[] { 50, 100, 35, 20 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_XXHDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_XXHDPI); } else { mMultiRenderer.setMargins(new int[] { 30, 50, 25, 10 }); mMultiRenderer.setAxisTitleTextSize(Constants.TEXT_SIZE_LDPI); mMultiRenderer.setChartTitleTextSize(Constants.TEXT_SIZE_LDPI); mMultiRenderer.setLabelsTextSize(Constants.TEXT_SIZE_LDPI); mMultiRenderer.setLegendTextSize(Constants.TEXT_SIZE_LDPI); } break; } mMultiRenderer.setXTitle(graphXAxis); mMultiRenderer.setLabelsColor(Color.BLACK); mMultiRenderer.setYTitle(graphYAxis); mMultiRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00)); mMultiRenderer.setPanEnabled(true, true); mMultiRenderer.setYLabelsColor(0, Color.BLACK); mMultiRenderer.setXLabelsColor(Color.BLACK); mMultiRenderer.setApplyBackgroundColor(true); mMultiRenderer.setBackgroundColor(Color.WHITE); mMultiRenderer.setGridColor(Color.BLACK); mMultiRenderer.setShowGrid(true); mMultiRenderer.setShowLegend(false); // Adding mRenderer to multipleRenderer mMultiRenderer.addSeriesRenderer(mRenderer); // Getting a reference to LinearLayout of the MainActivity Layout mGraphLayoutParent = (LinearLayout) parent.findViewById(R.id.chart_container); mChart = ChartFactory.getLineChartView(getActivity(), mDataset, mMultiRenderer); // Adding the Line Chart to the LinearLayout mGraphLayoutParent.addView(mChart); }