https://hal.archives-ouvertes.fr/hal-02177293
Raw File
Tip revision: a5c3a632ff52caf942ac0457ce1ec733926a867b authored by Software Heritage on 01 January 2004, 00:00:00 UTC
hal: Deposit 315 in collection hal
Tip revision: a5c3a63
Commun.java
/*
 * Créé le 7 juin 04
 *
 */
package syl.principal;

import java.awt.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.zip.*;

import javax.swing.*;

import fonction.magnitude.*;
import fonction.reel.*;
import fonction.similitude.*;
import fonction.tpt.*;
import fonction.type.*;

/**
 * ensemble de données et de méthodes utilisées ŕ d'uatres endroits du programme.
 * 
 * @author	Sylvain
  */
public class Commun
{	/**
	* version du programme
	 */
	public static Float VERSION = new Float(0.250); 
	/**
	* codes pour identifier les fichiers
	 */
	public static final String FICHIER_CODE_ENTREE = "Stimulation"; 
	public static final String FICHIER_CODE_OBSERVATION = "Observation"; 
	public static final String FICHIER_CODE_RESULTAT = "Résultats"; 
	public static final String FICHIER_CODE_PROJET = "Projet"; 
	public static final String FICHIER_CODE_MODELE = "Modele"; 
	public static final String FICHIER_CODE_NOEUD = "Noeud"; 
	/**
	* extensions des fichiers
	 */
	public static final String EXT_ENTREE = ".entree"; 
	public static final String EXT_OBSERVATION = ".obs"; 
	public static final String EXT_RESULTAT = ".res"; 
	public static final String EXT_PROJET = ".proj"; 
	public static final String EXT_MODELE = ".modl"; 
	public static final String EXT_NOEUD = ".noeud"; 
	public static final String EXT_BACK = ".back"; 
	/**
	* description des fichiers
	 */
	public static final String FICHIER_DESCRIPTION_ENTREE = "Fichiers d'Entrées";
	public static final String FICHIER_DESCRIPTION_OBSERVATION = "Fichiers d'Observations";
	public static final String FICHIER_DESCRIPTION_RESULTAT = "Fichiers contenant des Résultats de simulation";
	public static final String FICHIER_DESCRIPTION_PROJET = "Fichiers contenant un Projet";
	public static final String FICHIER_DESCRIPTION_MODELE = "Fichiers contenant un Modele";
	public static final String FICHIER_DESCRIPTION_NOEUD = "Fichiers contenant un Noeud";
	/**
	* description courte des fichiers
	 */
	public static final String FICHIER_TIP_ENTREE = "Fichier d'Entrée";
	public static final String FICHIER_TIP_OBSERVATION = "Fichier d'Observation";
	public static final String FICHIER_TIP_RESULTAT = "Fichier de Résultat";
	public static final String FICHIER_TIP_PROJET = "Fichier Projet";
	public static final String FICHIER_TIP_MODELE = "Fichier Modele";
	public static final String FICHIER_TIP_NOEUD = "Fichier Noeud";
	/**
	* index
	 */
	public static final int INDEX_UNIQUE = 0;
	public static final int INDEX_PILE = 0;
	public static final int INDEX_FACE = 1;
	/**
	* diverses chaines de caractčres
	 */
	public static final String STRING_VIDE = "<vide>";
	public static final String STRING_ACTIVATION = "Activation";
	public static final String STRING_EMISSION = "Émission";
	public static final String STRING_APPRENTISSAGE = "Apprentissage";
	public static final String STRING_ENTREE = "Entrée";
	public static final String STRING_ENTREES = "Entrées";
	public static final String STRING_OBSERVATION = "Observation";
	public static final String STRING_OBSERVATIONS = "Observations";
	public static final String STRING_PROJET = "Projet";
	public static final String STRING_MODELE = "Modčle";
	public static final String STRING_MODELES = "Modčles";
	public static final String STRING_NOEUD = "Noeud";
	public static final String STRING_NOEUDS = "Noeuds";
	public static final String STRING_NOEUD_ENDOGENE = "Noeud Endogčne";
	public static final String STRING_NOEUD_EXOGENE = "Noeud Exogčne";
	public static final String STRING_TPT = "TPT";
	public static final String STRING_COMPOSANTE_TPT = "Composante de TPT";
	public static final String STRING_PREFERENCE = "Préférence";
	public static final String STRING_TYPE= "Type";
	public static final String STRING_TYPES= "Types";
	public static final String STRING_PARTIE_TYPE = "Partie de Type";
	public static final String STRING_POIDS = "Poids";
	public static final String STRING_GESTIONNAIRE = "Gestionnaire";
	public static final String STRING_CHAMP_CATEGORIEL = "Champ Catégoriel";
	public static final String STRING_CHAMPS_CATEGORIELS = "Champs Catégoriels";
	public static final String STRING_SYMBOLE = "Symbole";
	public static final String STRING_SYMBOLES = "Symboles";
	public static final String STRING_DOMAINE = "Domaine";
	public static final String STRING_DOMAINES = "Domaines";
	public static final String STRING_SIMULATION = "Simulation";
	public static final String STRING_SEPARATEUR = " - ";
	public static final String STRING_INSTANT = "Instant";
	public static final String STRING_MAGNITUDE = "Magnitude";
	public static final String STRING_MOYENNE = "Moyenne";
	public static final String STRING_ECART_TYPE = "Ecart-type";
	public static final String STRING_REPERTOIRE = "Répertoire";
	public static final String STRING_EDITEUR = "Éditeur";
	public static final String STRING_REEL = "Réel";
	public static final String STRING_SIMILITUDE = "Similitude";
	public static final String STRING_MOTEUR = "Moteur";
	public static final String STRING_MOTEUR_DET = "Déterministe";
	public static final String STRING_MOTEUR_DD2 = "DD2";
	public static final String STRING_VALEUR = "Valeur";
	public static final String STRING_VALEURS = "Valeurs";
	public static final String STRING_INITIAL = "initial";
	public static final String STRING_INITIAUX = "initiaux";
	public static final String STRING_INITIALES = "initiales";
	public static final String STRING_INITIALE = "initiale";
	public static final String STRING_FONCTION = "Fonction";
	public static final String STRING_FONCTIONS = "Fonctions";
	public static final String STRING_FICHIER = "Fichier";
	public static final String STRING_FICHIERS = "Fichiers";
	public static final String STRING_OPTION = "Option";
	public static final String STRING_OPTIONS = "Options";
	public static final String STRING_ARCHETYPE = "Archétype";
	public static final String STRING_RESULTATS = "Résultats";
	public static final String STRING_RAGE = "Rage";
	public static final String STRING_AIDE = "Aide";
	public static final String STRING_SOMMAIRE = "Sommaire";
	public static final String STRING_APROPOS = "Ŕ propos";
	public static final String STRING_DOMAINE_SEPARATEUR = "x";
	public static final String STRING_NOUVEAU = "Nouveau";
	public static final String STRING_ANONYME = "Anonyme";
	public static final String STRING_RESULTAT_SEPARATEUR = "@";
	public static final String STRING_IMPORTE = "importé";
	public static final String STRING_COLLE = "collé";
	public static final String STRING_VRAI = "Vrai";
	public static final String STRING_FAUX = "Faux";
	public static final String STRING_ET = "et";
	public static final String STRING_NUMERIQUE = "Numérique"; 
	public static final String STRING_GRAPHIQUE = "Graphique"; 
	public static final String STRING_VUE = "Vue"; 
	public static final String STRING_SESSION = "Session";
	public static final String STRING_RESULTAT = "Résultat";
	public static final String STRING_PREFERENCES = "Préférences";
	public static final String STRING_X = "X";
	public static final String STRING_Y = "Y";
	public static final String STRING_COULEUR = "Couleur";
	public static final String STRING_DISTANCE = "Distance";
	public static final String STRING_CADRILLAGE = "Cadrillage";
	public static final String STRING_SIMULABLE = "Simulable";
	public static final String STRING_NONSIMULABLE = "Non-simulable";
	public static final String STRING_EDITION = "Edition";
	public static final String STRING_OUTILS = "Barre Outils";
	public static final String STRING_PLUS = "+";
	public static final String STRING_MOINS = "-";
	public static final String STRING_SLOT = "Slot";
	public static final String STRING_REFERENCE = "Référence";
	public static final String STRING_SORTIE = "Sortie";
	public static final String STRING_NOEUD_STRUCTUREL = "Noeud Structurel";
	public static final String STRING_VUE_GENERALE="Vue générale";
	public static final String STRING_SLOTS_ENTREE="Slots D'Entrée";
	public static final String STRING_SLOTS_SORTIE="Slots De Sortie";
	public static final String STRING_DONNEES="Données";
	public static final String STRING_NO_SELECTION="Pas De Sélection";
	public static final String STRING_NO_SELECTION_MODELE="Pas De Modčle Sélectionné";
	/**
	* choix de boites de dialogues
	 */
	public static final String OPTION_ECRASER_SI_PRESENT = "Écraser si présent";
	public static final String OPTION_CREER_NOEUD_SI_ABSENT= "Créer Noeud si absent";
	public static final String OPTION_CREER_REFERENCE_SI_ABSENTE = "Créer Référence si absente";
	/**
	* noms abrégés
	 */
	public static final String ABREV_CHAMP_CATEGORIEL = "CC";
	/**
	* titres de fenętres
	 */
	// divers
	public static final String TITRE_INFORMATION = "Information";
	public static final String TITRE_ERREUR = "Erreur";
	public static final String TITRE_APROPOS = "Ŕ propos de Rage";
	public static final String TITRE_PRINCIPAL = "Rage v."+Commun.VERSION; 
	// directives
	public static final String TITRE_ENTRER_STRING = "Entrez une chaîne de caractčres";
	public static final String TITRE_ENTRER_REEL = "Entrez un réel";
	public static final String TITRE_ENTRER_CHAR = "Entrez un caractčre";
	public static final String TITRE_ENTRER_ENTIER = "Entrez un entier";
	public static final String TITRE_ENTRER_BOOL = "Choisissez Vrai ou Faux";
	// fichiers
	public static final String TITRE_FICHIER_OUVRIR = "Sélectionnez le fichier ŕ ouvrir";
	public static final String TITRE_FICHIER_CREER = "Entrez le nom du fichier ŕ créer";
	public static final String TITRE_PROJET_CREER = "Entrez le nom du projet ŕ créer";
	public static final String TITRE_REPERTOIRE_OUVRIR = "Sélectionnez un répertoire";
	// états
	public static final String ETAT_COMPLET = "(0)";
	public static final String ETAT_INCOMPLET = "(X)";
	public static final String ETAT_MODIFIE = "*";
	/**
	* chemins de fichiers
	 */
	public static final String PATH_IMAGE = "/image";
	public static final String PATH_FOND = PATH_IMAGE+"/fond";
	public static final String PATH_SPLASH = PATH_FOND+"/splash.jpg";
	public static final String PATH_APROPOS = PATH_FOND+"/aPropos.jpg";
	public static final String PATH_WALLPAP = PATH_FOND+"/wallpap.jpg";
	//
	public static final String PATH_ICONE = PATH_IMAGE+"/icone";
	public static final String PATH_ICONE_RAGE = PATH_ICONE+"/rage.gif";
//	public static final String PATH_ICONE_PROJET_PT = PATH_ICONE+"/projetPt.gif";
	public static final String PATH_ICONE_PROJET = PATH_ICONE+"/projet.gif";
//	public static final String PATH_ICONE_MODELE_PT = PATH_ICONE+"/modelePt.gif";
	public static final String PATH_ICONE_MODELE = PATH_ICONE+"/modele.gif";
//	public static final String PATH_ICONE_NOEUD_PT = PATH_ICONE+"/noeudPt.gif";
	public static final String PATH_ICONE_NOEUD = PATH_ICONE+"/noeud.gif";
//	public static final String PATH_ICONE_ENTREE_PT = PATH_ICONE+"/entreePt.gif";
	public static final String PATH_ICONE_ENTREE = PATH_ICONE+"/entree.gif";
//	public static final String PATH_ICONE_OBSERVATION_PT = PATH_ICONE+"/observationPt.gif";
	public static final String PATH_ICONE_OBSERVATION = PATH_ICONE+"/observation.gif";
//	public static final String PATH_ICONE_RESULTAT_PT = PATH_ICONE+"/resultatPt.gif";
	public static final String PATH_ICONE_RESULTAT = PATH_ICONE+"/resultat.gif";
	public static final String PATH_ICONE_COUPER = PATH_ICONE+"/couper.gif";
	public static final String PATH_ICONE_COPIER = PATH_ICONE+"/copier.gif";
	public static final String PATH_ICONE_COLLER = PATH_ICONE+"/coller.gif";
	public static final String PATH_ICONE_ARBRE_AJOUTER = PATH_ICONE+"/arbreAjouter.gif";
	public static final String PATH_ICONE_ARBRE_SUPPRIMER = PATH_ICONE+"/arbreSupprimer.gif";
	public static final String PATH_ICONE_LIGNE_AJOUTER = PATH_ICONE+"/ligneAjouter.gif";
	public static final String PATH_ICONE_LIGNE_SUPPRIMER = PATH_ICONE+"/ligneSupprimer.gif";
	public static final String PATH_ICONE_NOEUD_AJOUTER = PATH_ICONE+"/noeudAjouter.gif";
	public static final String PATH_ICONE_NOEUD_SUPPRIMER = PATH_ICONE+"/noeudSupprimer.gif";

	public static final String PATH_ICONE_DEFAIRE = PATH_ICONE+"/defaire.gif";
	public static final String PATH_ICONE_REFAIRE = PATH_ICONE+"/refaire.gif";
	public static final String PATH_ICONE_SIMULER = PATH_ICONE+"/simuler.gif";
	public static final String PATH_ICONE_ENREGISTRER = PATH_ICONE+"/enregistrer.gif";
	public static final String PATH_ICONE_MOTEUR = PATH_ICONE+"/choisirMoteur.gif";
	public static final String PATH_ICONE_NORMALISER = PATH_ICONE+"/normaliser.gif";
	public static final String PATH_ICONE_EDITER = PATH_ICONE+"/editer.gif";
	public static final String PATH_ICONE_RENOMMER = PATH_ICONE+"/renommer.gif";
	public static final String PATH_ICONE_GESTIONNAIRE = PATH_ICONE+"/editerRepertoireGestionnaire.gif";
	public static final String PATH_ICONE_TREE_MODELE = PATH_ICONE+"/treeModele.gif";
	public static final String PATH_ICONE_TREE_NOEUD_END = PATH_ICONE+"/treeNoeudEndogene.gif";
	public static final String PATH_ICONE_TREE_NOEUD_EX = PATH_ICONE+"/treeNoeudExogene.gif";
	public static final String PATH_ICONE_TREE_NOEUD_STRUCT = PATH_ICONE+"/treeNoeudStructurel.gif";
	public static final String PATH_ICONE_TREE_PROJET = PATH_ICONE+"/treeProjet.gif";
	public static final String PATH_ICONE_TREE_MODELE_INC = PATH_ICONE+"/treeModeleIncomplet.gif";
	public static final String PATH_ICONE_TREE_NOEUD_END_INC = PATH_ICONE+"/treeNoeudEndogeneIncomplet.gif";
	public static final String PATH_ICONE_TREE_NOEUD_EX_INC = PATH_ICONE+"/treeNoeudExogeneIncomplet.gif";
	public static final String PATH_ICONE_TREE_NOEUD_STRUCT_INC = PATH_ICONE+"/treeNoeudStructurelIncomplet.gif";
	public static final String PATH_ICONE_TREE_PROJET_INC = PATH_ICONE+"/treeProjetIncomplet.gif";
	
	public static final String PATH_ICONE_DESACTIVE = PATH_ICONE+"/desactive.gif";
	public static final String PATH_ICONE_ACTIVE = PATH_ICONE+"/active.gif";
	public static final String PATH_ICONE_VUE_GENERALE = PATH_ICONE+"/afficherVueGenerale.gif";
	public static final String PATH_ICONE_SLOTS_ENTREE = PATH_ICONE+"/afficherSlotsEntree.gif";
	public static final String PATH_ICONE_SLOTS_SORTIE= PATH_ICONE+"/afficherSlotsSortie.gif";
	public static final String PATH_ICONE_EDITER_DONNEES= PATH_ICONE+"/editerDonnees.gif";
	public static final String PATH_ICONE_EDITER_FONCTION= PATH_ICONE+"/editerFonction.gif";
	public static final String PATH_ICONE_EDITER_FICHIER= PATH_ICONE+"/editerFichier.gif";
	public static final String PATH_ICONE_EDITER_EMISSION= PATH_ICONE+"/editerEmission.gif";
	public static final String PATH_ICONE_EDITER_ACTIVATION= PATH_ICONE+"/editerActivation.gif";
	public static final String PATH_ICONE_EDITER_APPRENTISSAGE= PATH_ICONE+"/editerApprentissage.gif";
	public static final String PATH_ICONE_EXPORTER= PATH_ICONE+"/exporter.gif";
	public static final String PATH_ICONE_AJOUTER_NOEUD_EX= PATH_ICONE+"/noeudExogeneAjouter.gif";
	public static final String PATH_ICONE_AJOUTER_NOEUD_END= PATH_ICONE+"/noeudEndogeneAjouter.gif";
	public static final String PATH_ICONE_AJOUTER_NOEUD_STRUCT= PATH_ICONE+"/noeudStructurelAjouter.gif";
	public static final String PATH_ICONE_IMPORTER= PATH_ICONE+"/importer.gif";
	public static final String PATH_ICONE_REINIT= PATH_ICONE+"/reinitialiser.gif";
	
	/**
	* actions (pour boutons ou menus)
	 */
//	 undo/redo
	public static final String ACTION_UNDO = "Défaire";
	public static final String ACTION_REDO = "Refaire";
	// boutons
	public static final String ACTION_FERMER = "Fermer";
	public static final String ACTION_CONFIRMER = "Confirmer";
	public static final String ACTION_ANNULER= "Annuler";
	public static final String ACTION_RECOMMENCER = "Recommencer";
	public static final String ACTION_QUITTER = "Quitter";
	//
	public static final String ACTION_ACTIVER = "Activer";
	public static final String ACTION_DESACTIVER = "Désactiver";
	// simulation
	public static final String ACTION_DEMARRER = "Démarrer";
	public static final String ACTION_ARRETER = "Arręter";
	// manipulation constituants
	public static final String ACTION_CREER = "Créer";
	public static final String ACTION_AJOUTER = "Ajouter";
	public static final String ACTION_SUPPRIMER = "Supprimer";
	public static final String ACTION_RETIRER = "Retirer";
	// copier/coller
	public static final String ACTION_COPIER = "Copier";
	public static final String ACTION_COUPER = "Couper";
	public static final String ACTION_COLLER = "Coller";
	// accčs fichier
	public static final String ACTION_INSERER = "Inserer";
	public static final String ACTION_IMPORTER = "Importer";
	public static final String ACTION_EXPORTER = "Exporter";
	public static final String ACTION_RENOMMER = "Renommer";
	public static final String ACTION_OUVRIR = "Ouvrir";
	public static final String ACTION_ENREGISTRER = "Enregistrer";
	public static final String ACTION_ENREGISTRER_SOUS = "Enregistrer sous...";
	public static final String ACTION_REINITIALISER = "Reinitialiser";
	// edition
	public static final String ACTION_EDITER = "Éditer";
	public static final String ACTION_SELECTIONNER = "Sélectionner";
	public static final String ACTION_NORMALISER = "Normaliser";
	// zoom
	public static final String ACTION_ZOOM_IN = "Zoom In";
	public static final String ACTION_ZOOM_OUT = "Zoom Out";	
	
	
	
	
	/**
	* Messages d'information/erreur (boites de dialogue)
	 */
	// information
	public static final String MESSAGE_SIMULATION_TERMINEE = "La Simulation est terminée";
	public static final String MESSAGE_SIMULATION_INTERROMPUE = "La Simulation a été interrompue";
	// directives
	public static final String MESSAGE_ENTRER_VALEUR = "Entrez la valeur";		
	public static final String MESSAGE_ENTRER_VALEUR_VALIDE = "Entrez une valeur valide";
	public static final String MESSAGE_CHOISIR_COULEUR = "Choisissez une couleur.";
	// condition
	public static final String MESSAGE_CONDITION_PREFERENCE = "La préférence doit ętre comprise entre";
	public static final String MESSAGE_CONDITION_VALEUR = "La valeur doit ętre comprise entre";
	public static final String MESSAGE_CONDITION_INSTANT = "L'instant doit ętre positif et unique";
	public static final String MESSAGE_CONDITION_POIDS = "Le poids doit ętre compris entre ";
	// Erreur fichier
	public static final String MESSAGE_ERREUR_FICHIER_ACCES = "Erreur lors de l'accčs au fichier";
	public static final String MESSAGE_ERREUR_FICHIER_CONTENU = "Contenu invalide dans le fichier";
	public static final String MESSAGE_ERREUR_FICHIER_INTROUVABLE = "Impossible de trouver le fichier";
	public static final String MESSAGE_ERREUR_FICHIER_VERSION = "Version incompatible pour le fichier";
	public static final String MESSAGE_ERREUR_FICHIER_TYPE = "Le fichier n'est pas du bon type";
	public static final String MESSAGE_ERREUR_FICHIER_PAS_PROJET = "Le fichier n'est pas un fichier Projet";
	public static final String MESSAGE_ERREUR_FICHIER_PAS_MODELE = "Le fichier n'est pas un fichier Modčle";
	public static final String MESSAGE_ERREUR_FICHIER_PAS_NOEUD = "Le fichier n'est pas un fichier Noeud";
	public static final String MESSAGE_ERREUR_FICHIER_PAS_ENTREE = "Le fichier n'est pas un fichier d'Entrée";
	public static final String MESSAGE_ERREUR_FICHIER_PAS_OBSERVATION = "Le fichier n'est pas un fichier d'Observation";
	public static final String MESSAGE_ERREUR_FICHIER_PAS_RESULTAT = "Le fichier n'est pas un fichier de Résultat";
	// erreur existant
	public static final String MESSAGE_ERREUR_EXISTANT_SYMBOLE = "Un Symbole de ce nom existe déjŕ dans ce Champ Categoriel";
	public static final String MESSAGE_ERREUR_EXISTANT_CHAMP_CATEGORIEL = "Un Champ Catégoriel de ce nom existe déjŕ dans ce Gestionnaire";
	public static final String MESSAGE_ERREUR_EXISTANT_NOEUD = "Un Noeud de ce nom existe déjŕ dans ce Modčle";
	public static final String MESSAGE_ERREUR_EXISTANT_MODELE = "Un Modčle de ce nom existe déjŕ dans ce Projet";
	public static final String MESSAGE_ERREUR_EXISTANT_TYPE = "Un Type de ce nom existe déjŕ dans ce Répertoire";
	public static final String MESSAGE_ERREUR_EXISTANT_ARCHETYPE = "Un Archétype de ce nom existe déjŕ dans cette TPT";
	public static final String MESSAGE_ERREUR_EXISTANT_NOEUD_NOEUDSTRUCTUREL = "Un Noeud ou un Slot de ce nom existe déjŕ dans ce Modčle";
	public static final String MESSAGE_ERREUR_EXISTANT_RESULTAT = "Ce résultat est actuellement déjŕ ouvert.";
	// erreur divers
	public static final String MESSAGE_ERREUR_INCOMPLETUDE = "Problčme d'incomplétude";
	// a propos
	public static final String MESSAGE_APROPOS = "Rage : Réseaux Artificiels ŕ Grande Échelle.\n"
		+"version "+Commun.VERSION+"\n"
		+"© 2001-2004 INSERM unité 455\n";
	/**
	* icones
	 */
	public static final ImageIcon ICONE_N_IMPORTER= getImageIconNorm(PATH_ICONE_EXPORTER);
	public static final ImageIcon ICONE_N_EXPORTER= getImageIconNorm(PATH_ICONE_IMPORTER);
	public static final ImageIcon ICONE_EDITER_EMISSION = getImageIconNorm(PATH_ICONE_EDITER_EMISSION);
	public static final ImageIcon ICONE_EDITER_ACTIVATION = getImageIconNorm(PATH_ICONE_EDITER_ACTIVATION);
	public static final ImageIcon ICONE_EDITER_APPRENTISSAGE= getImageIconNorm(PATH_ICONE_EDITER_APPRENTISSAGE);
	public static final ImageIcon ICONE_EDITER_FONCTION = getImageIconNorm(PATH_ICONE_EDITER_FONCTION);
	public static final ImageIcon ICONE_EDITER_DONNEES = getImageIconNorm(PATH_ICONE_EDITER_DONNEES);
	public static final ImageIcon ICONE_EDITER_FICHIER = getImageIconNorm(PATH_ICONE_EDITER_FICHIER);
	
	public static final ImageIcon ICONE_VUE_GENERALE = getImageIconNorm(PATH_ICONE_VUE_GENERALE);
	public static final ImageIcon ICONE_SLOTS_ENTREE = getImageIconNorm(PATH_ICONE_SLOTS_ENTREE);
	public static final ImageIcon ICONE_SLOTS_SORTIE = getImageIconNorm(PATH_ICONE_SLOTS_SORTIE);
	
	public static final ImageIcon ICONE_TREE_PROJET = getImageIconPetit(Commun.PATH_ICONE_TREE_PROJET);
	public static final ImageIcon ICONE_TREE_NOEUD_END = getImageIconPetit(Commun.PATH_ICONE_TREE_NOEUD_END);
	public static final ImageIcon ICONE_TREE_NOEUD_EX = getImageIconPetit(Commun.PATH_ICONE_TREE_NOEUD_EX);
	public static final ImageIcon ICONE_TREE_NOEUD_STRUCT = getImageIconPetit(Commun.PATH_ICONE_TREE_NOEUD_STRUCT);
	public static final ImageIcon ICONE_TREE_MODELE = getImageIconPetit(Commun.PATH_ICONE_TREE_MODELE);
	
	public static final ImageIcon ICONE_TREE_PROJET_INC = getImageIconPetit(Commun.PATH_ICONE_TREE_PROJET_INC);
	public static final ImageIcon ICONE_TREE_NOEUD_END_INC = getImageIconPetit(Commun.PATH_ICONE_TREE_NOEUD_END_INC);
	public static final ImageIcon ICONE_TREE_NOEUD_EX_INC = getImageIconPetit(Commun.PATH_ICONE_TREE_NOEUD_EX_INC);
	public static final ImageIcon ICONE_TREE_NOEUD_STRUCT_INC = getImageIconPetit(Commun.PATH_ICONE_TREE_NOEUD_STRUCT_INC);
	public static final ImageIcon ICONE_TREE_MODELE_INC = getImageIconPetit(Commun.PATH_ICONE_TREE_MODELE_INC);
	
	public static final ImageIcon ICONE_P_PROJET = getImageIconPetit(Commun.PATH_ICONE_PROJET);
	public static final ImageIcon ICONE_P_MODELE = getImageIconPetit(Commun.PATH_ICONE_MODELE);
	public static final ImageIcon ICONE_P_NOEUD = getImageIconPetit(Commun.PATH_ICONE_NOEUD);
	public static final ImageIcon ICONE_P_ENTREE = getImageIconPetit(Commun.PATH_ICONE_ENTREE);
	public static final ImageIcon ICONE_P_OBSERVATION = getImageIconPetit(Commun.PATH_ICONE_OBSERVATION);
	public static final ImageIcon ICONE_P_RESULTAT = getImageIconPetit(Commun.PATH_ICONE_RESULTAT);
	public static final ImageIcon ICONE_P_DEFAIRE = getImageIconPetit(Commun.PATH_ICONE_DEFAIRE);
	public static final ImageIcon ICONE_P_REFAIRE = getImageIconPetit(Commun.PATH_ICONE_REFAIRE);
	public static final ImageIcon ICONE_P_LIGNE_AJOUTER = getImageIconPetit(Commun.PATH_ICONE_LIGNE_AJOUTER);
	public static final ImageIcon ICONE_P_LIGNE_SUPPRIMER = getImageIconPetit(Commun.PATH_ICONE_LIGNE_SUPPRIMER);
	public static final ImageIcon ICONE_P_COLLER = getImageIconPetit(Commun.PATH_ICONE_COLLER);
	public static final ImageIcon ICONE_P_COUPER = getImageIconPetit(Commun.PATH_ICONE_COUPER);
	public static final ImageIcon ICONE_P_COPIER = getImageIconPetit(Commun.PATH_ICONE_COPIER);
	public static final ImageIcon ICONE_P_EXPORTER = getImageIconPetit(Commun.PATH_ICONE_EXPORTER);
	public static final ImageIcon ICONE_P_ARBRE_SUPPRIMER = getImageIconPetit(Commun.PATH_ICONE_ARBRE_SUPPRIMER);
	public static final ImageIcon ICONE_P_RENOMMER = getImageIconPetit(Commun.PATH_ICONE_RENOMMER);
	public static final ImageIcon ICONE_P_ENREGISTRER = getImageIconPetit(Commun.PATH_ICONE_ENREGISTRER);
	public static final ImageIcon ICONE_P_GESTIONNAIRE = getImageIconPetit(Commun.PATH_ICONE_GESTIONNAIRE);
	
	public static final ImageIcon ICONE_N_NOEUD_AJOUTER = getImageIconNorm(Commun.PATH_ICONE_NOEUD_AJOUTER);
	public static final ImageIcon ICONE_N_NOEUD_SUPPRIMER = getImageIconNorm(Commun.PATH_ICONE_NOEUD_SUPPRIMER);
	public static final ImageIcon ICONE_N_ARBRE_AJOUTER = getImageIconNorm(Commun.PATH_ICONE_ARBRE_AJOUTER);
	public static final ImageIcon ICONE_N_ARBRE_SUPPRIMER = getImageIconNorm(Commun.PATH_ICONE_ARBRE_SUPPRIMER);
	public static final ImageIcon ICONE_N_LIGNE_AJOUTER = getImageIconNorm(Commun.PATH_ICONE_LIGNE_AJOUTER);
	public static final ImageIcon ICONE_N_LIGNE_SUPPRIMER = getImageIconNorm(Commun.PATH_ICONE_LIGNE_SUPPRIMER);
	public static final ImageIcon ICONE_N_COPIER = getImageIconNorm(Commun.PATH_ICONE_COPIER);
	public static final ImageIcon ICONE_N_COUPER = getImageIconNorm(Commun.PATH_ICONE_COUPER);
	public static final ImageIcon ICONE_N_COLLER = getImageIconNorm(Commun.PATH_ICONE_COLLER);
	public static final ImageIcon ICONE_N_NORMALISER = getImageIconNorm(Commun.PATH_ICONE_NORMALISER);
	public static final ImageIcon ICONE_N_MOTEUR = getImageIconNorm(Commun.PATH_ICONE_MOTEUR);
	public static final ImageIcon ICONE_N_ENREGISTRER = getImageIconNorm(Commun.PATH_ICONE_ENREGISTRER);
	public static final ImageIcon ICONE_N_SIMULER = getImageIconNorm(Commun.PATH_ICONE_SIMULER);
	public static final ImageIcon ICONE_N_EDITER = getImageIconNorm(Commun.PATH_ICONE_EDITER);
	public static final ImageIcon ICONE_N_RENOMMER = getImageIconNorm(Commun.PATH_ICONE_RENOMMER);
	public static final ImageIcon ICONE_N_GESTIONNAIRE = getImageIconNorm(Commun.PATH_ICONE_GESTIONNAIRE);
	public static final ImageIcon ICONE_N_EDITER_ACTIVATION = getImageIconNorm(Commun.PATH_ICONE_EDITER_ACTIVATION);
	
	public static final ImageIcon ICONE_N_DESACTIVE = getImageIconNorm(Commun.PATH_ICONE_DESACTIVE);
	public static final ImageIcon ICONE_N_ACTIVE = getImageIconNorm(Commun.PATH_ICONE_ACTIVE);
	public static final ImageIcon ICONE_N_DEFAIRE = getImageIconNorm(Commun.PATH_ICONE_DEFAIRE);
	public static final ImageIcon ICONE_N_REFAIRE = getImageIconNorm(Commun.PATH_ICONE_REFAIRE);
	public static final ImageIcon ICONE_N_REINIT = getImageIconNorm(Commun.PATH_ICONE_REINIT);
	
	
	public static final ImageIcon ICONE_P_ARBRE_AJOUTER = getImageIconPetit(Commun.PATH_ICONE_ARBRE_AJOUTER);
	public static final ImageIcon ICONE_P_MOTEUR = getImageIconPetit(Commun.PATH_ICONE_MOTEUR);
	public static final ImageIcon ICONE_P_NORMALISER = getImageIconPetit(Commun.PATH_ICONE_NORMALISER);
	public static final ImageIcon ICONE_P_EDITER = getImageIconPetit(Commun.PATH_ICONE_EDITER);
	public static final ImageIcon ICONE_P_AJOUTER_NOEUD_EX = getImageIconPetit(Commun.PATH_ICONE_AJOUTER_NOEUD_EX);
	public static final ImageIcon ICONE_P_AJOUTER_NOEUD_END = getImageIconPetit(Commun.PATH_ICONE_AJOUTER_NOEUD_END);
	public static final ImageIcon ICONE_P_AJOUTER_NOEUD_STRUCT= getImageIconPetit(Commun.PATH_ICONE_AJOUTER_NOEUD_STRUCT);
	/**
	* liste des fonctions existantes
	 */
	public static final Vector VECTOR_IFF_MAGNITUDE = initVectorIFF(InterfaceFonctionFilsMagnitude.class); 
	public static final Vector VECTOR_IFF_REEL = initVectorIFF(InterfaceFonctionFilsReel.class); 
	public static final Vector VECTOR_IFF_SIMILITUDE = initVectorIFF(InterfaceFonctionFilsSimilitude.class); 
	public static final Vector VECTOR_IFF_TPT = initVectorIFF(InterfaceFonctionFilsTPT.class); 
	public static final Vector VECTOR_IFF_TYPE = initVectorIFF(InterfaceFonctionFilsType.class); 
	
//	----------------------------------------	
//	Constructeurs
//	----------------------------------------
	/**
	 * crée cette boite ŕ outil commune.
	 * Méthode susceptible de réaliser certaines initialisations.
	 * 
	  */
	public Commun()
	{
	}
	
//	----------------------------------------	
//	Méthodes communes
//	----------------------------------------
	/**
	 * détermine et renvoie toutes les classes fonctions existantes, pour une interface passée en paramčtre.
	 *
	 * @param	inter	 interface dont on veut toutes les classes fonctions l'implémentant. Par exemple InterfaceFonctionFilsMagnitude permettra d'obtenir la liste de toutes les fonctions renvoyant une Magnitude.
	 * @return	un vecteur de Classes implémentant cette interfaces.
	  */
	public static Vector initVectorIFF(Class inter)
	{	Vector resultat = new Vector();

		try
		{	
			// init du nom du répertoire
			String packageName = inter.getPackage().getName();
			String interName = inter.getName();
			String filename = "/"+interName.replace('.','/')+".class";

			// on tente de localiser le package
			URL url = Commun.class.getResource(filename);
//System.out.println(url);
			File repertoire;
			URI uri = null;
			try
			{	uri = new URI(url.toString());
			}
			catch (URISyntaxException e2)
			{	e2.printStackTrace();
			} 

			// pas compressé ? on peut travailler dans le répertoire
			if (!uri.isOpaque())
			{	File[] list;
				int k;
				Class c;
		
				repertoire = new File(uri).getParentFile();
				// on liste les fichiers du dossier package
				list = repertoire.listFiles();
				// on regarde si le nom de fichier finit par .class
				for(k = 0; k<list.length; k++)
				{	String name = list[k].getName();
					if (name.endsWith(".class"))
					{	//on récupčre la classe
						try
						{	c = Class.forName(packageName+"."+name.substring(0, name.length()-6));
							//on teste si :
							// 1) elle implemente l'interface
							// 2) elle n'est pas elle-męme une interface
							// 3) elle n'est pas abstraite
							if (inter.isAssignableFrom(c) 
								&& !c.isInterface() 
								&& !Modifier.isAbstract(c.getModifiers()))
							{	// on l'ajoute aux résultats
								resultat.add(c);
							}
						}
						catch (ClassNotFoundException e)
						{	 e.printStackTrace();
						}
					}
				}
			}

			// compressé ? il faut parcourir l'archive
			else
			{	filename = packageName.replace('.','/');
				ZipFile zf;
				// d'abord on localise l'archive
				url = Commun.class.getProtectionDomain().getCodeSource().getLocation();
				try
				{	uri = new URI(url.toString());
				}
				catch (URISyntaxException e3)
				{	e3.printStackTrace();
				}
				
				// pui on l'ouvre
				File fZip = new File(uri);	
				zf = new ZipFile(fZip, ZipFile.OPEN_READ);
	
				// on cherche tout ce qui commence pareil que le répertoire/package
				ZipEntry entry;
				FileOutputStream fos;
				Enumeration entries = zf.entries();
				String entryName;
				Class c;
	
				while(entries.hasMoreElements())
				{	entry = (ZipEntry)entries.nextElement();
					entryName = entry.getName();
	        
					if(entryName.startsWith(filename))
					{	if (entryName.endsWith(".class"))
						{	//tu loades la classe
							try
							{	String className = entryName.replace('/','.');
								className = className.substring(0, className.length()-6);
								c = Class.forName(className);
								// męme traitement que plus haut
								if (inter.isAssignableFrom(c) && !c.isInterface() && !Modifier.isAbstract(c.getModifiers()))
								{	// et voila
									resultat.add(c);
								}
							}
							catch (ClassNotFoundException e)
							{	e.printStackTrace();
							}
						}
					}
				}
				zf.close();
				zf=null;
			}
		}
		catch (IOException e1)
		{	e1.printStackTrace();
		}
		
		// on renvoie le résultat
	  	return resultat;
	}
	/**
	 * duplique un fichier 'src' vers un emplacement 'dst'.
	 *
	 * @param	src	 le fichier source.
	 * @param	dst	 le path/fichier destination.
	 * @throws	IOException	si une erreur de fichier survient lors de la copie.
	  */
	public static void copierFichier(File src, File dst) throws IOException
	{	
		InputStream in = null;
		OutputStream out = null;
		try
		{	in = new FileInputStream(src);
			out = new FileOutputStream(dst);
		
			// Transfer bytes from in to out
			byte[] buf = new byte[1024];
			int len;
			while ((len = in.read(buf)) > 0) {
				out.write(buf, 0, len);
			}
			in.close();
			out.close();
		}
		catch (IOException e)
		{	if (in != null)
				in.close();
			if (out != null)
				out.close();
			throw e;			
		}
	}
	/**
	 * normalise un nom de fichier, c'est ŕ dire qu'on remplace tout caractčre
	 * interdit (ou susceptible de l'ętre) dans un nom de fichier par le 
	 * caractčre '_', et qu'on renvoie le résultat.
	 *
	 * @param	ancien	nom ŕ traiter.
	 * @return	le nom débarassé des caractčres interdits.
	  */
	public static String normaliserNomFichier(String ancien)
	{	String nouveau = ancien;

		// d'abord on vire les éventuels espaces au début
		while (nouveau.startsWith(" "))
			nouveau = nouveau.substring(1);

		// et ŕ la fin
		while (nouveau.endsWith(" "))
			nouveau = nouveau.substring(0,nouveau.length()-1);
		
		// puis les caractčres spéciaux
		nouveau = nouveau.replace(':','_'); 
		nouveau = nouveau.replace('/','_'); 
		nouveau = nouveau.replace('\\','_'); 
		nouveau = nouveau.replace('~','_'); 
		nouveau = nouveau.replace('*','_'); 
		nouveau = nouveau.replace('?','_'); 
		
		return nouveau;
	}
	/**
	 * renvoie la partie 'extension' d'un nom de fichier.
	 *
	 * @param	fichier	fichier ŕ traiter.
	 * @return	l'extension du fichier.
	  */
	public static String getExtensionFichier(File fichier)
	{	String resultat = null;
		String s = fichier.getName();
		
		int i = s.lastIndexOf('.');

		if (i > 0 &&  i < s.length() - 1)
			resultat = s.substring(i).toLowerCase();
		
		return resultat;
	}
	/**
	 * renvoie une ImageIcon construite grâce ŕ l'image trouvée ŕ l'emplacement spécifié en paramčtre.
	 *
	 * @param	path	chemin du fichier contenant l'image.
	 * @return	un ImageIcon construit sur ce fichier.
	  */
	public static ImageIcon getImageIcon(String path)
	{	java.net.URL imgURL = Commun.class.getResource(path);
		return new ImageIcon(imgURL);
	}
	/**
	 * renvoie une ImageIcon construite grâce ŕ l'image trouvée ŕ l'emplacement spécifié en paramčtre.
	 * L'image est automatiquement redimensionnée ŕ une taille de 16x16 pixels si elle est trop grande.
	 *
	 * @param	path	chemin du fichier contenant l'image.
	 * @return	un ImageIcon de taille 24x24 pixels, construit sur ce fichier.
	  */
	public static ImageIcon getImageIconNorm(String path)
	{	java.net.URL imgURL = Commun.class.getResource(path);
		ImageIcon resultat = new ImageIcon(imgURL);
		Image i = resultat.getImage().getScaledInstance(24,24,Image.SCALE_FAST);		
		resultat.setImage(i);
		return resultat;
	}
	
	/**
	 * renvoie une ImageIcon construite grâce ŕ l'image trouvée ŕ l'emplacement spécifié en paramčtre.
	 * L'image est automatiquement redimensionnée ŕ une taille de 16x16 pixels si elle est trop grande.
	 *
	 * @param	path	chemin du fichier contenant l'image.
	 * @return	un ImageIcon de taille 16x16 pixels, construit sur ce fichier.
	  */
	public static ImageIcon getImageIconPetit(String path)
	{	java.net.URL imgURL = Commun.class.getResource(path);
		ImageIcon resultat = new ImageIcon(imgURL);
		Image i = resultat.getImage().getScaledInstance(16,16,Image.SCALE_FAST);		
		resultat.setImage(i);
		return resultat;
	}
}
back to top