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 :

Exploitation d’un fichier résultat d’une application complexe


Sujet :

Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut Exploitation d’un fichier résultat d’une application complexe
    Bonsoir,

    Je suis apprenti, en entreprise mon tuteur m’a donné une problématique que je n’arrive pas à comprendre. Il est très occupé (toujours en réunion) il n’a pas le temps de m’expliquer. Il m’a vite fais expliquer ce qu’il voulait et il a codé un programme en java qu’il a développé devant moi sur mon ordinateur au fur et à mesure, ce qui donne au finale un projet dans éclipse qui est assez conséquent.

    Le point de départ est qu’ils ont, dans le service où je suis, plusieurs applications qui permette de faire des calculs d’aérodynamisme, simulation dans plusieurs cas de figure sur des structures. Mon tuteur a choisi une application et m’a dit pour cette application il en sort des fichiers résultats qui on se formalisme : un entête, des paramètres et des lignes de résultats.

    De là il m’a demandé d’écrire une librairie en java qui permet de lire dans ce fichier et de récupérer les données qui nous intéresse pour ensuite créer une interface homme machine en vue d’exploiter ces données pour formaliser le résultat que l’on désire.

    Son codes permet de récupérer des données dans un fichier, il formalise ces données à l’aide de plusieurs classe en vue de créer une librairie pour pouvoir adapter ce code à plusieurs autres fichiers. Je ne comprends pas du tout son code qui aborde des notions avancé en programmation JAVA. Je peux vous joindre sont codes si nécessaire, voici déjà l’ossature du projet :
    Nom : projetjava.jpg
Affichages : 102
Taille : 65,3 Ko

    Il a commencé à implémenter une interface homme-machine qui va utiliser notre librairie. L’utilisateur choisi le fichier dont il désire exploiter le résultat. Il va pouvoir de l’interface choisir la mise en forme du résultat, par exemple sous forme de courbe, je veux le poids en fonction de la vitesse et ça va modéliser la courbe dans l’interface. Car de notre librairie on aura récupérer tous les paramètres existant dans le fichier, l’utilisateur aura plus qu’à choisir les paramètres dont il veut modéliser les courbes.

    J’aimerai savoir si ce genre de programme vous parle. Est-ce que ça existe déjà ? J’aimerai récupérer des docs qui parle de ce sujet en parallèle bien surs je me forme à la programmation JAVA.

    Merci de vos réponses, veuillez m’excuser si ce n’est pas clair car en fait pour moi non plus ça ne l’est pas. Ça va faire 1 mois que je tourne avec ça et je n’arrive pas à avancer, j’avoue que ça commence à m’énerver.

    J’espère avec vous pouvoir améliorer la compréhension de ce sujet, n'hésitez pas à ma poser des questions. Je pense que je vais vous poster le code pour vous aillez une vision globale de ce dont j’aborde …

  2. #2
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    Voici le main du programme :
    Dans le package com.see
    C'est la classe TestSeeLibrary

    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
    package com.see;
     
    import java.io.FileNotFoundException;
    import java.io.IOException;
     
    import com.see.exceptions.HeaderException;
    import com.see.exceptions.SeeDataException;
     
    public class TestSeeLibrary {
     
    	/**
             * Main entry point for testing the SEE library
             * @param args
             */
    	public static void main(String[] args) 
    	{
    		String fileTestPath="C:\\Users\\Desktopcas_test\\test_ini.SEE";
     
    		SeeFile see = new SeeFile(fileTestPath);
    		try {
    			see.load();
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (HeaderException e) {
    			e.printStackTrace();
    		} catch (SeeDataException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
     
    		String[] strColValues = see.getParameterValues(3);
     
    		for (int i=0;i<strColValues.length;i++)
    			System.out.println("value["+i+"] = "+strColValues[i]);
     
    		SeeParameter[] prms = see.getParametersList();
    		for (int i=0;i<prms.length;i++)
    			System.out.println("prms["+i+"] = "+prms[i].getFullName());
    	}
    }
    Dans le package com.see
    C'est la classe SeeFile
    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
    package com.see;
     
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.ArrayList;
    import java.util.List;
     
    import com.see.exceptions.HeaderException;
    import com.see.exceptions.SeeDataException;
     
    public class SeeFile{
    	public final static int FILETYPE_SEE = 1;
    	public final static int FILETYPE_TST = 2;
     
    	private String _strPath;
    	private Header _header;
    	private SeeData _data;
    	private int _intType;
     
    	/**
             * Default constructor
             * @param strPath Complete file path
             */
    	public SeeFile(String strPath) {
    		this(strPath,FILETYPE_SEE);
    	}
     
    	/**
             * Default constructor
             * @param strPath Complete file path
             */
    	public SeeFile(String strPath, int type) {
    		this._strPath = strPath;
    		_intType = type;
    		if (_intType == FILETYPE_SEE){
    			_header = new SeeHeader();
    		}
    		else{
    			_header = new TstHeader();
    		}
     
    		_data = new SeeData();
     
    	}
     
    	/**
             * Gets the list of all the parameters
             * @return List of all the parameters as a table
             */
    	public SeeParameter[] getParametersList(){
    		return _header.getParametersList();
    	}
     
    	/**
             * Load the see file (ASCII format)
             */
    	public void load() throws FileNotFoundException, IOException, HeaderException, SeeDataException{
    		List<String> strLines = new ArrayList<String>();
     
    		InputStream ips = new FileInputStream(_strPath);
     
    		InputStreamReader ipsr=new InputStreamReader(ips);
    		BufferedReader br=new BufferedReader(ipsr);
     
    		String strLine = br.readLine();
    		while (strLine!=null){
    			strLines.add(strLine);
    			strLine = br.readLine();
    		}
     
    		br.close(); 
    		// Fill the header
    		_header.read(strLines);
     
    		// Fill the data
    		_data.read(strLines,_header.getRowDataStart(),_header.getParametersCount());
     
    		this.debugPrint();			
    	}
     
    	public void debugPrint(){
    		File f = new File (_strPath);
    		System.out.println("*** Debug output for "+f.getName());
    		System.out.println(" --- Amount of parameters: "+this.getParametersCount());
    		_header.debugPrint();
    	}
     
    	/**
             * Gets all the values for the specified parameter
             * @param name Parameter name
             * @param unit Parameter unit
             * @return Values as a String table
             */
    	public String[] getParameterValues(String name, String unit){
    		SeeParameter p = this.getParameter(name, unit);
     
    		return this.getParameterValues(p.getColumn());
    	}
     
    	/**
             * Gets all the values for the specified column
             * @param column Column index (1 is the first column)
             * @return Values as a String table
             */
    	public String[] getParameterValues(int column){
    		return _data.getColumn(column-1);
    	}
     
     
    	/**
             * Gets the parameter object at the specified column
             * @param column Column index (1 is the first column)
             * @return Parameter object
             */
    	public SeeParameter getParameterAt(int column){
    		return _header.getParameterAt(column);
    	}
     
    	/**
             * Gets the parameter object from its name and its unit
             * @param name Name of the parameter
             * @param unit Unit of the parameter
             * @return Parameter object
             */
    	public SeeParameter getParameter(String name, String unit){
    		// TODO
    		return null;
    	}
     
    	/**
             * Gets the value for the parameter at the given row index
             * @param p Parameter
             * @param rowIndex Row Index
             * @return Value of the parameter as a String
             */
    	public String getParameterValueAt(SeeParameter p, int rowIndex){
    		// TODO
    		return null;
    	}
     
    	/**
             * Gets the amount of parameters in the header
             * @return Amount of parameters in the header
             */
    	public int getParametersCount(){
    		return _header.getParametersCount();
    	}
    }
    Dans le package com.see
    C'est la classe SeeData
    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
    package com.see;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import com.see.exceptions.SeeDataException;
     
    public class SeeData {
    	private List<String[]> _strRowValues;
     
    	public SeeData(){
    		_strRowValues = new ArrayList<String[]>();
    	}
     
    	public void read(List<String> strLines, int rowStart, int colCount) throws SeeDataException {
    		for (int iRow=rowStart;iRow<strLines.size();iRow++){
    			String strValues[] = new String[colCount];
    			// Fill strValues from strLines.get(iRow)
    			String strLine = strLines.get(iRow);
    			// Store the values
    			for (int iCol=0;iCol<colCount;iCol++){
    				int j1 = iCol*13;
    				int j2 = Math.min(j1+13, strLine.length());
    				strValues[iCol] = strLine.substring(j1 , j2).trim();
    			}
     
    			// Fill the list
    			_strRowValues.add(strValues);
    		}
    	}
     
    	public String[] getColumn(int column) {
    		String[] strOut = new String[_strRowValues.size()];
    		for (int i=0;i<_strRowValues.size();i++)
    			strOut[i] = _strRowValues.get(i)[column];
    		return strOut;
    	}
    }
    Dans le package com.see
    C'est la classe SeeParameter
    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
    package com.see;
     
    public class SeeParameter {
    	private String _strName;
    	private String _strUnit;
    	private int _intColumn;
     
    	public SeeParameter(){
    		this("","",-1);
    	}
     
    	public SeeParameter(int col){
    		this("","",col);
    	}
     
    	public SeeParameter(String strName, String strUnit, int col) {
    		_strName = strName;
    		_strUnit = strUnit;
    		_intColumn = col;
    	}
     
    	public String getFullName(){
    		return _strName + " ["+_strUnit+"]";
    	}
     
    	public void setName(String name){
    		_strName = name;
    	}
     
    	public void setUnit(String unit){
    		_strUnit = unit;
    	}
     
    	public int getColumn(){
    		return _intColumn;
    	}
    }
    Dans le package com.see
    C'est la classe SeeHeader
    Elle implémente l'interface Header
    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
    package com.see;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import com.see.exceptions.HeaderException;
     
    public class SeeHeader implements Header{
    	private String _strTitle;
    	private String _strSubTitle;
    	private List<SeeParameter> _parameters;
     
    	public SeeHeader(){
    		_parameters = new ArrayList<SeeParameter>();
    	}
     
    	public void setTitle(String value){
    		_strTitle = value;
    	}
     
    	public void setSubTitle(String value){
    		_strSubTitle = value;
    	}
     
    	public void setParameters(String names, String units)  throws HeaderException {
    		/*
    		for (int i = 0 ; i < names.length() ;i++){
    		    System.out.print(names.charAt(i));
     
    		}		
    		System.out.println();
    		*/
    		int p; //Nombre de paquet présent dans la chaine
    		int nameLength = names.length();
    		int unitLength = units.length();
    		//System.out.println("Il y a "+n+" element(s) dans notre chaine");
    		p = nameLength / 13;
    		//System.out.println(p);
    		if(nameLength%13 != 0) p++;
    		//System.out.println(p);
    		//System.out.println("Il y a "+p+" paquet(s) dans notre chaine");
     
    		int i, j1, j2;
    //		String name[] = new String [p];
    		for(i=0 ; i<p ; i++){
    			j1 = i*13;
    			j2 = Math.min(j1+13,nameLength);
    			String strName = names.substring(j1 , j2).trim();
    			if (strName.length()==0){ //|| strUnit.length()==0){
    				throw new HeaderException("The parameter number "+(i+1)+" has no name!");
    			}
     
    			j1 = Math.min(j1, unitLength);
    			j2 = Math.min(j1+13, unitLength);
     
    			String strUnit = "";
    			if (j1!=j2) strUnit = units.substring(j1 , j2).trim();
     
    			SeeParameter param = new SeeParameter(strName, strUnit, i+1);
    			_parameters.add(param);
    //			name[i] = names.substring(j1 , j2);
    //			name[i] = name[i].trim();
    		}
    //		System.out.println(name[2]);
    	}
     
    	public void debugPrint() {
    		System.out.println("Title: "+_strTitle);
    		System.out.println("Subtitle: "+_strSubTitle);
     
    		for (int i=0;i<_parameters.size();i++)
    			System.out.println("Parameter ["+(i+1)+"] = "+_parameters.get(i).getFullName()+" column = "+_parameters.get(i).getColumn());
    	}
     
    	/**
             * Gets the amount of parameters
             * @return Amount of parameters
             */
    	public int getParametersCount() {
    		return _parameters.size();
    	}
     
    	public void read(List<String> strLines) throws HeaderException {
    		if (strLines.size()<4) throw new HeaderException("insufficient amount of lines!");
    		_strTitle = strLines.get(0);
    		_strSubTitle = strLines.get(1);
    		this.setParameters(strLines.get(2), strLines.get(3));
     
    	}
     
    	public SeeParameter[] getParametersList() {
    		SeeParameter[] p = _parameters.toArray(new SeeParameter[0]);
    		return p;
    	}
     
    	public SeeParameter getParameterAt(int column) {
    		// TODO Auto-generated method stub
    		return null;
    	}
     
    	@Override
    	public int getRowDataStart() {
    		return 4;
    	}
    }
    Dans le package com.see
    C'est la classe TstHeader
    Elle implémente également l'interface Header
    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
    package com.see;
     
    import java.util.List;
     
    import com.see.exceptions.HeaderException;
     
    public class TstHeader implements Header{
     
    	@Override
    	public void setParameters(String names, String units)
    			throws HeaderException {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public int getParametersCount() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
     
    	@Override
    	public void read(List<String> strLines) throws HeaderException {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public SeeParameter[] getParametersList() {
    		// TODO Auto-generated method stub
    		return null;
    	}
     
    	@Override
    	public void debugPrint() {
    		// TODO Auto-generated method stub
     
    	}
     
    	@Override
    	public SeeParameter getParameterAt(int column) {
    		// TODO Auto-generated method stub
    		return null;
    	}
     
    	@Override
    	public int getRowDataStart() {
    		return 8;
    	}
    }
    Dans le package com.see
    C'est l'interface Header
    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
    package com.see;
     
    import java.util.List;
     
    import com.see.exceptions.HeaderException;
     
    public interface Header {
    	public int getRowDataStart();
    	public void setParameters(String names, String units)  throws HeaderException;
    	public int getParametersCount();
    	public void read(List<String> strLines) throws HeaderException;
    	public SeeParameter[] getParametersList();
    	public void debugPrint();
    	public SeeParameter getParameterAt(int column);
    }
    Dans le package com.utils
    C'est la classe Sorting
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    package com.utils;
     
    public class Sorting {
    	public static void QuickIndexSort(){
     
    	}
    }

  3. #3
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    en gros ça te sort un fichier avec des données en colonnes et tu dois faire une interface pour afficher deux colonnes sous forme d'un chart. Je suppose que l'on parle d'une application en swing.
    JFreeChart est une librairie assez réputée pour ça http://www.jfree.org/jfreechart/

  4. #4
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    Dans ce fichier tu as une colonne pour chaque unité de mesure et les lignes, des relevés, qui remplisse les colonnes. En gros c'est un fichier texte qui a un formalisme genre chaque colonne fais 13 emplacements

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    Pour répondre à ta question, oui c'est une des fonctionnalités que devra faire mon interface homme machine

  6. #6
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2015
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2015
    Messages : 45
    Par défaut
    Est-ce-que tu connais des tutos que je peux suivre me permettant de me faire la main, se rapprochant au plus de ma problématique ?

    JFreeChart ça se rapproche vraiment beaucoup de ce que je recherche

    merci pour ton aide

Discussions similaires

  1. Réponses: 1
    Dernier message: 22/03/2010, 09h21
  2. Lancer une application à partir d’un fichier
    Par piet00000 dans le forum Entrée/Sortie
    Réponses: 0
    Dernier message: 10/03/2009, 13h02
  3. Gestion d’Un Msgbox dans la Fermeture d’une application
    Par hoummass dans le forum Windows Forms
    Réponses: 5
    Dernier message: 25/11/2005, 16h44
  4. Évolution d’une application existante. Quel choix ?
    Par BBerni dans le forum Décisions SGBD
    Réponses: 9
    Dernier message: 10/05/2004, 10h59

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