package demos.nurbs.surfaceapp; import java.awt.AWTEvent; import java.awt.event.ActionEvent; import java.util.Collections; import java.util.Vector; import javax.swing.AbstractAction; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import demos.nurbs.icons.*; /** * Class reacting to events occuring on toolbar and menu * Třída reagující na události z nástrojové lišty a menu * @author Tomáš Hráský * */ @SuppressWarnings("serial") public class ActListener extends AbstractAction { /** * Parent window * Odkaz na rodičovské okno */ private SurfaceApp app; /** * FIle chooser object * Objekt pro výběr souboru */ private JFileChooser fc; /** * Creates new instance with link to parent window * Vytvoří instanci objektu s odkazem na rodičovské okno * @param app parent window */ public ActListener(SurfaceApp app) { this.app=app; fc=new JFileChooser("./"); } /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { if(e.getActionCommand()==SurfaceApp.PRIDAT_AC_RADEK){ if(Surface.getInstance().getPointsInU()>=2){ Surface surface=Surface.getInstance(); Vector lastRow=new Vector(); int i; for(i=surface.getCtrlPoints().length-1;i>=surface.getCtrlPoints().length-surface.getPointsInV()*4;i--){ lastRow.add(surface.getCtrlPoints()[i]); } Collections.reverse(lastRow); for(int j=0;j prevLastRow=new Vector(); for(;i>=surface.getCtrlPoints().length-2*surface.getPointsInV()*4;i--){ prevLastRow.add(surface.getCtrlPoints()[i]); } Collections.reverse(prevLastRow); for(int j=0;j diffs=new Vector(); for(i=0;i newCtrls=new Vector(); i=0; for(float f:surface.getCtrlPoints()){ newCtrls.add(f); } // newCtrls.addAll(lastRow); for(i=0;i yes/no dialog -> if yes->new surface action //int retval=JOptionPane.showOptionDialog(null,"Malý počet bodů pro vytvoření nového řádku. Přejete si definovat novou plochu?","Definovat novou plochu?",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,JOptionPane.YES_OPTION); int retval=JOptionPane.showOptionDialog(null,"Not enough points for newe row. Would you like to define new surface?","Define new surface?",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,JOptionPane.YES_OPTION); if(retval==JOptionPane.YES_OPTION) actionPerformed(new ActionEvent(this,AWTEvent.RESERVED_ID_MAX+1,SurfaceApp.NOVA_AC)); } }else if(e.getActionCommand()==SurfaceApp.PRIDAT_AC_SLOUPEC){ if(Surface.getInstance().getPointsInV()>=2){ Surface srf = Surface.getInstance(); Vector leftCol=new Vector(); for(int i=0;i nextCol=new Vector(); for(int i=4;i diffs=new Vector(); for(int i=0;i newCol=new Vector(); for(int i=0;i oldPoints=new Vector(); for(int i=0;i indexes=new Vector(); for(int i=index;i=0&&j>=0;i--,j-=4){ for(int i=0,j=0;i souradnice=new Vector(); float x = 0,z = 0; for(int i=0;i