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

avec Java Discussion :

Linked liste Java problème de regroupement


Sujet :

avec Java

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2012
    Messages : 6
    Points : 4
    Points
    4
    Par défaut Linked liste Java problème de regroupement
    Bonjour les amis.
    C'est la première fois que j'écris ici dans développez.net.
    Bref, j'explique le problème :
    J'ai une fichier texte qui contient des lignes comme ça :
    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
    [#TasmanianDevil][#Marsupials]
    [#Koala][#isHardWorking]
    [#MaleStudentWith3Daughters][#Student][#hasChildren][#Female][#hasGender][#male][#hasChildren]
    [#Marsupials][#Animal]
    [#Forest][#Habitat]
    [#Parent][#Animal][#hasChildren]
    [#KoalaWithPhD][#Koala][#hasDegree][#PhD]
    [#Koala][#hasHabitat][#DryEucalyptForest]
    [#Animal][#hasGender]
    [#Quokka][#Marsupials]
    [#Student][#Person][#hasHabitat][#University][#isHardWorking]
    [#Parent][#Animal]
    [#Quokka][#isHardWorking]
    [#Female][#hasGender][#female]
    [#Person][#Animal]
    [#Rainforest][#Forest]
    [#GraduateStudent][#Student]
    [#Marsupials][#Person]
    [#Animal][#hasHabitat]
    [#DryEucalyptForest][#Forest]
    [#Male][#hasGender][#male]
    [#University][#Habitat]
    [#Koala][#Marsupials]
    [#GraduateStudent][#hasDegree][#BA][#BS]
    Je veux faire une regroupement comme suit :
    [#C1][#P1][#P2]
    [#C2][#P1][#P2]
    [#C3][#P1][#P2]
    [#C1][#P3][#P4]
    [#C2][#P3][#P4]
    [#C1][#P5][#P6]

    Alors comme résultat finale :
    [#C1][#P1][#P2][#P3][#P4][#P5][#P6]
    [#C2][#P1][#P2][#P3][#P4]
    [#C3][#P1][#P2]

    Par exemple quand je fais un parcours sur les lignes je trouve [#Koala][#isHardWorking] et par la suite je trouve [#Koala][#hasHabitat][#DryEucalyptForest].
    alors je regroupe les deux lignes et je les affecte dans un LinkedList comme ça [#Koala][#isHardWorking][#hasHabitat][#DryEucalyptForest].

    Merci de m'aider à programmer ce problème en Java.

  2. #2
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    Hello,

    Jusqu'à maintenant, où en sont tes propres réflexions sur la manière d'approcher ce problème ? Dis-nous, qu'on puisse voir de quoi tu as besoin.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2012
    Messages : 6
    Points : 4
    Points
    4
    Par défaut
    Hi, je travaille actuellement sur les ontologies dans le domaine de web sémantique et je besoin de fusionner les classes à base des propriétés

  4. #4
    Modérateur

    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    12 551
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 12 551
    Points : 21 607
    Points
    21 607
    Par défaut
    C'est à dire que ça ressemble pas trop à un premier essai de le faire par toi-même, tout ça. Il va falloir s'y mettre.
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  5. #5
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2012
    Messages : 6
    Points : 4
    Points
    4
    Par défaut
    j'ai essai des dizaines de fois mais toujours par échec
    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
        public static void remplir_jtree2()
        {
        	String line = null;
        	try{
        		InputStream flux=new FileInputStream("store\\anatomy\\Finding_F4.txt"); 
        		InputStreamReader lecture=new InputStreamReader(flux);
        		BufferedReader buff=new BufferedReader(lecture);
    			 LinkedList<String> tab=new  LinkedList<String>();
     
        		while ((line=buff.readLine())!=null)
        		{
        			if ( line.trim().length()!= 0) {
     
        				 LinkedList<String> vectorx=new  LinkedList<String>();
     
        				 for(int i=0; i<line.length();i++) 
        				 {
        					 if (line.charAt(i)=='#') 
        					 {
        						 vectorx.add(i+1+"");
        					 }
        				 }
        				 LinkedList<String> terminus=new  LinkedList<String>();
     
        				 for(int i=0; i<line.length();i++) 
        				 {
        					 if (line.charAt(i)==']') 
        					 {
        						 terminus.add(i+"");
        					 }
        				 }
        				 DefaultMutableTreeNode var1=null;
        				 for(int i=0; i<vectorx.size();i++) 
        					 { 
        					// total1.add(line.substring(Integer.parseInt(vectorx.get(i)),Integer.parseInt(terminus.get(i))));
        					 if (i==0)
        					 {
        						var1 = new DefaultMutableTreeNode(line.substring(Integer.parseInt(vectorx.get(i)),Integer.parseInt(terminus.get(i))));
        					 }
        					 else
        					 {
        						 var1.add(new DefaultMutableTreeNode(line.substring(Integer.parseInt(vectorx.get(i)),Integer.parseInt(terminus.get(i)))));
        					 }
        					 }
        				 treeNode2.add(var1);
     
        			}
        			line.replaceAll("[#", "");
    				  tab.add(line.replace("]", "/"));
        		}
     
     
     
     
        		for (int i=0; i<tab.size(); i++)
        		{
        			System.out.println(tab.get(i));
        		}
        		buff.close(); 
        		}		
        		catch (Exception e)
        		{
        		System.out.println(e.toString());
        		}
     
     
        }
     
    }

  6. #6
    Modérateur
    Avatar de joel.drigo
    Homme Profil pro
    Ingénieur R&D - Développeur Java
    Inscrit en
    Septembre 2009
    Messages
    12 430
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D - Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2009
    Messages : 12 430
    Points : 29 131
    Points
    29 131
    Billets dans le blog
    2
    Par défaut
    Salut,

    1. Que penses-tu que ce code est censé faire :
      Code : Sélectionner tout - Visualiser dans une fenêtre à part
      1
      2
      3
      4
      5
      6
      7
      8
      9
      LinkedList<String> vectorx=new  LinkedList<String>();
       
          				 for(int i=0; i<line.length();i++) 
          				 {
          					 if (line.charAt(i)=='#') 
          					 {
          						 vectorx.add(i+1+"");
          					 }
          				 }
    2. Tu devrais première décrire, sans impliquer d'écriture de code, comment réaliser la fonctionnalité qui consiste :
      1. à partir de lignes de texte lues depuis un fichier
      2. les convertir dans des données nécessaires pour réaliser la fonction, dont l'une, sert à priori à catégoriser en quelque sorte les autres
      3. et donc comment associer les éléments venant de différentes lignes, mais ayant une même catégorie
      4. et enfin, séparément, comment à partir de ces données les mettre dans la structure finale que tu désires. Une LinkedList d'après ton premier message. Mais on voit dans ton code l'utilisation de DefaultMutableTreeNode. Donc un modèle en arbre. Je vois bien le rapport entre la modélisation d'une ontologie et un arbre, moins avec une LinkedList. Il faudrait déjà décider de la structure que tu dois générer et comment les données sont censées y être stockées.
    L'expression "ça marche pas" ne veut rien dire. Indiquez l'erreur, et/ou les comportements attendus et obtenus, et donnez un Exemple Complet Minimal qui permet de reproduire le problème.
    La plupart des réponses à vos questions sont déjà dans les FAQs ou les Tutoriels, ou peut-être dans une autre discussion : utilisez la recherche interne.
    Des questions sur Java : consultez le Forum Java. Des questions sur l'EDI Eclipse ou la plateforme Eclipse RCP : consultez le Forum Eclipse.
    Une question correctement posée et rédigée et vous aurez plus de chances de réponses adaptées et rapides.
    N'oubliez pas de mettre vos extraits de code entre balises CODE (Voir Mode d'emploi de l'éditeur de messages).
    Nouveau sur le forum ? Consultez Les Règles du Club.

  7. #7
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2012
    Messages : 6
    Points : 4
    Points
    4
    Par défaut
    Citation Envoyé par joel.drigo Voir le message
    Salut,

    1. Que penses-tu que ce code est censé faire :
      Code : Sélectionner tout - Visualiser dans une fenêtre à part
      1
      2
      3
      4
      5
      6
      7
      8
      9
      LinkedList<String> vectorx=new  LinkedList<String>();
       
          				 for(int i=0; i<line.length();i++) 
          				 {
          					 if (line.charAt(i)=='#') 
          					 {
          						 vectorx.add(i+1+"");
          					 }
          				 }
    2. Tu devrais première décrire, sans impliquer d'écriture de code, comment réaliser la fonctionnalité qui consiste :
      1. à partir de lignes de texte lues depuis un fichier
      2. les convertir dans des données nécessaires pour réaliser la fonction, dont l'une, sert à priori à catégoriser en quelque sorte les autres
      3. et donc comment associer les éléments venant de différentes lignes, mais ayant une même catégorie
      4. et enfin, séparément, comment à partir de ces données les mettre dans la structure finale que tu désires. Une LinkedList d'après ton premier message. Mais on voit dans ton code l'utilisation de DefaultMutableTreeNode. Donc un modèle en arbre. Je vois bien le rapport entre la modélisation d'une ontologie et un arbre, moins avec une LinkedList. Il faudrait déjà décider de la structure que tu dois générer et comment les données sont censées y être stockées.
    J'ai déjà présenté mon problème, c'est essentiellement je ne connais pas comment je faire le parcours sur la totalité de fichier et je regroupe les classes avec ces propriétés comme il est expliqué précédemment dans le message initial
    cordialement

  8. #8
    Modérateur
    Avatar de joel.drigo
    Homme Profil pro
    Ingénieur R&D - Développeur Java
    Inscrit en
    Septembre 2009
    Messages
    12 430
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D - Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2009
    Messages : 12 430
    Points : 29 131
    Points
    29 131
    Billets dans le blog
    2
    Par défaut
    Citation Envoyé par hsanhsan Voir le message
    J'ai déjà présenté mon problème
    Oui, ça, on a compris quel est ton problème et ce que tu cherches à faire. Mais ce n'est pas nous qui allons coder. Tout ce qu'on peut faire c'est t'aider à le faire.

    Et pour ça, on t'invite à réfléchir à la façon de le faire et à réfléchir à ce que tu as essayé de faire, pour commencer. Si tu bloques sur quelque chose, on te débloquera. Mais, avant, il faudrait déjà commencer par la base et répondre aux questions qu'on te pose. Pour la lecture des lignes du fichier, tu as une base qui fonctionne, mais je t'ai mis le doigt sur une partie de l'exploitation de cette ligne : regarde-là bien et dis-moi ce que tu penses qu'elle fait...
    L'expression "ça marche pas" ne veut rien dire. Indiquez l'erreur, et/ou les comportements attendus et obtenus, et donnez un Exemple Complet Minimal qui permet de reproduire le problème.
    La plupart des réponses à vos questions sont déjà dans les FAQs ou les Tutoriels, ou peut-être dans une autre discussion : utilisez la recherche interne.
    Des questions sur Java : consultez le Forum Java. Des questions sur l'EDI Eclipse ou la plateforme Eclipse RCP : consultez le Forum Eclipse.
    Une question correctement posée et rédigée et vous aurez plus de chances de réponses adaptées et rapides.
    N'oubliez pas de mettre vos extraits de code entre balises CODE (Voir Mode d'emploi de l'éditeur de messages).
    Nouveau sur le forum ? Consultez Les Règles du Club.

  9. #9
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2012
    Messages : 6
    Points : 4
    Points
    4
    Par défaut
    Bonjour les amis j'ai essai de trouver la solution mais avec échec
    merci de me corriger
    voila le code complet
    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
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package aml;
     
    import java.io.BufferedReader;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.LinkedList;
     
    import javax.swing.tree.DefaultMutableTreeNode;
     
    public class showing extends javax.swing.JFrame {
     
     
        static String prop1 = new String();
        static String class1 = new String();
        static String prop2 = new String();
        static String class2 = new String();
     
        static LinkedList < String > tete1 = new LinkedList < String > ();
        static LinkedList < String > tete2 = new LinkedList < String > ();
        static LinkedList < String > tete1A = new LinkedList < String > ();
        static LinkedList < String > tete2A = new LinkedList < String > ();
     
        static LinkedList < String > p1 = new LinkedList < String > ();
        static LinkedList < String > c1 = new LinkedList < String > ();
        static LinkedList < String > p2 = new LinkedList < String > ();
        static LinkedList < String > c2 = new LinkedList < String > ();
        static LinkedList < String > g1 = new LinkedList < String > ();
        static LinkedList < String > g2 = new LinkedList < String > ();
     
     
        static javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Ontology 1");
        static javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Ontology 2");
     
        /**
         * Creates new form showing
         */
        public showing() {
            initComponents();
            this.setLocationRelativeTo(null);
            proprty1();
            classes1();
            proprty2();
            classes2();
            remplir_jtree1();
            jTree1.expandRow(0);
            remplir_jtree2();
            jTree2.expandRow(0);
        }
        public showing(String source, String target) {
            initComponents();
            this.setLocationRelativeTo(null);
            proprty1();
            classes1();
            proprty2();
            classes2();
            remplir_jtree1();
            jTree1.expandRow(0);
            remplir_jtree2();
            jTree2.expandRow(0);
            jLabel1.setText("O1:" + source);
            jLabel2.setText("O2:" + target);
        }
     
     
        private void initComponents() {
     
            jSeparator1 = new javax.swing.JSeparator();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jSeparator2 = new javax.swing.JSeparator();
            jButton1 = new javax.swing.JButton();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTree1 = new javax.swing.JTree();
            jScrollPane2 = new javax.swing.JScrollPane();
            jTree2 = new javax.swing.JTree();
     
            jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
     
            jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
            jLabel1.setText("Ontology 1");
     
            jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
            jLabel2.setText("Ontology 2");
     
            jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
            jButton1.setForeground(new java.awt.Color(0, 153, 0));
            jButton1.setText("Start fusion");
            jButton1.setToolTipText("");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
     
            jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
            jScrollPane1.setViewportView(jTree1);
     
            jTree2.setModel(new javax.swing.tree.DefaultTreeModel(treeNode2));
            jScrollPane2.setViewportView(jTree2);
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jSeparator2)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 453, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 536, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 194, Short.MAX_VALUE))
                        .addComponent(jScrollPane2))
                    .addContainerGap())
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(26, 26, 26))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(26, 26, 26)
                                    .addComponent(jLabel1))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jLabel2)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
                                .addComponent(jScrollPane1)))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 574, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(11, 11, 11)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            );
     
            pack();
        } // </editor-fold>                        
     
     
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            //String l1=jComboBox1.getSelectedItem().toString();
            //String l2=jComboBox2.getSelectedItem().toString();
            compairng cc = new compairng(p1, c1, p2, c2);
            cc.setVisible(true);
        }
     
     
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info: javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(showing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(showing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(showing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(showing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
     
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new showing().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JSeparator jSeparator1;
        private javax.swing.JSeparator jSeparator2;
        private javax.swing.JTree jTree1;
        private javax.swing.JTree jTree2;
        private static String ligne;
     
     
     
     
        //__________________________________________________________________
        public static void proprty1() {
            prop1 = null;
            ligne = null;
            //jTextArea1.append("|**********************(Propertys Classes Liste Ontology 1)****************************|"+"\n");
            try {
                InputStream flux = new FileInputStream("store\\anatomy\\Finding_F1.txt");
                InputStreamReader lecture = new InputStreamReader(flux);
                BufferedReader buff = new BufferedReader(lecture);
                while ((ligne = buff.readLine()) != null) {
                    if (ligne.trim().length() != 0) {
                        if (ligne.charAt(0) == '(') {
     
                            p1.add(ligne.substring(0, ligne.indexOf('#')) + ligne.substring(ligne.indexOf('#') + 1, ligne.length()));
                            //	jTextArea1.append(ligne+"\n" );
                        }
                    }
                }
                buff.close();
            } catch (Exception e) {
                System.out.println(e.toString());
            }
            //jTextArea1.append("|**********************(Propertys Classes Liste Ontology 1)****************************|"+"\n");
        }
     
     
        //__________________________________________________________________
        public static void classes1() {
            class1 = null;
            ligne = null;
            //jTextArea2.append("|**********************(Classes Liste Ontology 1)****************************|"+"\n");
            try {
                InputStream flux = new FileInputStream("store\\anatomy\\Finding_F1.txt");
                InputStreamReader lecture = new InputStreamReader(flux);
                BufferedReader buff = new BufferedReader(lecture);
                while ((ligne = buff.readLine()) != null) {
                    if (ligne.trim().length() != 0) {
                        if (ligne.charAt(0) == '#') {
                            c1.add(ligne.substring(1, ligne.length()));
                            //jTextArea2.append(ligne+"\n");
                            class1 = class1 + ligne + "\n";
                        }
                    }
                }
     
                buff.close();
            } catch (Exception e) {
                System.out.println(e.toString());
            }
            //jTextArea2.append("|**********************(Classes Liste Ontology 1)****************************|"+"\n");
     
        }
        //__________________________________________________________________
        public static void proprty2() {
            prop1 = null;
            ligne = null;
            //jTextArea3.append("|**********************(Propertys Classes Liste Ontology 2)****************************|"+"\n");
            try {
                InputStream flux = new FileInputStream("store\\anatomy\\Finding_F2.txt");
                InputStreamReader lecture = new InputStreamReader(flux);
                BufferedReader buff = new BufferedReader(lecture);
                while ((ligne = buff.readLine()) != null) {
                    if (ligne.trim().length() != 0) {
                        if (ligne.charAt(0) == '(') {
     
                            p2.add(ligne.substring(0, ligne.indexOf('#')) + ligne.substring(ligne.indexOf('#') + 1, ligne.length()));
                            //jTextArea3.append(ligne+"\n");
                        }
                    }
                }
                buff.close();
            } catch (Exception e) {
                System.out.println(e.toString());
            }
            //jTextArea3.append("|**********************(Propertys Classes Liste Ontology 2)****************************|"+"\n");
     
        }
     
     
        //__________________________________________________________________
        public static void classes2() {
            class1 = null;
            ligne = null;
            //jTextArea4.append("|**********************(Classes Liste Ontology 2)****************************|"+"\n");
            try {
                InputStream flux = new FileInputStream("store\\anatomy\\Finding_F2.txt");
                InputStreamReader lecture = new InputStreamReader(flux);
                BufferedReader buff = new BufferedReader(lecture);
                while ((ligne = buff.readLine()) != null) {
                    if (ligne.trim().length() != 0) {
                        if (ligne.charAt(0) == '#') {
                            c2.add(ligne.substring(1, ligne.length()));
                            //jTextArea4.append(ligne+"\n");
                            class1 = class1 + ligne + "\n";
                        }
                    }
                }
     
                buff.close();
            } catch (Exception e) {
                System.out.println(e.toString());
            }
            //jTextArea4.append("|**********************(Classes Liste Ontology 2)****************************|"+"\n");
        }
     
        //__________________________________________________________________
     
     
        public static void remplir_jtree1() {
            String line = null;
            try {
                InputStream flux = new FileInputStream("store\\anatomy\\Finding_F3.txt");
                InputStreamReader lecture = new InputStreamReader(flux);
                BufferedReader buff = new BufferedReader(lecture);
                int k=0;
                while ((line = buff.readLine()) != null) {
                    if (line.trim().length() != 0) {
     
                        LinkedList < String > vectorx = new LinkedList < String > ();
     
                        for (int i = 0; i < line.length(); i++) {
                            if (line.charAt(i) == '#') {
                                vectorx.add(i + 1 + "");
                            }
                        }
                        LinkedList < String > terminus = new LinkedList < String > ();
     
                        for (int i = 0; i < line.length(); i++) {
                            if (line.charAt(i) == ']') {
                                terminus.add(i + "");
                            }
                        }
                        DefaultMutableTreeNode
                        var = null;
     
                        for (int i = 0; i < vectorx.size(); i++) {
                            // total1.add(line.substring(Integer.parseInt(vectorx.get(i)),Integer.parseInt(terminus.get(i))));
                            if (i == 0) {
                                var = new DefaultMutableTreeNode("["+k+"]   "+line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i))));
                                tete1.add(line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i))));
                                k++;
                            } else {
                                var.add(new DefaultMutableTreeNode("["+i+"]   "+line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i)))));
                            }
                        }
                        treeNode1.add(var);
     
                    }
                }
                buff.close();
            } catch (Exception e) {
                System.out.println(e.toString());
            }
        }
     
        public static void remplir_jtree2() {
            String line = null;
            try {
                InputStream flux = new FileInputStream("store\\anatomy\\Finding_F4.txt");
                InputStreamReader lecture = new InputStreamReader(flux);
                BufferedReader buff = new BufferedReader(lecture);
                while ((line = buff.readLine()) != null) {
                    if (line.trim().length() != 0) {
     
                        LinkedList < String > vectorx = new LinkedList < String > ();
     
                        for (int i = 0; i < line.length(); i++) {
                            if (line.charAt(i) == '#') {
                                vectorx.add(i + 1 + "");
                            }
                        }
                        LinkedList < String > terminus = new LinkedList < String > ();
     
                        for (int i = 0; i < line.length(); i++) {
                            if (line.charAt(i) == ']') {
                                terminus.add(i + "");
                            }
                        }
                        DefaultMutableTreeNode var1 = null;
                        for (int i = 0; i < vectorx.size(); i++) {
                            if (i == 0) {
                                var1 = new DefaultMutableTreeNode(line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i))));
                                tete2.add(line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i))));
                            } else {
                                var1.add(new DefaultMutableTreeNode(line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i)))));
                            }
                        }
                        treeNode2.add(var1);
     
                    }
     
                }
                for (int i = 0; i < tete2.size(); i++) {
                    System.out.println(tete2.get(i));
                }
                System.out.println("1*********************************");
     
                HashSet < String > hs = new HashSet < String > (tete2);
     
                Iterator < String > it = hs.iterator();
                for (; it.hasNext();) {
                    String s = (String) it.next();
                    tete2A.add(s);
                }
                System.out.println("1****************Lecture***********");
                InputStream flux1 = new FileInputStream("store\\anatomy\\Finding_F4.txt");
                InputStreamReader lecture1 = new InputStreamReader(flux1);
                BufferedReader buff1 = new BufferedReader(lecture1);
                while ((line = buff1.readLine()) != null) {
                    if (line.trim().length() != 0) {
                        LinkedList < String > vectorx = new LinkedList < String > ();
                        for (int i = 0; i < line.length(); i++) {
                            if (line.charAt(i) == '#') {
                                vectorx.add(i + 1 + "");
                            }
                        }
                        LinkedList < String > terminus = new LinkedList < String > ();
     
                        for (int i = 0; i < line.length(); i++) {
                            if (line.charAt(i) == ']') {
                                terminus.add(i + "");
                            }
                        }
                        for (int i = 0; i < vectorx.size(); i++) {
                            if (i == 0) {
     
                                String var1 = line.substring(Integer.parseInt(vectorx.get(i)), Integer.parseInt(terminus.get(i)));
                                System.out.println(var1);
                                for (int j = 0; i < tete2A.size()-1; j++) {
                                    if (var1 == tete2A.get(j)) {
                                        System.out.println(tete2A.get(j));
                                    } else {
                                        System.out.println(tete2A.get(j)+"____"+var1);
                                    }
                                }
                            }
                        }
     
                    }
     
                }
                System.out.println("1****************fin lecture***********");
     
     
                System.out.println("2--------------------------------------------------");
     
                for (int i = 0; i < tete2.size(); i++) {
                    System.out.println(tete2.get(i));
                }
                System.out.println("1*********************************");
     
                HashSet < String > hs2 = new HashSet < String > (tete2);
     
                Iterator < String > it2 = hs2.iterator();
                for (; it2.hasNext();) {
                    String s = (String) it.next();
                    tete2A.add(s);
                }
     
                buff1.close();
                buff.close();
     
            } catch (Exception e) {
                System.out.println(e.toString());
            }
        }
     
     
     
     
     
    }

Discussions similaires

  1. Linked List en Java
    Par FANDENEGI dans le forum Général Java
    Réponses: 7
    Dernier message: 09/11/2013, 17h39
  2. [Java] Problème de liste vide et de parcours d'arborescence
    Par Sup3rc0c0 dans le forum Débuter avec Java
    Réponses: 5
    Dernier message: 05/12/2012, 13h54
  3. Linked List en Java - ConcurrentModificationException
    Par somaa dans le forum Débuter avec Java
    Réponses: 3
    Dernier message: 30/06/2010, 11h48
  4. Réponses: 7
    Dernier message: 22/06/2007, 10h56
  5. [Eclipse][Java]Problème de compilation sur CTRL+S
    Par ZeKiD dans le forum Eclipse Java
    Réponses: 5
    Dernier message: 27/05/2004, 11h49

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