From: <de...@us...> - 2008-08-18 14:10:45
|
Revision: 3823 http://fudaa.svn.sourceforge.net/fudaa/?rev=3823&view=rev Author: deniger Date: 2008-08-18 14:10:54 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeChild.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSimple.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSurfacePainter.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphe.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheModel.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheTreeModel.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGroup.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGRepere.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheDuplicator.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -244,7 +244,7 @@ protected abstract EGParent getEGParent(); - public abstract EGCourbe duplicate(); + public abstract EGCourbe duplicate(EGParent newParent,EGGrapheDuplicator _duplicator); protected Font getFont() { return font_; Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeChild.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeChild.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeChild.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -14,7 +14,8 @@ import com.memoire.fu.FuLog; /** - * Cette Courbe suppose que tous les x du mod\xE8le sont rang\xE9es dans l'ordre croissant. + * Cette Courbe suppose que tous les x du mod\xE8le sont rang\xE9es dans l'ordre + * croissant. * * @author deniger * @version $Id: EGCourbeChild.java,v 1.8 2007-05-04 13:49:41 deniger Exp $ @@ -31,9 +32,6 @@ super(_model); parent_ = _m; } - - - boolean setYaxe(final EGAxeVertical _v) { FuLog.warning(new Throwable()); @@ -83,33 +81,24 @@ public void setParentGroup(final EGGroup _g) { parent_ = _g; } - - - public EGCourbe duplicate() { - + + public EGCourbe duplicate(EGParent newParent, EGGrapheDuplicator _duplicator) { + EGCourbeChild duplic = null; + if (this.getModel() != null) duplic = new EGCourbeChild((EGGroup) newParent, this.getModel().duplicate()); + else duplic = new EGCourbeChild((EGGroup) newParent, null); - - if (this.getModel() != null) - duplic = new EGCourbeChild(this.parent_.duplicate(), this.getModel().duplicate()); - else - duplic = new EGCourbeChild(this.parent_.duplicate(), null); - - duplic.isVisible_ = this.isVisible_; - - + duplic.displayTitleOnCurve_ = this.displayTitleOnCurve_; duplic.font_ = new Font(this.font_.getFamily(), this.font_.getStyle(), this.font_.getSize()); - duplic.tbox_ = this.tbox_.duplicate(); - - - // -- duplication du egCourbeSurfacePainter --// + duplic.tbox_ = this.tbox_.duplicate(); + + // -- duplication du egCourbeSurfacePainter --// duplic.surfacePainter_ = this.surfacePainter_.duplicate(); - + return duplic; } - } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSimple.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSimple.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSimple.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -61,7 +61,7 @@ } @Override - public EGCourbe duplicate() { + public EGCourbe duplicate(EGParent newParent, EGGrapheDuplicator _duplicator) { EGCourbeSimple duplic = new EGCourbeSimple(this.v_.duplicate(), this.getModel().duplicate()); duplic.isVisible_ = this.isVisible_; Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSurfacePainter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSurfacePainter.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeSurfacePainter.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -317,8 +317,10 @@ model_ = _model; } - public EGCourbeSurfacePainter duplicate() { - EGCourbeSurfacePainter duplic = new EGCourbeSurfacePainter(this.targetCourbe_.duplicate(), this.model_.duplicate()); + public EGCourbeSurfacePainter duplicate(EGGrapheDuplicator _duplicator) { + //TODO: targetCourbe_.duplicate() n'est pas dans le graphe. Il faut une Map avec les anciennes/nouvelles valeurs + //pas bon la courbe va etre duplique ailleurs + EGCourbeSurfacePainter duplic = new EGCourbeSurfacePainter(this.targetCourbe_.duplicate(_duplicator), this.model_.duplicate(null)); duplic.alpha_ = this.alpha_; duplic.delegateCourbe_ = new DelegateCourbe(duplic.model_); duplic.down_ = this.down_; Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphe.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphe.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphe.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -863,12 +863,14 @@ } public EGGraphe duplicate() { - - EGGraphe duplic = new EGGraphe(this.getModel().duplicate()); + EGGrapheDuplicator duplicator=new EGGrapheDuplicator(); + EGGraphe duplic = new EGGraphe(this.getModel().duplicate(duplicator)); duplic.autoRestore_ = this.autoRestore_; duplic.cache_ = null; - duplic.cmd_ = this.cmd_; + //on ne partage pas les undo/redo + duplic.cmd_ = new CtuluCommandManager(); + //TODO: il y a soucis: les axes verticaux sont dupliqu\xE9 de partout et on n'a plus les ref // -- copie des axes --// if(this.axeOffset_!=null){ duplic.axeOffset_=new TObjectIntHashMap(); @@ -877,7 +879,7 @@ for (int i = 0; i < liste.length; i++) { int value = values[i]; EGAxeVertical axe = (EGAxeVertical) liste[i]; - duplic.axeOffset_.put(axe.duplicate(), value); + duplic.axeOffset_.put(duplicator.duplicateAxeV(axe), value); } } duplic.coeffLarger_=this.coeffLarger_; @@ -890,13 +892,13 @@ int cpt = 0; for (Iterator it = set.iterator(); it.hasNext();) { EGAxeVertical axe = (EGAxeVertical) it.next(); - duplic.objectInitAxe_.put(axe.duplicate(), vals[cpt++]); + duplic.objectInitAxe_.put(duplicator.duplicateAxeV(axe), vals[cpt++]); } } if (this.xRange_ != null) duplic.xRange_ = new CtuluRange(this.xRange_); if (this.transformer_ != null) - duplic.transformer_ = this.transformer_.duplicate(); + duplic.transformer_ = this.transformer_.duplicate(duplicator); if (this.xRangeSpecByUser_ != null) duplic.xRangeSpecByUser_ = new CtuluRange(this.xRangeSpecByUser_); Added: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheDuplicator.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheDuplicator.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheDuplicator.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -0,0 +1,50 @@ +package org.fudaa.ebli.courbe; + +import java.util.HashMap; +import java.util.Map; + +/** + * Permet de sauvegarder les axes deja duplique et de mettre \xE0 jour les + * r\xE9f\xE9rences + * + * @author deniger + * + */ +public class EGGrapheDuplicator { + + Map<EGAxeVertical, EGAxeVertical> oldNew_ = new HashMap<EGAxeVertical, EGAxeVertical>(); + EGAxeHorizontal oldH_; + EGAxeHorizontal newH_; + + /** + * @param _vert l'axe a dupliquer + * @return l'axe duplique en prenant soin de ne pas le recreer + */ + public EGAxeVertical duplicateAxeV(EGAxeVertical _vert) { + EGAxeVertical res = oldNew_.get(_vert); + if (res == null) { + res = _vert.duplicate(); + oldNew_.put(_vert, res); + } + return res; + } + + /** + * @param _vert l'axe horizontal a dupliquer. On suppose qu'il n'y a qu'un + * seul axe h. + * @return l'axe duplique + */ + public EGAxeHorizontal duplicateAxeH(EGAxeHorizontal _vert){ + if(oldH_!=null && _vert!=oldH_){ + //est-ce necessaire... + throw new IllegalArgumentException(" un seul axe horizontal par graphe"); + } + + if(newH_==null) { + oldH_=_vert; + newH_=oldH_.duplicate(); + } + return newH_; + + } +} Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheModel.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheModel.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -143,7 +143,8 @@ /** * methode qui permet de dupliquer les models de courbe + * @param _duplicator TODO */ - public EGGrapheModel duplicate(); + public EGGrapheModel duplicate(EGGrapheDuplicator _duplicator); } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheSimpleModel.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -756,33 +756,35 @@ } - public EGGrapheModel duplicate() { + //TODO a reprendre + public EGGrapheModel duplicate(EGGrapheDuplicator _duplicator) { //--duplication de la liste des courbes --// - ArrayList<EGCourbeSimple> listeElements = new ArrayList<EGCourbeSimple>(); + ArrayList<EGCourbeSimple> listeElements = new ArrayList<EGCourbeSimple>(element_.size()); for (Iterator<EGCourbeSimple> it = this.element_.iterator(); it.hasNext();) { EGCourbeSimple courbe = it.next(); - listeElements.add((EGCourbeSimple) courbe.duplicate()); + listeElements.add((EGCourbeSimple) courbe.duplicate(this,_duplicator)); } EGGrapheSimpleModel duplic = new EGGrapheSimpleModel((EGCourbeSimple[]) listeElements.toArray()); - + //a corriger duplic.axeX_ = this.axeX_.duplicate(); // duplication du listselectionModel - try { - duplic.selection_ = (DefaultListSelectionModel) this.selection_.clone(); - } catch (CloneNotSupportedException e) { - +// try { +// duplic.selection_ = (DefaultListSelectionModel) this.selection_.clone(); +// } catch (CloneNotSupportedException e) { + //TODO cela suffit bien // -- si ce n'est pas duplicable, en cree un par defaut --// duplic.selection_ = new DefaultListSelectionModel(); - } +// } // -- pas besoin de dupliquer le tableModel, il ne fait que gerer la liste // elements --// - duplic.tableModel_ = new SimpleTableModel(); + //FRED ok +// duplic.tableModel_ = new SimpleTableModel(); return duplic; Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheTreeModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheTreeModel.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGrapheTreeModel.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -1064,7 +1064,9 @@ internFireCourbeChanged((EGObject) _path.getLastPathComponent()); } - public EGGrapheModel duplicate() { + + //TODO il faut dupliquer tous les groupes + public EGGrapheModel duplicate(EGGrapheDuplicator _duplicator) { EGGrapheTreeModel duplic = new EGGrapheTreeModel(); duplic.axeX_ = this.axeX_.duplicate(); duplic.selectionModel_.setSelectionMode(this.selectionModel_.getSelectionMode()); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGroup.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGroup.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGroup.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -46,13 +46,12 @@ super(); comp_ = new ArrayList(10); } - - public EGGroup(List l) { - super(); - comp_ = l; - } - + // public EGGroup(List l) { + // super(); + // comp_ = l; + // } + private EGParent.TreeNodes getEgParent() { return n_; } @@ -74,17 +73,13 @@ } public boolean canDescendre(final EGObject _o) { - if (comp_.size() <= 1) { - return false; - } + if (comp_.size() <= 1) { return false; } final int idx = comp_.indexOf(_o); return idx >= 0 && idx < comp_.size() - 1; } public boolean canMonter(final EGObject _o) { - if (comp_.size() <= 1) { - return false; - } + if (comp_.size() <= 1) { return false; } return comp_.indexOf(_o) > 0; } @@ -104,9 +99,7 @@ * @param _idx l'indice d'ajout */ public void addEGComponent(final EGCourbeChild _i, final int _idx) { - if (comp_.contains(_i)) { - return; - } + if (comp_.contains(_i)) { return; } if (_i.getParentGroup() != null) { _i.getParentGroup().removeEGComponent(_i); } @@ -130,9 +123,7 @@ } public boolean ajuste(final CtuluRange _x, final CtuluRange _y) { - if (comp_.size() == 0) { - return false; - } + if (comp_.size() == 0) { return false; } boolean r = false; for (final Iterator it = comp_.iterator(); it.hasNext();) { final EGCourbeChild c = (EGCourbeChild) it.next(); @@ -144,9 +135,7 @@ } public boolean ajusteX(final CtuluRange _x) { - if (comp_.size() == 0) { - return false; - } + if (comp_.size() == 0) { return false; } boolean r = false; for (final Iterator it = comp_.iterator(); it.hasNext();) { final EGCourbeChild c = (EGCourbeChild) it.next(); @@ -158,9 +147,7 @@ } public boolean ajusteY(final CtuluRange _y) { - if (comp_.size() == 0) { - return false; - } + if (comp_.size() == 0) { return false; } boolean r = false; for (final Iterator it = comp_.iterator(); it.hasNext();) { final EGCourbeChild c = (EGCourbeChild) it.next(); @@ -199,9 +186,7 @@ } public void dessine(final Graphics2D _g, final EGRepere _f) { - if (!isVisible_ || !isAtLeastOneObjectVisible()) { - return; - } + if (!isVisible_ || !isAtLeastOneObjectVisible()) { return; } final Color old = _g.getColor(); _g.setColor(Color.black); final int nbElement = this.comp_.size(); @@ -360,7 +345,8 @@ if (Double.isNaN(x.max_)) { x.max_ = 0; /* - * if (x.min == x.max) { if (x.min != 0) { x.min = x.min * 0.9; x.max = x.max * 1.1; } else { x.max = 1; } } + * if (x.min == x.max) { if (x.min != 0) { x.min = x.min 0.9; x.max = + * x.max 1.1; } else { x.max = 1; } } */ } } else { @@ -386,16 +372,15 @@ x.max_ = 0; } /* - * if (x.min == x.max) { if (x.min != 0) { x.min = x.min * 0.9; x.max = x.max * 1.1; } else { x.max = 1; } } + * if (x.min == x.max) { if (x.min != 0) { x.min = x.min 0.9; x.max = x.max + * 1.1; } else { x.max = 1; } } */ return x; } public boolean isAtLeastOneObjectVisible() { for (int i = getChildCount() - 1; i >= 0; i--) { - if (getCourbe(i).isVisible_) { - return true; - } + if (getCourbe(i).isVisible_) { return true; } } return false; } @@ -454,9 +439,7 @@ * @param _i la courbe a enelever */ public void removeEGComponent(final EGCourbeChild _i) { - if (!comp_.contains(_i)) { - return; - } + if (!comp_.contains(_i)) { return; } comp_.remove(_i); _i.setParentGroup(null); } @@ -464,9 +447,7 @@ public void removeEGComponent(final List _list) { for (final Iterator it = _list.iterator(); it.hasNext();) { final EGCourbeChild i = (EGCourbeChild) it.next(); - if (!comp_.contains(i)) { - return; - } + if (!comp_.contains(i)) { return; } comp_.remove(i); i.setParentGroup(null); } @@ -509,37 +490,24 @@ public String toString() { return EbliLib.getS("Groupe") + CtuluLibString.ESPACE + title_; } - - public EGGroup duplicate() { - - - //-- duplication de comp --// - - ArrayList liste = new ArrayList(this.comp_.size()); - for(Iterator it=this.comp_.iterator();it.hasNext();){ - Object item=it.next(); - if (item instanceof EGCourbeChild) { - - // -- !!! reccurence !!! egcourbechild se duplique provoquqnt la - // duplication de eggroup et ainsi de suite --// - liste.add(((EGCourbeChild) item).duplicate()); - }else - // FIXME: adrien si c est pas instance de egcourbeChild, c estquoi ??? - // dans ce cas on duplique ?? - liste.add(item); - - } - + + // TODO a continuer + public EGGroup duplicate(EGGrapheDuplicator _duplicator) { + // -- duplication de l objet --// - EGGroup duplic = new EGGroup(liste); + EGGroup duplic = new EGGroup(); duplic.isVisible_ = this.isVisible_; duplic.title_ = this.title_; duplic.n_ = this.n_; duplic.y_ = this.y_.duplicate(); - - + for (Iterator it = this.comp_.iterator(); it.hasNext();) { + Object item = it.next(); + if (item instanceof EGCourbeChild) { + duplic.addEGComponent((EGCourbeChild)((EGCourbeChild) item).duplicate(duplic,_duplicator)); + } + + } + return duplic; } - - } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGRepere.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGRepere.java 2008-08-18 13:33:11 UTC (rev 3822) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGRepere.java 2008-08-18 14:10:54 UTC (rev 3823) @@ -115,7 +115,7 @@ } - public EGRepere duplicate() { + public EGRepere duplicate(EGGrapheDuplicator _duplicator) { EGRepere duplic = new EGRepere(); duplic.h_ = this.h_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |