/** * Returns the Android ICS holo blue light color. * * @return */ public static int getHoloBlue() { return Color.rgb(51, 181, 229); }
/** * Converts the given hex-color-string to rgb. * * @param hex * @return */ public static int rgb(String hex) { int color = (int) Long.parseLong(hex.replace("#", ""), 16); int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = (color >> 0) & 0xFF; return Color.rgb(r, g, b); }
/** * Default constructor. */ public BaseDataSet() { mColors = new ArrayList<Integer>(); mValueColors = new ArrayList<Integer>(); // default color mColors.add(Color.rgb(140, 234, 255)); mValueColors.add(Color.BLACK); }
public LineDataSet(List<Entry> yVals, String label) { super(yVals, label); // mCircleRadius = Utils.convertDpToPixel(4f); // mLineWidth = Utils.convertDpToPixel(1f); if (mCircleColors == null) { mCircleColors = new ArrayList<Integer>(); } mCircleColors.clear(); // default colors // mColors.add(Color.rgb(192, 255, 140)); // mColors.add(Color.rgb(255, 247, 140)); mCircleColors.add(Color.rgb(140, 234, 255)); }
public RadarChartRenderer(RadarChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) { super(animator, viewPortHandler); mChart = chart; mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHighlightPaint.setStyle(Paint.Style.STROKE); mHighlightPaint.setStrokeWidth(2f); mHighlightPaint.setColor(Color.rgb(255, 187, 115)); mWebPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mWebPaint.setStyle(Paint.Style.STROKE); mHighlightCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG); }
public BarChartRenderer(BarDataProvider chart, ChartAnimator animator, ViewPortHandler viewPortHandler) { super(animator, viewPortHandler); this.mChart = chart; mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHighlightPaint.setStyle(Paint.Style.FILL); mHighlightPaint.setColor(Color.rgb(0, 0, 0)); // set alpha after color mHighlightPaint.setAlpha(120); mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mShadowPaint.setStyle(Paint.Style.FILL); mBarBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBarBorderPaint.setStyle(Paint.Style.STROKE); }
public DataRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) { super(viewPortHandler); this.mAnimator = animator; mRenderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mRenderPaint.setStyle(Style.FILL); mDrawPaint = new Paint(Paint.DITHER_FLAG); mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mValuePaint.setColor(Color.rgb(63, 63, 63)); mValuePaint.setTextAlign(Align.CENTER); mValuePaint.setTextSize(Utils.convertDpToPixel(9f)); mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mHighlightPaint.setStyle(Paint.Style.STROKE); mHighlightPaint.setStrokeWidth(2f); mHighlightPaint.setColor(Color.rgb(255, 187, 115)); }
/** * Blend {@code color1} and {@code color2} using the given ratio. * * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend, * 0.0 will return {@code color2}. */ private static int blendColors(int color1, int color2, float ratio) { final float inverseRation = 1f - ratio; float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation); float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation); float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation); return Color.rgb((int) r, (int) g, (int) b); }
public BarDataSet(List<BarEntry> yVals, String label) { super(yVals, label); mHighLightColor = Color.rgb(0, 0, 0); calcStackSize(yVals); calcEntryCountIncludingStacks(yVals); }
private LineDataSet createSet() { LineDataSet set = new LineDataSet(null, "DataSet 1"); set.setLineWidth(2.5f); set.setCircleRadius(4.5f); set.setColor(Color.rgb(240, 99, 99)); set.setCircleColor(Color.rgb(240, 99, 99)); set.setHighLightColor(Color.rgb(190, 190, 190)); set.setAxisDependency(AxisDependency.LEFT); set.setValueTextSize(10f); return set; }
@Override public void onValueChanged(int value) { color = Color.rgb(red.getValue(), green.getValue(), blue.getValue()); colorView.setBackgroundColor(color); }
/** * generates a random ChartData object with just one DataSet * * @return Bar data */ private BarData generateData(int cnt) { ArrayList<BarEntry> entries = new ArrayList<>(); for (int i = 0; i < 12; i++) { entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30)); } BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt); d.setColors(ColorTemplate.VORDIPLOM_COLORS); d.setBarShadowColor(Color.rgb(203, 203, 203)); ArrayList<IBarDataSet> sets = new ArrayList<>(); sets.add(d); BarData cd = new BarData(sets); cd.setBarWidth(0.9f); return cd; }
/** * Blend {@code color1} and {@code color2} using the given ratio. * * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend, * 0.0 will return {@code color2}. */ private static int blendColors(int color1, int color2, float ratio) { final float inverseRation = 1f - ratio; float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation); float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation); float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation); return Color.rgb((int) r, (int) g, (int) b); }
private LineData generateLineData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<>(); for (int index = 0; index < count; index++) entries.add(new Entry(index + 0.5f, getRandom(15, 5))); LineDataSet set = new LineDataSet(entries, "Line DataSet"); set.setColor(Color.rgb(240, 238, 70)); set.setLineWidth(2.5f); set.setCircleColor(Color.rgb(240, 238, 70)); set.setCircleRadius(5f); set.setFillColor(Color.rgb(240, 238, 70)); set.setMode(LineDataSet.Mode.CUBIC_BEZIER); set.setDrawValues(true); set.setValueTextSize(10f); set.setValueTextColor(Color.rgb(240, 238, 70)); set.setAxisDependency(YAxis.AxisDependency.LEFT); d.addDataSet(set); return d; }
@Override protected void init() { super.init(); mAxisLeft = new YAxis(AxisDependency.LEFT); mAxisRight = new YAxis(AxisDependency.RIGHT); mLeftAxisTransformer = new Transformer(mViewPortHandler); mRightAxisTransformer = new Transformer(mViewPortHandler); mAxisRendererLeft = new YAxisRenderer(mViewPortHandler, mAxisLeft, mLeftAxisTransformer); mAxisRendererRight = new YAxisRenderer(mViewPortHandler, mAxisRight, mRightAxisTransformer); mXAxisRenderer = new XAxisRenderer(mViewPortHandler, mXAxis, mLeftAxisTransformer); setHighlighter(new ChartHighlighter(this)); mChartTouchListener = new BarLineChartTouchListener(this, mViewPortHandler.getMatrixTouch(), 3f); mGridBackgroundPaint = new Paint(); mGridBackgroundPaint.setStyle(Style.FILL); // mGridBackgroundPaint.setColor(Color.WHITE); mGridBackgroundPaint.setColor(Color.rgb(240, 240, 240)); // light // grey mBorderPaint = new Paint(); mBorderPaint.setStyle(Style.STROKE); mBorderPaint.setColor(Color.BLACK); mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); }
private CandleData generateCandleData() { CandleData d = new CandleData(); ArrayList<CandleEntry> entries = new ArrayList<>(); for (int index = 0; index < count; index += 2) entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f)); CandleDataSet set = new CandleDataSet(entries, "Candle DataSet"); set.setDecreasingColor(Color.rgb(142, 150, 175)); set.setShadowColor(Color.DKGRAY); set.setBarSpace(0.3f); set.setValueTextSize(10f); set.setDrawValues(false); d.addDataSet(set); return d; }
@Test public void testRgb() { int color = Color.rgb(160, 160, 160); assertThat(color).isEqualTo(-6250336); }
@Test public void testRgbColorParsingRgbValuesOutOfBounds() { int outOfBounds = ColorParser.parseTtmlColor("rgb(999, 999, 999)"); int color = Color.rgb(999, 999, 999); // Behave like the framework does. assertThat(outOfBounds).isEqualTo(color); }
private void setData(int count) { ArrayList<BarEntry> entries = new ArrayList<>(); for (int i = 0; i < count; i++) { entries.add(data.get(i)); } BarDataSet set; if (chart.getData() != null && chart.getData().getDataSetCount() > 0) { set = (BarDataSet) chart.getData().getDataSetByIndex(0); set.setValues(entries); chart.getData().notifyDataChanged(); chart.notifyDataSetChanged(); } else { set = new BarDataSet(entries, "Sinus Function"); set.setColor(Color.rgb(240, 120, 124)); } BarData data = new BarData(set); data.setValueTextSize(10f); data.setValueTypeface(tfLight); data.setDrawValues(false); data.setBarWidth(0.8f); chart.setData(data); }
private LineDataSet createSet() { LineDataSet set = new LineDataSet(null, "Dynamic Data"); set.setAxisDependency(AxisDependency.LEFT); set.setColor(ColorTemplate.getHoloBlue()); set.setCircleColor(Color.WHITE); set.setLineWidth(2f); set.setCircleRadius(4f); set.setFillAlpha(65); set.setFillColor(ColorTemplate.getHoloBlue()); set.setHighLightColor(Color.rgb(244, 117, 117)); set.setValueTextColor(Color.WHITE); set.setValueTextSize(9f); set.setDrawValues(false); return set; }