|
From: <bma...@us...> - 2013-07-29 08:55:57
|
Revision: 8452
http://sourceforge.net/p/fudaa/svn/8452
Author: bmarchan
Date: 2013-07-29 08:55:53 +0000 (Mon, 29 Jul 2013)
Log Message:
-----------
Mascaret : Animation des cotes d'eau sur profil en travers.
Modified Paths:
--------------
trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilPane.java
trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/Hydraulique1dGrapheProfil.java
Modified: trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilPane.java
===================================================================
--- trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilPane.java 2013-07-29 08:52:55 UTC (rev 8451)
+++ trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/editor/profil/Hydraulique1dProfilPane.java 2013-07-29 08:55:53 UTC (rev 8452)
@@ -11,6 +11,7 @@
import gnu.trove.TDoubleArrayList;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
@@ -27,6 +28,7 @@
import java.util.Map;
import java.util.Vector;
+import javax.swing.AbstractButton;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.Box;
@@ -51,6 +53,9 @@
import org.fudaa.dodico.hydraulique1d.metier.MetierReseau;
import org.fudaa.dodico.hydraulique1d.metier.MetierResultatsTemporelSpatial;
import org.fudaa.dodico.hydraulique1d.metier.MetierResultatsTemporelSpatialBief;
+import org.fudaa.ebli.animation.EbliAnimationAction;
+import org.fudaa.ebli.animation.EbliAnimationSourceInterface;
+import org.fudaa.ebli.commun.EbliComponentFactory;
import org.fudaa.ebli.impression.EbliPrinter;
import org.fudaa.fudaa.hydraulique1d.CGlobal;
import org.fudaa.fudaa.hydraulique1d.Hydraulique1dBaseApplication;
@@ -85,7 +90,98 @@
* @author Bertrand Marchand
*/
public class Hydraulique1dProfilPane extends JPanel implements CurveOptionTargetI, ActionListener, Hydraulique1dProfilSelectionListener, Hydraulique1dProfilDataListener, BuCutCopyPasteInterface, BuUndoRedoInterface {
+
+ /**
+ * Une classe d'animation du graphe.
+ * @author Bertrand Marchand (mar...@de...)
+ */
+ class GrapheAnimation implements EbliAnimationSourceInterface {
+ private Hydraulique1dProfilPane panel_;
+
+ GrapheAnimation(Hydraulique1dProfilPane editeur) {
+ panel_ = editeur;
+ }
+
+ /**
+ * @return le nombre de pas de temps a parcourir
+ */
+ @Override
+ public int getNbTimeStep() {
+ return panel_.coTemps_.getItemCount();
+ }
+
+ /**
+ * @param _idx indice du pas de temps [0;getNbTimeStep()[
+ * @return representation de ce pas de temps
+ */
+ @Override
+ public String getTimeStep(int _idx) {
+ return panel_.coTemps_.getItemAt(_idx).toString();
+ }
+
+ @Override
+ public double getTimeStepValueSec(int _idx) {
+ try {
+ return Double.parseDouble(getTimeStep(_idx));
+ } catch (NumberFormatException numberFormatException) {
+ }
+ return 0;
+ }
+
+ /**
+ * @param _idx l'indice a afficher
+ */
+ @Override
+ public void setTimeStep(int _idx) {
+ panel_.coTemps_.setSelectedIndex(_idx);
+ }
+
+ @Override
+ public String getTitle() {
+ return panel_.getTitle();
+ }
+
+ /**
+ * Permet d'avertir le client que la video est en cours
+ *
+ * @param _b true si video en cours
+ */
+ @Override
+ public void setVideoMode(boolean _b) {
+ }
+
+ /**
+ * @return le composant contenant l'affichage (optionnel)
+ */
+ @Override
+ public Component getComponent() {
+ return null;
+
+ }
+
+ /**
+ * @return l'image produite dans la taille courant du composant.
+ */
+ @Override
+ public BufferedImage produceImage(Map _params) {
+ return panel_.produceImage(null);
+ }
+
+ @Override
+ public BufferedImage produceImage(int _w, int _h, Map _params) {
+ return panel_.produceImage(_w, _h, null);
+ }
+
+ /**
+ * @return les dimensions de l'image produite
+ */
+ @Override
+ public Dimension getDefaultImageDimension() {
+ return panel_.graphe_.getSize();
+ }
+ }
+
class TpsComboboxModel implements ComboBoxModel {
HashSet<ListDataListener> hlisteners=new HashSet<ListDataListener>();
Object selected;
@@ -184,7 +280,6 @@
private JToggleButton btVoirRives_=new JToggleButton();
private JButton btFixerBornes_=new JButton();
private JToggleButton btAjusterBornes_=new JToggleButton();
- private JButton btAnimation_=new JButton();
private JComboBox coTemps_=new JComboBox();
private JToggleButton btCoteMinMax_=new JToggleButton();
@@ -293,9 +388,8 @@
coTemps_.setSelectedIndex(0);
}
- private void changeTempsSelection() {
- int itps=coTemps_.getSelectedIndex();
- if (itps==-1) return;
+ private void changeTempsSelection(int _itps) {
+ if (_itps==-1) return;
int[] ibiefs=lsBief_.getSelectedIndices();
@@ -306,7 +400,7 @@
int nbProfil = b.profils().length;
for (int iprof = 0; iprof < nbProfil; iprof++) {
Hydraulique1dProfilModel pModel= profilsBief_[icpt++];
- double z=calculeCoteZProfil(ibiefs[i], iprof,itps);
+ double z=calculeCoteZProfil(ibiefs[i], iprof,_itps);
pModel.setNiveauEau(z);
}
}
@@ -336,7 +430,7 @@
setProfilsModeleBief(listeProfils_.toArray(new Hydraulique1dProfilModel[listeProfils_.size()]));
setProfilCourant(0);
- changeTempsSelection();
+ changeTempsSelection(coTemps_.getSelectedIndex());
}
/**
@@ -629,17 +723,17 @@
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange()==ItemEvent.DESELECTED) return;
- changeTempsSelection();
+ changeTempsSelection(coTemps_.getSelectedIndex());
}
});
pn.add(coTemps_);
- btAnimation_.setIcon(Hydraulique1dResource.HYDRAULIQUE1D.getIcon("video"));
- btAnimation_.setToolTipText(Hydraulique1dResource.getS("Animation du temps courant"));
- btAnimation_.setMargin(new Insets(1,1,1,1));
- pn.add(btAnimation_);
-
+ EbliAnimationAction act=new EbliAnimationAction(new GrapheAnimation(this));
+ AbstractButton btAnimation=act.buildButton(EbliComponentFactory.INSTANCE);
+ btAnimation.setMargin(new Insets(1,1,1,1));
+ btAnimation.setEnabled(true);
+ pn.add(btAnimation);
}
return pn;
@@ -781,6 +875,10 @@
return iprofilCourant_;
}
+ public String getTitle() {
+ return lbTitle_.getText();
+ }
+
public void setTitle(String _s) {
lbTitle_.setText(_s);
}
@@ -1106,15 +1204,22 @@
* @return l'image produite dans la taille courante du composant.
*/
public BufferedImage produceImage(Map _params) {
- if (pnTableau_.hasFocus()) {
- BufferedImage i=new BufferedImage(pnTableau_.getTableau().getWidth(), pnTableau_.getTableau().getHeight(), BufferedImage.TYPE_3BYTE_BGR);
- pnTableau_.getTableau().paint(i.createGraphics());
- return i;
- }
+// if (pnTableau_.hasFocus()) {
+// BufferedImage i=new BufferedImage(pnTableau_.getTableau().getWidth(), pnTableau_.getTableau().getHeight(), BufferedImage.TYPE_3BYTE_BGR);
+// pnTableau_.getTableau().paint(i.createGraphics());
+// return i;
+// }
return graphe_.produceImage(null);
}
/**
+ * @return l'image produite pour une taille donnee.
+ */
+ public BufferedImage produceImage(int _w, int _h, Map _params) {
+ return graphe_.produceImage(_w, _h, null);
+ }
+
+ /**
* Le nombre de pages : 2. La premi\xE8re pour le graphique, la deuxi\xE8me pour le tableau.
* @return Le nombre de pages.
*/
Modified: trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/Hydraulique1dGrapheProfil.java
===================================================================
--- trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/Hydraulique1dGrapheProfil.java 2013-07-29 08:52:55 UTC (rev 8451)
+++ trunk/soft/fudaa-mascaret/ui/src/main/java/org/fudaa/fudaa/hydraulique1d/graphe/Hydraulique1dGrapheProfil.java 2013-07-29 08:55:53 UTC (rev 8452)
@@ -327,6 +327,13 @@
public BufferedImage produceImage(Map _params) {
return CtuluLibImage.produceImageForComponent(this, _params);
}
+
+ /**
+ * @return l'image produite pour une taille donnee.
+ */
+ public BufferedImage produceImage(int _w, int _h, Map _params) {
+ return CtuluLibImage.produceImageForComponent(this, _w, _h, _params);
+ }
/**
* Definit le mode interactif du graphique.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|