Вопрос

Is there a way to have the graph of an AndroidPlot XYPlot fill the entire view without padding?

I am specifically talking about the space on the left side that I marked red in the image:

enter image description here

My goal is to overlay the graph over an image and have it flush with the parent views borders. I haved removed all the labels in my subclass of XYPlot, by setting their Paint to null, the space they would take up remains though.

Here is how I set up the plot:

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));

}
Это было полезно?

Решение

Got it, here is the code I am using to set up a Plot without any margins, padding or labels:

    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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top