From: <de...@us...> - 2008-10-30 17:09:05
|
Revision: 4120 http://fudaa.svn.sourceforge.net/fudaa/?rev=4120&view=rev Author: deniger Date: 2008-10-30 17:09:00 +0000 (Thu, 30 Oct 2008) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostDialogLigneCourants.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostWizardProfilSpatial.java Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostDialogLigneCourants.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostDialogLigneCourants.java 2008-10-30 17:08:35 UTC (rev 4119) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostDialogLigneCourants.java 2008-10-30 17:09:00 UTC (rev 4120) @@ -2,89 +2,118 @@ import java.awt.BorderLayout; import java.awt.FlowLayout; -import java.awt.Frame; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import javax.swing.BorderFactory; -import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JDialog; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTable; import javax.swing.ListModel; import javax.swing.ListSelectionModel; import javax.swing.table.DefaultTableModel; +import org.fudaa.ctulu.CtuluAnalyze; +import org.fudaa.ctulu.CtuluLibArray; +import org.fudaa.ctulu.CtuluLibString; +import org.fudaa.ctulu.CtuluNumberFormatDefault; +import org.fudaa.ctulu.CtuluVariable; import org.fudaa.ctulu.ProgressionInterface; -import org.fudaa.ctulu.gui.CtuluLibSwing; -import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; -import org.fudaa.ebli.geometrie.GrPoint; -import org.fudaa.ebli.ressource.EbliResource; -import org.fudaa.fudaa.commun.FudaaLib; +import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gui.CtuluComboBoxModelAdapter; +import org.fudaa.ctulu.gui.CtuluValueEditorDouble; +import org.fudaa.ctulu.gui.CtuluValueEditorInteger; +import org.fudaa.ctulu.gui.CtuluValueTimeEditor; +import org.fudaa.dodico.ef.operation.EfIndexHelper; +import org.fudaa.dodico.ef.operation.EfTrajectoireParameters; +import org.fudaa.dodico.h2d.type.H2dVariableType; +import org.fudaa.ebli.commun.EbliLib; +import org.fudaa.fudaa.commun.impl.FudaaPanelTaskModel; +import org.fudaa.fudaa.meshviewer.profile.MvLineChooser; +import org.fudaa.fudaa.tr.common.TrLib; import org.fudaa.fudaa.tr.common.TrResource; import org.fudaa.fudaa.tr.post.TrComputeLigneCourantTrajectoire; -import org.fudaa.fudaa.tr.post.TrPostCommonImplementation; import org.fudaa.fudaa.tr.post.TrPostFlecheContent; -import org.fudaa.fudaa.tr.post.TrPostProjet; import org.fudaa.fudaa.tr.post.TrPostSource; import org.fudaa.fudaa.tr.post.TrPostVisuPanel; -import com.memoire.bu.BuCharValidator; -import com.memoire.bu.BuStringValidator; -import com.memoire.bu.BuTextField; +import com.memoire.bu.BuComboBox; +import com.memoire.bu.BuGridLayout; +import com.memoire.bu.BuPanel; import com.memoire.bu.BuValueValidator; +import com.memoire.bu.BuVerticalLayout; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.LineString; -public class TrPostDialogLigneCourants { +public class TrPostDialogLigneCourants implements FudaaPanelTaskModel { + /** + * + */ + private static final double MAXDIST = 1E-3; + + TrComputeLigneCourantTrajectoire algoCalcul_; + + /** * booleen qui indique si le wizard a \xE9t\xE9t lanc\xE9 depuis un calque */ // ArrayList<TrPostSource> source_; TrPostVisuPanel calque_; - TrPostSource source_; - TrPostCommonImplementation impl_; - TrComputeLigneCourantTrajectoire algoCalcul_; - // donnees graphiques - JDialog dialog_; - // choix mode - JComboBox choixMode_ = new JComboBox(new String[] { "Lignes de courant", "Trajectoires" }); + JComboBox choixMode_ = new JComboBox(new String[] { TrLib.getString("Lignes de courant"), + TrLib.getString("Trajectoires") }); - // choix segment - BuTextField x_ = new BuTextField(5); - BuTextField y_ = new BuTextField(5); - BuTextField x2_ = new BuTextField(5); - BuTextField y2_ = new BuTextField(5); - BuTextField nbPoints_ = new BuTextField(3); + JComponent duree_; - // variables et pdt - private JPanel panelVariables_; - ListModel modelVariables_; + JComponent finesse_; + + final MvLineChooser lineChooser_; + JComboBox cbFirstTime_; JList listVar_; ListModel modelPdt_; - JList listPdt_; - // finesse et duree et point - private JPanel panelSeuil_; - BuTextField finesse_ = new BuTextField(5); - BuTextField duree_ = new BuTextField(5); + // donnees graphiques + // JDialog dialog_; - // results - JPanel panelResults_; - JLabel results_; - JButton ajouter_ = new JButton("Valider", EbliResource.EBLI.getIcon("crystal_valider")); DefaultTableModel modelResult_; + + // results + // JPanel panelResults_; /** + * Creation du panel graphique. + * + * @return + */ + // JPanel panelSegment_; + // finesse et duree et point + // private JPanel panelSeuil_; + // variables et pdt + // private JPanel panelVariables_; + TrPostSource source_; + CtuluValueEditorDouble doubleEditor = new CtuluValueEditorDouble(false); + CtuluValueEditorInteger integerEditor_ = new CtuluValueEditorInteger(false); + JComboBox cbVitesse_; + JComponent nbPoints_; + + // choix segment + JComponent x_; + JComponent x2_; + JComponent y_; + JComponent y2_; + CtuluValueTimeEditor dureeEditor_; + + /** * Constructeur reserv\xE9 au calques * * @param _builderParams @@ -93,217 +122,131 @@ * @param _panelVariables * @param _source */ - public TrPostDialogLigneCourants(final TrPostProjet projet, final TrPostCommonImplementation impl, - final TrPostVisuPanel calque) { - impl_ = impl; + public TrPostDialogLigneCourants(final TrPostVisuPanel calque) { calque_ = calque; source_ = calque.getSource(); + int nbTimeStep = source_.getNbTimeStep(); + if (nbTimeStep < 2) choixMode_.setEnabled(false); + doubleEditor.setFormatter(CtuluNumberFormatDefault.buildNoneFormatter(3, true)); + x_ = doubleEditor.createEditorComponent(); + x2_ = doubleEditor.createEditorComponent(); + y_ = doubleEditor.createEditorComponent(); + y2_ = doubleEditor.createEditorComponent(); + + dureeEditor_ = new CtuluValueTimeEditor(); + dureeEditor_.setFmt(source_.getTimeFormatter()); + duree_ = dureeEditor_.createEditorComponent(); + double defaut = 60; + if (nbTimeStep > 2) { + defaut = (source_.getTimeStep(nbTimeStep - 1) - source_.getTimeStep(0)) / 2; + } + dureeEditor_.setValue(defaut, duree_); + integerEditor_.setVal(BuValueValidator.MIN(1)); + integerEditor_.setEditable(true); + nbPoints_ = integerEditor_.createEditorComponent(); + finesse_ = integerEditor_.createEditorComponent(); + integerEditor_.setValue(Integer.valueOf(1), nbPoints_); + integerEditor_.setValue(Integer.valueOf(1), finesse_); + lineChooser_ = new MvLineChooser(calque.getSelectedLine(), calque); // modelVariables_ = source_.getNewVarListModel();//doit contenir les vecteurs - modelVariables_ = source_.getNewFlecheListModel();// doit contenir les vecteurs modelPdt_ = source_.getNewTimeListModel(); // -- construction de la dialog --// - buildDialog(); } - private JPanel buildresults() { - final JPanel conteneur = new JPanel(new BorderLayout()); + private List<Coordinate> getPoints() { + Coordinate c = getFirsCoordinate(); + Coordinate cEnd = getEndCoordinate(); + int nbLigne = (Integer) integerEditor_.getValue(nbPoints_); + List<Coordinate> res = new ArrayList<Coordinate>(nbLigne); + if (c.distance(cEnd) < MAXDIST) { + res.add(c); + return res; + } + if (nbLigne == 1) { + c.x = (c.x + cEnd.x) / 2D; + c.y = (c.y + cEnd.y) / 2D; + res.add(c); + return res; + } + int nbIteration = nbLigne - 1; + double deltaX = (cEnd.x - c.x) / nbIteration; + double deltaY = (cEnd.y - c.y) / nbIteration; + res.add(c); + for (int i = 1; i < nbIteration; i++) { + Coordinate ci = new Coordinate(c.x + i * deltaX, c.y + i * deltaY); + res.add(ci); + } + res.add(cEnd); + return res; - final JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER)); + } - results_ = new JLabel(""); - content.add(ajouter_); - // content.add(new JLabel(TrResource.getS("R\xE9sultat:"))); - content.add(results_); + private Coordinate getEndCoordinate() { + return new Coordinate(getDoubleValue(x2_), getDoubleValue(y2_)); + } - conteneur.setBorder(BorderFactory.createTitledBorder(TrResource.getS("R\xE9sultats"))); + private Coordinate getFirsCoordinate() { + return new Coordinate(getDoubleValue(x_), getDoubleValue(y_)); + } - // -- action relatives aux resultats --// - ajouter_.addActionListener(new ActionListener() { - - public void actionPerformed(final ActionEvent _e) { - if (controleDataOk()) { - computeResults(); - } + public void actTask(final ProgressionInterface _prog, final CtuluAnalyze _analyze, final String[] _messages) { + List<Coordinate> points = getPoints(); + int idxRemove = 0; + for (Iterator<Coordinate> it = points.iterator(); it.hasNext();) { + Coordinate c = it.next(); + int idx = EfIndexHelper.getElementEnglobant(source_.getGrid(), c.x, c.y, _prog); + if (idx < 0) { + idxRemove++; + it.remove(); } - - }); - - modelResult_ = new DefaultTableModel(); - - final JTable tableauRes = new JTable(modelResult_); - conteneur.add(tableauRes.getTableHeader(), BorderLayout.NORTH); - conteneur.add(tableauRes, BorderLayout.CENTER); - conteneur.add(content, BorderLayout.SOUTH); - return conteneur; - } - - public boolean controleDataOk() { - - if (finesse_.getText().equals("")) { - impl_.error(TrResource.getS("La finesse doit \xEAtre d\xE9fini par un r\xE9el ")); - return false; } - if (duree_.getText().equals("")) { - impl_.error(TrResource.getS("La dur\xE9e doit \xEAtre d\xE9fini par un r\xE9el en secondes ")); - return false; + if (points.size() == 0) { + _analyze.addFatalError(TrResource.getS("Aucun point de d\xE9part n'appartient au maillage")); + return; } - if (x_.getText().equals("")) { - impl_.error(TrResource.getS("Le point doit etre form\xE9 de 2 r\xE9els ")); - return false; + if (idxRemove > 0) { + String txt = null; + if (idxRemove == 1) { + txt = TrResource.getS("1 point de d\xE9part a \xE9t\xE9 ignor\xE9 car il en dehors du maillage"); + } else { + txt = TrResource.getS("{0} points de d\xE9part ont \xE9t\xE9 ignor\xE9s car ils en dehors du maillage", CtuluLibString + .getString(idxRemove)); + } + _messages[0] = txt; } - if (nbPoints_.getText().equals("")) { - impl_.error(TrResource.getS("Le nombre de points \xE0 r\xE9partir manquant")); - return false; - } - if (y_.getText().equals("")) { - impl_.error(TrResource.getS("Le point doit etre form\xE9 de 2 r\xE9els ")); - return false; - } - if (x2_.getText().equals("")) { - impl_.error(TrResource.getS("Le point doit etre form\xE9 de 2 r\xE9els ")); - return false; - } - if (y2_.getText().equals("")) { - impl_.error(TrResource.getS("Le point doit etre form\xE9 de 2 r\xE9els ")); - return false; - } - if (listVar_.getSelectedIndex() == -1) { - impl_.error(TrResource.getS("Il faut choisir une variable")); - return false; - } - if (listPdt_.getSelectedIndex() == -1) { - impl_.error(TrResource.getS("Il faut choisir un pas de temps")); - return false; - } + // creqtion de l algo + algoCalcul_ = new TrComputeLigneCourantTrajectoire(calque_); - if (getNbPoints() < 2) { - nbPoints_.setText("" + 2); + final TrPostFlecheContent flecheContent = getSelectedVariable(); + final EfTrajectoireParameters data = new EfTrajectoireParameters(); + data.vx = flecheContent.getVx(); + data.vy = flecheContent.getVy(); + data.dureeIntegration_ = getDuree(); + data.finesse_ = (Integer) integerEditor_.getValue(finesse_); + data.firstTimeStepIdx_ = getSelectedTimeStep(); + data.firstTimeStep_ = source_.getTimeStep(data.firstTimeStepIdx_); + data.isLigneDeCourant = isLigneCourant(); + if (!listVar_.isSelectionEmpty()) { + Object[] selectedValues = listVar_.getSelectedValues(); + data.varsASuivre_ = new ArrayList<CtuluVariable>(selectedValues.length); + for (int i = 0; i < selectedValues.length; i++) { + data.varsASuivre_.add((CtuluVariable) selectedValues[i]); + } } - return true; - } + data.points_ = points; + algoCalcul_.computeLigneCourant(data, _analyze, _prog); - /** - * retourne la variable selectionnee - * - * @return - */ - protected TrPostFlecheContent getSelectedVariable() { + // -- mise a jour du tableau de res --// + // modelResult_.fireTableDataChanged(); - return (TrPostFlecheContent) modelVariables_.getElementAt(listVar_.getSelectedIndex()); } - /** - * retourne l indice du pas de temps. - * - * @return - */ - protected int getSelectedTimeStep() { - return listPdt_.getSelectedIndex(); - } + JPanel content_; - // JList listeSources_; - // DefaultListModel modelSources_; - // private JPanel buildSources() { - // JPanel conteneur = new JPanel(new BorderLayout()); - // JPanel content = new JPanel(new GridLayout(1, 2)); - // modelSources_=new DefaultListModel(); - // for(TrPostSource source:source_) - // modelSources_.addElement(source.getFile().getPath()); - // listeSources_ = new JList(modelSources_); - // listeSources_.setSelectedIndex(0); - // listeSources_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - // content.add(new JScrollPane(listeSources_)); - // content.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix du source"))); - // conteneur.add(content, BorderLayout.CENTER); - // - // listeSources_.addListSelectionListener(new ListSelectionListener(){ - // - // @Override - // public void valueChanged(ListSelectionEvent e) { - // //reconstruction des models de var et de pdt - // if(listeSources_.getSelectedIndex()!=-1){ - // modelVariables_ = source_.get(listeSources_.getSelectedIndex()).getNewVarListModel(); - // modelPdt_ = source_.get(listeSources_.getSelectedIndex()).getNewTimeListModel(); - // listPdt_.setModel(modelPdt_); - // listVar_.setModel(modelVariables_); - // } - // } - // - // }); - // - // return content; - // } - - private JPanel buildVariables() { - final JPanel conteneur = new JPanel(new BorderLayout()); - final JPanel content = new JPanel(new GridLayout(1, 2)); - listVar_ = new JList(modelVariables_); - listVar_.setSelectedIndex(0); - listPdt_ = new JList(modelPdt_); - listPdt_.setSelectedIndex(0); - listVar_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listPdt_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - content.add(new JScrollPane(listVar_)); - content.add(new JScrollPane(listPdt_)); - content.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix des variables et pas de temps"))); - conteneur.add(content, BorderLayout.CENTER); - conteneur.add(new JLabel(TrResource.getS("Veuillez s\xE9lectionner la variable et pas de temps")), BorderLayout.NORTH); - return content; - } - - private JPanel buildSegments() { - - final JPanel conteneur = new JPanel(new GridLayout(3, 1)); - x_.setCharValidator(BuCharValidator.FLOAT); - x_.setStringValidator(BuStringValidator.FLOAT); - x_.setValueValidator(BuValueValidator.FLOAT); - y_.setCharValidator(BuCharValidator.FLOAT); - y_.setStringValidator(BuStringValidator.FLOAT); - y_.setValueValidator(BuValueValidator.FLOAT); - x2_.setCharValidator(BuCharValidator.FLOAT); - x2_.setStringValidator(BuStringValidator.FLOAT); - x2_.setValueValidator(BuValueValidator.FLOAT); - y2_.setCharValidator(BuCharValidator.FLOAT); - y2_.setStringValidator(BuStringValidator.FLOAT); - y2_.setValueValidator(BuValueValidator.FLOAT); - nbPoints_.setCharValidator(BuCharValidator.INTEGER); - nbPoints_.setStringValidator(BuStringValidator.INTEGER); - nbPoints_.setValueValidator(BuValueValidator.INTEGER); - - final JPanel contPoint1 = new JPanel(new FlowLayout(FlowLayout.CENTER)); - contPoint1.add(new JLabel("Point 1:")); - contPoint1.add(x_); - contPoint1.add(new JLabel(TrResource.getS("-"))); - contPoint1.add(y_); - final JPanel contPoint2 = new JPanel(new FlowLayout(FlowLayout.CENTER)); - contPoint2.add(new JLabel("Point 2:")); - contPoint2.add(x2_); - contPoint2.add(new JLabel(TrResource.getS("-"))); - contPoint2.add(y2_); - final JPanel contPoint3 = new JPanel(new FlowLayout(FlowLayout.CENTER)); - contPoint3.add(new JLabel("Nb pts uniform\xE9ments r\xE9partis sur le segment:")); - contPoint3.add(nbPoints_); - - nbPoints_.setText("" + 4); - - conteneur.add(contPoint1); - conteneur.add(contPoint2); - conteneur.add(contPoint3); - conteneur.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix du segment"))); - conteneur.setSize(400, 250); - return conteneur; - } - private JPanel buildParams() { - finesse_.setCharValidator(BuCharValidator.FLOAT); - finesse_.setStringValidator(BuStringValidator.FLOAT); - finesse_.setValueValidator(BuValueValidator.FLOAT); - duree_.setCharValidator(BuCharValidator.FLOAT); - duree_.setStringValidator(BuStringValidator.FLOAT); - duree_.setValueValidator(BuValueValidator.FLOAT); final JPanel conteneur = new JPanel(new GridLayout(1, 1)); conteneur.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix de la finesse et dur\xE9e"))); @@ -318,136 +261,213 @@ return conteneur; } - /** - * Creation du panel graphique. - * - * @return - */ - JPanel panelSegment_; + public boolean isSegmentValid() { + final boolean segValid = !doubleEditor.isEmpty(x_) && !doubleEditor.isEmpty(x2_) && !doubleEditor.isEmpty(y2_) + && !doubleEditor.isEmpty(y_); + return segValid && integerEditor_.getValue(nbPoints_) != null; + } - public Box buildContent() { + public double getDoubleValue(final JComponent c) { + return ((Double) doubleEditor.getValue(c)).doubleValue(); + } - final Box content = Box.createVerticalBox(); - - content.add(choixMode_); - // -- panel des segements --// - if (panelSegment_ == null) panelSegment_ = buildSegments(); - - content.add(panelSegment_); - - // -- panel des variables --// - if (panelVariables_ == null) panelVariables_ = buildVariables(); - content.add(panelVariables_); - - // -- panelSeuil - if (panelSeuil_ == null) panelSeuil_ = buildParams(); - content.add(panelSeuil_); - - // -- panel des resultats --// - if (panelResults_ == null) panelResults_ = buildresults(); - content.add(panelResults_); - - return content; + protected void updateView(final boolean _zoom) { + if (isSegmentValid()) { + lineChooser_.update(GISGeometryFactory.INSTANCE.createSegment(getDoubleValue(x_), getDoubleValue(y_), + getDoubleValue(x2_), getDoubleValue(y2_)), _zoom); + } } - public void buildDialog() { + private JPanel buildSegments() { - // CtuluUIDialog ui_ = new - // CtuluUIDialog(listeWidgetCalque_.get(0).getCalqueController - // ().getVisuPanel()); + final JPanel conteneur = new JPanel(new BuGridLayout(3, 5, 5, false, false, false, false, false)); + conteneur.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix du segment"))); + conteneur.add(new JLabel("")); + conteneur.add(new JLabel("x:")); + conteneur.add(new JLabel("y:")); + conteneur.add(new JLabel("Point 1:")); + conteneur.add(x_); + conteneur.add(y_); + conteneur.add(new JLabel("Point 2:")); + conteneur.add(x2_); + conteneur.add(y2_); + conteneur.add(new JLabel("Nombre de points uniform\xE9ments r\xE9partis sur le segment:")); + conteneur.add(nbPoints_); + final LineString initSelected = lineChooser_.getInitSelected(); + if (initSelected != null) { + final int nbCoordinate = initSelected.getNumPoints(); + doubleEditor.setValue(initSelected.getCoordinateSequence().getX(0), x_); + doubleEditor.setValue(initSelected.getCoordinateSequence().getY(0), y_); + doubleEditor.setValue(initSelected.getCoordinateSequence().getX(nbCoordinate - 1), x2_); + doubleEditor.setValue(initSelected.getCoordinateSequence().getY(nbCoordinate - 1), y2_); + updateView(false); + } + JPanel mainSegment = new JPanel(new BuVerticalLayout(5, false, true)); + mainSegment.add(conteneur); + JPanel pn = new JPanel(new BuGridLayout(3, 2, 0)); + JButton bt = new JButton(TrLib.getString("zoomer sur le segment")); + bt.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent _e) { + updateView(true); - final Frame f = CtuluLibSwing.getFrameAncestorHelper(impl_.getCurrentInternalFrame()); - dialog_ = new JDialog(f); + } + }); + pn.add(bt); + bt = new JButton(TrLib.getString("Zoom initial")); + bt.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent _e) { + lineChooser_.zoomInitial(); - dialog_.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(final WindowEvent _e) { - // on desactive l action de suivi sur le graphe - dialog_ = null; } + }); + pn.add(bt); + bt = new JButton(EbliLib.getS("Restaurer")); + bt.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent _e) { + lineChooser_.restaurer(); - @Override - public void windowClosing(final WindowEvent _e) { - dialog_ = null; } }); + pn.add(bt); + mainSegment.add(pn); + return mainSegment; + } - dialog_.setModal(true); - dialog_.pack(); - dialog_.setTitle(getTitle()); - final JPanel container = new JPanel(new BorderLayout()); - container.add(buildContent(), BorderLayout.CENTER); - container.add(new JLabel("<html> <body><b><center>" + getTitle() + "</center></b> </body></html>"), - BorderLayout.NORTH); - dialog_.setContentPane(container); - dialog_.setSize(400, 450); - dialog_.setLocationRelativeTo(CtuluLibSwing.getFrameAncestor(impl_.getCurrentInternalFrame())); - dialog_.setVisible(true); + private JPanel buildVariables() { + final JPanel conteneur = new JPanel(new BorderLayout()); + listVar_ = new JList(source_.getNewVarListModel()); + listVar_.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + conteneur.add(new JScrollPane(listVar_)); + conteneur.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix des variables"))); + return conteneur; + } + public void decoreBtApply(final JButton _bt) {} + + public int getNbMessageMax() { + return 1; } - public String getTitle() { - return TrResource.getS("Lignes de courants/trajectoires"); + public JComponent getPanel() { + if (content_ != null) return content_; + content_ = new BuPanel(new BuVerticalLayout(5)); + content_.add(buildMainProperties()); + // -- panel des segements --// + content_.add(buildSegments()); + // -- panel des variables --// + content_.add(buildVariables()); + content_.add(buildParams()); + return content_; } - protected double getFinesse() { - return Double.parseDouble(finesse_.getText()); + private JPanel buildMainProperties() { + JPanel pn = new JPanel(new BuGridLayout(2, 5, 5)); + pn.add(new JLabel(TrResource.getS("Mode"))); + pn.add(choixMode_); + pn.add(new JLabel(TrResource.getS("Pas de temps intial"))); + cbFirstTime_ = new BuComboBox(new CtuluComboBoxModelAdapter(source_.getNewTimeListModel())); + cbFirstTime_.setSelectedIndex(0); + pn.add(cbFirstTime_); + pn.add(new JLabel(TrResource.getS("Vecteur"))); + ListModel flecheListModel = source_.getNewFlecheListModel(); + CtuluComboBoxModelAdapter cb = new CtuluComboBoxModelAdapter(flecheListModel); + cbVitesse_ = new BuComboBox(cb); + cb.setSelectedItem(flecheListModel.getElementAt(0)); + // on s\xE9lectionne la vitesse par defaut + if (flecheListModel.getSize() > 1) { + for (int i = flecheListModel.getSize() - 1; i >= 0; i--) { + TrPostFlecheContent flecheContent = (TrPostFlecheContent) flecheListModel.getElementAt(i); + if (flecheContent.getVar() == H2dVariableType.VITESSE) { + cb.setSelectedItem(flecheListModel.getElementAt(i)); + break; + } + } + } + return pn; } - protected int getNbPoints() { - return Integer.parseInt(nbPoints_.getText()); + /** + * retourne l indice du pas de temps. + * + * @return + */ + protected int getSelectedTimeStep() { + return cbFirstTime_.getSelectedIndex(); } - protected double getX() { - return Double.parseDouble(x_.getText()); + /** + * retourne la variable selectionnee + * + * @return + */ + protected TrPostFlecheContent getSelectedVariable() { + + return (TrPostFlecheContent) cbVitesse_.getSelectedItem(); } - protected double getY() { - return Double.parseDouble(y_.getText()); + public String getTitre() { + return TrResource.getS("Lignes de courants") + "/" + TrResource.getS("Trajectoires"); } - protected double getX2() { - return Double.parseDouble(x2_.getText()); + protected boolean isLigneCourant() { + return choixMode_.getSelectedIndex() == 0; } - protected double getY2() { - return Double.parseDouble(y2_.getText()); + protected boolean isTrajectoire() { + return choixMode_.getSelectedIndex() == 1; } - protected double getDuree() { - return Double.parseDouble(duree_.getText()); + public String isValid() { + // pas necessaire + // if (listVar_.getSelectedIndex() == -1) { return TrResource.getS("Il faut choisir une variable"); } + // if (cbFirstTime_.getSelectedIndex() == -1) { return TrResource.getS("Il faut choisir un pas de temps"); } + if (!this.integerEditor_.isValueValidFromComponent(finesse_)) { return TrResource + .getS("La finesse doit \xEAtre d\xE9fini par un entier sup\xE9rieur \xE0 1"); } + if (!isSegmentValid()) { return TrResource.getS("Le segment n'est pas d\xE9fini"); } + if (integerEditor_.getValue(nbPoints_) == null) { return TrResource.getS("Pr\xE9ciser le nombre de trajectoires"); } + if (dureeEditor_.isEmpty(duree_)) { return TrResource.getS("La dur\xE9e doit \xEAtre d\xE9finie par un r\xE9el en secondes"); } + // on doit verifier que la duree est bien comprise dans les pas de temps du projet + if (isTrajectoire()) { + final int duree = getDuree(); + final double timeSelected = source_.getTimeStep(cbFirstTime_.getSelectedIndex()); + final double timeEnd = timeSelected + duree; + final double lastTimeStep = source_.getTimeStep(source_.getNbTimeStep() - 1); + if (timeEnd < source_.getTimeStep(0) || timeEnd > lastTimeStep) { + final String min = "-".concat(source_.getTimeFormatter().format(timeSelected - source_.getTimeStep(0))); + final String max = source_.getTimeFormatter().format(lastTimeStep - timeSelected); + return TrResource.getS("la dur\xE9e du calcul doit \xEAtre comprise entre {0} et {1}", min, max); + } + + } + if (getFirsCoordinate().distance(getEndCoordinate()) < MAXDIST) { + boolean res = calque_ + .getCtuluUI() + .question( + TrResource.getS("Calculer une seule trajectoire"), + TrResource + .getS("Les extremit\xE9s du segment sont confondues. Une seule trajectoire sera calcul\xE9e.\nVoulez-vous continuer ?")); + if (!res) { return TrResource.getS("Choisir 2 points diff\xE9rents"); } + + } + + return null; } - /** - * Methode qui realise les calculs d'int\xE9grale par rapport aux donn\xE9es - */ - private void computeResults() { + private Integer getDuree() { + return ((Integer) dureeEditor_.getValue(duree_)); + } - new CtuluTaskOperationGUI(impl_, FudaaLib.getS("Calcul Bilan")) { - @Override - public void act() { - final ProgressionInterface prog = getMainStateReceiver(); + // EfLigneDeCourantActivity activity_; - // creqtion de l algo - algoCalcul_ = new TrComputeLigneCourantTrajectoire(calque_); + public void stopTask() { + if (algoCalcul_ != null) algoCalcul_.stop(); - // creation de la liste des points uniform\xE9ment r\xE9partie sur le segment // - final GrPoint point1 = new GrPoint(getX(), getY(), 0); - final GrPoint point2 = new GrPoint(getX2(), getY2(), 0); - final int nbPoints = getNbPoints(); - // FIXME il faut selectionner une variable vecteur avec + } - final TrPostFlecheContent flecheContent = getSelectedVariable(); - algoCalcul_.computeLigneCourant(point1, point2, nbPoints, getDuree(), getSelectedTimeStep(), getFinesse(), - flecheContent.getVx(), flecheContent.getVy(), getMainStateReceiver()); + public void dialogClosed() { + lineChooser_.close(); - // -- mise a jour du tableau de res --// - modelResult_.fireTableDataChanged(); - impl_.unsetMainMessage(); - impl_.unsetMainProgression(); - } - }.start(); } } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostWizardProfilSpatial.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostWizardProfilSpatial.java 2008-10-30 17:08:35 UTC (rev 4119) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/dialogSpec/TrPostWizardProfilSpatial.java 2008-10-30 17:09:00 UTC (rev 4120) @@ -12,7 +12,6 @@ import org.fudaa.ctulu.gui.CtuluLibSwing; import org.fudaa.dodico.ef.operation.EfLineIntersectionsResultsI; import org.fudaa.dodico.h2d.type.H2dVariableType; -import org.fudaa.ebli.commun.EbliLib; import org.fudaa.ebli.courbe.EGGraphe; import org.fudaa.fudaa.commun.FudaaLib; import org.fudaa.fudaa.meshviewer.profile.MvProfileBuilderFromTree; @@ -83,14 +82,11 @@ for (int i = 0; i < this.actionChoixGraphes_.listeGraphesChoisis.size(); i++) { final EGGraphe graphe = this.actionChoixGraphes_.listeGraphesChoisis.get(i); + // -- preliminaire --// - if (builderParams_.btSelectedLine_.isSelected()) { - builderParams_.selectedLine_ = builderParams_.initSelected_; - builderParams_.name_ = EbliLib.getS("S\xE9lection"); - } else { - builderParams_.selectedLine_ = builderParams_.getSelectedLineInTree(builderParams_.tree_); - builderParams_.name_ = builderParams_.getSelectedLineTitle(builderParams_.tree_); - } + //bizarre ? + builderParams_.selectedLine_ = builderParams_.getSelectedLine(); + builderParams_.name_ = builderParams_.getSelectedLineName(); // -- Creation d un nouveau graphe panel sans widget--// final CtuluTaskDelegate task = impl.createTask(FudaaLib.getS("Construction des courbes")); @@ -192,21 +188,15 @@ return null; } - private static int cptGraphe = 1; +// private static int cptGraphe = 1; /** * Action de creation d un nouveau widget graphe en live */ protected void createNewGraphe() { - // -- creation auto d un nouveau graphe widget avec courbe temporelle - if (builderParams_.btSelectedLine_.isSelected()) { - builderParams_.selectedLine_ = builderParams_.initSelected_; - builderParams_.name_ = EbliLib.getS("S\xE9lection"); - } else { - builderParams_.selectedLine_ = builderParams_.getSelectedLineInTree(builderParams_.tree_); - builderParams_.name_ = builderParams_.getSelectedLineTitle(builderParams_.tree_); - } + builderParams_.selectedLine_ = builderParams_.getSelectedLine(); + builderParams_.name_ = builderParams_.getSelectedLineName(); final CtuluTaskDelegate task = builderParams_.ui_.createTask(FudaaLib.getS("Construction des courbes")); @@ -243,8 +233,7 @@ public int getStepDisabledButtons() { int r = super.getStepDisabledButtons(); if (current_ == 0) { - if (!builderParams_.btSelectedLine_.isSelected() - && builderParams_.getSelectedLineInTree(builderParams_.tree_) == null) r |= BuButtonPanel.SUIVANT; + if (builderParams_.getSelectedLine() == null) r |= BuButtonPanel.SUIVANT; } else if (current_ == 2) { if ((actionChoixGraphes_.listeGraphesChoisis == null || actionChoixGraphes_.listeGraphesChoisis.size() == 0) && !checkboxNewGraphe_.isSelected()) r |= BuButtonPanel.TERMINER; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |