Android 缩放图表

发布于 2024-11-24 11:48:40 字数 3473 浏览 1 评论 0原文

我需要为从网络检索的图形实现缩放功能。这些图表来自 php web 服务器,那么如何对这些图表实现缩放功能。任何人都可以帮助我解决这个问题。这是我用于从网络检索图形的 java 类代码。

  localPalladium1YButton.setOnClickListener( new View.OnClickListener() {    
            public void onClick(View view)
            {

                localPalladium1DButton.setBackgroundResource(R.drawable.onedicon);
                localPalladium5DButton.setBackgroundResource(R.drawable.fived);
                localPalladium1MButton.setBackgroundResource(R.drawable.whitem);
                localPalladium1YButton.setBackgroundResource(R.drawable.yover);

                android.view.View.OnClickListener getImgListener = null;
                localPalladium1YButton.setOnClickListener(getImgListener);
                Bitmap palladiumBitmap3=fetchImage( PalladiumImageUrl4.trim() );        
                localPalladiumImageView.setImageBitmap( palladiumBitmap3 );
                mSoundManager.playSound(1);
            }

        });

..................................
..................................
..................................


 Bitmap bmImg;
                            void downloadFile(String fileUrl){
                            URL myFileUrl =null; 

                            try {  

                                myFileUrl= new URL(fileUrl);

                                  } 
                            catch (MalformedURLException e)
                                {                               
                                    // TODO Auto-generated catch block                      
                                    e.printStackTrace();
                                }

                            try {

                                String url1 = "my url";
                                URL url = new URL(url1);
                                URLConnection conn = url.openConnection();
                                conn.connect();
                                InputStream is = conn.getInputStream();
                                BufferedInputStream bis = new BufferedInputStream(is);
                                BitmapFactory.Options bf = new BitmapFactory.Options();
                                Bitmap bm = BitmapFactory.decodeStream(bis);
                                ImageView localGoldImageView = null;
                                localGoldImageView.setImageBitmap(bm);

                                } catch (IOException e) {
                                         // TODO Auto-generated catch block
                                    e.printStackTrace();
                                      }
                            }





     Bitmap fetchImage( String urlstr )
    {
        try
        {
            URL url;
            url = new URL( urlstr );

            HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
            c.setDoInput( true );
            c.connect();
            InputStream is = c.getInputStream();
            Bitmap img;
            img = BitmapFactory.decodeStream( is );
            return img;
        }
        catch ( MalformedURLException e )
        {
            Log.d( "RemoteImageHandler", "fetchImage passed invalid URL: " + urlstr );
            e.printStackTrace();
        }
        catch ( IOException e )
        {
            Log.d( "RemoteImageHandler", "fetchImage IO exception: " + e );
           e.printStackTrace();
        }
        return null;
    }

谢谢,

穆拉里。

I need to implement zoom functionality for graphs which are retrieving from web. These graphs are from php web-server so how to implement zooming functionality to these graphs. Any one can help me to come out from this issue. This is my java class code for retriving graphs from web.

  localPalladium1YButton.setOnClickListener( new View.OnClickListener() {    
            public void onClick(View view)
            {

                localPalladium1DButton.setBackgroundResource(R.drawable.onedicon);
                localPalladium5DButton.setBackgroundResource(R.drawable.fived);
                localPalladium1MButton.setBackgroundResource(R.drawable.whitem);
                localPalladium1YButton.setBackgroundResource(R.drawable.yover);

                android.view.View.OnClickListener getImgListener = null;
                localPalladium1YButton.setOnClickListener(getImgListener);
                Bitmap palladiumBitmap3=fetchImage( PalladiumImageUrl4.trim() );        
                localPalladiumImageView.setImageBitmap( palladiumBitmap3 );
                mSoundManager.playSound(1);
            }

        });

..................................
..................................
..................................


 Bitmap bmImg;
                            void downloadFile(String fileUrl){
                            URL myFileUrl =null; 

                            try {  

                                myFileUrl= new URL(fileUrl);

                                  } 
                            catch (MalformedURLException e)
                                {                               
                                    // TODO Auto-generated catch block                      
                                    e.printStackTrace();
                                }

                            try {

                                String url1 = "my url";
                                URL url = new URL(url1);
                                URLConnection conn = url.openConnection();
                                conn.connect();
                                InputStream is = conn.getInputStream();
                                BufferedInputStream bis = new BufferedInputStream(is);
                                BitmapFactory.Options bf = new BitmapFactory.Options();
                                Bitmap bm = BitmapFactory.decodeStream(bis);
                                ImageView localGoldImageView = null;
                                localGoldImageView.setImageBitmap(bm);

                                } catch (IOException e) {
                                         // TODO Auto-generated catch block
                                    e.printStackTrace();
                                      }
                            }





     Bitmap fetchImage( String urlstr )
    {
        try
        {
            URL url;
            url = new URL( urlstr );

            HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
            c.setDoInput( true );
            c.connect();
            InputStream is = c.getInputStream();
            Bitmap img;
            img = BitmapFactory.decodeStream( is );
            return img;
        }
        catch ( MalformedURLException e )
        {
            Log.d( "RemoteImageHandler", "fetchImage passed invalid URL: " + urlstr );
            e.printStackTrace();
        }
        catch ( IOException e )
        {
            Log.d( "RemoteImageHandler", "fetchImage IO exception: " + e );
           e.printStackTrace();
        }
        return null;
    }

Thanks,

Murali.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文