Package kartoMNT

Source Code of kartoMNT.InterpolationDialog$MyDocumentListener

/**
* Boite de dialogue permettant d'�diter les param�tres de g�n�ration du MNT et
* de lancer l'interpolation
*
* @author HEIT Sylvestre & Coustillac Laurent
*
*
* Programme kartoMNT : g�n�ration de MNT � partir d'une carte de lignes de niveaux
* Copyright (C) 2002  HEIT Sylvestre & Coustillac Laurent
*
* Ce programme est libre, vous pouvez le redistribuer et/ou le modifier selon les termes de la Licence
*Publique G�n�rale GNU publi�e par la Free Software Foundation (version 2).
*
*Ce programme est distribu� car potentiellement utile, mais SANS AUCUNE GARANTIE, ni explicite ni implicite,
*y compris les garanties de commercialisation ou d'adaptation dans un but sp�cifique. Reportez-vous � la
*Licence Publique G�n�rale GNU pour plus de d�tails.
*
*Vous devez avoir re�u une copie de la Licence Publique G�n�rale GNU en m�me temps que ce programme ; si
*ce n'est pas le cas, �crivez � la
*Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, �tats-Unis.
*/
package kartoMNT;

import javax.swing.*;
import java.lang.*;
import kartoMNT.karto.math.*;
import java.awt.*;
import java.awt.geom.*;
import kartoMNT.org.netbeans.lib.awtextra.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
import javax.swing.event.*;

import kartoMNT.karto.outils.MsgInfo;

/*
* interpolationDialog.java
*
* Created on 6 mars 2002, 19:52
* @author  sylvestre heit
*/


public class InterpolationDialog extends DocumentDialog //implements ComponentListener
{

    private JLabel jLabel1;
    private JTextField jTextFieldx2;
    private JTextField jTextFieldy2;
    private JLabel jLabel2;
    private JLabel jLabel3;
    private JLabel jLabel4;
    private JTextField jTextField3;
    private JTextField jTextFieldy1;
    private JLabel jLabel5;
  //private JCheckBox jCheckBox3;
    private JCheckBox jCheckBox4;
    private JCheckBox jCheckBox5;
    private JLabel jLabel6;
    private JLabel jLabel7;
    private JTextField jTextFieldx1;
    private JLabel jLabel8,jLabel9,jLabel10,jLabel11;
    private JTextField jTextField6;
    private JButton jButton2;
    private JButton jButton3;
    private JButton jButtonView;
    private JTextField jTextFieldNbiter,jTextResiduMax;
    private ButtonGroup buttonGroup;
    private JToggleButton buttonSelectRegion;
    private ActionToolContextual actionSelectRegion;

  // End of variables declaration//GEN-END:variables
    DocumentKartoContainer documentKartoContainer;
    DocumentMNTContainer documentMNTContainer;
    DocumentKarto document;

    SelectionRegion selectionRegion;
    DecimalFormat format;
    boolean flag,first;
 
 
  /** Creates new form interpolationDialog */
    public InterpolationDialog(java.awt.Frame parent, DocumentKartoContainer _documentKartoContainer,
                 DocumentMNTContainer _documentMNTContainer,
                 ActionToolContextual _actionSelectRegion,JToggleButton _button
                )
  {
      super(parent, false);
      first=true;
      flag=true;
      actionSelectRegion=_actionSelectRegion;
      buttonSelectRegion=_button;
      initComponents();
      documentKartoContainer=_documentKartoContainer;
      documentMNTContainer=_documentMNTContainer;
      selectionRegion=((ToolSelectRegionMNT)actionSelectRegion.getTool()).getSelectionRegion();
      DecimalFormatSymbols sym=new DecimalFormatSymbols();
      sym.setDecimalSeparator('.');
      format=new DecimalFormat("#.###",sym);
      updateDelta();
      modeManual();

  }

  /**
   * This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
    private void initComponents()
  {//GEN-BEGIN:initComponents
      jLabel1 = new javax.swing.JLabel();
      jTextFieldx2 = new javax.swing.JTextField();
      jTextFieldy2 = new javax.swing.JTextField();
      jLabel2 = new javax.swing.JLabel();
      jLabel3 = new javax.swing.JLabel();
      jLabel4 = new javax.swing.JLabel();
      jTextField3 = new javax.swing.JTextField();
      jTextFieldy1 = new javax.swing.JTextField();
      jLabel5 = new javax.swing.JLabel();
    //jCheckBox3 = new javax.swing.JCheckBox();
      jCheckBox4 = new javax.swing.JCheckBox();
      jCheckBox5 = new javax.swing.JCheckBox();
      jLabel6 = new javax.swing.JLabel();
      jLabel7 = new javax.swing.JLabel();
      jTextFieldx1 = new javax.swing.JTextField();
      jLabel8 = new javax.swing.JLabel();
      jTextField6 = new javax.swing.JTextField();
      jButton2 = new javax.swing.JButton();
      jButton3 = new javax.swing.JButton();
      jButtonView = new javax.swing.JButton();
      jLabel9 = new javax.swing.JLabel();
      jLabel10 = new javax.swing.JLabel();
      jLabel11 = new javax.swing.JLabel();
      jTextFieldNbiter= new JTextField();
      jTextResiduMax= new JTextField();
      buttonGroup = new ButtonGroup();

      getContentPane().setLayout(new kartoMNT.org.netbeans.lib.awtextra.AbsoluteLayout());

      addWindowListener(new java.awt.event.WindowAdapter()
              {
                public void windowClosing(java.awt.event.WindowEvent evt)
                {
                  closeDialog(evt);
                }
              }
             );

      addWindowListener(new java.awt.event.WindowAdapter()
              {
                public void windowClosed(java.awt.event.WindowEvent evt)
                {
                  close(evt);
                }
                public void windowActivated(WindowEvent evt)
                {
                  activate(evt);
                }
              }
             );


      jLabel6.setText(ResourceManager.get("mntDim"));
      getContentPane().add(jLabel6, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, -1, -1));
      getContentPane().add(buttonSelectRegion, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(150, 1, -1, -1));

      jCheckBox4.setText(ResourceManager.get("manChoice"));
      jCheckBox4.addActionListener(new java.awt.event.ActionListener()
                   {
                     public void actionPerformed(java.awt.event.ActionEvent evt)
                     {
                       option1(evt);
                     }
                   }
                  );

    //getContentPane().add(jCheckBox4, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1));
      int h=30;


      jLabel2.setText("x1=");
      getContentPane().add(jLabel2, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(20, h, -1, -1));

      jTextFieldx1.setText("0");
      getContentPane().add(jTextFieldx1, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(40, h, 60, -1));

      jLabel5.setText("y1=");
      getContentPane().add(jLabel5, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(120, h, -1, -1));

      jTextFieldy1.setText("0");
      getContentPane().add(jTextFieldy1, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(140, h, 60, -1));

      h+=30;

      jLabel4.setText("x2=");
      getContentPane().add(jLabel4, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(20, h, -1, -1));

      jTextFieldx2.setText("0");
      getContentPane().add(jTextFieldx2, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(40, h, 60, -1));

      jLabel3.setText("y2=");
      getContentPane().add(jLabel3, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(120, h, 20, -1));

      jTextFieldy2.setText("0");
      getContentPane().add(jTextFieldy2, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(140, h, 60, -1));

      MyDocumentListener listenerSize=new MyDocumentListener()
                    {
                        public void run()
                      {
                          if(flag)
                            updateSize();
                      }
                    };
      jTextFieldx1.getDocument().addDocumentListener(listenerSize);
      jTextFieldy1.getDocument().addDocumentListener(listenerSize);
      jTextFieldx2.getDocument().addDocumentListener(listenerSize);
      jTextFieldy2.getDocument().addDocumentListener(listenerSize);


    /*jCheckBox5.setText("MNT de taille minimale contenant tous les points de la carte");
      jCheckBox5.addActionListener(new java.awt.event.ActionListener()
                   {
                     public void actionPerformed(java.awt.event.ActionEvent evt)
                     {
                       option2(evt);
                     }
                   }
                  );
    */

    //getContentPane().add(jCheckBox5, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, -1, -1));
      h+=40;

      jLabel1.setText(ResourceManager.get("echantillonnage"));
      getContentPane().add(jLabel1, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(10, h, -1, -1));

      h+=20;

      jLabel8.setText("deltaX=");
      getContentPane().add(jLabel8, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(30, h, -1, -1));

      jTextField6.setText("1");
      getContentPane().add(jTextField6, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(70, h, 50, -1));



      jLabel7.setText("deltaY=");
      getContentPane().add(jLabel7, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(140, h, -1, -1));

      jTextField3.setText("1");
      getContentPane().add(jTextField3, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(180, h, 50, -1));


    /*MyDocumentListener listenerDelta=new MyDocumentListener()
                     {
                       public void run()
                       {
                         updateDelta();
                       }
                     };

      jTextField6.getDocument().addDocumentListener(listenerDelta);
      jTextField3.getDocument().addDocumentListener(listenerDelta);*/
      h+=30;


      jButtonView.setText(ResourceManager.get("seePoints"));
      getContentPane().add(jButtonView, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(50, h, -1, -1));
      jButtonView.addActionListener(new java.awt.event.ActionListener()
                    {
                      public void actionPerformed(java.awt.event.ActionEvent evt)
                      {
                        viewPoints(evt);
                      }
                    }
                   );

      h+=30;

      jLabel9.setText(ResourceManager.get("interpParam"));
      getContentPane().add(jLabel9, new AbsoluteConstraints(10, h, -1, -1));

      h+=20;

      jLabel10.setText(ResourceManager.get("iterMax"));
      getContentPane().add(jLabel10, new AbsoluteConstraints(30, h, -1, -1));

      jTextFieldNbiter.setText("5000");
      getContentPane().add(jTextFieldNbiter, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(190, h, 50, -1));

      h+=30;

      jLabel11.setText(ResourceManager.get("resMax"));
      getContentPane().add(jLabel11, new AbsoluteConstraints(30, h, -1, -1));

      jTextResiduMax.setText(".1");
      getContentPane().add(jTextResiduMax, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(190, h, 50, -1));

      jButton2.setText(ResourceManager.get("OkKey"));
      jButton2.addActionListener(new java.awt.event.ActionListener()
                   {
                     public void actionPerformed(java.awt.event.ActionEvent evt)
                     {
                       actionOk(evt);
                     }
                   }
                  );
      h+=30;
      getContentPane().add(jButton2, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(80, h, -1, -1));

      jButton3.setText(ResourceManager.get("CancelKey"));
      jButton3.addActionListener(new java.awt.event.ActionListener()
                   {
                     public void actionPerformed(java.awt.event.ActionEvent evt)
                     {
                       actionCancel(evt);
                     }
                   }
                  );

      getContentPane().add(jButton3, new kartoMNT.org.netbeans.lib.awtextra.AbsoluteConstraints(140, h, -1, -1));
      buttonGroup.add(jCheckBox4);
      buttonGroup.add(jCheckBox5);
      setTitle(ResourceManager.get("MNTGeneration"));
      jCheckBox4.setSelected(true);
      pack();
      Util.centrer(this);
  }
  //GEN-END:initComponents

  /**
   * Ferme le dialogue
   */
    private void fermer()
  {
      buttonSelectRegion.setSelected(false);
      actionSelectRegion.actionPerformed(new ActionEvent(buttonSelectRegion,0,"selected"));
      setVisible(false);
      dispose();
  }

  /**
   * Annule tout : ferme le dialogue
   */
    private void actionCancel(java.awt.event.ActionEvent evt)
  {
      fermer();
  }

  /**
   * Fixe la region dans laquelle on va g�n�rer le MNT
   */
    public void setRegion(double x1,double y1,double x2,double y2)
  {
      flag=false;
      double xx1=Math.min(x1,x2);
      double xx2=Math.max(x1,x2);
      double yy1=Math.min(y1,y2);
      double yy2=Math.max(y1,y2);

    // on arrondi par exces sinon on a un message indiquant qu'il y a des points a l'ext�rieur de la carte
    // quand on lance l'interpolation
      jTextFieldx1.setText(""+format.format(Math.ceil(xx1*1000)/1000.0));
      jTextFieldy1.setText(""+format.format(Math.ceil(yy1*1000)/1000.0));
      jTextFieldx2.setText(""+format.format(Math.floor(xx2*1000)/1000.0));
      jTextFieldy2.setText(""+format.format(Math.floor(yy2*1000)/1000.0));
      flag=true;
  }

  /**
   * Selection en mode manuel
   */
    public void modeManual()
  {
      option1(null);
      jCheckBox4.setSelected(true);
  }

  /**
   * Indique un FloatData contient la donn�e de coordonn�e x,y
   * @param x la coordonn�e en X
   * @param y la coordonn�e en y
   * @return true si (x,y) est dans le FloatData, false sinon
   */
    public boolean inside(FloatData d,double x,double y)
  {
      return ( (x>=0)&&(y>=0)&&(x<d.getXMax())&&(y<d.getYMax()) );
  }

  /**
   * Validation du dialogue
   * C'est � partir de l� qu'on lance la g�n�ration du MNT
   */
    private void actionOk(java.awt.event.ActionEvent evt)
  {
    // On recup�re le doc courant
      DocumentKarto doc=documentKartoContainer.getCurrentDocumentKarto();
      if(doc==null)
    {
        MsgInfo msg=new MsgInfo(frame,MsgInfo.INFO,MsgInfo.OK,ResourceManager.get("noDocOpenError"));

        return;
    }
      try
      {
        // R�cup�ration des dimensions du MNT � g�n�rer
          double deltax,deltay;
          Rectangle2 rect=new Rectangle2();
          if(true/*jCheckBox4.isSelected()*/)
        {
            double xx1,yy1,xx2,yy2;
            xx1=Double.parseDouble(jTextFieldx1.getText());
            yy1=Double.parseDouble(jTextFieldy1.getText());

            xx2=Double.parseDouble(jTextFieldx2.getText());
            yy2=Double.parseDouble(jTextFieldy2.getText());
            rect.x1=Math.min(xx1,xx2);

            rect.y1=Math.min(yy1,yy2);

            rect.x2=Math.max(xx1,xx2);

            rect.y2=Math.max(yy1,yy2);

        } else
          {// on obtient un rectangle englobant
              Proj projection=doc.getProjection();
              if(projection==null)
              {
                  MsgInfo msg=new MsgInfo(frame,MsgInfo.ERROR,MsgInfo.OK,ResourceManager.get("mapNotCalibError"));

                  return;
              }
              rect=MathUtil.getEnglobingRect(projection,0,0,doc.getLignesDeNiveaux().getXMax()-1,doc.getLignesDeNiveaux().getYMax()-1);

          }
          deltax=Double.parseDouble(jTextField6.getText());
          deltay=Double.parseDouble(jTextField3.getText());
          int nbiter=Integer.parseInt(jTextFieldNbiter.getText());
          double residumax=Double.parseDouble(jTextResiduMax.getText());

          Proj projection=doc.getProjection();
          FloatData fd=doc.getLignesDeNiveaux();

          boolean generate=true;
          if(!(inside(fd,projection.projX(rect.x1,rect.y1),projection.projY(rect.x1,rect.y1)) &&
              inside(fd,projection.projX(rect.x1,rect.y2),projection.projY(rect.x1,rect.y2)) &&
              inside(fd,projection.projX(rect.x2,rect.y1),projection.projY(rect.x2,rect.y1)) &&
              inside(fd,projection.projX(rect.x2,rect.y2),projection.projY(rect.x2,rect.y2)) ) )
        {
            MsgInfo msg=new MsgInfo(frame,MsgInfo.INFO,MsgInfo.OUI|MsgInfo.NON,ResourceManager.get("regionOut"));
            generate=(msg.reponse()==MsgInfo.OUI);
        }

          if(generate)
          {
            //on lance l'interpolation dans un thread
              class Run extends Thread
              {
                  LignesDeNiveaux lignesDeNiveaux;
                  public int nbiter;
                  public  float residumax;
                  public  Proj projection;
                  public  double x1,y1,dx,dy;
                  public  int sx,sy;
                  public MNT mnt;
                  ProgressionDialog pd;
                  public void run()
                {
                  //G�neration du MNT � partir des lignes de niveau
                  //mnt=lignesDeNiveaux.interpolationOLd(nbiter,residumax,projection,x1,y1,dx,sx,dy,sy);
                  // Correction bug de generation :
                    mnt=lignesDeNiveaux.interpolation(nbiter,residumax,projection,x1,y1,dx,sx,dy,sy);
                 
                  //notifyInterpolationFinished();
                    if(pd!=null)
                      pd.taskFinished();
                }
              };
              Run mythread=new Run();
              mythread.lignesDeNiveaux=doc.getLignesDeNiveaux();
              mythread.nbiter=nbiter;
              mythread.residumax=(float)residumax;
              mythread.projection=projection;
              mythread.x1= rect.x1;
              mythread.y1= rect.y1;
              mythread.dx= deltax;
              mythread.dy= deltay;
              mythread.sx=(int)((rect.x2-rect.x1)/deltax+1) ;
              mythread.sy=(int)((rect.y2-rect.y1)/deltay+1) ;

              ProgressionDialog pd=new ProgressionDialog(frame,doc.getLignesDeNiveaux(),mythread);
              doc.getLignesDeNiveaux().setProgressionDialog(pd);
//System.out.println("GFE progression InterpolationDialog");
              mythread.pd=pd;
              mythread.start();
              pd.setVisible(true);
              doc.getLignesDeNiveaux().setProgressionDialog(null);
            /*MNT mnt=doc.getLignesDeNiveaux().interpolation(nbiter,(float)residumax,
                doc.getProjection(), rect.x1,rect.y1,deltax,(int)((rect.x2-rect.x1)/deltax+1), deltay,(int)((rect.y2-rect.y1)/deltay+1));
            */
              MNT mnt_final=mythread.mnt;
             
//  System.out.println("InterpolationDialog mnt="+mnt_final);
              if(mnt_final!=null)
              {
                // Ici on cr�e le document MNT-->faire passer aussi le lignes
                  DocumentMNTContainer cont=documentMNTContainer.nextDocumentMNTContainer();
                  DocumentMNT dmnt=new DocumentMNT(cont);
                  dmnt.setMNT(mnt_final);
             
               
                  LignesDeNiveaux ldn=doc.getLignesDeNiveaux();
                // Nouvelles lignes de niveau � la dimension du MNT selectionn�
                  double x1lignes=doc.calibration.projX(rect.x1,rect.y1);     
                  double y1lignes=doc.calibration.projY(rect.x1,rect.y1);
                  double x2lignes=doc.calibration.projX(rect.x2,rect.y2);
                  double y2lignes=doc.calibration.projY(rect.x2,rect.y2);
                // Valeurs absolues : la calibration peut �tre invers�e...
                  int dx = Math.abs((int)(x2lignes-x1lignes));
                  int dy = Math.abs((int)(y2lignes-y1lignes));
                  //System.out.println("dimensions: " + dx + " x " + dy);
                  LignesDeNiveaux newLdn = new LignesDeNiveaux(dx-1,dy-1);
                int posX,posY;
                for (int y = 0; y < newLdn.getYMax(); y++){
                  for (int x = 0; x < newLdn.getXMax(); x++){
                    //newLdn.setValue(x,y,ldn.getValue((int)(Math.min(x1lignes,x2lignes)+x),(int)(Math.min(y1lignes,y2lignes)+y)));
                     if(x1lignes<x2lignes)
                       posX = (int)(x1lignes+x);
                     else
                       posX = (int)(x1lignes-x);
                    if(y1lignes<y2lignes)
                      posY = (int)(y1lignes+y);
                     else
                       posY = (int)(y1lignes-y);
                     // l'image est invers�e en Y (pb de librairie graphique)
                     y=dy-y-2;
                    newLdn.setValueData(x,y,ldn.getValueData(posX,posY));
                  }
                }
               
               
                // Attacher les lignes pour la superposition
                  dmnt.setLdn(newLdn);
               
                // Ajuster l'�chelle en fonction des pas d'echantillonnage
                  dmnt.setScale(1,1);
               
                  dmnt.setFileName(ResourceManager.get("noTitle"));
                  cont.addDocument(dmnt);

                  fermer();
              }
          }
      }
      catch (NumberFormatException ne)
      {
          MsgInfo msg=new MsgInfo(frame,MsgInfo.ERROR,MsgInfo.OK,ResourceManager.get("fillError"));
      }


  }



  /**
   * Selectionner la region avec la souris
   */
    private void option2(java.awt.event.ActionEvent evt)
  {
      jTextFieldx2.setEnabled(false);
      jTextFieldy2.setEnabled(false);
      jTextFieldy1.setEnabled(false);
      jTextFieldx1.setEnabled(false);
      if(document!=null)
      {
          Rectangle2 rect=MathUtil.getEnglobingRect(document.getProjection(),0,0,
                  document.getLignesDeNiveaux().getXMax()-1,document.getLignesDeNiveaux().getYMax()-1);
          selectionRegion.setVisible(true);
          selectionRegion.setRegionLambert(rect.x1,rect.y1,rect.x2,rect.y2);
          setRegion(rect.x1,rect.y1,rect.x2,rect.y2);
        //document.setTool(null);
      }
  }

 
  /**
   * Selectionner la region en entrant les  coordonn�es
   */
    private void option1(java.awt.event.ActionEvent evt)
  {
      jTextFieldx2.setEnabled(true);
      jTextFieldy2.setEnabled(true);
      jTextFieldy1.setEnabled(true);
      jTextFieldx1.setEnabled(true);

    /*if(document!=null)
      {
          ToolSelectRegionMNT tool;
          document.setTool(tool=new ToolSelectRegionMNT(selectionRegion));
          tool.setInterpolationDialog(this);
      }*/

  }

 
  /**
   * Afficher les points d'�chantillonnage
   */
    private void viewPoints(java.awt.event.ActionEvent evt)
  {
      updateDelta();
      selectionRegion.afficherLesPoints(true);
  }

  /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt)
  {
      fermer();
  }



    public void documentSelected(Document doc)
  {
      if(document!=null)
        document.removeObject(selectionRegion);
      document=(DocumentKarto)doc;
      if( (document!=null)&&(isVisible()) )
      {
          activate(null);
      }
  }

    public void close(WindowEvent evt)
  {
      if(document!=null)
      {
          document.removeObject(selectionRegion);

          first=true;
      }
  }

    public void activate(WindowEvent evt)
  {
      if(document!=null)
    {
        if(!document.containsObject(selectionRegion))
      {
          selectionRegion.afficherLesPoints(false);
          document.addObject(1000,selectionRegion);
          ToolSelectRegionMNT tool=((ToolSelectRegionMNT)actionSelectRegion.getTool());
        /*if(jCheckBox4.isSelected())
          {*/
          buttonSelectRegion.setSelected(true);
          actionSelectRegion.actionPerformed(new ActionEvent(buttonSelectRegion,0,"selected"));
        /*document.setTool(tool=new ToolSelectRegionMNT(selectionRegion));*/
          tool.setInterpolationDialog(this);
        //}
          selectionRegion.setEnabled(true);
          selectionRegion.setProj(document.getProjection());
          selectionRegion.setDimension(document.getCarte().getWidth(),document.getCarte().getHeight());

        /*if(jCheckBox5.isSelected()||first)
          {
              first=false;
              if(document.getProjection()!=null)
              {
                  Rectangle2 rect=MathUtil.getEnglobingRect(document.getProjection(),0,0,
                          document.getLignesDeNiveaux().getXMax()-1,document.getLignesDeNiveaux().getYMax()-1);
                  selectionRegion.setVisible(true);
                  selectionRegion.setRegionLambert(rect.x1,rect.y1,rect.x2,rect.y2);
              }
          }*/
      }
    }
  }

 
  /**
   * Mise � jour des pas d'�chantillonnages
   */
    private void updateDelta()
  {
      try
      {

          double dx=Double.parseDouble(jTextField6.getText());
          double dy=Double.parseDouble(jTextField3.getText());
          selectionRegion.setEchantillonDelta(dx,dy);
      }
      catch (NumberFormatException ne)
      {
        /*MsgInfo msg=new MsgInfo(frame,MsgInfo.ERROR,MsgInfo.OK,"Un des champs n'est pas correctement rempli:\n"
        +"verifiez que les nombres que vous avez entr� ne contiennent pas\n de carat�re invalides (par exemples des lettres)");
        */

      }
  }

  /**
   * Met � jour la taille de la region selectionn�e
   */
    private void updateSize()
  {
      selectionRegion.afficherLesPoints(false);
      try
      {
          double xx1,yy1,xx2,yy2;
          xx1=Double.parseDouble(jTextFieldx1.getText());
          yy1=Double.parseDouble(jTextFieldy1.getText());

          xx2=Double.parseDouble(jTextFieldx2.getText());
          yy2=Double.parseDouble(jTextFieldy2.getText());
          selectionRegion.setRegionLambert(xx1,yy1,xx2,yy2);
      }
      catch (NumberFormatException ne)
      {
        /*MsgInfo msg=new MsgInfo(frame,MsgInfo.ERROR,MsgInfo.OK,"Un des champs n'est pas correctement rempli:\n"
        +"verifiez que les nombres que vous avez entr� ne contiennent pas\n de carat�re invalides (par exemples des lettres)");
        */
      }
  }

    protected class MyDocumentListener implements DocumentListener
  {
      public void changedUpdate(DocumentEvent e)
    {
        run();
    }
      public void insertUpdate(DocumentEvent e)
    {
        run();
    }
      public void removeUpdate(DocumentEvent e)
    {
        run();
    }
      public void run()
    {}
  }
}
TOP

Related Classes of kartoMNT.InterpolationDialog$MyDocumentListener

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.