Ajout des fichiers restants

This commit is contained in:
Olivier DOSSMANN
2008-06-04 12:03:04 +02:00
parent 48ff5f7c7a
commit 6dc3725ec8
30 changed files with 10484 additions and 0 deletions

View File

@ -0,0 +1,52 @@
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Element.java
// @ Date : 20/01/2008
// @ Author :
//
//
package Documents;
public abstract class Element {
public int reference;
public int coefficient = 0;
public String annotation="";
public Section Conteneur = null;
public String type;
public int getNiveau() {
if(this.Conteneur == null) {
return 0;
}
else {
return this.Conteneur.getNiveau()+1;
}
}
public abstract int getOrdre();
public abstract int getPoids();
public abstract Element GetChild(int ind);
public abstract String afficher();
public String getAnnotation() {
return this.annotation;
}
public void setAnnotation(String ann) {
this.annotation = ann;
}
public int getCoeff() { return this.coefficient; }
public void setCoeff(int co) { this.coefficient = co; }
}

View File

@ -0,0 +1,54 @@
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Figure.java
// @ Date : 20/01/2008
// @ Author :
//
//
package Documents;
public class Figure extends Element {
public int hauteur;
public String legende;
public int largeur;
public Figure(int ID, int haut, int larg, String lgd) {
this.hauteur = haut;
this.reference = ID;
this.largeur = larg;
this.legende = lgd;
this.type = "figure";
}
public String getLegende() {
return this.legende;
}
public int getOrdre() {
return this.Conteneur.Elements.indexOf(this);
}
public int getPoids() {
return this.largeur*this.hauteur+legende.length();
}
public Element GetChild(int i) {
return null;
}
public String afficher() {
String rep = "Element N°" + this.reference;
rep+= '\n' + "Contenu par N°: " + this.Conteneur.reference;
rep += '\n' + "Hauteur: "+this.hauteur + " Largeur: "+this.largeur;
rep += '\n' + "Legende: "+this.legende;
rep+= '\n' + "Annotation: " + this.annotation + " Coef:" + this.coefficient;
rep += '\n' + "Poids: " + this.getPoids() + " Lv: " + this.getNiveau() + '\n';
return rep;
}
}

View File

@ -0,0 +1,86 @@
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Section.java
// @ Date : 20/01/2008
// @ Author :
//
//
package Documents;
import java.util.ArrayList;
public class Section extends Element {
public String titre;
public ArrayList<Element> Elements;
public Section(int ID, String title) {
this.titre = title;
this.reference = ID;
this.Elements = new ArrayList<Element>();
this.type = "section";
}
public void addElement(Element el) {
el.Conteneur = this;
Elements.add(el);
}
public void removeElement(Element el) {
Elements.remove(el);
}
public int getOrdre() {
if(this.Conteneur == null) {
return 1;
}
else {
return this.Conteneur.Elements.indexOf(this);
}
}
public int getPoids() {
int poids = 0;
for(int i = 0; i<Elements.size();i++){
poids+= Elements.get(i).getPoids();
}
return poids;
}
public Element GetChild(int indice) {
if(Elements.size() != 0) {
return Elements.get(indice);
}
else {
return null;
}
}
public String afficher() {
String rep="Element N°" + this.reference + ": " + this.type + " Titre: " + this.titre;
if(this.Conteneur != null)
{ rep+= '\n' + "Contenu par N°: " + this.Conteneur.reference; }
rep += '\n' + "Contient " + this.Elements.size() + " Elements";
rep+= '\n' + "Annotation: " + this.annotation + " Coef:" + this.coefficient;
rep += '\n' + "Poids: " + this.getPoids() + " Lv: " + this.getNiveau() + '\n';
return rep;
}
public String afficherFils() {
String rep="Element N°" + this.reference + ": " + this.type + " Titre: " + this.titre;
if(this.Conteneur != null)
{ rep+= '\n' + "Contenu par N°: " + this.Conteneur.reference; }
rep += '\n' + "Contient " + this.Elements.size() + " Elements";
rep+= '\n' + "Annotation: " + this.annotation + " Coef:" + this.coefficient;
rep += '\n' + "Poids: " + this.getPoids() + " Lv: " + this.getNiveau();
for(int i = 0; i< this.Elements.size() && !this.Elements.isEmpty() ; i++)
{
rep += '\n' + this.Elements.get(i).afficher() + '\n';
}
return rep;
}
}

View File

@ -0,0 +1,59 @@
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Texte.java
// @ Date : 20/01/2008
// @ Author :
//
//
package Documents;
public class Texte extends Element {
public String txt;
public String auteur;
public Texte(int ID, String text, String aut) {
this.reference=ID;
this.txt = text;
this.auteur = aut;
this.type = "texte";
}
public String getTxt() {
return this.txt;
}
public void ModifyTxt(String newt) {
this.txt=newt;
}
public int getOrdre() {
return this.Conteneur.Elements.indexOf(this);
}
public int getPoids() {
return this.txt.length();
}
public Element GetChild(int indice) {
return null;
}
public String afficher() {
String rep = "Element N°" + this.reference;
rep+= '\n' + "Contenu par N°: " + this.Conteneur.reference;
rep += '\n'+"Auteur:" + this.auteur;
rep+= '\n' + this.txt;
rep+= '\n' + "Annotation: " + this.annotation + " Coef:" + this.coefficient;
rep += '\n' + "Poids: " + this.getPoids() + " Lv: " + this.getNiveau() + '\n';
return rep;
}
}

View File

@ -0,0 +1,63 @@
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Fabrique.java
// @ Date : 20/01/2008
// @ Author :
//
//
package Gestion;
import java.util.ArrayList;
public class Fabrique {
public int nextID = 1;
public ArrayList<Documents.Element> documents;
private static Fabrique INSTANCE = null;
private Fabrique() {
this.documents = new ArrayList<Documents.Element>();
}
public static Fabrique getInstance() {
if(INSTANCE == null) {
INSTANCE = new Fabrique(); }
return INSTANCE;
}
public Documents.Element getElement(int ref) {
return documents.get(ref-1);
}
public Documents.Texte CreateElem(String text, String auteur) {
int oldID = this.nextID;
this.nextID++;
Documents.Texte txt = new Documents.Texte(oldID,text,auteur);
this.documents.add(txt);
return txt;
}
public Documents.Figure CreateElem( int haut, int larg, String legende) {
int oldID = this.nextID;
this.nextID++;
Documents.Figure fig = new Documents.Figure(oldID,haut,larg,legende);
this.documents.add(fig);
return fig;
}
public Documents.Section CreateElem( String titre) {
int oldID = this.nextID;
this.nextID++;
Documents.Section sec = new Documents.Section(oldID,titre);
this.documents.add(sec);
return sec;
}
public void ajouterElem(Documents.Element e) {
this.documents.add(e);
}
}

320
G54/G54/IHM/IHM_Acteur.java Normal file
View File

@ -0,0 +1,320 @@
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : IHM_Acteur.java
// @ Date : 20/01/2008
// @ Author :
//
//
package IHM;
import Documents.Element;
import java.io.*;
public class IHM_Acteur {
public Gestion.Fabrique gestionnaire = Gestion.Fabrique.getInstance();
public void AfficherDoc() {
int ref = 0;
System.out.println("Entrez le numero du document à afficher:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try {ref = new Integer(bfr.readLine());}
catch(IOException e) {e.printStackTrace();}
try{
Documents.Section doc = (Documents.Section) gestionnaire.getElement(ref);
System.out.println(doc.afficherFils());}
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");}
}
public Documents.Element getDocument() {
int ref = 0;
System.out.println("Entrez le numero du document:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try {ref = new Integer(bfr.readLine());}
catch(IOException e) {e.printStackTrace();}
try{return gestionnaire.getElement(ref);}
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");}
return null;
}
public void listeDocuments() {
for(int j = 0;j<30;j++)
{System.out.println("");}
for(int i = 1; i < gestionnaire.documents.size();i++)
{
Element e = gestionnaire.getElement(i);
if(e instanceof Documents.Section)
{
if(e.getNiveau() == 0)
System.out.println(e.afficher());
}
}
try{new BufferedReader(new InputStreamReader(System.in)).readLine();}
catch(IOException e) {}
}
public void noter() {
int ref = 0;
System.out.println("Entrez le numero du document à noter:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try {ref = new Integer(bfr.readLine());}
catch(IOException e) {e.printStackTrace();}
try{
Element el = gestionnaire.getElement(ref);
System.out.println("Entrez la note:");
try {int note = new Integer(bfr.readLine());
el.setCoeff(note);
}
catch(IOException e) {System.out.println("La note entrée n'est pas correcte!");}
}
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");
}
}
public void annoter() {
int ref = 0;
System.out.println("Entrez le numero du document à noter:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try {ref = new Integer(bfr.readLine());}
catch(IOException e) {e.printStackTrace();}
try{
Element el = gestionnaire.getElement(ref);
System.out.println("Entrez l'annotation:");
try {
String annot = bfr.readLine();
el.setAnnotation(annot);
}
catch(IOException e) {System.out.println("Entrée incorrecte!");}
}
catch(IndexOutOfBoundsException e) {System.out.println("Element inexistant!");
}
}
public void creerDocument() {
System.out.println("Entrez le titre du document :");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String titre="";
try {
/** Lecture d'une ligne : */
titre = bfr.readLine();
this.gestionnaire.CreateElem(titre);
} catch( IOException e ) {System.out.println("Titre incorrect");}
}
public void supprimerDocument() {
Documents.Element el = this.getDocument();
System.out.println("Selectionnez le document cible ****");
Documents.Element cbl = this.getDocument();
if(cbl instanceof Documents.Section)
{
Documents.Section sec = (Documents.Section) cbl;
sec.addElement(el);
el.Conteneur.removeElement(el);
}
else
{
System.out.println("L'element cible n'est pas une section");
}
}
public int identifier() {
int rep = 1;
System.out.println("Pour vous logguer en tant que redacteur, entrez votre code de 3 lettres:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String code="";
try {
/** Lecture d'une ligne : */
code = bfr.readLine();
} catch( IOException e ) {e.printStackTrace();}
if(code.equals("RED"))
{rep = 2;}
else if (code.equals("FIN"))
{rep = 3;}
return rep;
}
public static void main(String[] args){
IHM_Acteur ihm = new IHM_Acteur();
jeuDeDonnees(ihm);
int type = ihm.identifier();
while(type != 3)
{
if(type == 1)
{ ihmLecteur(ihm);}
else
{ihmRedacteur(ihm);}
type= ihm.identifier();
}
}
public static void ihmLecteur(IHM_Acteur ihm)
{
String ligne = "";
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
while(!(ligne.equals("FIN")))
{
menuLec();
try {
System.out.println("Entrez votre choix: ");
ligne = bfr.readLine();
}catch( IOException e ) {e.printStackTrace();}
int choix = new Integer(ligne);
switch(choix) {
case 1: ihm.listeDocuments(); break;
case 2: ihm.AfficherDoc(); break;
case 3: ihm.annoter(); break;
case 4: ihm.noter(); break;
case 5: ligne = "FIN"; break;
}
}
}
public void creerElement(IHM_Acteur ihm)
{
String ligne ="";
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
menuElem();
try {
System.out.println("Entrez votre choix: ");
ligne = bfr.readLine();
}catch( IOException e ) {e.printStackTrace();}
int choix = new Integer(ligne);
switch(choix) {
case 1: ihm.listeDocuments(); break;
case 2: ihm.creerSection(); break;
case 3: ihm.creerTexte(); break;
case 4: ihm.creerImage(); break;
case 5: ligne = "FIN"; break;
}
}
public static void ihmRedacteur(IHM_Acteur ihm)
{
String ligne = "";
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
while(!ligne.equals("FIN"))
{
menuRed();
try {
System.out.println("Entrez votre choix:");
ligne = bfr.readLine();
int choix = new Integer(ligne);
switch(choix) {
case 1: ihm.listeDocuments(); break;
case 2: ihm.AfficherDoc(); break;
case 3: ihm.creerDocument(); break;
case 4: ihm.creerElement(ihm); break;
case 5: ihm.supprimerDocument(); break;
case 6: ligne = "FIN"; break;
}
}catch( IOException e ) {e.printStackTrace();}
}
}
public void creerSection() {
Documents.Section el = (Documents.Section) this.getDocument();
System.out.println("Entrez le titre de la section à ajouter:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try{String titre = bfr.readLine();
Documents.Section sec= this.gestionnaire.CreateElem(titre);
if(sec == null)
{return;}
el.addElement(sec);}
catch(IOException e) {System.out.println("Pas bien!");}
}
public void creerTexte() {
Documents.Section el = (Documents.Section) this.getDocument();
System.out.println("Entrez l'auteur du texte:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try{String auteur = bfr.readLine();
System.out.println("Saisissez le texte:");
String texte = bfr.readLine();
Documents.Texte txt= this.gestionnaire.CreateElem(texte, auteur);
if(txt == null)
{return;}
el.addElement(txt);}
catch(IOException e) {System.out.println("Pas bien!");}
}
public void creerImage() {
Documents.Section el = (Documents.Section) this.getDocument();
System.out.println("Entrez la legende de l'image:");
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
try{String legende = bfr.readLine();
System.out.println("Saisissez la hauteur:");
String hauteur = bfr.readLine();
String largeur = bfr.readLine();
Documents.Figure img= this.gestionnaire.CreateElem(new Integer(hauteur),new Integer(largeur), legende);
if(img == null)
{return;}
el.addElement(img);}
catch(IOException e) {System.out.println("Pas bien!");}
catch(NumberFormatException nfe) {System.out.println("Faut ecrire des chiffres hein...");}
}
public static void menuLec() {
System.out.println("1: Lister les documents");
System.out.println("2: Afficher un document");
System.out.println("3: Annoter un document");
System.out.println("4: Noter un document");
System.out.println("5: Se déconnecter");
}
public static void menuRed() {
System.out.println("1: Lister les documents");
System.out.println("2: Afficher un document");
System.out.println("3: Créer un document");
System.out.println("4: Créer un element et l'ajouter");
System.out.println("5: Deplacer un element");
System.out.println("6: Se déconnecter");
}
public static void menuElem() {
System.out.println("1: Lister les documents");
System.out.println("2: Créer et ajouter une section");
System.out.println("3: Créer et ajouter un texte");
System.out.println("4: Créer et ajouter une image");
System.out.println("5: Revenir au menu");
}
/**
**/
public static void jeuDeDonnees(IHM_Acteur ihm){
/* Creation du document */
Documents.Section el = ihm.gestionnaire.CreateElem("Chasse à la mouche");
/* Creation d'une section */
Documents.Section el2 = ihm.gestionnaire.CreateElem("Chapitre 1");
el.addElement(el2);
/* Ajout de texte */
el2.addElement(ihm.gestionnaire.CreateElem("Prenez un morceau de tissu vaudoux fraîchement récupéré d'un cadavre.","DOSSMANN"));
/* Ajout d'image */
el2.addElement(ihm.gestionnaire.CreateElem(150,150,"Image d'un cadavre vaudoux"));
Documents.Section el3 = ihm.gestionnaire.CreateElem("Chapitre 2");
el.addElement(el3);
el3.addElement(ihm.gestionnaire.CreateElem("Trouvez une mouche"));
Documents.Section el4 = ihm.gestionnaire.CreateElem("Chapitre 3");
el.addElement(el4);
el4.addElement(ihm.gestionnaire.CreateElem("Lancez le tissu vaudoux au dessus de la mouche et patientez que la mouche vienne se loger dans le tissu, après quoi le tissu prend pleine possession de ladite mouche.","LEVAL"));
/* Création d'un autre document */
Documents.Section doc = ihm.gestionnaire.CreateElem("Javana Split");
Documents.Section doc2 = ihm.gestionnaire.CreateElem("Chapitre 1");
doc.addElement(doc2);
doc2.addElement(ihm.gestionnaire.CreateElem("Faites une application Java, lancez, cela plante ! Beau Javana Split que nous avons là !","DIVOUX"));
}
}