From: <de...@us...> - 2008-11-02 01:09:20
|
Revision: 4149 http://fudaa.svn.sourceforge.net/fudaa/?rev=4149&view=rev Author: deniger Date: 2008-11-02 01:09:08 +0000 (Sun, 02 Nov 2008) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/operation/EfTrajectoireGridDataProvider.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/tree/EbliWidgetTreeTableNode.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheSoftReferenceDecorator.java Removed Paths: ------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheWeakDecorator.java Copied: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheSoftReferenceDecorator.java (from rev 4135, branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheWeakDecorator.java) =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheSoftReferenceDecorator.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheSoftReferenceDecorator.java 2008-11-02 01:09:08 UTC (rev 4149) @@ -0,0 +1,130 @@ +/** + * Licence GPL + * Copyright Genesis + */ +package org.fudaa.dodico.ef.decorator; + +import gnu.trove.TIntObjectHashMap; + +import java.io.IOException; +import java.lang.ref.SoftReference; +import java.util.HashMap; +import java.util.Map; + +import org.fudaa.ctulu.CtuluVariable; +import org.fudaa.dodico.ef.EfData; +import org.fudaa.dodico.ef.EfGridData; +import org.fudaa.dodico.ef.EfGridInterface; + +import com.memoire.fu.FuLog; + +/** + * Un decorateur permettant de cacher des donnees. Utilise des SoftReference pour les datas pour eviter d'encombrer la + * memoire + * + * @author deniger + */ +public class EfGridDataCacheSoftReferenceDecorator implements EfGridData { + + final EfGridData init_; + + int maxSize_ = 10; + + TIntObjectHashMap timeMap_ = new TIntObjectHashMap((int) (maxSize_ / 0.75)); + + public EfGridDataCacheSoftReferenceDecorator(EfGridData _init) { + super(); + init_ = _init; + } + + @SuppressWarnings("unchecked") + protected EfData getCachedData(CtuluVariable _o, int _timeIdx) { + Map<CtuluVariable, SoftReference<EfData>> res = (Map<CtuluVariable, SoftReference<EfData>>) timeMap_.get(_timeIdx); + if (res == null) return null; + SoftReference<EfData> reference = res.get(_o); + EfData efData = reference == null ? null : reference.get(); + if (FuLog.isDebug()) { + + FuLog.debug("EfGridDataCacheDecorator getDataFrom cache for " + _o + " " + _timeIdx + " found " + + (efData != null)); + + } + return efData; + + } + + public EfData getData(CtuluVariable _o, int _timeIdx) throws IOException { + EfData data = getCachedData(_o, _timeIdx); + // en cache: on renvoie + if (data != null) return data; + data = init_.getData(_o, _timeIdx); + if (data != null) setCachedData(_o, _timeIdx, data); + return data; + } + + public double getData(CtuluVariable _o, int _timeIdx, int _idxObjet) throws IOException { + EfData data = getCachedData(_o, _timeIdx); + if (data != null) return data.getValue(_idxObjet); + return init_.getData(_o, _timeIdx, _idxObjet); + } + + /** + * @return + * @see org.fudaa.dodico.ef.EfGridData#getGrid() + */ + public EfGridInterface getGrid() { + return init_.getGrid(); + } + + /** + * @return the maxSize + */ + public int getMaxSize() { + return maxSize_; + } + + /** + * @param _var + * @return + * @see org.fudaa.dodico.ef.EfGridData#isDefined(org.fudaa.ctulu.CtuluVariable) + */ + public boolean isDefined(CtuluVariable _var) { + return init_.isDefined(_var); + } + + /** + * @param _idxVar + * @return + * @see org.fudaa.dodico.ef.EfGridData#isElementVar(org.fudaa.ctulu.CtuluVariable) + */ + public boolean isElementVar(CtuluVariable _idxVar) { + return init_.isElementVar(_idxVar); + } + + @SuppressWarnings("unchecked") + protected void setCachedData(CtuluVariable _o, int _timeIdx, EfData _data) { + Map<CtuluVariable, SoftReference<EfData>> res = (Map<CtuluVariable, SoftReference<EfData>>) timeMap_.get(_timeIdx); + if (res == null) { + // on reduit la map + // if (timeMap_.size() > maxSize_) { + // int[] keys = timeMap_.keys(); + // Arrays.sort(keys); + // timeMap_.remove(keys[0]); + // } + res = new HashMap<CtuluVariable, SoftReference<EfData>>(10); + timeMap_.put(_timeIdx, res); + } + res.put(_o, new SoftReference<EfData>(_data)); + + } + + /** + * La taille max du nombre de pas de pour lesquels on veut cacher les donnees + * + * @param _maxSize the maxSize to set + */ + public void setMaxSize(int _maxSize) { + maxSize_ = _maxSize; + } + +} Property changes on: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheSoftReferenceDecorator.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheWeakDecorator.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheWeakDecorator.java 2008-11-02 00:42:09 UTC (rev 4148) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/decorator/EfGridDataCacheWeakDecorator.java 2008-11-02 01:09:08 UTC (rev 4149) @@ -1,131 +0,0 @@ -/** - * Licence GPL - * Copyright Genesis - */ -package org.fudaa.dodico.ef.decorator; - -import gnu.trove.TIntObjectHashMap; - -import java.io.IOException; -import java.lang.ref.WeakReference; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.fudaa.ctulu.CtuluVariable; -import org.fudaa.dodico.ef.EfData; -import org.fudaa.dodico.ef.EfGridData; -import org.fudaa.dodico.ef.EfGridInterface; - -import com.memoire.fu.FuLog; - -/** - * Un decorateur permettant de cacher des donnees. Utilise des WeakReference pour les datas pour eviter d'encombrer la - * memoire - * - * @author deniger - */ -public class EfGridDataCacheWeakDecorator implements EfGridData { - - final EfGridData init_; - - int maxSize_ = 10; - - TIntObjectHashMap timeMap_ = new TIntObjectHashMap((int) (maxSize_ / 0.75)); - - public EfGridDataCacheWeakDecorator(EfGridData _init) { - super(); - init_ = _init; - } - - @SuppressWarnings("unchecked") - protected EfData getCachedData(CtuluVariable _o, int _timeIdx) { - Map<CtuluVariable, WeakReference<EfData>> res = (Map<CtuluVariable, WeakReference<EfData>>) timeMap_.get(_timeIdx); - if (res == null) return null; - WeakReference<EfData> reference = res.get(_o); - EfData efData = reference == null ? null : reference.get(); - if (FuLog.isDebug()) { - - FuLog.debug("EfGridDataCacheDecorator getDataFrom cache for " + _o + " " + _timeIdx + " found " - + (efData != null)); - - } - return efData; - - } - - public EfData getData(CtuluVariable _o, int _timeIdx) throws IOException { - EfData data = getCachedData(_o, _timeIdx); - // en cache: on renvoie - if (data != null) return data; - data = init_.getData(_o, _timeIdx); - if (data != null) setCachedData(_o, _timeIdx, data); - return data; - } - - public double getData(CtuluVariable _o, int _timeIdx, int _idxObjet) throws IOException { - EfData data = getCachedData(_o, _timeIdx); - if (data != null) return data.getValue(_idxObjet); - return init_.getData(_o, _timeIdx, _idxObjet); - } - - /** - * @return - * @see org.fudaa.dodico.ef.EfGridData#getGrid() - */ - public EfGridInterface getGrid() { - return init_.getGrid(); - } - - /** - * @return the maxSize - */ - public int getMaxSize() { - return maxSize_; - } - - /** - * @param _var - * @return - * @see org.fudaa.dodico.ef.EfGridData#isDefined(org.fudaa.ctulu.CtuluVariable) - */ - public boolean isDefined(CtuluVariable _var) { - return init_.isDefined(_var); - } - - /** - * @param _idxVar - * @return - * @see org.fudaa.dodico.ef.EfGridData#isElementVar(org.fudaa.ctulu.CtuluVariable) - */ - public boolean isElementVar(CtuluVariable _idxVar) { - return init_.isElementVar(_idxVar); - } - - @SuppressWarnings("unchecked") - protected void setCachedData(CtuluVariable _o, int _timeIdx, EfData _data) { - Map<CtuluVariable, WeakReference<EfData>> res = (Map<CtuluVariable, WeakReference<EfData>>) timeMap_.get(_timeIdx); - if (res == null) { - // on reduit la map - // if (timeMap_.size() > maxSize_) { - // int[] keys = timeMap_.keys(); - // Arrays.sort(keys); - // timeMap_.remove(keys[0]); - // } - res = new HashMap<CtuluVariable, WeakReference<EfData>>(10); - timeMap_.put(_timeIdx, res); - } - res.put(_o, new WeakReference<EfData>(_data)); - - } - - /** - * La taille max du nombre de pas de pour lesquels on veut cacher les donnees - * - * @param _maxSize the maxSize to set - */ - public void setMaxSize(int _maxSize) { - maxSize_ = _maxSize; - } - -} Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/operation/EfTrajectoireGridDataProvider.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/operation/EfTrajectoireGridDataProvider.java 2008-11-02 00:42:09 UTC (rev 4148) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/ef/operation/EfTrajectoireGridDataProvider.java 2008-11-02 01:09:08 UTC (rev 4149) @@ -8,7 +8,7 @@ import org.fudaa.dodico.ef.EfGridData; import org.fudaa.dodico.ef.EfGridInterface; import org.fudaa.dodico.ef.decorator.EfGridDataCacheOneTimeDecorator; -import org.fudaa.dodico.ef.decorator.EfGridDataCacheWeakDecorator; +import org.fudaa.dodico.ef.decorator.EfGridDataCacheSoftReferenceDecorator; import org.fudaa.dodico.ef.decorator.EfGridDataTimeDecorator; /** @@ -48,7 +48,7 @@ public Trajectoire(double[] _initTimeStep, EfGridData _init) { super(); - init_ = new EfGridDataCacheWeakDecorator(_init); + init_ = new EfGridDataCacheSoftReferenceDecorator(_init); initTimeStep_ = _initTimeStep; } Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java 2008-11-02 00:42:09 UTC (rev 4148) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetGraphe.java 2008-11-02 01:09:08 UTC (rev 4149) @@ -14,7 +14,10 @@ import org.fudaa.ctulu.image.CtuluLibImage; import org.fudaa.ebli.animation.EbliAnimatedInterface; +import org.fudaa.ebli.animation.EbliAnimationAdapterInterface; +import org.fudaa.ebli.calque.BCalque; import org.fudaa.ebli.courbe.EGAxe; +import org.fudaa.ebli.courbe.EGCourbe; import org.fudaa.ebli.courbe.EGFillePanel; import org.fudaa.ebli.courbe.EGGraphe; import org.fudaa.ebli.courbe.EGGrapheModelListener; @@ -23,6 +26,8 @@ import org.fudaa.ebli.visuallibrary.EbliNodeDefault; import org.fudaa.ebli.visuallibrary.EbliScene; import org.fudaa.ebli.visuallibrary.EbliWidget; +import org.fudaa.ebli.visuallibrary.animation.EbliWidgetAnimatedItem; +import org.geotools.xml.xsi.XSISimpleTypes.Int; import org.netbeans.api.visual.action.InplaceEditorProvider; import org.netbeans.api.visual.widget.Widget; @@ -43,7 +48,7 @@ public EGFillePanel getPanelGraphe() { return panelGraphe_; } - + BuPanel conteneurEditor; private EbliNodeDefault nodeLegende = null; @@ -51,16 +56,41 @@ public EbliNodeDefault getNodeLegende() { return nodeLegende; } - - public EbliAnimatedInterface getAnimatedInterface() { if (panelGraphe_ instanceof EbliAnimatedInterface) return (EbliAnimatedInterface) panelGraphe_; return null; } + @Override + public List<EbliWidgetAnimatedItem> getAnimatedItems() { + final EGCourbe[] cqs = panelGraphe_.getGraphe().getModel().getCourbes(); + final List<EbliWidgetAnimatedItem> res = new ArrayList<EbliWidgetAnimatedItem>(20); + for (int i = 0; i < cqs.length; i++) { + EGCourbe courbe = cqs[i]; + if (courbe.isVisible() && courbe instanceof EbliAnimationAdapterInterface) { + res.add(new EbliWidgetAnimatedItem((EbliAnimationAdapterInterface) courbe, courbe, getId(), getAnimId(courbe), + courbe.getTitle())); + } + } + return res; + } + private String getAnimId(EGCourbe courbe) { + return courbe.hashCode() + courbe.getTitle(); + } + @Override + public boolean isAnimatedItemAlive(final String _id) { + if(_id==null) return false; + final EGCourbe[] cqs = panelGraphe_.getGraphe().getModel().getCourbes(); + for (int i = 0; i < cqs.length; i++) { + EGCourbe courbe = cqs[i]; + if(_id.equals(getAnimId(courbe))) return true; + } + return false; + } + public void setNodeLegende(final EbliNodeDefault node) { nodeLegende = node; } @@ -77,7 +107,7 @@ // this.graphe_ = graphe; // } EbliWidgetControllerGraphe controllerGraphe_; - + public EbliWidgetGraphe(final EbliScene scene, final Point preferredLocation, final EGFillePanel _pn) { super(scene); panelGraphe_ = _pn; @@ -117,24 +147,24 @@ final Rectangle rec = getClientArea(); final Graphics2D g = getGraphics(); // g.translate(rec.x, rec.y); - if(rec.width>0 && rec.height>0){ - if (frame_ == null) { - getGraphe().setSize(rec.width - 1, rec.height - 1); - // getGraphe().computeMarges(g); - // getGraphe().dessine(g, rec.width - 1, rec.height - 1, false); - } + if (rec.width > 0 && rec.height > 0) { + if (frame_ == null) { + getGraphe().setSize(rec.width - 1, rec.height - 1); + // getGraphe().computeMarges(g); + // getGraphe().dessine(g, rec.width - 1, rec.height - 1, false); + } - // mode edition - if (imageGraphe == null || imageGraphe.getWidth() != rec.width || imageGraphe.getHeight() != rec.height) { - FuLog.debug("EWI: recreate image"); - final Map params = new HashMap(); - CtuluLibImage.setCompatibleImageAsked(params); + // mode edition + if (imageGraphe == null || imageGraphe.getWidth() != rec.width || imageGraphe.getHeight() != rec.height) { + FuLog.debug("EWI: recreate image"); + final Map params = new HashMap(); + CtuluLibImage.setCompatibleImageAsked(params); - imageGraphe = getGraphe().produceImage(rec.width - 1, rec.height - 1, params); + imageGraphe = getGraphe().produceImage(rec.width - 1, rec.height - 1, params); + } + g.drawImage(imageGraphe, rec.x, rec.y, rec.width - 1, rec.height - 1, null); } - g.drawImage(imageGraphe, rec.x, rec.y, rec.width - 1, rec.height - 1, null); - } // g.translate(-rec.x, -rec.y); } @@ -285,14 +315,12 @@ } public boolean hasSattelite() { - if (controllerGraphe_.hasLegende()) - return true; + if (controllerGraphe_.hasLegende()) return true; return false; } public List<EbliWidget> getSattelite() { - if (!hasSattelite()) - return null; + if (!hasSattelite()) return null; List<EbliWidget> liste = new ArrayList<EbliWidget>(); liste.add(getNodeLegende().getWidget()); @@ -300,17 +328,15 @@ return liste; } - + public void setSattelite(List<EbliWidget> liste) { - if(liste.size()<=0) - return; - - EbliWidget widg=liste.get(0); - - EbliNodeDefault node= (EbliNodeDefault) getEbliScene().findObject(widg); - setNodeLegende( node); - - + if (liste.size() <= 0) return; + + EbliWidget widg = liste.get(0); + + EbliNodeDefault node = (EbliNodeDefault) getEbliScene().findObject(widg); + setNodeLegende(node); + } - + } Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/tree/EbliWidgetTreeTableNode.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/tree/EbliWidgetTreeTableNode.java 2008-11-02 00:42:09 UTC (rev 4148) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/tree/EbliWidgetTreeTableNode.java 2008-11-02 01:09:08 UTC (rev 4149) @@ -1,6 +1,7 @@ package org.fudaa.ebli.visuallibrary.tree; import java.util.ArrayList; +import java.util.List; import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ebli.visuallibrary.EbliNode; @@ -33,7 +34,9 @@ static void addChilds(final ObjectScene _sc, final Widget w, final EbliWidgetTreeTableNode parent, final EbliNode parentNode) { - for (final Widget child : w.getChildren()) { + List<Widget> children = w.getChildren(); + for (int i = children.size() - 1; i >= 0; i--) { + Widget child = children.get(i); final EbliNode n = (EbliNode) _sc.findObject(child); if (n != null && n != parentNode) { final EbliWidgetTreeTableNode treeNode = new EbliWidgetTreeTableNode(n); @@ -94,7 +97,7 @@ // -- cas particulier si il s agit d un calque ou d un graphe, on masque // aussi - + if ((((EbliNode) getUserObject()).getWidget()) instanceof EbliWidgetBordureSingle && (((EbliNode) getUserObject()).getWidget()).getChildren() != null) { @@ -102,16 +105,16 @@ final EbliWidgetVueCalque wid = (EbliWidgetVueCalque) (((EbliNode) getUserObject()).getWidget()) .getChildren().get(0); if (((EbliWidgetControllerCalque) wid.getController()).hasLegende()) { - wid.nodeLegende.getWidget().setVisible(((Boolean) _value).booleanValue()); - listeWidgetUndo.add(wid.nodeLegende.getWidget()); + wid.nodeLegende.getWidget().setVisible(((Boolean) _value).booleanValue()); + listeWidgetUndo.add(wid.nodeLegende.getWidget()); } } else if ((((EbliNode) getUserObject()).getWidget()).getChildren().get(0) instanceof EbliWidgetGraphe) { final EbliWidgetGraphe wid = (EbliWidgetGraphe) (((EbliNode) getUserObject()).getWidget()).getChildren() .get(0); if (((EbliWidgetControllerGraphe) wid.getController()).hasLegende()) { - wid.getNodeLegende().getWidget().setVisible(((Boolean) _value).booleanValue()); - listeWidgetUndo.add(wid.getNodeLegende().getWidget()); + wid.getNodeLegende().getWidget().setVisible(((Boolean) _value).booleanValue()); + listeWidgetUndo.add(wid.getNodeLegende().getWidget()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |