From: <de...@us...> - 2012-11-09 08:19:27
|
Revision: 7863 http://fudaa.svn.sourceforge.net/fudaa/?rev=7863&view=rev Author: deniger Date: 2012-11-09 08:19:19 +0000 (Fri, 09 Nov 2012) Log Message: ----------- Modified Paths: -------------- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGraphePersist.java trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheTreeModel.java Added Paths: ----------- trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/XstreamCustomizer.java Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGraphePersist.java =================================================================== --- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGraphePersist.java 2012-11-06 17:03:01 UTC (rev 7862) +++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGraphePersist.java 2012-11-09 08:19:19 UTC (rev 7863) @@ -28,6 +28,7 @@ import org.fudaa.ctulu.gui.CtuluLibSwing; import org.fudaa.ctulu.gui.CtuluUIDialog; import org.fudaa.ebli.commun.EbliLib; +import org.fudaa.ebli.commun.XstreamCustomizer; /** * Classe qui se charge de rendre persistant les donn\xE9es des graphes en xml. @@ -35,7 +36,7 @@ * @author Adrien Hadoux */ public class EGGraphePersist { - + private static final String PANEL = "Panel:"; /** * Path du repertoire dans lequel seront enregistr\xE9 toute les courbes, groupes et model... @@ -46,11 +47,11 @@ private static String SPECIFIQUEFILE = "specificDatas.xml"; private static String COURBEDIRECTORY = "COURBES"; CtuluAnalyze log = new CtuluAnalyze(); - + public EGGraphePersist(String directoryPath_) throws IOException { this.directoryPath_ = directoryPath_; } - + private File getBinFileForCurve(int i) { return new File(getDirectoryCurves(), i + ".bin"); } @@ -99,7 +100,7 @@ private String getMainFilePath() { return directoryPath_ + File.separator + MAINFILE; } - + private String getPanelFilePath() { return directoryPath_ + File.separator + MAINFILE; } @@ -136,7 +137,7 @@ while (list.size() != 0) { list.remove(0); } - + } /** @@ -160,11 +161,11 @@ // creates the list of curves: List<EGCourbePersist> persistCurves = new ArrayList<EGCourbePersist>(); List<EGCourbe> persistedCurves = new ArrayList<EGCourbe>(); - + List<EGGroupPersist> listeGroupePersistance = new ArrayList<EGGroupPersist>(grapheTopersist.getModel().getNbEGObject()); int nbEgObjects = grapheTopersist.getModel().getNbEGObject(); int idxGroup = 0; - int idxCurve=0; + int idxCurve = 0; Map<EGCourbe, Integer> idByCurve = new HashMap<EGCourbe, Integer>(); Map<EGGroup, Integer> groupIdx = new HashMap<EGGroup, Integer>(); for (int egObjectIdx = 0; egObjectIdx < nbEgObjects; egObjectIdx++) { @@ -176,23 +177,23 @@ EGGroupPersistBuilder<EGGroup> persistBuilder = groupe.createPersistBuilder(); EGGroupPersist persist = persistBuilder.persistObject(groupe, grapheTopersist, null); persist.setIdx(idxGroup++); - int groupId=persist.getIdx(); + int groupId = persist.getIdx(); listeGroupePersistance.add(persist); EGObject[] childs = groupe.getEGChilds(); for (int k = 0; k < childs.length; k++) { if (childs[k] instanceof EGCourbeChild) { // -- ajout de la courbe persitante dans un fichier avec pour groupee le i eme EGCourbeChild courbeChild = (EGCourbeChild) childs[k]; - persistCurves.add(createPersist(courbeChild, groupId, grapheTopersist,idxCurve)); - idByCurve.put(courbeChild,idxCurve); + persistCurves.add(createPersist(courbeChild, groupId, grapheTopersist, idxCurve)); + idByCurve.put(courbeChild, idxCurve); idxCurve++; persistedCurves.add(courbeChild); } } } else if (objet instanceof EGCourbeChild) { // le groupe d appartenance est -1 - persistCurves.add(createPersist((EGCourbeChild) objet, -1, grapheTopersist,idxCurve)); - idByCurve.put((EGCourbeChild) objet,idxCurve); + persistCurves.add(createPersist((EGCourbeChild) objet, -1, grapheTopersist, idxCurve)); + idByCurve.put((EGCourbeChild) objet, idxCurve); idxCurve++; persistedCurves.add((EGCourbeChild) objet); } @@ -206,7 +207,7 @@ persistCurves.get(i).surfacePainter = builder.build(egCourbe.getSurfacePainter(), idByCurve); } savedCurves.add(persistCurves.get(i)); - + } // --on enregistre des infos bidons pour l'utilisateur --// out.writeObject(PANEL + graphePanelClass); @@ -261,18 +262,18 @@ } finally { CtuluLibFile.close(out); } - + } - + @SuppressWarnings("unchecked") - private EGCourbePersist createPersist(EGCourbeChild egCourbeChild, int groupIdx, EGGraphe grapheTopersist,int courbeUniqueId) { + private EGCourbePersist createPersist(EGCourbeChild egCourbeChild, int groupIdx, EGGraphe grapheTopersist, int courbeUniqueId) { EGCourbePersistBuilder<EGCourbeChild> builder = (EGCourbePersistBuilder<EGCourbeChild>) egCourbeChild.createPersistBuilder(); EGCourbePersist courbePersist = builder.persistObject(egCourbeChild, grapheTopersist, getBinFileForCurve(courbeUniqueId)); courbePersist.setId(courbeUniqueId); courbePersist.setIdgroup(groupIdx); return courbePersist; } - + private static TIntArrayList getGroupIdxInMap(Map<EGGroup, Integer> groupIdx, List<EGObject> list) { TIntArrayList idx = new TIntArrayList(list.size()); for (EGObject o : list) { @@ -284,8 +285,7 @@ } /** - * Genere une instance de model par rapport au model serializ\xE9. Renvoie forc\xE9ment une class implements EGGrapheTreeModel sinon - * null + * Genere une instance de model par rapport au model serializ\xE9. Renvoie forc\xE9ment une class implements EGGrapheTreeModel sinon null * * @param className * @return @@ -308,12 +308,12 @@ if (myModel == null) { myModel = new EGGrapheTreeModel(); } - + if (myModel instanceof EGGrapheTreeModel) { return (EGGrapheTreeModel) myModel; } return null; - + } Map<String, EGGroupPersistBuilder> cacheGroupBuilder = new HashMap<String, EGGroupPersistBuilder>(); Map<String, EGCourbePersistBuilder> cacheCurveBuilder = new HashMap<String, EGCourbePersistBuilder>(); @@ -344,16 +344,16 @@ // --lecture biddon --// graphePanelClass = (String) in.readObject(); in.readObject(); - + boolean doHorizontalRezoom = false; // - Etape 1: lecture de l'axe --// EGAxeHorizontalPersist axeHorizontalPersist = (EGAxeHorizontalPersist) in.readObject(); - + if (axeHorizontalPersist.range == null) { doHorizontalRezoom = true; } - + EGAxeHorizontal axeX = axeHorizontalPersist.generateAxe(); // - Etape 2: lecture du modele --// @@ -365,11 +365,11 @@ int nbGroups = in.readInt(); Map<Integer, EGGroup> groupIdx = new HashMap<Integer, EGGroup>(); Set<EGGroup> groupToRefresh = new HashSet<EGGroup>(); - + for (int i = 0; i < nbGroups; i++) { // -- lecture du groupe --// EGGroupPersist groupPersist = (EGGroupPersist) in.readObject(); - + EGGroupPersistBuilder<EGGroup> builder = getGroupBuilder(groupPersist); Map groupParam = new HashMap(); if (parameters != null) { @@ -393,7 +393,7 @@ } catch (EOFException eof) { } catch (Exception e) { FuLog.error(e); - + } // -- Etape 4: lecture des courbes --// @@ -403,7 +403,7 @@ List<EGCourbe> restoredCurves = new ArrayList<EGCourbe>(); for (EGCourbePersist cbPersist : listeCourbesPersistantes) { EGGroup container = model.getGroup(cbPersist.Idgroup); - + if (container != null) { EGCourbePersistBuilder<? extends EGCourbeChild> builder = getCourbeBuilder(cbPersist); if (builder != null) { @@ -413,7 +413,7 @@ } courbeParameters.put(EGCourbePersistBuilder.GROUPE_KEY, container); EGCourbeChild newCurve = builder.restoreObject(cbPersist, courbeParameters, log, getBinFileForCurve(cbPersist.getId())); - if(newCurve==null){ + if (newCurve == null) { continue; } if (cbPersist.getId() >= 0) { @@ -440,7 +440,7 @@ } catch (Exception e) { ((List<String>) parameters.get("errorMsg")).add("Erreur, la tentative de finalisation des donn\xE9es du graphe a \xE9chou\xE9 "); ((List<String>) parameters.get("errorMsg")).add("Cette erreur est peut \xEAtre due \xE0 une incompatibilit\xE9 des variables pour un rejoue de donn\xE9es."); - + } // -- Etape finale: creation du graphe --// graphe = new EGGraphe(model); @@ -460,7 +460,7 @@ axeToMerge.add(groupIdx.get(Integer.valueOf(idxs[i])).getAxeY()); } graphe.mergeAxis(axeToMerge.toArray(new EGAxeVertical[axeToMerge.size()]), merge.getPersist().generateAxe()); - + } } // mise a jour des b\xE9b\xE9s @@ -477,13 +477,17 @@ try { // -- inputstream du xstream pour chargement des diff\xE9rents groupes--// in = EbliLib.createObjectInpuStream(new File(getSpecifiqueDataFilePath()), parser); + XstreamCustomizer customizer = (XstreamCustomizer) parameters.get(XstreamCustomizer.PARAMETER_ID); + if (customizer != null) { + customizer.configureXstream(parser); + } // -- lecture des donn\xE9es specifiques --// Object specifiquesDatas = in.readObject(); // -- remplissage du modele avec les donn\xE9es persistantes --// graphe.getModel().setSpecificPersitDatas(specifiquesDatas, parameters); - + } catch (IOException e) { FuLog.error(e); } finally { @@ -508,12 +512,12 @@ } catch (Exception e) { FuLog.error(e); } - + } - + return new EGFillePanel(graphe); } - + @SuppressWarnings("unchecked") private EGGroupPersistBuilder<EGGroup> getGroupBuilder(EGGroupPersist groupPersist) { String builderClass = groupPersist.builderClass; @@ -535,7 +539,7 @@ } return builder; } - + @SuppressWarnings("unchecked") private EGCourbePersistBuilder<? extends EGCourbeChild> getCourbeBuilder(EGCourbePersist courbePersist) { String builderClass = courbePersist.builderClass; @@ -557,7 +561,7 @@ } return builder; } - + public static void addEGAxeHorizontalPersistCompatibilityConfiguration(XStream parser) { parser.aliasAttribute(EGAxeHorizontalPersist.class, "range", "minMax"); } Modified: trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheTreeModel.java =================================================================== --- trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheTreeModel.java 2012-11-06 17:03:01 UTC (rev 7862) +++ trunk/framework/ebli-1d/src/main/java/org/fudaa/ebli/courbe/EGGrapheTreeModel.java 2012-11-09 08:19:19 UTC (rev 7863) @@ -80,11 +80,10 @@ } } - class CommandAddCourbe implements CtuluCommand { + public class CommandAddCourbe implements CtuluCommand { EGCourbeChild c_; int idx_; - EGGroup parentGroup_; public CommandAddCourbe(final EGCourbeChild _c) { @@ -97,7 +96,7 @@ @Override public void redo() { parentGroup_.addEGComponent(c_, idx_); - nodesWereInserted(parentGroup_, new int[] { parentGroup_.getChildCount() - 1 }); + nodesWereInserted(parentGroup_, new int[]{parentGroup_.getChildCount() - 1}); // fullRepaint(); selectPath(c_); @@ -107,16 +106,15 @@ public void undo() { final int i = parentGroup_.getIndex(c_); parentGroup_.removeEGComponent(c_); - nodesWereRemoved(parentGroup_, new int[] { i }, new Object[] { c_ }); + nodesWereRemoved(parentGroup_, new int[]{i}, new Object[]{c_}); // fullRepaint(); selectPath(parentGroup_); } } - class CommandAddCourbes implements CtuluCommand { + public class CommandAddCourbes implements CtuluCommand { final EGCourbeChild[] c_; - final EGGroup parentGroup_; public CommandAddCourbes(final EGCourbeChild[] _c) { @@ -151,7 +149,6 @@ final List curveCopied_; final List curveToCopy_; - final EGGroup groupDest_; public CommandCourbeCopie(final EGGroup _dest, final List _courbeToCopy, final List _curveCopied) { @@ -180,7 +177,6 @@ class CommandCourbeMove implements CtuluCommand { Map curveOldGroup_; - EGGroup groupDest_; public CommandCourbeMove(final EGGroup _dest, final Map _curveOldGroup) { @@ -231,9 +227,11 @@ } public EGGroup getGroup(final int _i) { - if (components_.size() > _i) + if (components_.size() > _i) { return (EGGroup) components_.get(_i); - else return null; + } else { + return null; + } } protected void setDispatcher(final EGParent.Tree _dispatcher) { @@ -403,7 +401,6 @@ @Override public void paintIcon(final Component _c, final Graphics _g, final int _x, final int _y) { - } } @@ -435,10 +432,9 @@ } } - protected class CommandAddCourbesMulti implements CtuluCommand { + public class CommandAddCourbesMulti implements CtuluCommand { final EGCourbeChild[] c_; - final EGGroup[] parentGroup_; public CommandAddCourbesMulti(final EGCourbeChild[] _c, final EGGroup[] _parentGroup) { @@ -531,9 +527,7 @@ } } } - EGAxeHorizontal axeX_; - TreeSelectionModel selectionModel_; public EGGrapheTreeModel() { @@ -604,7 +598,7 @@ if (_c == null) { return; } - nodesWereInserted(_c.getParentGroup(), new int[] { _c.getParentGroup().getChildCount() - 1 }); + nodesWereInserted(_c.getParentGroup(), new int[]{_c.getParentGroup().getChildCount() - 1}); // fullRepaint(); selectPath(_c); if (_mng != null) { @@ -705,7 +699,7 @@ /** * n'envoie pas d'evt. - * + * * @param _g le groupe a ajouter */ public void add(final EGGroup _g) { @@ -860,7 +854,7 @@ /** * methode qui demande a l user de choisir sa courbe puis genere une copie avec la source en cours. - * + * * @param _child * @return */ @@ -907,7 +901,6 @@ internFireCourbeChanged(_o); fireCourbeAspectChanged(_o, _visibility, listenerList); } - protected boolean blockEvents_; @Override @@ -1066,7 +1059,6 @@ groupeMoved(_o); } } - boolean isUpdating; @Override @@ -1220,7 +1212,6 @@ @Override public void setSpecificPersitDatas(Object sepcPersitData, Map Params) { - } @Override @@ -1229,11 +1220,10 @@ } /** - * Methode qui est appelee apres avoir charg\xE9 un model de graphe persistant. Doit etre surcharg\xE9 a plus haut niveau - * pour effectuer des actions de finalisation specifiques. + * Methode qui est appelee apres avoir charg\xE9 un model de graphe persistant. Doit etre surcharg\xE9 a plus haut niveau pour effectuer des actions de + * finalisation specifiques. */ public void finalizePersistance() { - } /** @@ -1250,5 +1240,4 @@ public void setUpdating(boolean isUpdating) { this.isUpdating = isUpdating; } - } \ No newline at end of file Added: trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/XstreamCustomizer.java =================================================================== --- trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/XstreamCustomizer.java (rev 0) +++ trunk/framework/ebli-common/src/main/java/org/fudaa/ebli/commun/XstreamCustomizer.java 2012-11-09 08:19:19 UTC (rev 7863) @@ -0,0 +1,17 @@ +/* + GPL 2 + */ +package org.fudaa.ebli.commun; + +import com.thoughtworks.xstream.XStream; + +/** + * + * @author Frederic Deniger + */ +public interface XstreamCustomizer { + + String PARAMETER_ID = "parameterId"; + + void configureXstream(XStream xstream); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |