List of usage examples for android.graphics Color argb
@ColorInt public static int argb(float alpha, float red, float green, float blue)
From source file:com.saulcintero.moveon.fragments.Summary4.java
private void lineChartView() { TypedValue outValue1 = new TypedValue(); TypedValue outValue2 = new TypedValue(); TypedValue outValue3 = new TypedValue(); TypedValue outValue4 = new TypedValue(); mContext.getResources().getValue(R.dimen.line_axis_title_text_size_value, outValue1, true); mContext.getResources().getValue(R.dimen.line_chart_title_text_size_value, outValue2, true); mContext.getResources().getValue(R.dimen.line_labels_text_size_value, outValue3, true); mContext.getResources().getValue(R.dimen.line_legend_text_size_value, outValue4, true); float lineAxisTitleTextSizeValue = outValue1.getFloat(); float lineCharTitleTextSizeValue = outValue2.getFloat(); float lineLabelsTextSizeValue = outValue3.getFloat(); float lineLegendTextSizeValue = outValue4.getFloat(); XYMultipleSeriesDataset mDataset = getDataset(); XYMultipleSeriesRenderer mRenderer = getRenderer(); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.TRANSPARENT); mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01)); mRenderer.setAxisTitleTextSize(lineAxisTitleTextSizeValue); mRenderer.setChartTitleTextSize(lineCharTitleTextSizeValue); mRenderer.setLabelsTextSize(lineLabelsTextSizeValue); mRenderer.setLegendTextSize(lineLegendTextSizeValue); mRenderer.setMargins(new int[] { 12, 25, 12, 12 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setPointSize(10);/*from ww w .j av a 2 s . co m*/ mRenderer.setClickEnabled(true); mChartView = ChartFactory.getLineChartView(getActivity(), mDataset, mRenderer); mChartView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint(); if (seriesSelection != null) { UIFunctionUtils.showMessage(mContext, true, (int) seriesSelection.getValue() + " " + getString(R.string.beats_per_minute)); } } }); layout.addView(mChartView); }
From source file:io.jawg.osmcontributor.ui.utils.BitmapHandler.java
/** * Get the white icon corresponding to a poiType. * * @param poiType the PoiType or null for notes. * @return The white icon./*from w w w .ja va2s .com*/ */ public Drawable getIconWhite(PoiType poiType) { Bitmap myBitmap = BitmapFactory.decodeResource(context.getResources(), poiType == null ? R.drawable.open_book : getIconDrawableId(poiType)); myBitmap = myBitmap.copy(myBitmap.getConfig(), true); int[] allpixels = new int[myBitmap.getHeight() * myBitmap.getWidth()]; myBitmap.getPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight()); for (int i = 0; i < myBitmap.getHeight() * myBitmap.getWidth(); i++) { if (allpixels[i] != 0) { int A = Color.alpha(allpixels[i]); // inverting byte for each R/G/B channel int R = 255 - Color.red(allpixels[i]); int G = 255 - Color.green(allpixels[i]); int B = 255 - Color.blue(allpixels[i]); // set newly-inverted pixel to output image allpixels[i] = Color.argb(A, R, G, B); } } myBitmap.setPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight()); return new BitmapDrawable(context.getResources(), myBitmap); }
From source file:com.ywesee.amiko.MainActivity.java
/** * Sets action bar tab click listeners/*from w ww.ja v a 2 s . co m*/ */ private void addTabNavigation() { ActionBar actionBar = getSupportActionBar(); // Disable activity title actionBar.setDisplayShowTitleEnabled(false); // Hide caret symbol ("<") upper left corner actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setHomeButtonEnabled(false); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setIcon(R.drawable.ic_launcher); // Sets color of action bar (including alpha-channel) actionBar.setBackgroundDrawable(new ColorDrawable(Color.argb(255, 180, 180, 180))); // actionBar.removeAllTabs(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setTitle(R.string.app_name); Tab tab = actionBar.newTab().setText(R.string.tab_name_1).setTabListener( new MyTabListener(this, TabFragment.class.getName(), getString(R.string.tab_name_1))); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tab_name_2).setTabListener( new MyTabListener(this, TabFragment.class.getName(), getString(R.string.tab_name_2))); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tab_name_3).setTabListener( new MyTabListener(this, TabFragment.class.getName(), getString(R.string.tab_name_3))); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tab_name_4).setTabListener( new MyTabListener(this, TabFragment.class.getName(), getString(R.string.tab_name_4))); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tab_name_5).setTabListener( new MyTabListener(this, TabFragment.class.getName(), getString(R.string.tab_name_5))); actionBar.addTab(tab); }
From source file:com.initiativaromania.hartabanilorpublici.IRUserInterface.activities.MainActivity.java
/** * Manipulates the map once available.//from w w w . jav a2 s .c om * This callback is triggered when the map is ready to be used. * This is where we can add markers or lines, add listeners or move the camera. In this case, * we just add a marker near Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Override public void onMapReady(GoogleMap googleMap) { System.out.println("Map ready"); mMap = googleMap; // Add a marker in Bucharest and move the camera LatLng bucharest = new LatLng(44.435503, 26.102513); circle = mMap.addCircle(new CircleOptions().center(bucharest).radius(CIRCLE_DEFAULT_RADIUS) .fillColor(Color.argb(CIRCLE_ALPHA, DEFAULT_COLOR_RED, DEFAULT_COLOR_GREEN, DEFAULT_COLOR_BLUE)) .strokeColor(Color.rgb(DEFAULT_COLOR_RED, DEFAULT_COLOR_GREEN, DEFAULT_COLOR_BLUE)) .strokeWidth(CIRCLE_MARGIN)); seekBarListener.setCircle(circle); currentPos = mMap.addMarker(new MarkerOptions().position(bucharest).title("Locatia ta")); mMap.moveCamera(CameraUpdateFactory.newLatLng(bucharest)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(bucharest, MAP_DEFAULT_ZOOM)); /* Initialize GPS location */ this.locationListener = IRLocationListener.getLocationManager(this); /* Init data from server */ initData(); }
From source file:com.cypress.cysmart.BLEServiceFragments.HealthTemperatureService.java
/** * Setting up the aChart Third party library * @param parent/*from w ww .j a v a 2s .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.saulcintero.moveon.fragments.Summary3.java
private void lineChartView_type2(final int type) { if (paintChartView) { txt1.setVisibility(View.GONE); TypedValue outValue1 = new TypedValue(); TypedValue outValue2 = new TypedValue(); TypedValue outValue3 = new TypedValue(); TypedValue outValue4 = new TypedValue(); mContext.getResources().getValue(R.dimen.line2_axis_title_text_size_value, outValue1, true); mContext.getResources().getValue(R.dimen.line2_chart_title_text_size_value, outValue2, true); mContext.getResources().getValue(R.dimen.line2_labels_text_size_value, outValue3, true); mContext.getResources().getValue(R.dimen.line2_legend_text_size_value, outValue4, true); float line2AxisTitleTextSizeValue = outValue1.getFloat(); float line2CharTitleTextSizeValue = outValue2.getFloat(); float line2LabelsTextSizeValue = outValue3.getFloat(); float line2LegendTextSizeValue = outValue4.getFloat(); XYMultipleSeriesDataset mDataset = null; XYMultipleSeriesRenderer mRenderer = null; switch (type) { case 1:// w w w.ja v a2 s . com mDataset = getDataset_type2(1); break; case 2: mDataset = getDataset_type2(2); break; } mRenderer = getRenderer_type2(type); mRenderer.setApplyBackgroundColor(true); mRenderer.setBackgroundColor(Color.TRANSPARENT); mRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01)); mRenderer.setAxisTitleTextSize(line2AxisTitleTextSizeValue); mRenderer.setChartTitleTextSize(line2CharTitleTextSizeValue); mRenderer.setLabelsTextSize(line2LabelsTextSizeValue); mRenderer.setLegendTextSize(line2LegendTextSizeValue); mRenderer.setMargins(new int[] { 12, 25, 12, 12 }); mRenderer.setZoomButtonsVisible(true); mRenderer.setPointSize(10); mRenderer.setClickEnabled(true); mChartView = ChartFactory.getLineChartView(getActivity(), mDataset, mRenderer); mChartView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint(); if (seriesSelection != null) { switch (type) { case 1: UIFunctionUtils.showMessage(mContext, true, (int) seriesSelection.getValue() + " " + (isMetric ? getString(R.string.long_unit1_detail_4) : getString(R.string.long_unit2_detail_4))); break; case 2: UIFunctionUtils.showMessage(mContext, true, (int) seriesSelection.getValue() + " " + (isMetric ? getString(R.string.long_unit1_detail_2) : getString(R.string.long_unit2_detail_2))); break; } } } }); chartLayout.addView(mChartView); } else { setCorrectText(); } }
From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java
private View createRoot() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); backgroundLayer = new View(getActivity()); backgroundLayer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); backgroundLayer.setBackgroundColor(Color.argb(136, 0, 0, 0)); backgroundLayer.setOnClickListener(new View.OnClickListener() { @Override//from ww w .j ava2s. c o m public void onClick(View v) { dismiss(); if (actionListener != null) { actionListener.onCancel(); } } }); sheetContainer = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; sheetContainer.setLayoutParams(params); sheetContainer.setOrientation(LinearLayout.VERTICAL); sheetContainer.setPadding(dp2px(8), dp2px(8), dp2px(8), dp2px(8)); parent.setPadding(0, 0, 0, getNavBarHeight(getActivity())); parent.addView(backgroundLayer); parent.addView(sheetContainer); return parent; }
From source file:com.jaredrummler.android.colorpicker.ColorPickerDialog.java
private void loadPresets() { int alpha = Color.alpha(color); presets = getArguments().getIntArray(ARG_PRESETS); if (presets == null) presets = MATERIAL_COLORS;/*from w w w . j a va 2 s . c o m*/ boolean isMaterialColors = presets == MATERIAL_COLORS; presets = Arrays.copyOf(presets, presets.length); // don't update the original array when modifying alpha if (alpha != 255) { // add alpha to the presets for (int i = 0; i < presets.length; i++) { int color = presets[i]; int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); presets[i] = Color.argb(alpha, red, green, blue); } } presets = unshiftIfNotExists(presets, color); if (isMaterialColors && presets.length == 19) { // Add black to have a total of 20 colors if the current color is in the material color palette presets = pushIfNotExists(presets, Color.argb(alpha, 0, 0, 0)); } }
From source file:fr.tvbarthel.apps.simpleweatherforcast.MainActivity.java
private int getColor(int currentPosition, float positionOffset) { //retrieve current color and next color relative to the current position. final int colorSize = mBackgroundColors.length; final int currentColor = mBackgroundColors[(currentPosition) % colorSize]; final int nextColor = mBackgroundColors[(currentPosition + 1) % colorSize]; //Compute the deltas relative to the current position offset. final int deltaR = (int) ((Color.red(nextColor) - Color.red(currentColor)) * positionOffset); final int deltaG = (int) ((Color.green(nextColor) - Color.green(currentColor)) * positionOffset); final int deltaB = (int) ((Color.blue(nextColor) - Color.blue(currentColor)) * positionOffset); return Color.argb(255, Color.red(currentColor) + deltaR, Color.green(currentColor) + deltaG, Color.blue(currentColor) + deltaB); }
From source file:com.cypress.cysmart.BLEServiceFragments.HeartRateService.java
/** * Setting up the aChart Third party library * @param parent/*from w ww. j a v a 2 s . c o m*/ */ 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); }