2016-12-26 1 views
1

나는 그래프 그리기 응용 프로그램이 있으며 그래프는 다음과 같습니다. 무엇 내가 알 필요가AndroidPlot에서 플롯 된 점의 격자를 확인하십시오.

enter image description here

은 가능 이런 같은 형식 (ROW_INDEX, column_index) 또는 뭔가 말을 ... 점 플롯 된 아 격자를 아는 것입니다. 사실 그것이 가능한 시나리오인지 여부를 모르겠습니다. 그래서 이것을 할 방법이 없다면 저에게 알려주세요. 내 그래프 구성 방법은 다음과 같습니다. 사전에

private void configureGraph() { 
/** 
    * ecgPlot corresponds to XYPlot 
    */ 
    XYGraphWidget graph = ecgPlot.getGraph(); 

    /** 
    * Paint to denote line color 
    */ 
    Paint paint = new Paint(); 
    paint.setColor(Color.WHITE); 
    paint.setStrokeWidth(3.0f); 
    /** 
    * Setting graph x and y boundary values 
    */ 
    ecgPlot.setRangeBoundaries(-40, 40, BoundaryMode.FIXED); 
    ecgPlot.setDomainBoundaries(0, 1500, BoundaryMode.FIXED); 

    ecgPlot.setPlotPadding(-10, 0, 0, 0); 

    /** 
    * Removes default bkg - ie; black 
    */ 
    ecgPlot.setBackgroundPaint(null); 
    graph.setBackgroundPaint(null); 
    graph.setGridBackgroundPaint(null); 
    /** 
    * Adjusting grid line width 
    */ 
    graph.getDomainGridLinePaint().setStrokeWidth(4.0f); 
    graph.getRangeGridLinePaint().setStrokeWidth(4.0f); 
    graph.getDomainSubGridLinePaint().setStrokeWidth(1.0f); 
    graph.getRangeSubGridLinePaint().setStrokeWidth(1.0f); 

    /** 
    * Removes border 
    */ 
    ecgPlot.setBorderPaint(null); 
    /** 
    * Setting grid color 
    */ 
    graph.getDomainGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid)); 
    graph.getRangeGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid)); 
    graph.getRangeSubGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid)); 
    graph.getDomainSubGridLinePaint().setColor(getResources().getColor(R.color.colorECGGrid)); 
    /** 
    * Setting number of sub grid lines per grid 
    */ 
    graph.setLinesPerDomainLabel(5); 
    graph.setLinesPerRangeLabel(5); 

    ecgPlot.setRangeStep(StepMode.INCREMENT_BY_VAL, 1); 
    ecgPlot.setDomainStepValue(75); 
    ecgPlot.setLinesPerDomainLabel(5); 
    ecgPlot.setDomainLabel(null); 
    ecgPlot.setRangeLabel(null); 

    Paint paintTest = new Paint(); 
    paintTest.setColor(Color.TRANSPARENT); 
    paintTest.setStrokeWidth(3.0f); 

    ecgLinePointFormatter.setLegendIconEnabled(false); 
    // PointLabelFormatter pointLabelFormatter = new PointLabelFormatter(); 
    // pointLabelFormatter.setTextPaint(paint); 

}                            

감사

+0

위의 그리드의 5x5 섹션을 의미하는 subgrid로 확인 하시겠습니까? – Nick

+0

예. 정확히 @Nick –

+0

그리드 간격과 특정 도메인/범위 경계 설정을 정의하는 코드 부분을 보여줄 수 있습니까? (당신이 당신의 요구가 그 변수들에 달려있는 것을 이루는 방법) – Nick

답변

0

불행하게도 나는 실제로이 코드는 작동하지만, 여기 당신이 아 격자 좌표로 실제 XY 값으로 변환하는 방법에 대한 일반적인 생각이 있는지 여부를 테스트 할 수있는 장소에 아니에요 : 그런 다음

double subX(Number x) { 
    // calculate the value each subgrid represents: 
    double stepVal = (plot.getBounds().getWidth().doubleValue()/75) * 5; 

    // find the value of x relative to the left edge of the screen 
    double xOff = x.doubleValue() - plot.getBounds().getMinX().doubleValue();  
    return xOff/stepVal; 
} 

double subY(Number y) { 
    double stepVal = plot.getBounds().getHeight().doubleValue()/5; 

    double yOff = y.doubleValue() - plot.getBounds().getMinY().doubleValue(); 
    return yOff/stepVal; 
} 

, 당신이 아 격자 좌표로 변환하려는 번호 x와 번호 Y 주어진 :

Number x = subX(realX); 
Number y = subY(realY); 

실제 값 대신 픽셀 값이 필요한 경우 XYPlot.seriesToScreenX/Y(Number)XYPlot.screenToSeriesX/Y(Number) 메서드를 사용하여 앞뒤로 변환 할 수 있습니다.

+0

일단 내가 그것을 확인하면, 나는 당신에게 돌아갈 것이다 @ 닉 –