双刻度XY绘图示例

时间:2014-06-26 10:51:50

标签: androidplot

我试图缩放&滚动Android绘图提供的DualScaleXYPlotExampleActivity.java。所以我添加了必要的缩放和放大代码。滚动到相同的示例代码。但是在尝试缩放时,我观察到的只有1个图形正在缩放,图形区域显示2个图形,但是单个图形正在缩放。任何人都可以帮我解决这个问题,如何缩放图表。

2 个答案:

答案 0 :(得分:0)

双比例示例使用一点点黑客来获得效果。我的意思是最尊重,因为它是一个非常聪明的黑客。基本上第二个图叠加在第一个图的顶部。要确保的主要内容是缩放/滚动代码对plot1的任何操作都是对plot2进行的。如果在确定您仍有问题的情况下,您需要使用缩放/滚动例程的代码更新您的问题。

答案 1 :(得分:0)

Thanks Nick, am able to zoom the Dual Scale example code, actually I foundout the problem i.e.

@Override
    public boolean onTouch(View arg0, MotionEvent event) {
         switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN: // Start gesture
                firstFinger = new PointF(event.getX(), event.getY());
       --------------------
       --------------------
Whenever "onTouch" is getting called, View-ID was not correct check below

com.example.plotexample.DualXYPlot{43b52138 V.ED.... ........ 0,0-1080,1701 #7f080002 app:id/myXYPlot_R}

Solution:-

Implementing the Touch Event Listener as shown below i.e.

dual_scale_xy_plot_example.xml:-

    <RelativeLayout 
               android:id="@+id/sectionGraph" 
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_weight="1"
               android:layout_marginTop="0px"
               android:layout_marginBottom="0px"
               android:layout_marginLeft="0px"
               android:layout_marginRight="0px">

                    <com.androidplot.xy.XYPlot
                        android:id="@+id/mySimpleXYPlot_L"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        androidPlot.title="A Simple XY Plot"
                        androidPlot.graphWidget.gridLinePaint.color="#000000"/>
                    <com.androidplot.xy.XYPlot
                        android:id="@+id/mySimpleXYPlot_R"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        androidPlot.title="A Simple XY Plot"
                        androidPlot.graphWidget.gridLinePaint.color="#000000"/>

        </RelativeLayout>

DualScaleXYPlotExampleActivity.java:-

private RelativeLayout mRelativeLayout;
--------------
--------------

    @Override
        public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setContentView(R.layout.dual_scale_xy_plot_example);

            mRelativeLayout = (RelativeLayout)findViewById(R.id.sectionGraph);

            mRelativeLayout.setOnTouchListener(
                    new RelativeLayout.OnTouchListener() {
                        public boolean onTouch(View v, MotionEvent motion) {
                            System.out.println("Coming to onTouch");
                            myXYPlot_L.onTouch((View)myXYPlot_L,motion);
                            myXYPlot_R.onTouch((View)myXYPlot_R,motion);
                            return true;
                        }
                    }
               );
}

-------------
-------------

This solution is working fine for me.........