wangyao5 / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

"GraphicalView" repaint problem with GestureOverlayView #126

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

there seems to be a repaint problem when the AChartEngine "GraphicalView" is 
embedded into a android.gesture.GestureOverlayView.

I have attached a screenshot showing the repaint issue. You can always 
reproduce this behaviour by modifying the XYChartBuilder in the following way.

1) Surround the default xy_chart.xml contents with the following 
GestureOverlayView (modified file attached).

<?xml version="1.0" encoding="utf-8"?>
<android.gesture.GestureOverlayView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/chart_gestures"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    android:gestureStrokeType="single"
    android:eventsInterceptionEnabled="true"
    android:orientation="vertical"
    >
<LinearLayout
...
</LinearLayout>
</android.gesture.GestureOverlayView>

2) Add the following statements at the end of XYChartBuilder.onCreate() 
(modified file attached).

protected void onCreate(Bundle savedInstanceState) {
...
  // GestureOverlayView
  android.gesture.GestureOverlayView lGestureOverlay = (android.gesture.GestureOverlayView) findViewById(R.id.chart_gestures);
  if (lGestureOverlay != null) {
    lGestureOverlay.setGestureColor(Color.TRANSPARENT);
    lGestureOverlay.setUncertainGestureColor(Color.TRANSPARENT);
    lGestureOverlay.addOnGesturePerformedListener(new OnGesturePerformedListener() {            
      @Override
      public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
      }
    });
  }    
}

3) Start the Embedded chart demo in the emulator

4) Press "New series" button

5) Hold the left mouse button in the GraphicalView area a move the mouse around

As you can see the repaint problem exist only in the GraphicalView area. There 
are no repaint problems under the TextView / EditText widgets at the top or 
under the New series button at the bottom.

Thanks and Kind Regards
Michael

Original issue reported on code.google.com by michael....@gmail.com on 29 Aug 2011 at 7:00

Attachments:

GoogleCodeExporter commented 9 years ago
I have this problem as well, when trying to overlay 
buttons\seekbars\slidingdrawer on graph.

Currently I invalided the GraphicalView after any operation on the buttons.

I would really be happy to get a better way to do so.

Original comment by niro...@gmail.com on 8 Sep 2011 at 7:01

GoogleCodeExporter commented 9 years ago
I think the problem is in the way onDraw is done on GraphicalView.
I also think it can be fix by replacing the call of 
"canvas.getClipBounds(mRect)" to "getDrawingRect(mRect)". 

Best regards,
Nir Ofry

Original comment by niro...@gmail.com on 27 Oct 2011 at 1:32

GoogleCodeExporter commented 9 years ago
With #2 the repaint problem in "normal" charts seems to be solved BUT with the 
mentioned modification the charts in my widgets are not visible anymore!

Now i changed the following that seems to solve both topics (a) repaint problem 
and (b) correct widget output:

GraphicalView.onDraw(Canvas canvas) {
  .
  .
  .
  invalidate(left,top,left+width,top+height);
}

The line "invalidate(left,top,left+width,top+height);" did the trick for me.

Thanks and Regards
Michael

Original comment by michael....@gmail.com on 27 Oct 2011 at 2:49

GoogleCodeExporter commented 9 years ago
Hard to say which solution is best here.
Try to do: renderer.setInScroll(true); and let me know if it fixes this issue.

Original comment by dandrome...@gmail.com on 5 Jan 2012 at 4:05

GoogleCodeExporter commented 9 years ago
renderer.setInScroll(true); fixes these issues.

Original comment by dandrome...@gmail.com on 10 Jan 2012 at 8:21