【问题标题】:Have a GraphWidget fill the entire View in AndroidPlot让 GraphWidget 填充 AndroidPlot 中的整个视图
【发布时间】:2013-10-30 23:24:24
【问题描述】:

有没有办法让 AndroidPlot XYPlot 的图形填充整个视图而不进行填充?

我特意说的是我在图片中标记为红色的左侧空间:

我的目标是将图形覆盖在图像上并使其与父视图边框齐平。我已经删除了我的 XYPlot 子类中的所有标签,通过将它们的 Paint 设置为 null,它们将占用的空间仍然存在。

这是我设置情节的方式:

public void setup() {
    this.setBackgroundPaint(null);
    setPlotMarginLeft(0);

    setRangeBoundaries(-2, 2, BoundaryMode.FIXED);
    setDomainBoundaries(0, HISTORY_SIZE, BoundaryMode.FIXED);


    XYGraphWidget g = getGraphWidget();

    g.setDomainLabelPaint(null);
    g.setRangeLabelPaint(null);
    g.setDomainOriginLabelPaint(null);
    g.setRangeOriginLabelPaint(null);
    g.setGridBackgroundPaint(null);
    g.setGridPaddingLeft(0);
    g.setGridPaddingRight(0);
    g.setMarginLeft(0);
    g.setBackgroundPaint(null);
    g.position(-0.5f, XLayoutStyle.RELATIVE_TO_RIGHT, 
            -0.5f, YLayoutStyle.RELATIVE_TO_BOTTOM,
            AnchorPosition.CENTER);
    g.setSize(new SizeMetrics(
            0, SizeLayoutType.FILL,
            0, SizeLayoutType.FILL));

    LayoutManager l = getLayoutManager();
    l.remove(this.getDomainLabelWidget());
    l.remove(this.getRangeLabelWidget());
    l.remove(getLegendWidget());

    mSeries = new SimpleXYSeries("Azimuth");
    mSeries.useImplicitXVals();
    addSeries(mSeries, new LineAndPointFormatter(Color.BLACK, null, null, null));

}

【问题讨论】:

    标签: androidplot


    【解决方案1】:

    知道了,这是我用来设置没有任何边距、填充或标签的 Plot 的代码:

        XYGraphWidget g = getGraphWidget();
    
        g.setDomainLabelPaint(null);
        g.setRangeLabelPaint(null);
        g.setDomainOriginLabelPaint(null);
        g.setRangeOriginLabelPaint(null);
        g.setGridBackgroundPaint(null);
        g.setGridPaddingLeft(0);
        g.setGridPaddingRight(0);
        g.setMarginLeft(0);
        g.setBackgroundPaint(null);
        g.position(-0.5f, XLayoutStyle.RELATIVE_TO_RIGHT, 
                -0.5f, YLayoutStyle.RELATIVE_TO_BOTTOM,
                AnchorPosition.CENTER);
        g.setSize(new SizeMetrics(
                0, SizeLayoutType.FILL,
                0, SizeLayoutType.FILL));
    
        LayoutManager l = getLayoutManager();
        l.remove(this.getDomainLabelWidget());
        l.remove(this.getRangeLabelWidget());
        l.remove(getLegendWidget());
    
        g.setRangeLabelWidth(0);
        g.setDomainLabelWidth(0);
        g.setPadding(0, 0, 0, 0);
        g.setMargins(0, 0, 0, 0);
        g.setGridPadding(0, 0, 0, 0);
        setPlotMargins(0, 0, 0, 0);
        setPlotPadding(0, 0, 0, 0);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-10
      • 2012-08-25
      • 1970-01-01
      • 2012-10-08
      • 1970-01-01
      • 1970-01-01
      • 2020-08-16
      • 1970-01-01
      相关资源
      最近更新 更多