Example usage for android.graphics Paint setShader

List of usage examples for android.graphics Paint setShader

Introduction

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

Prototype

public Shader setShader(Shader shader) 

Source Link

Document

Set or clear the shader object.

Usage

From source file:org.wikipedia.page.shareafact.SnippetImage.java

private static void drawGradient(@NonNull Canvas canvas) {
    // draw a dark gradient over the image, so that the white text
    // will stand out better against it.
    final int gradientStartColor = 0x60000000;
    final int gradientStopColor = 0xA0000000;
    Shader shader = new LinearGradient(0, 0, 0, canvas.getHeight(), gradientStartColor, gradientStopColor,
            Shader.TileMode.CLAMP);/*from ww w  .  j a  v  a2s.c  o  m*/
    Paint paint = new Paint();
    paint.setShader(shader);
    canvas.drawRect(new Rect(0, 0, canvas.getWidth(), canvas.getHeight()), paint);
}

From source file:com.wareninja.opensource.gravatar4android.common.Utils.java

public static Bitmap getBitmapWithReflection(Bitmap originalImage) {

    //The gap we want between the reflection and the original image
    final int reflectionGap = 4;

    int width = originalImage.getWidth();
    int height = originalImage.getHeight();

    //This will not scale but will flip on the Y axis
    Matrix matrix = new Matrix();
    matrix.preScale(1, -1);//from  w  ww  . j  a  v a  2 s .  c om

    //Create a Bitmap with the flip matrix applied to it.
    //We only want the bottom half of the image
    Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, height / 2, width, height / 2, matrix,
            false);

    //Create a new bitmap with same width but taller to fit reflection
    Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height / 2), Config.ARGB_8888);

    //Create a new Canvas with the bitmap that's big enough for
    //the image plus gap plus reflection
    Canvas canvas = new Canvas(bitmapWithReflection);
    //Draw in the original image
    canvas.drawBitmap(originalImage, 0, 0, null);
    //Draw in the gap
    Paint deafaultPaint = new Paint();
    canvas.drawRect(0, height, width, height + reflectionGap, deafaultPaint);
    //Draw in the reflection
    canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);

    //Create a shader that is a linear gradient that covers the reflection
    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0, originalImage.getHeight(), 0,
            bitmapWithReflection.getHeight() + reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
    //Set the paint to use this shader (linear gradient)
    paint.setShader(shader);
    //Set the Transfer mode to be porter duff and destination in
    paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
    //Draw a rectangle using the paint with our linear gradient
    canvas.drawRect(0, height, width, bitmapWithReflection.getHeight() + reflectionGap, paint);

    return bitmapWithReflection;
}

From source file:com.bamobile.fdtks.util.Tools.java

public static Bitmap getCircularBitmapWithWhiteBorder(Bitmap bitmap, int borderWidth) {
    if (bitmap == null || bitmap.isRecycled()) {
        return null;
    }/*w  ww.jav a  2s  .c  o m*/

    final int width = bitmap.getWidth() + borderWidth;
    final int height = bitmap.getHeight() + borderWidth;

    Bitmap canvasBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Canvas canvas = new Canvas(canvasBitmap);
    float radius = width > height ? ((float) height) / 2f : ((float) width) / 2f;
    canvas.drawCircle(width / 2, height / 2, radius, paint);
    paint.setShader(null);
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.BLUE);
    paint.setStrokeWidth(borderWidth);
    canvas.drawCircle(width / 2, height / 2, radius - borderWidth / 2, paint);
    return canvasBitmap;
}

From source file:com.liferay.mobile.screens.viewsets.defaultviews.userportrait.UserPortraitView.java

protected Paint getPaint(Bitmap bitmap) {
    BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setAntiAlias(true);/*from  w  w  w. j ava  2 s. c  o  m*/
    paint.setShader(shader);
    return paint;
}

From source file:org.stockchart.core.Appearance.java

public void applyOutline(Paint p) {
    p.reset();//  w  w  w  . j  av  a 2  s.  c om
    p.setShader(null);
    p.setColor(fOutlineColor);
    p.setAntiAlias(fIsAntialias);
    p.setStrokeWidth(fOutlineWidth);
    p.setStyle(Style.STROKE);

    switch (fOutlineStyle) {
    case DASH:
        p.setPathEffect(DASH_EFFECT);
        break;
    default:
        p.setPathEffect(null);
    }
}

From source file:com.camnter.easyrecyclerviewsidebar.EasyRecyclerViewSidebar.java

private void setPaintShader(@NonNull EasyImageSection imageSection) {
    Drawable drawable;/*  w  w  w  .j a v a2 s  .  co  m*/
    if (imageSection.drawable == null && imageSection.resId >= 0) {
        drawable = ResourcesCompat.getDrawable(this.getResources(), imageSection.resId, null);
    } else {
        drawable = imageSection.drawable;
    }
    if (drawable == null)
        return;

    Bitmap bitmap = this.drawableToBitmap(drawable);
    BitmapShader sectionBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    float scale;
    scale = Math.max(this.letterSize * 1.0f / bitmap.getWidth(), this.letterSize * 1.0f / bitmap.getHeight());
    this.imageSectionMatrix.setScale(scale, scale);
    sectionBitmapShader.setLocalMatrix(this.imageSectionMatrix);
    Paint imagePaint = this.imagePaints.get(imageSection.hashCode());
    imagePaint.setShader(sectionBitmapShader);
}

From source file:project.pamela.slambench.fragments.TemperaturePlot.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.ja  v a  2  s .  co m*/

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

    plot.setBackgroundColor(Color.WHITE);
    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_degrees));
    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);

    int strokecolor = Color.rgb(67, 137, 192);
    int fillcolor = Color.rgb(213, 229, 255);

    Double temperatureNumbers[] = value.gettemperatureList();
    XYSeries series = new SimpleXYSeries(Arrays.asList(temperatureNumbers),
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, this.getResources().getString(R.string.legend_degrees));
    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);

    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:project.pamela.slambench.fragments.AccuracyPlot.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;
    }/*w  w  w.  j  a va2 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_ate));
    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);

    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 fillcolor = Color.rgb(255, 213, 226);
    int strokecolor = Color.rgb(225, 99, 70);

    Double accuracyNumbers[] = value.getATEList();
    XYSeries series = new SimpleXYSeries(Arrays.asList(accuracyNumbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
            this.getResources().getString(R.string.legend_ate));
    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);

    if (SLAMBenchApplication.getBenchmark() != null) {
        Number[] line = { 0, SLAMBenchApplication.getBenchmark().getMaxAccuracyError(),
                value.test.dataset.getFrameCount() - 1,
                SLAMBenchApplication.getBenchmark().getMaxAccuracyError() };
        XYSeries expected = new SimpleXYSeries(Arrays.asList(line),
                SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED,
                getResources().getString(R.string.legend_error_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;
}

From source file:project.pamela.slambench.fragments.FrequencyPlot.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  ww .j ava2 s  . c  o  m

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

    plot.setBackgroundColor(Color.WHITE);
    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.frequency_domain));
    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);

    for (int i = 0; i < value.getCPUCount(); i++) {

        int strokecolor = Color.rgb(i * (255 / value.getCPUCount()), 137, 192);
        int fillcolor = Color.rgb(i * (255 / value.getCPUCount()), 229, 255);

        Double frequencyNumbers[] = value.getfrequencyList(i);
        XYSeries series = new SimpleXYSeries(Arrays.asList(frequencyNumbers),
                SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,
                this.getResources().getString(R.string.frequency_legend, i));
        LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null);

        seriesFormat.setPointLabeler(new PointLabeler() {
            @Override
            public String getLabel(XYSeries series, int index) {
                return "o";
            }
        });

        Paint lineFill = new Paint();
        lineFill.setAlpha(150);
        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.setFillPaint(lineFill);

        plot.addSeries(series, seriesFormat);
    }

    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: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;
    }// ww w  .  j a  v  a 2s  . c  om

    // 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;
}