2013-12-19 1 views
1

나는 안드로이드 음모를 사용하여 막 대형 차트를 만들었습니다.하나의 도메인 레이블의 색상 변경 - 안드로이드 플롯

바를 클릭 한 후 일치하는 도메인 레이블이 색상을 변경하고 싶습니다.

모든 도메인 레이블 색상을 설정하는 방법을 알고 있습니다.

plot.getGraphWidget().getDomainLabelPaint().setColor(Color.WHITE); 

을하지만 난 레이블의 한의 색상을 변경하려면 : 사용.

내 도메인 단계는 다음과 같습니다

plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1); 

내가이와 도메인의 형식을 변경 :

plot.setDomainValueFormat(new Format() { 

     @Override 
     public StringBuffer format(final Object obj, 
       final StringBuffer toAppendTo, final FieldPosition pos) { 
      final int index = ((Number) obj).intValue(); 
      return new StringBuffer("").append((char) (index + 'A')); 
     } 

     @Override 
     public Object parseObject(final String string, 
       final ParsePosition position) { 
      return null; 
     } 

    }); 

나는 (내가 실패) 두 가지 아이디어를 가지고 :

1) 수 위의 메서드에서 Format 클래스를 확장하여 도메인 레이블 문자열의 색상을 변경합니까? 또는 2) 기존 도메인 레이블 위에 다른 도메인 레이블 집합을 그릴 수 있습니까? (다른 색상으로 표시 될 것입니다)

다른 방법이 있습니까?

답변

0

다음 Androidplot 빌드에는 새로운 클래스와이 작업을 수행하는 데 사용할 수있는 몇 가지 새로운 메소드가 포함됩니다. 현재이 새로운 기능이 포함 된 here's a development build입니다. 새로운 클래스는 com.androidplot.util.Mapping이며 관심있는 새로운 메소드가 com.androidplot.xy.XYGraphWidget에 추가됩니다. 그들은 :

plot.getGraphWidget().setRangeLabelPaintMap(new Mapping<Paint, Number>() { 

    private Paint customPaint; 

    { 
     // configure Paint instances either programmatically 
     // (as shown here) or use Configurator to initialize via XML. 
     customPaint = new Paint(); 
     customPaint.setColor(Color.RED); 
    } 

    @Override 
    public Paint get(Number number) { 
     if(number.doubleValue() > 1) { 
      return customPaint; 
     } 
     return null; 
    } 
}); 
: 여기
public void setDomainLabelPaintMap(Mapping<Paint, Number> domainLabelPaintMap) 
public void setRangeLabelPaintMap(Mapping<Paint, Number> rangeLabelPaintMap) 

들이 사용할 수있는 방법에 대한 간단한 예제