IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Comment faire un système de plan?


Sujet :

Android

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mars 2013
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2013
    Messages : 17
    Par défaut Comment faire un système de plan?
    Bonjour à tous.


    Je suis en train de développer une application sous éclipse, j'aimerais avoir un plan sur le quel je puis naviguer dans le style "google map" mais avec un plan fait sous Autocad.

    Comment je peux faire?


    Après est-ce qu'il est possible de mettre une sorte de calque avec des éléments, qui seraient par dessus le plan, que je puis animé et qui grossiraient en même temps que le plan quand je zoomerai?


    Un gros merci pour ce qui peuvent m'aider je suis débutant et c'est vrai que c'est tendu

  2. #2
    Membre éclairé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2011
    Messages
    262
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2011
    Messages : 262
    Par défaut
    tu sais la plupart des livres d'enseignment d'android laisse la partie consernat google map aux derniers chapitres , alors toi tu fais le contraire tu veux commencer depuis là.

    je te conseille de ne pas faire ça essaye d'apprendre les bases , essay de faire des petits programme , comme ça tu vas mieux apprendre , quand on construit une maison on commence pas par le toit .

    bon courage

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mars 2013
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2013
    Messages : 17
    Par défaut
    Je comprend, mais hélas c'est pour un projet de stage, donc je suis limité en temps :/

    Après je cherche juste la partie zoom avec deux doigts pour commencer, ce que je ne trouve pas sur le net :/

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Mars 2013
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2013
    Messages : 17
    Par défaut
    Vouala j'ai trouvé une solution mais j'arrive pas à le compiler, y a une erreur d'encapsulage j'ai l'impression.

    Peut-on m'aidait?


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    package com.example.incendie;
    
    import android.app.Activity;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.PointF;
    import android.os.Bundle;
    import android.util.FloatMath;
    import android.view.MotionEvent;
    import android.view.ScaleGestureDetector;
    import android.view.View;
    import android.view.View.OnTouchListener;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    
    
    
    public class PlanActivity extends Activity implements OnClickListener{ // sans oublier l'implémentation de l'interface OnClickListener
    	 
    	 TextView myTouchEvent;
    	 ImageView myImageView;
    	 Bitmap bitmap;
    	 int bmpWidth, bmpHeight;
    	 
    	 //Touch event related variables
    	 int touchState;
    	 final int IDLE = 0;
    	 final int TOUCH = 1;
    	 final int PINCH = 2;
    	 float dist0, distCurrent;
    	 
    	  
    	    @Override
    	    public void onCreate(Bundle savedInstanceState) {
    	        super.onCreate(savedInstanceState);
    	        setContentView(R.layout.plan);
    	        
    	        myImageView = (ImageView)findViewById(R.id.imageView);
    	        
    	        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    	        bmpWidth = bitmap.getWidth();
    	        bmpHeight = bitmap.getHeight();
    	        
    	        distCurrent = 1; //Dummy default distance
    	        dist0 = 1;   //Dummy default distance
    	        drawMatrix();
    	        
    	        myImageView.setOnTouchListener(MyOnTouchListener);
    	        touchState = IDLE;
    	    }
    	    
    	    private void drawMatrix(){
    	     float curScale = distCurrent/dist0;
    	     if (curScale < 0.1){
    	      curScale = 0.1f; 
    	     }
    	     
    	     Bitmap resizedBitmap;    
    	     int newHeight = (int) (bmpHeight * curScale);
    	     int newWidth = (int) (bmpWidth * curScale);
    	     resizedBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);
    	     myImageView.setImageBitmap(resizedBitmap); 
    	    
             } //Il y aurait une erreur Ici!
    	    
    	    OnTouchListener MyOnTouchListener
    	    = new OnTouchListener(){
    
    	  @Override
    	  public boolean onTouch(View view, MotionEvent event) {
    	   // TODO Auto-generated method stub
    	   
    	   float distx, disty;
    	   
    	   switch(event.getAction() & MotionEvent.ACTION_MASK){
    	   case MotionEvent.ACTION_DOWN:
    	    //A pressed gesture has started, the motion contains the initial starting location.
    	    myTouchEvent.setText("ACTION_DOWN"); 
    	    touchState = TOUCH;
    	    break;
    	   case MotionEvent.ACTION_POINTER_DOWN:
    	    //A non-primary pointer has gone down.
    	    myTouchEvent.setText("ACTION_POINTER_DOWN"); 
    	    touchState = PINCH;
    	    
    	    //Get the distance when the second pointer touch
    	    distx = event.getX(0) - event.getX(1);
    	    disty = event.getY(0) - event.getY(1);
    	    dist0 = FloatMath.sqrt(distx * distx + disty * disty);
    
    	    break;
    	   case MotionEvent.ACTION_MOVE:
    	    //A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).
    	    myTouchEvent.setText("ACTION_MOVE");
    	    
    	    if(touchState == PINCH){      
    	     //Get the current distance
    	     distx = event.getX(0) - event.getX(1);
    	     disty = event.getY(0) - event.getY(1);
    	     distCurrent = FloatMath.sqrt(distx * distx + disty * disty);
    
    	     drawMatrix();
    	    }
    	    
    	    break;
    	   case MotionEvent.ACTION_UP:
    	    //A pressed gesture has finished.
    	    myTouchEvent.setText("ACTION_UP"); 
    	    touchState = IDLE;
    	    break;
    	   case MotionEvent.ACTION_POINTER_UP:
    	    //A non-primary pointer has gone up.
    	    myTouchEvent.setText("ACTION_POINTER_UP"); 
    	    touchState = TOUCH;
    	    break;
    	   }
    	   
    	   return true;
    	  }
    	     
    	    };
    
    // A partir d'ici le code me sert pour le bouton retour au menu:
    Button button20 = (Button) findViewById(R.id.button20);
     
    button20.setOnClickListener(new View.OnClickListener() {
     
    public void onClick(View button20) {
     
    	Intent intent = new Intent(PlanActivity.this, MainActivity.class);
     
    startActivity(intent);
    }
     
    });
    }
    
    
    @Override
    public void onClick(DialogInterface arg0, int arg1) {
    	// TODO Auto-generated method stub
    	
    }
     
    }

  5. #5
    Membre expérimenté
    Homme Profil pro
    Développeur Java / C++
    Inscrit en
    Mars 2013
    Messages
    128
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Java / C++

    Informations forums :
    Inscription : Mars 2013
    Messages : 128
    Par défaut
    Bonsoir LightShooter,

    Vous avez mal géré vos accolades:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
     
    package com.example.incendie;
     
    import android.app.Activity;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.PointF;
    import android.os.Bundle;
    import android.util.FloatMath;
    import android.view.MotionEvent;
    import android.view.ScaleGestureDetector;
    import android.view.View;
    import android.view.View.OnTouchListener;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.LinearLayout;
    import android.widget.TextView;
     
     
     
    public class PlanActivity extends Activity implements OnClickListener{ // sans oublier l'implémentation de l'interface OnClickListener
     
    	 TextView myTouchEvent;
    	 ImageView myImageView;
    	 Bitmap bitmap;
    	 int bmpWidth, bmpHeight;
     
    	 //Touch event related variables
    	 int touchState;
    	 final int IDLE = 0;
    	 final int TOUCH = 1;
    	 final int PINCH = 2;
    	 float dist0, distCurrent;
     
     
    	    @Override
    	    public void onCreate(Bundle savedInstanceState) {
    	        super.onCreate(savedInstanceState);
    	        setContentView(R.layout.plan);
     
    	        myImageView = (ImageView)findViewById(R.id.imageView);
     
    	        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    	        bmpWidth = bitmap.getWidth();
    	        bmpHeight = bitmap.getHeight();
     
    	        distCurrent = 1; //Dummy default distance
    	        dist0 = 1;   //Dummy default distance
    	        drawMatrix();
     
    	        myImageView.setOnTouchListener(MyOnTouchListener);
    	        touchState = IDLE;
    	    } // Fin de onCreate();
     
    	    private void drawMatrix(){
    	     float curScale = distCurrent/dist0;
    	     if (curScale < 0.1){
    	      curScale = 0.1f; 
    	     } // Fin de drawMatrix
     
    // Ce code semble être en dehors de toute fonction, eclipse ne vous dit rien ici?
    	     Bitmap resizedBitmap;    
    	     int newHeight = (int) (bmpHeight * curScale);
    	     int newWidth = (int) (bmpWidth * curScale);
    	     resizedBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);
    	     myImageView.setImageBitmap(resizedBitmap); 
     
             } //Il y aurait une erreur Ici! <= Fin de classe
     
     
    // Tou ce qui suit est donc déclaré en dehors de la classe.
    	    OnTouchListener MyOnTouchListener
    	    = new OnTouchListener(){
     
    	  @Override
    	  public boolean onTouch(View view, MotionEvent event) {
    	   // TODO Auto-generated method stub
     
    	   float distx, disty;
     
    	   switch(event.getAction() & MotionEvent.ACTION_MASK){
    	   case MotionEvent.ACTION_DOWN:
    	    //A pressed gesture has started, the motion contains the initial starting location.
    	    myTouchEvent.setText("ACTION_DOWN"); 
    	    touchState = TOUCH;
    	    break;
    	   case MotionEvent.ACTION_POINTER_DOWN:
    	    //A non-primary pointer has gone down.
    	    myTouchEvent.setText("ACTION_POINTER_DOWN"); 
    	    touchState = PINCH;
     
    	    //Get the distance when the second pointer touch
    	    distx = event.getX(0) - event.getX(1);
    	    disty = event.getY(0) - event.getY(1);
    	    dist0 = FloatMath.sqrt(distx * distx + disty * disty);
     
    	    break;
    	   case MotionEvent.ACTION_MOVE:
    	    //A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).
    	    myTouchEvent.setText("ACTION_MOVE");
     
    	    if(touchState == PINCH){      
    	     //Get the current distance
    	     distx = event.getX(0) - event.getX(1);
    	     disty = event.getY(0) - event.getY(1);
    	     distCurrent = FloatMath.sqrt(distx * distx + disty * disty);
     
    	     drawMatrix();
    	    }
     
    	    break;
    	   case MotionEvent.ACTION_UP:
    	    //A pressed gesture has finished.
    	    myTouchEvent.setText("ACTION_UP"); 
    	    touchState = IDLE;
    	    break;
    	   case MotionEvent.ACTION_POINTER_UP:
    	    //A non-primary pointer has gone up.
    	    myTouchEvent.setText("ACTION_POINTER_UP"); 
    	    touchState = TOUCH;
    	    break;
    	   }
     
    	   return true;
    	  }
     
    	    };
     
    // A partir d'ici le code me sert pour le bouton retour au menu:
    Button button20 = (Button) findViewById(R.id.button20);
     
    button20.setOnClickListener(new View.OnClickListener() {
     
    public void onClick(View button20) {
     
    	Intent intent = new Intent(PlanActivity.this, MainActivity.class);
     
    startActivity(intent);
    }
     
    });
    }
     
     
    @Override
    public void onClick(DialogInterface arg0, int arg1) {
    	// TODO Auto-generated method stub
     
    }
     
    }
    Je vous ai mit des commentaires qui suivent les accolades dans le code, à vous de les réorganiser.

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Mars 2013
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2013
    Messages : 17
    Par défaut
    Merci Minicalion pour ta réponse, j'ai trouvé le problème, ça venait d'un conflit entre le programme du bouton et du zoom, donc j'ai viré le bouton car après réflexion y ne me servait à rien, par contre comment je peux faire une insérer un scrollview?

  7. #7
    Membre extrêmement actif
    Profil pro
    Développeur
    Inscrit en
    Mars 2012
    Messages
    1 970
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2012
    Messages : 1 970
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    ScrollView sv = new ScrollView(getApplicationContext());
    ...
    sv.addView(<child>); //Ici généralement tu lui ajoutes un enfant de type LinearLayout
     
    //Et ajoute ton sv dans un parent:
    <parent>.addView(sv);
    Rem: la Scrollview est généralement le 2 élément de ton activité.
    Le 1er (le parent) étant une LinearLayout.
    Et son parent étant l'activité.

Discussions similaires

  1. Comment faire une horloge système
    Par vantoff dans le forum C++Builder
    Réponses: 1
    Dernier message: 06/07/2006, 16h29
  2. Comment faire pour désactiver la restauration système ?
    Par chocococo dans le forum Windows Serveur
    Réponses: 14
    Dernier message: 30/12/2005, 10h08
  3. Réponses: 1
    Dernier message: 22/11/2005, 11h00
  4. Comment faire pour qu'une Form reste en avant-plan?
    Par Bodom-Child dans le forum C++Builder
    Réponses: 3
    Dernier message: 25/08/2005, 10h28
  5. Système de licence : comment faire ???
    Par hubble dans le forum Langages de programmation
    Réponses: 11
    Dernier message: 23/11/2004, 21h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo