Example usage for android.graphics Paint setColor

List of usage examples for android.graphics Paint setColor

Introduction

In this page you can find the example usage for android.graphics Paint setColor.

Prototype

public void setColor(@ColorInt int color) 

Source Link

Document

Set the paint's color.

Usage

From source file:com.microsoft.mimickeralarm.appcore.AlarmListItemTouchHelperCallback.java

@Override
public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX,
        float dY, int actionState, boolean isCurrentlyActive) {

    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {

        View itemView = viewHolder.itemView;
        Resources resources = AlarmApplication.getAppContext().getResources();
        Bitmap icon = BitmapFactory.decodeResource(resources, R.drawable.delete_trash_can);
        int iconPadding = resources.getDimensionPixelOffset(R.dimen.alarm_list_delete_icon_padding);
        int maxDrawWidth = (iconPadding * 2) + icon.getWidth();

        Paint paint = new Paint();
        paint.setColor(ContextCompat.getColor(AlarmApplication.getAppContext(), R.color.red));

        int x = Math.round(Math.abs(dX));

        // Reset the dismiss flag if the view resets to its default position
        if (x == 0) {
            mCanDismiss = false;/*from w  w w  . ja  v a2  s  .  c  o m*/
        }

        // If we have travelled beyond the icon area via direct user interaction
        // we will dismiss when we get a swipe callback.  We do this to try to avoid
        // unwanted swipe dismissal
        if ((x > maxDrawWidth) && isCurrentlyActive) {
            mCanDismiss = true;
        }

        int drawWidth = Math.min(x, maxDrawWidth);
        // Cap the height of the drawable area to the selectable area - this improves the visual
        // for the first taller item in the alarm list
        int itemTop = itemView.getBottom() - resources.getDimensionPixelSize(R.dimen.alarm_list_item_height);

        if (dX > 0) {
            // Handle swiping to the right
            // Draw red background in area that we vacate up to maxDrawWidth
            canvas.drawRect((float) itemView.getLeft(), (float) itemTop, drawWidth,
                    (float) itemView.getBottom(), paint);

            // Only draw icon when we've past the padding threshold
            if (x > iconPadding) {

                Rect destRect = new Rect();
                destRect.left = itemView.getLeft() + iconPadding;
                destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2;
                int maxRight = destRect.left + icon.getWidth();
                destRect.right = Math.min(x, maxRight);
                destRect.bottom = destRect.top + icon.getHeight();

                // Only draw the appropriate parts of the bitmap as it is revealed
                Rect srcRect = null;
                if (x < maxRight) {
                    srcRect = new Rect();
                    srcRect.top = 0;
                    srcRect.left = 0;
                    srcRect.bottom = icon.getHeight();
                    srcRect.right = x - iconPadding;
                }

                canvas.drawBitmap(icon, srcRect, destRect, paint);
            }

        } else {
            // Handle swiping to the left
            // Draw red background in area that we vacate  up to maxDrawWidth
            canvas.drawRect((float) itemView.getRight() - drawWidth, (float) itemTop,
                    (float) itemView.getRight(), (float) itemView.getBottom(), paint);

            // Only draw icon when we've past the padding threshold
            if (x > iconPadding) {
                int fromLeftX = itemView.getRight() - x;
                Rect destRect = new Rect();
                destRect.right = itemView.getRight() - iconPadding;
                destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2;
                int maxFromLeft = destRect.right - icon.getWidth();
                destRect.left = Math.max(fromLeftX, maxFromLeft);
                destRect.bottom = destRect.top + icon.getHeight();

                // Only draw the appropriate parts of the bitmap as it is revealed
                Rect srcRect = null;
                if (fromLeftX > maxFromLeft) {
                    srcRect = new Rect();
                    srcRect.top = 0;
                    srcRect.right = icon.getWidth();
                    srcRect.bottom = icon.getHeight();
                    srcRect.left = srcRect.right - (x - iconPadding);
                }

                canvas.drawBitmap(icon, srcRect, destRect, paint);
            }
        }

        // Fade out the item as we swipe it
        float alpha = 1.0f - Math.abs(dX) / (float) itemView.getWidth();
        itemView.setAlpha(alpha);
        itemView.setTranslationX(dX);
    } else {
        super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
    }
}

From source file:com.jungle.toolbaractivity.layout.HorizontalSwipeBackLayout.java

@Override
protected void dispatchDraw(Canvas canvas) {
    if (!mSwipeBackEnable) {
        super.dispatchDraw(canvas);
        return;//from   w ww.  j a va2 s .com
    }

    final int width = getMeasuredWidth();
    final int height = getMeasuredHeight();

    if (mBkgDrawable != null) {
        mBkgDrawable.setBounds((int) (mTranslationX + 0.5f), 0, width, height);
        mBkgDrawable.draw(canvas);
    } else {
        Paint paint = new Paint();
        paint.setColor(Color.WHITE);
        canvas.drawRect(mTranslationX, 0, width, height, paint);
    }

    if (mTranslationX > 0) {
        canvas.save();
        canvas.translate(mTranslationX - mShadowWidth, 0);
        mEdgeShadowDrawable.setBounds(0, 0, mShadowWidth, height);
        mEdgeShadowDrawable.draw(canvas);
        canvas.restore();
    }

    super.dispatchDraw(canvas);
}

From source file:android.support.v7.graphics.drawable.VectorDrawableCompat.java

@Override
public void draw(Canvas canvas) {
    Paint paint = new Paint();
    for (Pair<Path, Integer> pair : mPaths) {
        Path path = pair.first;/*from   w  w w  .  j  a v  a 2  s  .  c  o  m*/
        int color = pair.second;
        paint.setColor(color);
        canvas.drawPath(path, paint);
    }
}

From source file:com.jwetherell.quick_response_code.DecoderActivity.java

protected void drawResultPoints(Bitmap barcode, Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
        Canvas canvas = new Canvas(barcode);
        Paint paint = new Paint();
        paint.setColor(getResources().getColor(R.color.result_image_border));
        paint.setStrokeWidth(3.0f);/* ww  w . jav a 2 s  .c  o m*/
        paint.setStyle(Paint.Style.STROKE);
        Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
        canvas.drawRect(border, paint);

        paint.setColor(getResources().getColor(R.color.result_points));
        if (points.length == 2) {
            paint.setStrokeWidth(4.0f);
            drawLine(canvas, paint, points[0], points[1]);
        } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A
                || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
            // Hacky special case -- draw two lines, for the barcode and
            // metadata
            drawLine(canvas, paint, points[0], points[1]);
            drawLine(canvas, paint, points[2], points[3]);
        } else {
            paint.setStrokeWidth(10.0f);
            for (ResultPoint point : points) {
                canvas.drawPoint(point.getX(), point.getY(), paint);
            }
        }
    }
}

From source file:project.pamela.slambench.fragments.PowerPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }/*from w  w w  . ja  v  a  2 s .c o  m*/

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_power));
    plot.setBackgroundColor(Color.WHITE);
    plot.getBorderPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    //Remove legend
    //plot.getLayoutManager().remove(plot.getLegendWidget());
    //plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    //plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    int strokecolor = Color.rgb(91, 255, 159);
    int fillcolor = Color.rgb(91, 255, 184);

    Double powerNumbers[] = value.getPowerList();
    for (int i = 0; i < value.test.dataset.getFrameCount(); i++) {
        powerNumbers[i] = powerNumbers[i] / -1000;
    }
    XYSeries series = new SimpleXYSeries(Arrays.asList(powerNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
            this.getResources().getString(R.string.legend_power));
    LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null);

    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    DisplayMetrics metrics = new DisplayMetrics();
    super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    lineFill.setShader(
            new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR));
    seriesFormat.setPointLabeler(new PointLabeler() {
        @Override
        public String getLabel(XYSeries series, int index) {
            return "o";
        }
    });
    seriesFormat.setFillPaint(lineFill);
    plot.addSeries(series, seriesFormat);

    // same as above
    LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null);
    //change the line width
    Paint paint = lineFormat.getLinePaint();
    paint.setStrokeWidth(5);
    lineFormat.setLinePaint(paint);

    Number[] line = { 0, 3, value.test.dataset.getFrameCount() - 1, 3 };
    XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,
            getResources().getString(R.string.legend_power_limit));
    plot.addSeries(expected, lineFormat);

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(Math.min(0, minXY.y), maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:com.example.grayapps.contextaware.BarGraphFragment.java

/**
 *
 * Chart 1/*ww w.j  av  a  2  s . c  o m*/
 *
 */

public void produceOne(ChartView chart, Runnable action) {
    BarChartView barChart = (BarChartView) chart;

    barChart.setOnEntryClickListener(new OnEntryClickListener() {
        @Override
        public void onClick(int setIndex, int entryIndex, Rect rect) {
            System.out.println("OnClick " + rect.left);
        }
    });

    // Tooltip tooltip = new Tooltip(getActivity(), R.layout.barchart_one_tooltip);
    //if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    //   tooltip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1));
    //   tooltip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0));
    // }
    // barChart.setTooltips(tooltip);
    //mValuesOne[0][1] = Float.valueOf(String.valueOf(10 * Math.random()));
    //mValuesOne[0][2] = Float.valueOf(String.valueOf(10 * Math.random()));
    BarSet barSet = new BarSet(mLabelsOne, mValuesOne[0]);
    barSet.setColor(Color.parseColor(mStressColor));
    barChart.addData(barSet);
    barChart.setBarSpacing(Tools.fromDpToPx(35));

    barSet.getEntry(0).setColor(Color.parseColor(getResources().getString(R.color.colorNeutral)));
    barSet.getEntry(1).setColor(Color.parseColor(getResources().getString(R.color.colorStress)));
    barSet.getEntry(2).setColor(Color.parseColor(getResources().getString(R.color.colorNoise)));
    barSet.getEntry(3).setColor(Color.parseColor(getResources().getString(R.color.colorAnxious)));

    Paint gridColor = new Paint();
    gridColor.setColor(Color.parseColor(getResources().getString(R.color.textAccent)));
    barChart.setBorderSpacing(5).setAxisBorderValues(0, 100, 20).setYAxis(true)
            .setXLabels(XController.LabelPosition.OUTSIDE).setYLabels(YController.LabelPosition.OUTSIDE)
            .setGrid(ChartView.GridType.HORIZONTAL, 10, 1, gridColor)
            .setLabelsColor(Color.parseColor(getResources().getString(R.color.textPrimary))).setFontSize(24)
            .setAxisColor(Color.parseColor(getResources().getString(R.color.textAccent)));

    int[] order = { 3, 1, 0, 2 };//, 0, 4};
    final Runnable auxAction = action;
    Runnable chartOneAction = new Runnable() {
        @Override
        public void run() {
            //showTooltipOne();
            auxAction.run();
        }
    };
    barChart.show(new Animation().setOverlap(.5f, order).setEndAction(chartOneAction))
    //.show()
    ;
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {

    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);/*from  ww  w .  j  a v  a  2 s . c o  m*/
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}

From source file:org.iota.wallet.ui.fragment.NodeInfoFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ((AppCompatActivity) getActivity()).setSupportActionBar(nodeInfoToolbar);
    chart.setNoDataText(getString(R.string.messages_no_chart_data));
    chart.setNoDataTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
    chart.setEntryLabelColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
    Paint p = chart.getPaint(Chart.PAINT_INFO);
    p.setColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
    initializeChart();//from   ww  w  .  j  a v  a 2 s. c o m
}

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentWeight.java

private void chart() {
    mLineChart = (LineChartView) v.findViewById(R.id.linechart);
    mLineChart.reset();/* w w w. j  a v  a  2  s .  c o m*/
    dataSet = new LineSet();
    simpleArray = new float[weightLogAdapter.getCount()];
    dates = new String[weightLogAdapter.getCount()];
    for (int i = 0; i < weightLogAdapter.getCount(); i++) {
        WeightLog weightLogWeight = weightLogAdapter.getItem(i);
        simpleArray[i] = (float) weightLogWeight.getCurrentWeight();
        dates[i] = String.valueOf(DateFormat.format("MMM dd", weightLogWeight.getDate()));
    }
    dataSet.addPoints(dates, simpleArray);
    mLineGridPaint = new Paint();
    mLineGridPaint.setColor(this.getResources().getColor(R.color.accent));
    mLineGridPaint.setStyle(Paint.Style.FILL);
    mLineGridPaint.setAntiAlias(true);
    /**
     * Controlling the data set and setting it to the chart.
     */
    dataSet.setDots(true).setDotsColor(this.getResources().getColor(R.color.primary))
            .setDotsRadius(Tools.fromDpToPx(3)).setDotsStrokeThickness(Tools.fromDpToPx(1))
            .setDotsStrokeColor(this.getResources().getColor(R.color.primary))
            .setLineColor(this.getResources().getColor(R.color.primary_dark))
            .setLineThickness(Tools.fromDpToPx(1)).beginAt(0).endAt(weightLogAdapter.getCount());
    mLineChart.addData(dataSet);

    mLineChart.setBorderSpacing(Tools.fromDpToPx(0)).setGrid(LineChartView.GridType.HORIZONTAL, mLineGridPaint)
            .setXAxis(false).setXLabels(XController.LabelPosition.OUTSIDE).setYAxis(false)
            .setYLabels(YController.LabelPosition.OUTSIDE).setAxisBorderValues(min, max, 5)
            .setLabelColor(this.getResources().getColor(R.color.text_color))
            .setLabelsFormat(new DecimalFormat("##' lbs'")).show();

    Paint paint = new Paint();
    paint.setStrokeWidth((float) Equations.dpToPx(getActivity(), 2));
    paint.setColor(getActivity().getResources().getColor(R.color.green));
    mLineChart.setThresholdLine(goalWeightLine, paint);
}

From source file:project.pamela.slambench.fragments.DurationPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }/*from   www  .  j  a v  a 2  s.c o  m*/

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_duration));
    plot.setBackgroundColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    //Remove legend
    //plot.getLayoutManager().remove(plot.getLegendWidget());
    //plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    //plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    // Prepare Data (fill stack and add lines)

    KFusion.FieldIndex[] stackIndex = new KFusion.FieldIndex[] { (KFusion.FieldIndex.AQUISITION_DURATION),
            (KFusion.FieldIndex.PREPROCESSING_DURATION), (KFusion.FieldIndex.TRACKING_DURATION),
            (KFusion.FieldIndex.INTEGRATION_DURATION), (KFusion.FieldIndex.RAYCASTING_DURATION),
            (KFusion.FieldIndex.RENDERING_DURATION), (KFusion.FieldIndex.TOTAL_DURATION) };

    Double[][] stackNumbers = new Double[][] { value.getField(stackIndex[0]), value.getField(stackIndex[1]),
            value.getField(stackIndex[2]), value.getField(stackIndex[3]), value.getField(stackIndex[4]),
            value.getField(stackIndex[5]) };

    Double[][] stack = new Double[stackNumbers.length + 1][stackNumbers[0].length];

    int[] stackColor = new int[] { Color.rgb(240, 0, 0), Color.rgb(255, 155, 0), Color.rgb(255, 255, 0),
            Color.rgb(155, 255, 98), Color.rgb(0, 212, 255), Color.rgb(0, 155, 255), Color.rgb(0, 0, 127) };

    stack[0] = stackNumbers[0];

    for (int i = 0; i < stackNumbers[0].length; ++i) {
        for (int j = 1; j < stackNumbers.length; ++j) {
            stack[j][i] = stack[j - 1][i] + stackNumbers[j][i];
        }
    }
    stack[stackNumbers.length] = value.getField(KFusion.FieldIndex.TOTAL_DURATION);

    for (int i = stack.length - 1; i >= 0; --i) {
        // Turn the above arrays into XYSeries':
        XYSeries series = new SimpleXYSeries(Arrays.asList(stack[i]), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
                stackIndex[i].getName());

        LineAndPointFormatter seriesFormat = new LineAndPointFormatter(Color.rgb(73, 73, 73), null,
                stackColor[i], null);
        Paint paint = seriesFormat.getLinePaint();
        paint.setStrokeWidth(1.0f);
        seriesFormat.setLinePaint(paint);

        // setup our line fill paint to be a slightly transparent gradient:
        //Paint lineFill = new Paint();
        // lineFill.setAlpha(200);
        //lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, stackColor[i], Shader.TileMode.MIRROR));
        //seriesFormat.setFillPaint(lineFill);

        plot.addSeries(series, seriesFormat);

    }

    // same as above
    LineAndPointFormatter lineFormat = new LineAndPointFormatter(Color.BLACK, null, null, null);
    //change the line width
    Paint paint = lineFormat.getLinePaint();
    paint.setStrokeWidth(5);
    lineFormat.setLinePaint(paint);

    Number[] line = { 0, 0.033, stack[0].length - 1, 0.033 };
    XYSeries expected = new SimpleXYSeries(Arrays.asList(line), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,
            getResources().getString(R.string.legend_realtime_limit));
    plot.addSeries(expected, lineFormat);

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(0, maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}