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

Java Discussion :

Création d'un arbre à partir de deux listes


Sujet :

Java

  1. #1
    Membre habitué Avatar de mailbox
    Profil pro
    Inscrit en
    Février 2010
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Février 2010
    Messages : 140
    Points : 159
    Points
    159
    Par défaut Création d'un arbre à partir de deux listes
    Bonjour,

    J'ai deux listes a partir desquelles je souhaite realiser un arbrem voila les deux listes:

    La premiere est une liste de tables (j'ai rajoute cette indentation pour etre plus precis mais les espaces n'y sont pas en realite):

    resultList:
    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
    CX_MVT  
              S_PROD_INT  
              S_PROD_INT_X  
              CX_OPEIND  
              S_ASSET  
                        S_BU  
                        S_ORG_BU  
                        S_ORG_EXT  
                        S_ORG_EXT_X 
                        S_ORG_INT  
                        S_PARTY  
                        S_PARTY_RPT_REL  
                        S_SRV_REQ 
                        S_SRV_REQ3_FNX  
                        S_CONTACT  
                        S_USER  
                        S_ORG_EXT_FNX  
                                  S_CP_EMP_PER  
                                  S_EMP_PER 
                                  S_PARTY_PER

    La seconde est une liste precisant combien de tables sont liees, par exemple les 4premieres tables sont liees a CX_MVT, les 7 suivantes a S_PROD_INT, les 4 suivantes a CX_OPEIND, ...etc

    linkTableList:
    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
    CX_MVT
    CX_MVT
    CX_MVT
    CX_MVT
    S_PROD_INT
    S_PROD_INT
    S_PROD_INT
    S_PROD_INT
    S_PROD_INT
    S_PROD_INT
    S_PROD_INT
    CX_OPEIND
    CX_OPEIND
    CX_OPEIND
    CX_OPEIND
    S_ASSET
    S_SRV_REQ
    S_SRV_REQ
    S_CONTACT

    Mon objectif est d'afficher a l'ecran:

    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
    CX_MVT  
    	S_PROD_INT  
    		S_BU  
    		S_ORG_BU  
    		S_ORG_EXT  
    		S_ORG_EXT_X  
    		S_ORG_INT  
     		S_PARTY  
    		S_PARTY_RPT_REL  
    	S_PROD_INT_X 
    	CX_OPEIND  
    		S_SRV_REQ  
    			S_CP_EMP_PER  
    			S_EMP_PER  
    		S_SRV_REQ3_FNX  
    		S_CONTACT  
    			S_PARTY_PER  
    		S_USER  
    	S_ASSET 
    		S_ORG_EXT_FNX
    Afin de bien voir les liens entre les tables Vous avez des idées de comment je pourrai faire? (sachant que le nombre de tables peut varier, je fais tout un traitement avant)

  2. #2
    Membre habitué Avatar de mailbox
    Profil pro
    Inscrit en
    Février 2010
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Février 2010
    Messages : 140
    Points : 159
    Points
    159
    Par défaut
    Voila mon code (ça compile) pour l'instant si certains veulent regarder

    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
    import java.util.ArrayList;
    import java.util.List;
     
     
    public class Arbre {
    	public static List<String> resultList = new ArrayList<String>();
    	public static List<String> linkTableList = new ArrayList<String>();
     
    	public static void main(String[] args) throws Throwable{
     
    		resultList.add("CX_MVT");
    		resultList.add("S_PROD_INT");
    		resultList.add("S_PROD_INT_X");
    		resultList.add("CX_OPEIND");
    		resultList.add("S_ASSET");
    		resultList.add("S_BU");
    		resultList.add("S_ORG_BU");
    		resultList.add("S_ORG_EXT");
    		resultList.add("S_ORG_EXT_X");
    		resultList.add("S_ORG_INT");
    		resultList.add("S_PARTY");
    		resultList.add("S_PARTY_RPT_REL");
    		resultList.add("S_SRV_REQ");
    		resultList.add("S_SRV_REQ3_FNX");
    		resultList.add("S_CONTACT");
    		resultList.add("S_USER");
    		resultList.add("S_ORG_EXT_FNX");
    		resultList.add("S_CP_EMP_PER");
    		resultList.add("S_EMP_PER");
    		resultList.add("S_PARTY_PER");
     
    		linkTableList.add("CX_MVT");
    		linkTableList.add("CX_MVT");
    		linkTableList.add("CX_MVT");
    		linkTableList.add("CX_MVT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("S_PROD_INT");
    		linkTableList.add("CX_OPEIND");
    		linkTableList.add("CX_OPEIND");
    		linkTableList.add("CX_OPEIND");
    		linkTableList.add("CX_OPEIND");
    		linkTableList.add("S_ASSET");
    		linkTableList.add("S_SRV_REQ");
    		linkTableList.add("S_SRV_REQ");
    		linkTableList.add("S_CONTACT");
     
    		Integer space=0;
     
    		for (int i=0; i < resultList.size(); i++){
    //			if (i==0)
    //				System.out.println(resultList.get(i)+"  ("+rowIdList.get(i)+")");
    			if (i>0 && i <=4)
    				System.out.println(indent(space+0)+linkTableList.get(i-1)+":  "+resultList.get(i));
    			if (i>4 && i<=16)
    				System.out.println(indent(space+1)+linkTableList.get(i-1)+":  "+resultList.get(i));
    			if (i>16 && i<=19)
    				System.out.println(indent(space+2)+linkTableList.get(i-1)+":  "+resultList.get(i));
    		}
     
    		for (int i=0; i<linkTableList.size();i++)
    			System.out.println(linkTableList.get(i));
    	}
     
     
    	public static String indent(Integer nb){
    		StringBuffer buffer=new StringBuffer();
     
    		for(int i=1;i<=nb;i++)
    			buffer.append("          ");
     
    		return buffer.toString();
    	}
    }

Discussions similaires

  1. Calcul dynamique à partir de deux listes déroulantes
    Par Invité dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 08/12/2012, 19h47
  2. [Débutant] Création d'une classe à partir de deux autres
    Par a.floranc dans le forum VB.NET
    Réponses: 13
    Dernier message: 10/06/2012, 20h41
  3. Création d'une courbe à partir de deux autres
    Par Nathaniel_etudiant dans le forum Simulink
    Réponses: 2
    Dernier message: 12/10/2010, 15h01
  4. Création d'un calendrier à partir d'une liste
    Par lesanglier dans le forum SharePoint
    Réponses: 3
    Dernier message: 22/10/2009, 11h03
  5. Création d'un arbre à partir d'une liste contigue
    Par karaz_karaz dans le forum C
    Réponses: 2
    Dernier message: 28/06/2008, 23h51

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