androidPlot黑色边框 [英] androidPlot black border

查看:313
本文介绍了androidPlot黑色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行code波纹管,并添加 mySimpleXYPlot.getGraphWidget()getBorderPaint()的setColor(Color.WHITE);

当我启动它在我的设备上的应用程序崩溃。

我想要做到的是摆脱黑边的整个图形周围。它是约2cm厚在位于顶部,左侧和图的底侧。请问有什么办法可以摆脱这种黑色边框?

 公共类MainActivity延伸活动{私人XYPlot mySimpleXYPlot;@覆盖
公共无效的onCreate(捆绑savedInstanceState)
{    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main); //创建y值绘制的一对夫妇的数组:
    数[]天= {1,2,3,4,5,6,7};
    号码[] =值380 {1433,1965,3200,3651,3215,3217};    //初始化我们XYPlot参考:
    mySimpleXYPlot =(XYPlot)findViewById(R.id.mySimpleXYPlot);
    。mySimpleXYPlot.getBackgroundPaint()的setColor(Color.WHITE);
    mySimpleXYPlot.setBorderStyle(XYPlot.BorderStyle.NONE,NULL,NULL);
    。mySimpleXYPlot.getGraphWidget()getBackgroundPaint()的setColor(Color.WHITE)。
    。mySimpleXYPlot.getGraphWidget()getGridBackgroundPaint()的setColor(Color.WHITE)。    //域名
    mySimpleXYPlot.getGraphWidget()setDomainLabelPaint(空)。
    mySimpleXYPlot.getGraphWidget()setDomainOriginLinePaint(空)。
    mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL,days.length);
    mySimpleXYPlot.setDomainValueFormat(新DecimalFormat的(0));
    //范围
    mySimpleXYPlot.getGraphWidget()setRangeOriginLinePaint(空)。
    mySimpleXYPlot.setRangeStep(XYStepMode.SUBDIVIDE,values​​.length);
    mySimpleXYPlot.setRangeValueFormat(新DecimalFormat的(0));
    //删除传奇
    。mySimpleXYPlot.getLayoutManager()删除(mySimpleXYPlot.getLegendWidget());
    。mySimpleXYPlot.getLayoutManager()删除(mySimpleXYPlot.getDomainLabelWidget());
    。mySimpleXYPlot.getLayoutManager()删除(mySimpleXYPlot.getRangeLabelWidget());
    。mySimpleXYPlot.getLayoutManager()删除(mySimpleXYPlot.getTitleWidget());    //开启上面的阵列到XYSeries:
    XYSeries系列1 =新SimpleXYSeries(
            Arrays.asList(天),
            Arrays.asList(值)
            系列1); //设置一系列的显示标题    //创建一个格式化用于绘制使用LineAndPointRenderer系列:
    LineAndPointFormatter series1Format =新LineAndPointFormatter(
            Color.rgb(0,200,0),//线的颜色
            Color.rgb(0,100,0),//点色
            Color.CYAN); //填充颜色 //设置我们的产品线补漆是一种略微透明的渐变:
    油漆行填充=新的油漆();
    lineFill.setAlpha(200);
    lineFill.setShader(新的LinearGradient(0,0,0,250,Color.WHITE,Color.GREEN,Shader.TileMode.MIRROR));    series1Format.setFillPaint(行填充);    //添加一个新的系列到xyplot:
    mySimpleXYPlot.addSeries(系列1,series1Format);    //默认情况下,AndroidPlot显示开发者指南铺设出你的阴谋,以帮助。
    //摆脱他们的调用disableAllMarkup():
    mySimpleXYPlot.disableAllMarkup();
}}


解决方案

如果你想摆脱所有的图形背后的颜色,你需要以下三种方法。其中每个摆脱不同部分。

  //这摆脱了灰色网格
。mySimpleXYPlot.getGraphWidget()getGridBackgroundPaint()的setColor(Color.TRANSPARENT)。//这摆脱了黑色边框(达图)周围有没有标签的黑色边框
。mysimpleXYPlot.getBackgroundPaint()的setColor(Color.TRANSPARENT);//这摆脱了黑色的图形背后
。mySimpleXYPlot.getGraphWidget()getBackgroundPaint()的setColor(Color.TRANSPARENT)。//随着AndroidPlot新版本你也设置边框油漆
。plot.getBorderPaint()的setColor(Color.TRANSPARENT);

希望这有助于。

When i execute the code bellow and add in mySimpleXYPlot.getGraphWidget().getBorderPaint().setColor(Color.WHITE);

the app crashes when i launch it on my device.

what i'm trying to accomplish is getting rid of the black border around the entire graph. it is about 2cm thick on located on the top, left and bottom sides of the chart. Is there any way i can get rid of this black border?

public class MainActivity extends Activity {

private XYPlot mySimpleXYPlot;

@Override
public void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

 // Create a couple arrays of y-values to plot:
    Number[] days =   { 1  , 2   , 3   , 4   , 5   , 6   , 7 };
    Number[] values = { 380, 1433, 1965, 3200, 3651, 3215, 3217 };

    // initialize our XYPlot reference:
    mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
    mySimpleXYPlot.getBackgroundPaint().setColor(Color.WHITE);
    mySimpleXYPlot.setBorderStyle(XYPlot.BorderStyle.NONE, null, null);
    mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);



    // Domain
    mySimpleXYPlot.getGraphWidget().setDomainLabelPaint(null);
    mySimpleXYPlot.getGraphWidget().setDomainOriginLinePaint(null);
    mySimpleXYPlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, days.length);     
    mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("0"));


    //Range
    mySimpleXYPlot.getGraphWidget().setRangeOriginLinePaint(null);
    mySimpleXYPlot.setRangeStep(XYStepMode.SUBDIVIDE, values.length);
    mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("0"));


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

    // Turn the above arrays into XYSeries':
    XYSeries series1 = new SimpleXYSeries(
            Arrays.asList(days),          
            Arrays.asList(values), 
            "Series1");                             // Set the display title of the series

    // Create a formatter to use for drawing a series using LineAndPointRenderer:
    LineAndPointFormatter series1Format = new LineAndPointFormatter(
            Color.rgb(0, 200, 0),                   // line color
            Color.rgb(0, 100, 0),                   // point color
            Color.CYAN);                            // fill color 

 // 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, Color.GREEN, Shader.TileMode.MIRROR));

    series1Format.setFillPaint(lineFill);

    // add a new series' to the xyplot:
    mySimpleXYPlot.addSeries(series1, series1Format);

    // by default, AndroidPlot displays developer guides to aid in laying out your plot.
    // To get rid of them call disableAllMarkup():
    mySimpleXYPlot.disableAllMarkup();
}

}

解决方案

If you want to get rid of all of the color behind your graph, you will need the following three methods. Each of which gets rid of different parts.

//This gets rid of the gray grid
mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.TRANSPARENT);

//This gets rid of the black border (up to the graph) there is no black border around the labels
mysimpleXYPlot.getBackgroundPaint().setColor(Color.TRANSPARENT);

//This gets rid of the black behind the graph
mySimpleXYPlot.getGraphWidget().getBackgroundPaint().setColor(Color.TRANSPARENT);

//With a new release of AndroidPlot you have to also set the border paint
plot.getBorderPaint().setColor(Color.TRANSPARENT);

Hope this helps.

这篇关于androidPlot黑色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆