https://hal.archives-ouvertes.fr/hal-02177293
Tip revision: a5c3a632ff52caf942ac0457ce1ec733926a867b authored by Software Heritage on 01 January 2004, 00:00:00 UTC
hal: Deposit 315 in collection hal
hal: Deposit 315 in collection hal
Tip revision: a5c3a63
AbstractSectionInformation.java
/*
* Crťť le 17 aoŻt 2004
*
*/
package traitement.section;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Vector;
import fichier.ContenuFichierIncompatibleException;
import fichier.TypeFichierIncompatibleException;
import fichier.VersionFichierIncompatibleException;
import fichier.flux.RageInputStream;
import principal.Commun;
import principal.copiercoller.InterfaceCopiable;
import principal.copiercoller.Tampon;
import information.DomaineIncompatibleException;
import information.InformationEvent;
import information.InformationIncompleteException;
import information.InformationListener;
import information.InterfaceInformation;
import information.domaine.InterfaceContientDomaine;
import information.domaine.InterfaceDomaine;
import information.magnitude.InterfaceContientMagnitude;
import information.magnitude.Magnitude;
import information.magnitude.VectorMagnitude;
import information.reference.InterfaceChampCategoriel;
import information.type.InterfaceContientType;
import information.type.Type;
import information.type.VectorType;
import resultat.vue.VueMagnitude;
import resultat.vue.VueType;
import traitement.TraitementAdapter;
import traitement.TraitementEvent;
import traitement.TraitementIncompletException;
import traitement.TraitementListener;
import traitement.modele.Modele;
import traitement.noeud.fonctionnel.AbstractNoeudFonctionnelPlein;
/**
* base des constituants des Noeuds.
* Ce type de Section est utilisť pour gťrer les parties d'activation d'un NoeudFonctionnelEndogene ou
* les parties d'ťmission d'un NoeudFonctionnelEndogene ou d'un NoeudFonctionnelExogene.
* Une AbstractSectionInformation possŤde son propre Domaine, et des historiques de Magnitudes et de Types
* sous la forme d'un VectorMagnitude et d'un VectorType.
* A noter que la gestion de l'apprentissage et des TPT se fait via une SectionApprentissage.
*
* @author Vincent Labatut
* @version 1
* @see traitement.noeud.fonctionnel.NoeudFonctionnelEndogene
* @see traitement.noeud.fonctionnel.NoeudFonctionnelExogene
* @see traitement.section.SectionApprentissage
*/
public abstract class AbstractSectionInformation extends TraitementAdapter implements InterfaceSection, InterfaceContientMagnitude, InterfaceContientType, InterfaceContientDomaine, InformationListener, TraitementListener
{ /**
* Domaine de cette AbstractSectionInformation.
*/
protected InterfaceDomaine domaine;
/**
* Historique des Magnitudes.
*/
protected VectorMagnitude vectorMagnitude;
/**
* Historique des Types.
*/
protected VectorType vectorType;
/**
* InterfaceNoeudFonctionnel parent de cette AbstractSectionInformation.
*/
protected AbstractNoeudFonctionnelPlein parent;
/**
* Liste des TraitementListeners qui ťcoutent cette AbstractSectionInformation.
*/
protected Vector vectorTraitementListener;
/**
* Rťpertoire contenant les rťsultats de la simulation.
*/
protected File repertoireSimulation;
/**
* la Vue associťe aux Types de cette Section.
*/
protected VueType vueType;
/**
* la Vue associťe aux Magnitudes de cette Section.
*/
protected VueMagnitude vueMagnitude;
/**
* indique si cet objet a ťtť modifť depuis sa derniŤre sauvegarde.
*/
protected boolean modifie;
// ----------------------------------------
// HistoriqueMagnitude
// ----------------------------------------
/*
*
*/
public Magnitude getMagnitude(int instant)
{ if (instant<0)
return vectorMagnitude.getMagnitude(0);
else
return vectorMagnitude.getMagnitude(instant);
}
/**
* renvoie la Magnitude initiale.
*
* @return la Magnitude initiale.
*/
public Magnitude getMagnitudeInitiale()
{ return getMagnitude(0);
}
/**
* rajoute une Magnitude dans l'historique.
* Emission de TraitementEvents de raffraichissement et de complťtude.
*
* @param magnitude la Magnitude ŗ rajouter.
*/
public void addMagnitude(Magnitude magnitude)
{ vectorMagnitude.addMagnitude(magnitude);
magnitude.setParent(this);
setModifie();
fireTraitementRaffr(new TraitementEvent(this));
}
/**
* remplace, dans l'historique, la Magnitude
* de l'instant spťcifiť, par la Magnitude passťe en paramŤtre.
* Si aucune Magnitude n'existe ŗ l'instant spťcifiť, la Magnitude est simplement rajoutťe.
* Emission de TraitementEvents de raffraichissement et de complťtude.
*
* @param instant de la substitution.
* @param magnitude la Magnitude ŗ substituer.
*/
public void setMagnitude(int instant, Magnitude magnitude)
{ if (vectorMagnitude.size()>instant)
{ vectorMagnitude.getMagnitude(instant).remove();
vectorMagnitude.setMagnitude(instant,magnitude);
magnitude.setParent(this);
}
else
addMagnitude(magnitude);
setModifie();
fireTraitementRaffr(new TraitementEvent(this));
}
/**
* remplace la Magnitude initiale
* par la Magnitude passťe en paramŤtre.
*
* @param magnitude la Magnitude ŗ substituer.
*/
public void setMagnitudeInitiale(Magnitude magnitude)
{ getMagnitudeInitiale().removeInformationListener(this);
setMagnitude(0,magnitude);
magnitude.addInformationListener(this);
}
// ----------------------------------------
// HistoriqueType
// ----------------------------------------
/*
*
*/
public Type getType(int instant)
{ if (instant<0)
return vectorType.getType(0);
else
return vectorType.getType(instant);
}
/**
* renvoie le Type initial.
*
* @return le Type initial.
*/
public Type getTypeInitial()
{ return getType(0);
}
/**
* rajoute un Type dans l'historique.
* Emission de TraitementEvents de raffraichissement et de complťtude.
*
* @param type le Type ŗ rajouter.
* @throws DomaineIncompatibleException si le Domaine du Type est
* incompatible avec celui de cette AbstractSectionInformation.
*/
public void addType(Type type) throws DomaineIncompatibleException
{ if (domaine.estCompatibleDomaine(type.getDomaine()))
{ vectorType.addType(type);
type.setParent(this);
}
else
throw new DomaineIncompatibleException(getIdentification()+":"+type.getIdentification());
setModifie();
fireTraitementRaffr(new TraitementEvent(this));
}
/**
* remplace, dans l'historique, le Type
* de l'instant spťcifiť, par le Type passťe en paramŤtre.
* Si aucun Type n'existe ŗ l'instant spťcifiť, le Type est simplement rajoutť.
* Emission de TraitementEvents de raffraichissement et de complťtude.
*
* @param instant de la substitution.
* @param type le Type ŗ substituer.
* @throws DomaineIncompatibleException si le Domaine du Type est
* incompatible avec celui de cette AbstractSectionInformation.
*/
public void setType(int instant, Type type) throws DomaineIncompatibleException
{ if (domaine.estCompatibleDomaine(type.getDomaine()))
if (vectorType.size()>instant)
if (domaine.estCompatibleDomaine(type.getDomaine()))
{ getType(instant).remove();
vectorType.setType(instant,type);
type.setParent(this);
}
else
addType(type);
else
throw new DomaineIncompatibleException(getIdentification()+":"+type.getIdentification());
setModifie();
fireTraitementRaffr(new TraitementEvent(this));
}
/**
* remplace le Type initial
* par le Type passť en paramŤtre.
*
* @param type le Type ŗ substituer.
* @throws DomaineIncompatibleException si le Domaine du Type est
* incompatible avec celui de cette AbstractSectionInformation.
*/
public void setTypeInitial(Type type) throws DomaineIncompatibleException
{ getTypeInitial().removeInformationListener(this);
setType(0,type);
type.addInformationListener(this);
}
// ----------------------------------------
// Domaine
// ----------------------------------------
/*
*
*/
public InterfaceDomaine getDomaine()
{ return domaine;
}
/**
* remplace le Domaine de cette AbstractSectionInformation par celui passť
* en paramŤtre. L'ancien Domaine apparenant ŗ cette AbstractSectionInformation,
* il n'est pas nťcessaire de le remplacer vťritablement : ce sont ses ChampCategoriels
* qui sont ťchangťs, et les listeners du Domaine s'adaptent tous seuls.
* En consťquence, le nouveau Domaine est une copie de celui passť en paramŤtre.
* Un TraitementEvent de raffraichissement est indirectemet ťmis, puisque cette
* AbstractSectionInformation ťcoute son Domaine, qui va lui-mÍme ťmettre un ťvŤnement.
*
* @param d le nouveau Domaine de cette AbstractSectionInformation.
*/
public void setDomaine(InterfaceDomaine d)
{ // pour chaque CC du nouveau Domaine
for (int i=0;i<d.size();i++)
{ InterfaceChampCategoriel cc2 = d.getChampCategoriel(i);
// si pas de CC correspondant ds ancien Domaine : on rajoute
if (domaine.size()<=i)
addChampCategoriel(cc2);
// si CC correspondant : on ťcrase si l'ancien CC est diffťrent du nouveau ou vide
else
{ InterfaceChampCategoriel cc1 = domaine.getChampCategoriel(i);
try
{ if (!cc1.egaleChampCategoriel(cc2) || cc1.getModele()!=(cc2.getModele()))
setChampCategoriel(i,cc2);
}
catch (InformationIncompleteException e)
{ // cc1 ou cc2 est vide
setChampCategoriel(i,cc2);
}
}
}
// on vire tout les vieux CC qui dťpasseraient
while (domaine.size()>d.size())
removeChampCategoriel(domaine.size()-1);
}
// ----------------------------------------
// ChampCategoriel
// ----------------------------------------
/**
* ajoute un ChampCategoriel dans le Domaine de cette AbstractSectionInformation.
*
* @param cc ChampCategoriel ŗ ajouter au Domaine.
*/
public void addChampCategoriel(InterfaceChampCategoriel cc)
{ domaine.addChampCategoriel(cc);
}
/**
* insŤre un ChampCategoriel dans le Domaine de cette AbstractSectionInformation, au rang spťcifiť.
*
* @param rang rang oý insťrer le ChampCategoriel.
* @param cc ChampCategoriel ŗ ajouter au Domaine.
*/
public void addChampCategoriel(int rang, InterfaceChampCategoriel cc)
{ domaine.addChampCategoriel(rang, cc);
}
/**
* remplace, dans le Domaine de cette AbstractSectionInformation, le ChampCategoriel
* de rang 'rang' par le ChampCategoriel passť en paramŤtre.
*
* @param rang rang ChampCategoriel ŗ remplacer.
* @param cc ChampCategoriel ŗ substituer dans le Domaine.
*/
public void setChampCategoriel(int rang, InterfaceChampCategoriel cc)
{ domaine.setChampCategoriel(rang, cc);
}
/**
* supprime un ChampCategoriel dans le Domaine de cette AbstractSectionInformation, au rang spťcifiť.
*
* @param rang rang du ChampCategoriel ŗ supprimer.
*/
public void removeChampCategoriel(int rang)
{ domaine.removeChampCategoriel(rang);
}
// ----------------------------------------
// Parent
// ----------------------------------------
/**
* renvoie l'InterfaceNoeudFonctionnel parent de cette AbstractSectionInformation.
*
* @return l'InterfaceNoeudFonctionnel parent.
*/
public AbstractNoeudFonctionnelPlein getParent()
{ return parent;
}
/**
* modifie l'InterfaceNoeudFonctionnel parent de cette AbstractSectionInformation.
* Ceci peut provenir d'un changement de Modele, donc cette action est
* propagťe aux fils de cette AbstractSectionInformation.
*
* @param n le nouvel InterfaceNoeudFonctionnel parent de cette AbstractSectionInformation.
*/
public void setParent(AbstractNoeudFonctionnelPlein n)
{ parent = n;
//
domaine.setParent(this);
//
for (int i=0;i<vectorMagnitude.size();i++)
vectorMagnitude.getMagnitude(i).setParent(this);
for (int i=0;i<vectorType.size();i++)
vectorType.getType(i).setParent(this);
}
// ----------------------------------------
// Tampon
// ----------------------------------------
/**
* renvoie le Tampon du Projet auquel appartient indirectemlent cette AbstractSectionInformation.
*
* @return le Tampon du Projet.
*/
public Tampon getTampon()
{ Tampon resultat = null;
resultat = parent.getTampon();
return resultat;
}
// ----------------------------------------
// Fichier
// ----------------------------------------
/**
* renvoie le rťpertoire qui contiendra
* les rťsultats de la simulation.
*
* @return le rťpertoire contenant les rťsultats de la simulation.
*/
public File getRepertoireSimulation()
{ return repertoireSimulation;
}
/**
* modifie le rťpertoire de simulation.
*
* @param repertoire nouveau rťpertoire de simulation.
*/
public void setRepertoireSimulation(File repertoire)
{ repertoireSimulation = repertoire;
}
// ----------------------------------------
// Modele
// ----------------------------------------
/*
*
*/
public Modele getModele()
{ Modele resultat = null;
resultat = parent.getModele();
return resultat;
}
// ----------------------------------------
// This
// ----------------------------------------
/*
*
*/
public abstract void remove();
// ----------------------------------------
// InterfaceTraitement
// ----------------------------------------
/*
*
*/
public void addTraitementListener(TraitementListener i)
{ vectorTraitementListener.add(i);
}
/*
*
*/
public void removeTraitementListener(TraitementListener i)
{ vectorTraitementListener.remove(i);
}
/**
* annonce la suppression de cette AbstractSectionInformation.
* Chaque TraitementListener doit se supprimer lui-mÍme de la liste des listeners de cette AbstractSectionInformation.
*
* @param e le TraitementEvent qui est ťmis vers les TraitementListeners.
*/
protected void fireTraitementSuppr(TraitementEvent e)
{
while (vectorTraitementListener.size()!=0)
try
{ ((TraitementListener) vectorTraitementListener.get(0)).traitementSuppr(e);
}
catch (TraitementIncompletException e1)
{ e1.printStackTrace();
}
}
/**
* annonce une modification d'un des constituants de cette AbstractSectionInformation.
* Ceci ne concerne pas les historiques.
*
* @param e le TraitementEvent qui est ťmis vers les TraitementListeners.
*/
protected void fireTraitementEltModif(TraitementEvent e)
{
for (int i=0;i<vectorTraitementListener.size();i++)
try
{ ((TraitementListener) vectorTraitementListener.get(i)).traitementEltModif(e);
}
catch (TraitementIncompletException e1)
{ e1.printStackTrace();
}
}
/**
* annonce un raffraichissement de cette AbstractSectionInformation.
*
* @param e le TraitementEvent qui est ťmis vers les TraitementListeners.
*/
protected void fireTraitementRaffr(TraitementEvent e)
{
for (int i=0;i<vectorTraitementListener.size();i++)
try
{ ((TraitementListener) vectorTraitementListener.get(i)).traitementRaffr(e);
}
catch (TraitementIncompletException e1)
{ e1.printStackTrace();
}
}
/**
* annonce un ťchange.
*
* @param e l'TraitementEvent qui est ťmis vers les TraitementListeners.
*/
protected void fireTraitementRempl(TraitementEvent e)
{ for (int i=0;i<vectorTraitementListener.size();i++)
try
{ ((TraitementListener) vectorTraitementListener.get(i)).traitementRempl(e);
}
catch (TraitementIncompletException e1)
{ e1.printStackTrace();
}
}
/**
* annonce un masquage.
*
* @param e l'TraitementEvent qui est ťmis vers les TraitementListeners.
*/
protected void fireTraitementCache(TraitementEvent e)
{ for (int i=0;i<vectorTraitementListener.size();i++)
try
{ ((TraitementListener) vectorTraitementListener.get(i)).traitementCache(e);
}
catch (TraitementIncompletException e1)
{ e1.printStackTrace();
}
}
/**
* annonce qu'un Modele rťalise une itťration de simulation.
* Inutile ici.
*
* @param e le TraitementEvent qui est ťmis vers les TraitementListeners.
*/
protected void fireTraitementSimulation(TraitementEvent e)
{ for (int i=0;i<vectorTraitementListener.size();i++)
try
{ ((TraitementListener) vectorTraitementListener.get(i)).traitementSimulation(e);
}
catch (TraitementIncompletException e1)
{ e1.printStackTrace();
}
}
// ----------------------------------------
// InformationListener
// ----------------------------------------
/*
*
*/
public void informationSuppr(InformationEvent e)
{
}
/*
* appelťe lors de la rťception d'un InformationEvent de modification de constituant.
* Cette AbstractSectionInformation ťcoute ses Types et Magnitudes initiaux,
* ainsi que son Domaine.
* Le Type ou le Domaine peuvent ťmettre ce type d'InformationEvent.
* Ils dťclenchent alors l'ťmission d'un TraitementEvent de raffraichissement.
*/
public void informationEltModif(InformationEvent e)
{ setModifie();
fireTraitementRaffr(new TraitementEvent(this));
}
/*
* appelťe lors de la rťception d'un InformationEvent de raffraichissement.
* Cette AbstractSectionInformation ťcoute ses Types et Magnitudes initiaux,
* ainsi que son Domaine.
* On lŤve un TraitementEvent de raffraichissement
*/
public void informationRaffr(InformationEvent e)
{ if (e.getSource().estModifie())
{ setModifie();
fireTraitementRaffr(new TraitementEvent(this));
}
}
/*
* appelťe lors de la rťception d'un InformationEvent de remplacement.
* Cette AbstractSectionInformation ťcoute ses Types et Magnitudes initiaux,
* ainsi que son Domaine.
* mťthode inutile ici.
*/
public void informationRempl(InformationEvent e) throws InformationIncompleteException
{
}
/*
* appelťe lors de la rťception d'un InformationEvent de masquage.
* Cette AbstractSectionInformation ťcoute ses Types et Magnitudes initiaux,
* ainsi que son Domaine.
* mťthode inutile ici.
*/
public void informationCache(InformationEvent e) throws InformationIncompleteException
{
}
/*
* appelťe lors de la rťception d'un InformationEvent de changement de Modele.
* Cette AbstractSectionInformation ťcoute ses Types et Magnitudes initiaux,
* ainsi que son Domaine.
* Cela peut concerner un Type ou une Magnitude. Dans les deux cas, on remplace
* l'information par une nouvelle information neutre.
*/
public void informationChangementModele(InformationEvent e)
{ InterfaceInformation temp = (InterfaceInformation)e.getSource();
try
{ if (temp.getModele() != getModele())
{ temp.removeInformationListener(this);
if (temp instanceof Type)
{ vectorType.setType(0,new Type(this));
getTypeInitial().addInformationListener(this);
}
else if (temp instanceof Magnitude)
{ vectorMagnitude.setMagnitude(0,new Magnitude(this));
getMagnitudeInitiale().addInformationListener(this);
}
}
}
catch (InformationIncompleteException e1)
{ e1.printStackTrace();
}
}
// ----------------------------------------
// InterfaceContientType
// ----------------------------------------
/*
*
*/
public int indexOfType(Type type)
{ return vectorType.indexOfObjet(type);
}
// ----------------------------------------
// InterfaceContientMagnitude
// ----------------------------------------
/*
*
*/
public int indexOfMagnitude(Magnitude magnitude)
{ return vectorMagnitude.indexOfObjet(magnitude);
}
// ----------------------------------------
// Simulation
// ----------------------------------------
/*
* dťtermine si cette AbstractSectionInformation est complŤtement dťfinie.
* Cette mťthode est appellťe juste avant la simulation.
* Une AbstractSectionInformation est complete si son domaine est complet
* et si ses historiques contiennent au moins
* un ťlťment chacun, et que ces ťlťments sont complets.
*/
public boolean estComplet()
{ boolean resultat = true;
if (!domaine.estComplet())
resultat = false;
else if (vectorMagnitude.size()==0 || vectorType.size()==0)
resultat = false;
else if (!vectorMagnitude.estComplet() || !vectorType.estComplet())
resultat = false;
return resultat;
}
// ----------------------------------------
// Copier/Coller/Undo
// ----------------------------------------
/*
* renvoie une copie de cette AbstractSectionInformation.
* La nouvelle AbstractSectionInformation a le mÍme parent que cette AbstractSectionInformation,
* mais c'est temporaire : la copie est destinťe ŗ
* Ítre insťrťe dans un autre Noeud.
* Les historiques et le Domaine qui composent la copie doivent Ítre des copies
* de celles de cette AbstractSectionInformation.
* De plus, le Domaine doit Ítre clonť en premier.
*/
public abstract AbstractSectionInformation cloner();
/*
*
*/
public void copier()
{ getTampon().set(this);
}
/*
*
*/
public boolean estCollable()
{ boolean resultat = true;
Tampon tampon = getModele().getTampon();
if (tampon.estVide())
resultat = false;
else
{ InterfaceCopiable buffer = tampon.get();
if (buffer instanceof Type)
{ if (domaine.estCompatibleDomaine(((Type)buffer).getDomaine()))
resultat = true;
else
resultat = false;
}
else if (buffer instanceof Magnitude)
{ resultat = true;
}
else
resultat = false;
}
return resultat;
}
// ----------------------------------------
// Divers
// ----------------------------------------
/*
*
*/
public abstract String toString();
/**
* ouvre le fichier de donnťes prťcťdemment enregistrť par cette Section suite
* ŗ une simulation, et met les donnťes dans l'historique.
*
* @throws VersionFichierIncompatibleException si le fichier n'a pas ťtť gťnťrť par une version de Rage compatible avec cette version-ci.
* @throws TypeFichierIncompatibleException si le fichier qu'on tente d'ouvrir n'est pas un fichier de rťsultats.
* @throws ContenuFichierIncompatibleException si le contenu du fichier est erronť.
* @throws IOException si une erreur survient lors de l'accŤs au fichier.
* @throws ClassNotFoundException si une erreur survient lors de l'accŤs au fichier.
* @throws InformationIncompleteException si le fichier contient des informations incomplŤtes.
* @throws TraitementIncompletException si le fichier contient des traitements incomplets.
*/
public void recupererResultat() throws VersionFichierIncompatibleException, TypeFichierIncompatibleException, ContenuFichierIncompatibleException, IOException, ClassNotFoundException, InformationIncompleteException, TraitementIncompletException
{ // on ouvre les rťsultats de Type
File fichier = new File
( getRepertoireSimulation().getPath()
+"-"+Commun.STRING_TYPE
+Commun.EXT_RESULTAT);
FileInputStream in = new FileInputStream(fichier);
RageInputStream inputStream = new RageInputStream(in, true, true);
// on rťcupŤre la version du fichier
Float version = (Float)inputStream.readObject();
if (version.compareTo(Commun.VERSION)>0)
throw new VersionFichierIncompatibleException(fichier.getPath());
// on rťcupŤre le type de fichier
String typeFichier = (String)inputStream.readObject();
if (!typeFichier.equals(Commun.FICHIER_CODE_RESULTAT))
throw new TypeFichierIncompatibleException(fichier.getPath());
// le Domaine d'activation
InterfaceDomaine dom;
dom = inputStream.readDomaineComplexe(this);
if (!dom.egaleDomaine(domaine))
throw new ContenuFichierIncompatibleException(fichier.getPath());
// on n'a plus besoin de ce Domaine, il ne sert que pour le test.
dom.remove();
// la taille du Vector ŗ ťcrire
int taille = ((Integer)inputStream.readObject()).intValue();
// et enfin chaque information
for (int i=1;i<taille;i++)
try
{ Type tempType = inputStream.readType(this);
if (!tempType.getDomaine().egaleDomaine(domaine))
throw new ContenuFichierIncompatibleException(fichier.getPath());
// if (!tempType.estComplet())
// throw new ContenuFichierIncompatibleException();
addType(tempType);
}
catch (InformationIncompleteException e)
{ e.printStackTrace();
throw new ContenuFichierIncompatibleException(fichier.getPath());
}
catch (DomaineIncompatibleException e)
{ throw new ContenuFichierIncompatibleException(fichier.getPath());
}
// on referme le fichier
in.close();
// on ouvre les rťsultats de Magnitude
fichier = new File
( getRepertoireSimulation().getPath()
+"-"+Commun.STRING_MAGNITUDE
+Commun.EXT_RESULTAT);
in = new FileInputStream(fichier);
inputStream = new RageInputStream(in,true,true);
// on rťcupŤre la version du fichier
//Object o = inputStream.readObject();
version = (Float)inputStream.readObject();
if (version.compareTo(Commun.VERSION)>0)
throw new VersionFichierIncompatibleException(fichier.getPath());
// on rťcupŤre le type de fichier
typeFichier = (String)inputStream.readObject();
if (!typeFichier.equals(Commun.FICHIER_CODE_RESULTAT))
throw new TypeFichierIncompatibleException(fichier.getPath());
// la taille du Vector ŗ ťcrire
taille = ((Integer)inputStream.readObject()).intValue();
// et enfin chaque information
for (int i=1;i<taille;i++)
{ Magnitude tempMagnitude = inputStream.readMagnitude(this);
addMagnitude(tempMagnitude);
}
// on referme le fichier
in.close();
}
/**
* renvoie la vue permettant ŗ la GUI d'avoir accŤs aux Types de cette Section.
* Si la vue n'existe pas encore, elle est crťťe.
*
* @return la Vue des Types de cette Section.
*/
public VueType getVueType()
{ if (vueType == null)
vueType = new VueType(this,vectorType);
return vueType;
}
/**
* renvoie la vue permettant ŗ la GUI d'avoir accŤs aux Magnitudes de cette Section.
* Si la vue n'existe pas encore, elle est crťťe.
*
* @return la Vue des Magnitudes de cette Section.
*/
public VueMagnitude getVueMagnitude()
{ if (vueMagnitude == null)
vueMagnitude = new VueMagnitude(this,vectorMagnitude);
return vueMagnitude;
}
/**
* supprime toutes les valeurs des historiques, sauf les valeurs initiales.
* Cette mťthode est utilisťe pour interrompre/finaliser une simulation.
*
*/
public void effacerHistorique()
{ // on supprime toutes les valeurs sauf l'initiale
while (vectorType.size()>1)
{ vectorType.getType(1).remove();
vectorType.removeType(1);
}
while (vectorMagnitude.size()>1)
{ vectorMagnitude.getMagnitude(1).remove();
vectorMagnitude.removeMagnitude(1);
}
}
// ----------------------------------------
// Modification
// ----------------------------------------
/**
* met ŗ true l'indicateur de modification.
*
*/
public void setModifie()
{ modifie = true;
}
/**
* indique si cet Objet a besoin ou pas d'Ítre sauvegardť
* (dans le sens enregistrť dans un fichier).
*
* @return vrai si cet Objet a ťtť modifiť depuis le dernier enregistrement.
*
*/
public boolean estModifie()
{ return modifie;
}
/**
* renvoie l'indicateur indiquant si un Noeud nťcessaire
* mais absent doit Ítre crťť.
*
* @return l'indicateur.
*/
public boolean getCreerNoeudSiAbsent()
{ return getParent().getCreerNoeudSiAbsent();
}
}