Guest User

batepapo-paint_javaFx

a guest
Jul 17th, 2014
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 50.27 KB | None | 0 0
  1. /*
  2.   www.bem10jfx.blogspot.com.br
  3.   www.gradejfx.xpg.com.br
  4.   www.numagrandeviagem.blogspot.com
  5.  
  6.  * enquanto uma pessoa bate papo ela envia fotos e pints... desenhos pra outra pessoa
  7.    Obs.Todos prints numa pasta só no servidor e no computador
  8.  
  9. */
  10. package steelprint;
  11.  
  12. import java.io.BufferedWriter;
  13. import java.io.File;
  14. import java.io.FileFilter;
  15. import java.io.FileInputStream;
  16. import java.io.FileWriter;
  17. import java.io.IOException;
  18. import java.net.MalformedURLException;
  19. import java.util.Date;
  20. import java.util.Random;
  21. import java.util.logging.Level;
  22. import java.util.logging.Logger;
  23. import javafx.animation.Interpolator;
  24. import javafx.animation.TranslateTransition;
  25. import javafx.application.Application;
  26. import javafx.application.Platform;
  27. import javafx.collections.FXCollections;
  28. import javafx.collections.ObservableList;
  29. import javafx.embed.swing.SwingFXUtils;
  30. import javafx.event.ActionEvent;
  31. import javafx.event.Event;
  32. import javafx.event.EventHandler;
  33. import javafx.geometry.Pos;
  34. import javafx.scene.Group;
  35. import javafx.scene.Scene;
  36. import javafx.scene.control.Button;
  37. import javafx.scene.control.CheckBox;
  38. import javafx.scene.control.Label;
  39. import javafx.scene.control.ListView;
  40. import javafx.scene.control.Menu;
  41. import javafx.scene.control.MenuBar;
  42. import javafx.scene.control.MenuItem;
  43. import javafx.scene.control.ScrollPane;
  44. import javafx.scene.control.TextField;
  45. import javafx.scene.control.Tooltip;
  46. import javafx.scene.effect.BlendMode;
  47. import javafx.scene.image.Image;
  48. import javafx.scene.image.ImageView;
  49. import javafx.scene.image.WritableImage;
  50. import javafx.scene.input.MouseEvent;
  51. import javafx.scene.layout.HBox;
  52. import javafx.scene.layout.TilePane;
  53. import javafx.scene.layout.VBox;
  54. import javafx.scene.paint.Color;
  55. import javafx.scene.shape.Circle;
  56. import javafx.scene.shape.Line;
  57. import javafx.scene.shape.Rectangle;
  58. import javafx.scene.text.Text;
  59. import javafx.stage.Stage;
  60. import javafx.stage.StageStyle;
  61. import javafx.util.Duration;
  62. import javax.imageio.ImageIO;
  63. import org.apache.commons.net.ftp.FTPClient;
  64. import org.apache.commons.net.ftp.FTPFile;
  65. import org.apache.commons.net.ftp.FTPReply;
  66.  
  67. /**
  68.  *
  69.  * @author knb
  70.  */
  71. public class SteelPrint extends Application {
  72.  
  73.     public Group gpEnv;
  74.     final  Group go = new Group();
  75.  
  76.     final Group gp1 = new Group();
  77.     final Group gp2 = new Group();
  78.     final Group gp3 = new Group();
  79.     //diretorios
  80.     File fldir = new File(System.getProperty("user.home") + "\\Meus documentos\\Minhas imagens\\printsteel\\" + System.getProperty("user.name"));
  81.     File fdSPTexto = new File(System.getProperty("user.home") + "\\Meus documentos\\printsteel\\" + System.getProperty("user.name"));
  82.    
  83.     //names e listviews
  84.     ObservableList<String> names = FXCollections.observableArrayList("");
  85.     ListView<String> listView = new ListView<String>(names);
  86.     public TilePane tl = new TilePane();
  87.     public Button btenvi = new Button("enviar");
  88.     public TextField tfenvi = new TextField("");
  89.     Rectangle rect1 = new Rectangle();
  90.     Rectangle rect2 = new Rectangle();
  91.     Rectangle rect3 = new Rectangle();
  92.     MenuBar mbPrint = new MenuBar();
  93.     MenuBar mbBP = new MenuBar();
  94.     MenuBar mbSP = new MenuBar();
  95.     Menu mnPrint = new Menu("print");
  96.     Menu mnBatPapo = new Menu("BatePapo");
  97.     Menu mnSavesPrint = new Menu("Prints Feitos");
  98.     MenuItem miHistoric=new MenuItem("Historico");
  99.    
  100.     int i;
  101.     int j = 1;
  102.     int o = 0;
  103.     public int opx = 1;
  104.     FTPClient ftp = new FTPClient();
  105.     Text txEnvian, txStatus, txserv;
  106.      Image image[]=new Image[50];
  107.      ImageView img[]=new ImageView[50] ;
  108.      
  109.      CheckBox ch=new CheckBox("Enviar Foto Com a Msg?");
  110.       //so print
  111.      
  112.     public void max() throws MalformedURLException {
  113.  
  114.         if (fldir.exists()) {
  115.             FileFilter ff = new FileFilter() {
  116.                 public boolean accept(File b) {
  117.                     return b.getName().endsWith(".jpg");
  118.                 }
  119.             };
  120.  
  121.             final File flx[] = fldir.listFiles(ff);
  122.            
  123.             for ( i= 1; i < flx.length; i++) {
  124.                  
  125.                 System.out.println("Arquivo= " + flx[i].getName() + "\nNumero = o" + i
  126.                         + "\nurl =" + flx[i].toURL() + "\n length's " + flx.length);
  127.  
  128.                 final String nones=new String(flx[i].getName());
  129.                 image[i] = new Image("file:///" + fldir + "\\" + flx[i].getName());
  130.                 img[i] = new ImageView(image[i]);
  131.                 tl.getChildren().addAll(img[i]);
  132.                 img[i].setFitWidth(30);
  133.                 img[i].setFitHeight(30);
  134.                
  135.                 img[i].setOnMouseClicked(new EventHandler<Event>() {
  136.                     @Override
  137.                     public void handle(Event event) {
  138.                      
  139.                         System.out.println("imagen:"  +nones);
  140.                         Stage stgview=new Stage(StageStyle.UTILITY);
  141.                         stgview.setTitle("imagesview:"+nones);
  142.                         stgview.setHeight(400);
  143.                         stgview.setWidth(400);
  144.                         Image images = new Image("file:///" + fldir + "\\" + nones);
  145.                         final ImageView imageviews = new ImageView(images);
  146.                
  147.                 imageviews.fitWidthProperty().bind(stgview.widthProperty());
  148.                 imageviews.fitHeightProperty().bind(stgview.heightProperty());
  149.                  Group goimagesview=new Group();
  150.                  Scene sceneviews=new Scene(goimagesview,stgview.getWidth(),stgview.getHeight());
  151.                  goimagesview.getChildren().add(imageviews);
  152.                  stgview.setScene(sceneviews);
  153.                
  154.                        
  155.                         stgview.show();
  156.                     }
  157.                 });
  158.                 }
  159.         } else {
  160.             System.out.println("nao existe arquivos x.x" + System.getProperties().toString());
  161.         }
  162.     }
  163.  
  164.     public void verifyca() {
  165.  
  166. ///imagens recebida,imagens enviadas, textos,fraps,logderros
  167.         if (fldir.exists()) {
  168.             System.out.println("existe pasta" + fldir);
  169.         } else {
  170.             fldir.mkdirs();
  171.             System.out.println("nao existe pasta" + fldir + "\ncriando pasta");
  172.         }
  173.  
  174.         if (fdSPTexto.exists()) {
  175.             System.out.println("existe pasta" + fdSPTexto);
  176.         } else {
  177.  
  178.             System.out.println("nao existe pasta" + fdSPTexto + "\ncriando pasta");
  179.             fdSPTexto.mkdirs();
  180.         }
  181.  
  182.     }
  183. public void receivers() throws IOException{
  184. //receber arquivos i=1; receber i++.txt; 1 nome no listview por vez
  185. try {
  186.    if(ftp.isConnected()){
  187.    System.err.println("connectado");
  188.    
  189.    }else{   System.err.println("nao connectado!#");
  190.    }
  191.     System.out.println("iniciando receivers");
  192.        tfenvi.setPromptText("Recebendo Dados");
  193.         ftp.connect("ftp.xpg.com.br");
  194.          if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
  195.           txStatus.setText("Status: On");
  196.            ftp.login("xxxxxxxxx", "xxxxxxxxxx");
  197.             ftp.changeWorkingDirectory("steelprint");
  198.            
  199. //ftp.makeDirectory(System.getProperty("user.name").toString()+"IMGs");
  200.            
  201.              FTPFile ftpfile[]=ftp.listDirectories();
  202.              FTPFile ftpfileki[]=ftp.listFiles();
  203.              try {
  204.              for (int k = 0; k < ftpfile.length; k++) {
  205.                
  206.                  System.out.println("file :"+k+ftpfile[k].getName());
  207.                  if(ftpfile[k].getName().toString()== System.getProperty("user.name").toString()){
  208.                  
  209.                      System.out.println("=ISSO É IGUAL ="+
  210.                           ftpfile[k].getName().toString()+"=="+ System.getProperty("user.name").toString()
  211.                       );
  212.                
  213.             }else{
  214.              System.out.println("O RESTO AQUI É DIFERENTE "+ftpfile[k].getName().toString()+"!="+ System.getProperty("user.name").toString());
  215.                  }
  216.              }
  217.              
  218.              } catch (Exception e) {
  219.              e.getMessage();
  220.              }
  221.          }
  222.         }catch (Exception e) {
  223.           e.getMessage();
  224.                 }
  225. ftp.logout();
  226. ftp.disconnect();
  227.        
  228. }
  229.  
  230.     public VBox vb1 = new VBox(5);
  231.     public HBox hbv1x = new HBox();
  232.     public HBox hbv2x = new HBox(10);
  233.     public Line line1;
  234.     public int ios;
  235.     public Image image1 = new Image(LAPSeNDoNE.class.getResourceAsStream("circle.JPG"));
  236.     public Image image2 = new Image(LAPSeNDoNE.class.getResourceAsStream("lapiz.JPG"));
  237.     public Image image3 = new Image(LAPSeNDoNE.class.getResourceAsStream("line.JPG"));
  238.     public ImageView imageCircle, imageLaps, imageLine, vlRandOff, vlRandOn;
  239.     public int vlwCircle, vlwLaps, vlwLine;
  240.     public String strOn = "0", strOff = "1",
  241.             strPSOn = "0", strPSOff = "1",
  242.             strAnOn = "0", strAnOff = "1";
  243.     final Line lnCima = new Line();
  244.     final Line lnBaixo = new Line();
  245.     final Line lnDir = new Line();
  246.     final Line lnEsc = new Line();
  247.     final HBox hbAnime = new HBox(0.5);
  248.     public TextField tfFromY=new TextField();
  249.     public TextField tfFromX=new TextField();
  250.     public TextField tfToY=new TextField();
  251.     public TextField tfToX=new TextField();
  252.     public TextField tfByY=new TextField();
  253.     public TextField tfByX=new TextField();
  254.     public TextField tfSec=new TextField();
  255.    
  256.     public Label lbPause = new Label("PAUSE");
  257.     public Label lbPlay = new Label("PLAY");
  258.     public Label lbStop = new Label("STOP");
  259.     final TranslateTransition Tl = new TranslateTransition();
  260.     public Circle circleX;
  261.     public Circle circleLapis;
  262.     public CheckBox ChBoxAutoRevez = new CheckBox("Ativar");
  263.     public MenuBar mnbr=new MenuBar();
  264.     public Menu mnMenu = new Menu("Itens =)");
  265.     public MenuItem MIPrint = new MenuItem("New Print");
  266.     public MenuItem MIExit = new MenuItem("Exit");
  267.     public MenuItem MIClear = new MenuItem("Clear");
  268.     public MenuItem MIprintEnv = new MenuItem("PrintImg's ");
  269.        
  270.     public Label lbPoints = new Label("Pontilhados : ");
  271.     public Label lbPosition1 = new Label("Posicão X : ");
  272.     public Label lbpositions2 = new Label("Posição Y : ");
  273.     public Label lbrands = new Label("Rands : ON");
  274.     public Label lbRandPower = new Label("RAND");
  275.     public Label lbPosi = new Label("POSITION");
  276.     public Label lbPosiStatus = new Label("Posição : OFF");
  277.     public Label lbStatuAnime = new Label("Anime : OFF");
  278.     public Label lbAnimate = new Label("ANIME");
  279.    
  280.  
  281.  
  282.     Stage stage;
  283.     public Tooltip tlp;
  284.     public Tooltip tlpPosi;
  285.     public Tooltip tlpAnime;
  286.     public Tooltip tlpCheckboxRevz;
  287.  
  288.     public void initializesUI() {
  289.          
  290.       rect1 = new Rectangle();
  291.         rect1.setArcHeight(10);
  292.         rect1.setArcWidth(10);
  293.         rect1.setFill(Color.WHITE);
  294.         rect1.setStroke(Color.ORANGE);
  295.         rect1.setStrokeWidth(10);
  296.       gp1.getChildren().addAll(rect1);
  297.     }
  298.  
  299.     /*definiões de sets*/
  300.     public void defs() {
  301.  
  302.         lbPoints.setLayoutX(10);
  303.         lbPoints.setLayoutY(10);
  304.         lbPosition1.setLayoutX(10);
  305.         lbPosition1.setLayoutY(10 + 15);
  306.         lbpositions2.setLayoutX(10);
  307.         lbpositions2.setLayoutY(35);
  308.         lbrands.setLayoutX(10);
  309.         lbrands.setLayoutY(35 + 12);
  310.         lbPosiStatus.setLayoutX(10);
  311.         lbPosiStatus.setLayoutY(58);
  312.         lbStatuAnime.setLayoutY(58 + 13);
  313.         lbStatuAnime.setLayoutX(10);
  314.  
  315.         lbRandPower.setLayoutX(165);
  316.         lbRandPower.setLayoutY(15);
  317.         lbRandPower.setTextFill(Color.RED);
  318.         lbRandPower.setPrefSize(30, 15);
  319.  
  320.         lbPosi.setLayoutX(205);
  321.         lbPosi.setLayoutY(15);
  322.         lbPosi.setTextFill(Color.RED);
  323.         lbPosi.setPrefSize(50, 15);
  324.  
  325.         lbAnimate.setLayoutX(265);
  326.         lbAnimate.setLayoutY(15);
  327.         lbAnimate.setTextFill(Color.RED);
  328.         lbAnimate.setPrefSize(50, 15);
  329.  
  330.         imageLaps.setLayoutX(10);
  331.         imageLaps.setLayoutY(130);
  332.         imageLaps.setFitHeight(20);
  333.         imageLaps.setFitWidth(20);
  334.  
  335.         imageCircle.setLayoutX(10);
  336.         imageCircle.setLayoutY(100);
  337.         imageCircle.setFitHeight(20);
  338.         imageCircle.setFitWidth(20);
  339.  
  340.         imageLine.setLayoutX(10);
  341.         imageLine.setLayoutY(160);
  342.         imageLine.setFitHeight(20);
  343.         imageLine.setFitWidth(20);
  344.  
  345.         hbAnime.setVisible(false);
  346.  
  347.         lbRandPower.setTooltip(tlp);
  348.         lbPosi.setTooltip(tlpPosi);
  349.         lbAnimate.setTooltip(tlpAnime);
  350.         ChBoxAutoRevez.setTooltip(tlpCheckboxRevz);
  351.  
  352.     }
  353.  
  354.     public void InitializesgetChidrens() {
  355.        
  356.         mnbr.getMenus().add(mnMenu);
  357.         gp1.getChildren().addAll(lnCima, lnBaixo, lnEsc, lnDir);
  358.         hbv1x.getChildren().addAll(tfFromX, tfFromY, tfToX, tfToY, tfByX, tfByY);
  359.         vb1.getChildren().add(hbv1x);
  360.         hbAnime.getChildren().add(vb1);
  361.         vb1.getChildren().add(hbv2x);
  362.         /*checkboxs*/
  363.         hbv2x.getChildren().addAll(lbPause, lbPlay, lbStop, tfSec, ChBoxAutoRevez);
  364.         /*infos de diametros*/
  365.  
  366.         go.getChildren().addAll(
  367.                 lbPoints, lbPosition1, lbpositions2,
  368.                 lbrands, lbPosiStatus, lbStatuAnime,
  369.                 lbRandPower, lbPosi, lbAnimate
  370.         );
  371.         go.getChildren().add(hbAnime);
  372.         go.getChildren().addAll(imageCircle, imageLaps, imageLine);
  373.  
  374.     }
  375.  
  376.     public void initializeconfigs() {
  377.  
  378.         MIExit.setOnAction(new EventHandler<ActionEvent>() {
  379.             @Override
  380.             public void handle(ActionEvent event) {
  381.                 Platform.exit();
  382.             }
  383.         });
  384.  
  385.         MIPrint.setOnAction(new EventHandler<ActionEvent>() {
  386.             @Override
  387.             public void handle(ActionEvent event) {
  388.                 System.out.println("clears");
  389.  
  390.                 final Random randCorClear1 = new Random(System.currentTimeMillis());
  391.                 final int inrd1 = randCorClear1.nextInt(253);
  392.                 final Random randCorClear2 = new Random(System.currentTimeMillis());
  393.                 final int inrd2 = randCorClear2.nextInt(253);
  394.                 final Random randCorClear3 = new Random(System.currentTimeMillis());
  395.                 final int inrd3 = randCorClear3.nextInt(253);
  396.  
  397.                 rect1.setFill(Color.rgb(inrd1, inrd3, inrd2));
  398.                
  399.             }
  400.         });
  401.  
  402.         MIClear.setOnAction(new EventHandler<ActionEvent>() {
  403.  
  404.             @Override
  405.             public void handle(ActionEvent event) {
  406.                     go.getChildren().removeAll(gp1);
  407.                  try {
  408.                     initializesUI();
  409.                
  410.                 lbPoints = new Label("Pontilhados : ");
  411.                 lbPosition1 = new Label("Posicão X : ");
  412.                 lbpositions2 = new Label("Posição Y : ");
  413.                 lbrands = new Label("Rands : ON");
  414.                 lbRandPower = new Label("RAND");
  415.                 lbPosi = new Label("POSITION");
  416.                 lbPosiStatus = new Label("Posição : OFF");
  417.                 lbStatuAnime = new Label("Anime : OFF");
  418.                 lbAnimate = new Label("ANIME");
  419.  
  420.                 lbPoints.setLayoutX(10);
  421.                 lbPoints.setLayoutY(10);
  422.                 lbPosition1.setLayoutX(10);
  423.                 lbPosition1.setLayoutY(10 + 15);
  424.                 lbpositions2.setLayoutX(10);
  425.                 lbpositions2.setLayoutY(35);
  426.                 lbrands.setLayoutX(10);
  427.                 lbrands.setLayoutY(35 + 12);
  428.                 lbPosiStatus.setLayoutX(10);
  429.                 lbPosiStatus.setLayoutY(58);
  430.                 lbStatuAnime.setLayoutY(58 + 13);
  431.                 lbStatuAnime.setLayoutX(10);
  432.  
  433.                 lbRandPower.setLayoutX(165);
  434.                 lbRandPower.setLayoutY(15);
  435.                 lbRandPower.setTextFill(Color.RED);
  436.                 lbRandPower.setPrefSize(30, 15);
  437.  
  438.                 lbPosi.setLayoutX(205);
  439.                 lbPosi.setLayoutY(15);
  440.                 lbPosi.setTextFill(Color.RED);
  441.                 lbPosi.setPrefSize(50, 15);
  442.  
  443.                 lbAnimate.setLayoutX(265);
  444.                 lbAnimate.setLayoutY(15);
  445.                 lbAnimate.setTextFill(Color.RED);
  446.                 lbAnimate.setPrefSize(50, 15);
  447.              
  448.                 go.getChildren().addAll(
  449.                         lbPoints, lbPosition1, lbpositions2,
  450.                         lbrands, lbPosiStatus, lbStatuAnime,
  451.                         lbRandPower, lbPosi, lbAnimate
  452.        
  453.                 );
  454.  
  455.                 imageCircle = new ImageView(image1);
  456.                 imageLaps = new ImageView(image2);
  457.                 imageLine = new ImageView(image3);
  458.  
  459.                 imageLaps.setLayoutX(10);
  460.                 imageLaps.setLayoutY(130);
  461.                 imageLaps.setFitHeight(20);
  462.                 imageLaps.setFitWidth(20);
  463.  
  464.                 imageCircle.setLayoutX(10);
  465.                 imageCircle.setLayoutY(100);
  466.                 imageCircle.setFitHeight(20);
  467.                 imageCircle.setFitWidth(20);
  468.  
  469.                 imageLine.setLayoutX(10);
  470.                 imageLine.setLayoutY(160);
  471.                 imageLine.setFitHeight(20);
  472.                 imageLine.setFitWidth(20);
  473.                 // gp.getChildren().add(mnbr);
  474.  
  475.                 tlp = new Tooltip("RANDS LIGADO");
  476.                 tlpPosi = new Tooltip("POSITION DESLIGADO");
  477.                 tlpAnime = new Tooltip("ANIME DESLIGADO");
  478.                 tlpCheckboxRevz = new Tooltip("ativar efeito");
  479.                 lbRandPower.setTooltip(tlp);
  480.                 lbPosi.setTooltip(tlpPosi);
  481.                 lbAnimate.setTooltip(tlpAnime);
  482.                 ChBoxAutoRevez.setTooltip(tlpCheckboxRevz);
  483.        
  484.                 initializeconfigs();
  485.          
  486.                 initializingConfigAll();
  487.                 } catch (Exception e) {
  488.                 }
  489.                     }
  490.         });
  491.  
  492.     }
  493.  
  494.     public void initializingConfigAll() {
  495.  
  496.         imageCircle.setOnMouseClicked(new EventHandler<MouseEvent>() {
  497.             @Override
  498.             public void handle(MouseEvent t) {
  499.                 vlwCircle = 1;
  500.                 vlwLaps = 0;
  501.                 vlwLine = 0;
  502.  
  503.                 System.out.println("circle press...lapz =0...line =0");
  504.                 imageCircle.setBlendMode(BlendMode.ADD);
  505.  
  506.                 imageCircle.setOnMouseExited(new EventHandler<MouseEvent>() {
  507.                     @Override
  508.                     public void handle(MouseEvent t) {
  509.                         imageCircle.setBlendMode(null);
  510.                     }
  511.                 });
  512.             }
  513.         });
  514.  
  515.         imageLaps.setOnMouseClicked(new EventHandler<MouseEvent>() {
  516.             @Override
  517.             public void handle(MouseEvent t) {
  518.                 vlwCircle = 0;
  519.                 vlwLaps = 1;
  520.                 vlwLine = 0;
  521.                 System.out.println("lapz press...circle  =0...line =0");
  522.                 imageLaps.setBlendMode(BlendMode.ADD);
  523.  
  524.                 imageLaps.setOnMouseExited(new EventHandler<MouseEvent>() {
  525.                     @Override
  526.                     public void handle(MouseEvent t) {
  527.                         imageLaps.setBlendMode(null);
  528.                     }
  529.                 });
  530.             }
  531.         });
  532.  
  533.         imageLine.setOnMouseClicked(new EventHandler<MouseEvent>() {
  534.             @Override
  535.             public void handle(MouseEvent t) {
  536.                 vlwCircle = 0;
  537.                 vlwLaps = 0;
  538.                 vlwLine = 1;
  539.                 System.out.println("line press...circle  =0...Lapz =0");
  540.                 imageLine.setBlendMode(BlendMode.ADD);
  541.                 imageLine.setOnMouseExited(new EventHandler<MouseEvent>() {
  542.                     @Override
  543.                     public void handle(MouseEvent t) {
  544.                         imageLine.setBlendMode(null);
  545.                     }
  546.                 });
  547.             }
  548.         });
  549.         //menuexit
  550.         lbRandPower.setOnMouseClicked(new EventHandler<MouseEvent>() {
  551.             @Override
  552.             public void handle(MouseEvent t) {
  553.  
  554.                 if (strOff == "0" && strOn == "1") {
  555.                     strOff = "1";
  556.                     strOn = "0";
  557.  
  558.                     System.out.println("LIGADO");
  559.                     lbrands.setText("Rands : ON");
  560.                     tlp.setText("Rand Ligado");
  561.                 } else if (strOff == "1" && strOn == "0") {
  562.                     strOff = "0";
  563.                     strOn = "1";
  564.                     System.out.println("DESLIGADO");
  565.                     lbrands.setText("Rands : OFF");
  566.                     tlp.setText("Rand Desligado");
  567.                 }
  568.  
  569.             }
  570.         });
  571.  
  572.         lbPosi.setOnMouseClicked(new EventHandler<MouseEvent>() {
  573.             @Override
  574.             public void handle(MouseEvent t) {
  575.  
  576.                 if (strPSOff == "1" && strPSOn == "0") {
  577.                     strPSOn = "1";
  578.                     strPSOff = "0";
  579.  
  580.                     System.out.println("LIGADO");
  581.                     lbPosiStatus.setText("Posição : ON");
  582.                     tlpPosi.setText("Posiçoes Ligado");
  583.  
  584.                 } else if (strPSOff == "0" && strPSOn == "1") {
  585.                     strPSOff = "1";
  586.                     strPSOn = "0";
  587.                     System.out.println("DESLIGADO");
  588.                     lbPosiStatus.setText("Posição : OFF");
  589.                     tlpPosi.setText("Posições Desligado");
  590.                 }
  591.  
  592.             }
  593.         });
  594.  
  595.         //ANIMATES
  596.         lbPause.setOnMouseClicked(new EventHandler<MouseEvent>() {
  597.             @Override
  598.             public void handle(MouseEvent t) {
  599.                 Tl.pause();
  600.             }
  601.         });
  602.         lbPlay.setOnMouseClicked(new EventHandler<MouseEvent>() {
  603.             @Override
  604.             public void handle(MouseEvent t) {
  605.  
  606.                 Double dbfx = Double.parseDouble(tfFromX.getText());
  607.                 Double dbfy = Double.parseDouble(tfFromY.getText());
  608.                 Double dbbx = Double.parseDouble(tfByX.getText());
  609.                 Double dbby = Double.parseDouble(tfByY.getText());
  610.                 Double dbtoy = Double.parseDouble(tfToY.getText());
  611.                 Double dbtox = Double.parseDouble(tfToX.getText());
  612.                 Double dbSec = Double.parseDouble(tfSec.getText());
  613.  
  614.                 if (vlwCircle == 1 && vlwLaps == 0 && vlwLine == 0) {
  615.                     Tl.setNode(circleX);
  616.                 } else if (vlwCircle == 0 && vlwLaps == 1 && vlwLine == 0) {
  617.                     Tl.setNode(circleLapis);
  618.                 } else if (vlwCircle == 0 && vlwLaps == 0 && vlwLine == 1) {
  619.                     Tl.setNode(line1);
  620.                 }
  621.  
  622.                 Tl.setFromX(dbfx.intValue());
  623.                 Tl.setFromY(dbfy.intValue());
  624.                 Tl.setByY(dbby.intValue());
  625.                 Tl.setByX(dbbx.intValue());
  626.  
  627.                 Tl.setToX(dbtox.intValue());
  628.                 Tl.setToX(dbtoy.intValue());
  629.  
  630.                 Tl.setDuration(Duration.seconds(dbSec));
  631.                 Tl.setInterpolator(Interpolator.LINEAR);
  632.                 Tl.setCycleCount(2);
  633.                 Tl.setAutoReverse(true);
  634.                 Tl.play();
  635.             }
  636.         });
  637.  
  638.         lbStop.setOnMouseClicked(new EventHandler<MouseEvent>() {
  639.             @Override
  640.             public void handle(MouseEvent t) {
  641.                 Tl.stop();
  642.             }
  643.         });
  644.  
  645.         lbAnimate.setOnMouseClicked(new EventHandler<MouseEvent>() {
  646.             @Override
  647.             public void handle(MouseEvent t) {
  648.  
  649.                 if (strAnOff == "0" && strAnOn == "1") {
  650.                     strAnOn = "0";
  651.                     strAnOff = "1";
  652.  
  653.                     System.out.println("LIGADO");
  654.                     lbStatuAnime.setText("Anime : ON");
  655.                     tlpAnime.setText("ANIME Ligado");
  656.                     hbAnime.setPrefSize(300, 40);
  657.                     hbAnime.setLayoutX(300);
  658.                     hbAnime.setStyle("-fx-background-color: #FF4321;-fx-border-color: #aa7777;");
  659.                     hbAnime.setVisible(true);
  660.  
  661.                 } else if (strPSOn == "0" && strPSOff == "1") {
  662.                     strAnOff = "0";
  663.                     strAnOn = "1";
  664.                     System.out.println("DESLIGADO");
  665.                     lbStatuAnime.setText("Anime : OFF");
  666.                     tlpAnime.setText("ANIME Desligado");
  667.                     hbAnime.setVisible(false);
  668.  
  669.                 }
  670.  
  671.             }
  672.         });
  673.     }
  674.  
  675.     public void IMGreload() throws IOException{
  676.     //verificar pasta
  677.         File str_prn = null;
  678.                    Date dt=new Date();
  679.                    File filexxP = null;
  680.                    try {
  681.                    
  682.                     WritableImage writableImage = gp1.snapshot(null, null);
  683.                      filexxP = new File(
  684.                   fldir,  "\\" + dt.getSeconds()+dt.getMinutes()+ ".jpg");
  685.                     str_prn = filexxP.getAbsoluteFile();
  686.                     ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "jpg", filexxP);
  687.                     System.err.println(""+filexxP);
  688.                     } catch (IOException ex) {
  689.                     Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, ex);
  690.                 }
  691.    
  692.                  tl.getChildren().removeAll(img);
  693.                       try {
  694.                           max();
  695.                      
  696.                       } catch (MalformedURLException ex) {
  697.                           Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, ex);
  698.                       }
  699.                       System.err.print("preparando para enviar  img");
  700.                       ftp.connect("ftp.xpg.com.br");
  701.                      
  702.                       try {
  703.            
  704.          if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
  705.           txStatus.setText("Status: On");
  706.           txserv.setText("conectando.");
  707.            ftp.login("xxxxxxxxxx", "xxxxxxxxx");
  708.             ftp.changeWorkingDirectory("steelprint/IMGs");
  709.               txserv.setText("conectado!");
  710.              
  711.                    System.err.println(" rescrevendo logiins "
  712.                     + "\n conexao=" + ftp.getReplyString());
  713.  
  714.                 FileInputStream arqEnv = new FileInputStream(str_prn );
  715.                 if (ftp.storeFile( filexxP.getName(), arqEnv)) {
  716.                 txEnvian.setText("Enviado ult.msg " + ftp.getBufferSize() + "Kb");
  717.                 txserv.setText("Servidor:" + ftp.getSystemType());
  718.                 System.out.println("arquivo de IMG enviado" + ftp.getBufferSize());
  719.                 //######################################
  720.          
  721.         /*sysconectar*/try{ftp.disconnect();}catch(Exception e){/*josi-love*/e.getMessage();}
  722.        
  723.           try {
  724.               System.out.println("==============================="
  725.               +"\n preparando pra pra receber dados");
  726.               receivers();
  727.                System.out.println("\nFIM DE DADOS \n"
  728.                        +"==============================="
  729.               );
  730.              
  731.                         } catch (Exception e) {
  732.                             e.printStackTrace();
  733.                     }    } else {
  734.                                 System.out.println("arquivo nao enviadoenviado"
  735.                                         + "\n" + fdSPTexto + "\\" + opx + ".txt"
  736.                                         + "\nlista files" + ftp.getListHiddenFiles()
  737.                                         + ""
  738.                                         + "");
  739.                                 ftp.disconnect();
  740.                             }
  741.                
  742.          } else {
  743.                             System.out.println("restabelecendo conexao");
  744.  
  745.                             txStatus.setText("Status: off");
  746.                             txserv.setText("Verifique a conexão+error+21" + Exception.class.getName());
  747.                         }
  748.                       } catch (MalformedURLException ex) {
  749.                           Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, ex);
  750.                       }
  751.     };
  752.  
  753.     @Override
  754.     public void start(Stage stage) {
  755.         stage.setTitle("print text");
  756.         final Scene scene = new Scene(go, 700, 330);
  757.         scene.setFill(Color.web("#333333"));
  758.         //go.getStylesheets().add("-fx-background-color: #333333");
  759.         stage.setScene(scene);
  760.         imageCircle = new ImageView(image1);
  761.         imageLaps = new ImageView(image2);
  762.         imageLine = new ImageView(image3);
  763.  
  764.         verifyca();
  765.         initializesUI();
  766.         defs();
  767.         ios = 0;
  768.        
  769.         gp1.setVisible(true);
  770.        
  771.         tlp = new Tooltip("RANDS LIGADO");
  772.         tlpPosi = new Tooltip("POSITION DESLIGADO");
  773.         tlpAnime = new Tooltip("ANIME DESLIGADO");
  774.         tlpCheckboxRevz = new Tooltip("ativar efeito");
  775.        
  776.         gp1.setOnMouseDragged(new EventHandler<MouseEvent>() {
  777.             @Override
  778.             public void handle(MouseEvent NV) {
  779.  
  780.                 if (vlwCircle == 1 && vlwLaps == 0 && vlwLine == 0) {
  781.                     Tl.setNode(circleX);
  782.                 } else if (vlwCircle == 0 && vlwLaps == 1 && vlwLine == 0) {
  783.                     Tl.setNode(circleLapis);
  784.                 } else if (vlwCircle == 0 && vlwLaps == 0 && vlwLine == 1) {
  785.                     Tl.setNode(line1);
  786.                 }
  787.  
  788.                 if (ChBoxAutoRevez.isSelected() == true) {
  789.  
  790.                     Double dbfx = Double.parseDouble(tfFromX.getText());
  791.                     Double dbfy = Double.parseDouble(tfFromY.getText());
  792.                     Double dbbx = Double.parseDouble(tfByX.getText());
  793.                     Double dbby = Double.parseDouble(tfByY.getText());
  794.                     Double dbtoy = Double.parseDouble(tfToY.getText());
  795.                     Double dbtox = Double.parseDouble(tfToX.getText());
  796.                     Double dbSec = Double.parseDouble(tfSec.getText());
  797.  
  798.                     Tl.setFromX(dbfx.intValue());
  799.                     Tl.setFromY(dbfy.intValue());
  800.                     Tl.setByY(dbby.intValue());
  801.                     Tl.setByX(dbbx.intValue());
  802.  
  803.                     Tl.setToX(dbtox.intValue());
  804.                     Tl.setToX(dbtoy.intValue());
  805.  
  806.                     Tl.setDuration(Duration.seconds(dbSec));
  807.                     Tl.setInterpolator(Interpolator.LINEAR);
  808.                     Tl.setCycleCount(1);
  809.                     Tl.setAutoReverse(true);
  810.                     Tl.play();
  811.  
  812.                 }
  813.  
  814.                 line1 = new Line();
  815.                 Random rand = new Random(System.currentTimeMillis());
  816.                 final int c = rand.nextInt(253);
  817.                 final int o = rand.nextInt(256);
  818.                 final int r = rand.nextInt(169);
  819.  
  820.                 ios++;
  821.                 lbPoints.setText("Pontilhados : " + ios);
  822.  
  823.                 if (strPSOff == "0" && strPSOn == "1") {
  824.                     tlpPosi.setText("Posição Ligado");
  825.                     int ax = (int) NV.getSceneX();
  826.                     int ay = (int) NV.getSceneY();
  827.                     lbPosition1.setText("Posição X : " + ax);
  828.                     lbpositions2.setText("Posição Y : " + ay);
  829.                     lnCima.setVisible(true);
  830.                     lnBaixo.setVisible(true);
  831.                     lnDir.setVisible(true);
  832.                     lnEsc.setVisible(true);
  833.  
  834.                     lnCima.setStartX(0);
  835.                     lnCima.setEndY(ay - 10);
  836.                     lnCima.setEndX(0);
  837.                     lnCima.setStartY(10);
  838.                     lnCima.setLayoutX(ax);
  839.                     lnCima.setLayoutY(1);
  840.  
  841.                     lnBaixo.setStartX(0);
  842.                     lnBaixo.endYProperty().bind(rect1.heightProperty());
  843.                     lnBaixo.setEndX(0);
  844.                     lnBaixo.setStartY(10);
  845.                     lnBaixo.setLayoutX(ax);
  846.                     lnBaixo.setLayoutY(ay);
  847.  
  848.                     lnDir.setStartX(10);
  849.                     lnDir.setEndY(0);
  850.                     lnDir.endXProperty().bind(rect1.widthProperty());
  851.                     lnDir.setStartY(0);
  852.                     lnDir.setLayoutX(ax);
  853.                     lnDir.setLayoutY(ay);
  854.  
  855.                     lnEsc.setStartX(-rect1.getWidth());
  856.                     lnEsc.setEndY(0);
  857.                     lnEsc.setEndX(-10);
  858.                     lnEsc.setStartY(0);
  859.                     lnEsc.setLayoutX(ax);
  860.                     lnEsc.setLayoutY(ay);
  861.                 } else if (strPSOff == "1" && strPSOn == "0") {
  862.                     lbPosition1.setText("Posição X : ");
  863.                     lbpositions2.setText("Posição Y : ");
  864.                     tlpPosi.setText("Posição Desligado");
  865.                     // gp.getChildren().removeAll(lnCima,lnBaixo,lnDir,lnEsc);
  866.                     lnCima.setVisible(false);
  867.                     lnBaixo.setVisible(false);
  868.                     lnDir.setVisible(false);
  869.                     lnEsc.setVisible(false);
  870.                 }
  871.  
  872.                 if (vlwCircle == 1 && vlwLaps == 0 && vlwLine == 0) {
  873.                     circleX = new Circle(10);
  874.  
  875.                     if (strOff == "0" && strOn == "1") {
  876.                         tlp.setText("Rand Desligado");
  877.                         circleX.setFill(Color.BLACK);
  878.                         circleX.setStroke(Color.BLACK);
  879.  
  880.                     } else if (strOff == "1" && strOn == "0") {
  881.  
  882.                         circleX.setFill(Color.rgb(c, o, r, .254));
  883.                         circleX.setStroke(Color.rgb(c, o, r, .99));
  884.                         tlp.setText("Rand Ligado");
  885.                     }
  886.  
  887.                     //C
  888.                     int cimaInt = (int) NV.getSceneX();
  889.                     circleX.setLayoutX(cimaInt);
  890.                     //B
  891.                     int baixoInt = (int) NV.getSceneY();
  892.                     circleX.setLayoutY(baixoInt);
  893.  
  894.                     //D
  895.                     int rabizkX = (int) NV.getScreenX();
  896.                     circleX.setCenterX(10);
  897.                     //E
  898.                     int rabizkY = (int) NV.getScreenY();
  899.                     circleX.setCenterY(10);
  900.  
  901.                     gp1.getChildren().add(circleX);
  902.                 };
  903.  
  904.                 if (vlwCircle == 0 && vlwLaps == 0 && vlwLine == 1) {
  905.                     if (strOff == "0" && strOn == "1") {
  906.  
  907.                         line1.setFill(Color.BLACK);
  908.                         line1.setStroke(Color.BLACK);
  909.                         tlp.setText("Rand Desligado");
  910.  
  911.                     } else if (strOff == "1" && strOn == "0") {
  912.  
  913.                         line1.setFill(Color.rgb(c, o, r, .254));
  914.                         line1.setStroke(Color.rgb(c, o, r, .99));
  915.                         tlp.setText("Rand ligado");
  916.                     }
  917.                     //C
  918.                     int cimaInt = (int) NV.getSceneX();
  919.                     line1.setLayoutX(cimaInt);
  920.                     //B
  921.                     int baixoInt = (int) NV.getSceneY();
  922.                     line1.setLayoutY(baixoInt);
  923.  
  924.                     //D
  925.                     int rabizkX = (int) NV.getScreenX();
  926.                     line1.setEndX(10);
  927.                     //E
  928.                     int rabizkY = (int) NV.getScreenY();
  929.                     line1.setEndY(10);
  930.  
  931.                     gp1.getChildren().add(line1);
  932.  
  933.                 };
  934.                 if (vlwCircle == 0 && vlwLaps == 1 && vlwLine == 0) {
  935.                     circleLapis = new Circle(0.7);
  936.                     if (strOff == "0" && strOn == "1") {
  937.  
  938.                         circleLapis.setFill(Color.BLACK);
  939.                         circleLapis.setStroke(Color.BLACK);
  940.                         tlp.setText("Rand Desligado");
  941.                     } else if (strOff == "1" && strOn == "0") {
  942.  
  943.                         circleLapis.setFill(Color.rgb(c, o, r, .254));
  944.                         circleLapis.setStroke(Color.rgb(c, o, r, .99));
  945.                         tlp.setText("Rand ligado");
  946.                     }
  947.  
  948.                     //C
  949.                     int cimaInt = (int) NV.getSceneX();
  950.                     circleLapis.setLayoutX(cimaInt);
  951.                     //B
  952.                     int baixoInt = (int) NV.getSceneY();
  953.                     circleLapis.setLayoutY(baixoInt);
  954.  
  955.                     //D
  956.                     int rabizkX = (int) NV.getScreenX();
  957.                     circleLapis.setCenterX(10);
  958.                     //E
  959.                     int rabizkY = (int) NV.getScreenY();
  960.                     circleLapis.setCenterY(10);
  961.  
  962.                     gp1.getChildren().add(circleLapis);
  963.                 };
  964.  
  965.             }
  966.         });
  967.        
  968.         gp1.setLayoutX(5);
  969.         gp1.setLayoutY(17);
  970.         gp1.setStyle("-fx-background-color: #336699;");
  971.  
  972.         mbPrint.getMenus().addAll(mnPrint);
  973.         mbPrint.layoutYProperty().bind(stage.heightProperty().subtract(65));
  974.         mbPrint.prefWidthProperty().bind(rect1.widthProperty().add(0.9));
  975.  
  976.         mbBP.getMenus().addAll(mnBatPapo);
  977.         mbBP.layoutYProperty().bind(stage.heightProperty().subtract(65));
  978.         mbBP.layoutXProperty().bind(gp2.layoutXProperty());
  979.         mbBP.prefWidthProperty().bind(rect2.widthProperty().add(0.9));
  980.  
  981.         mbSP.getMenus().addAll(mnSavesPrint);
  982.         mbSP.layoutYProperty().bind(stage.heightProperty().subtract(65));
  983.         mbSP.layoutXProperty().bind(gp3.layoutXProperty());
  984.         mbSP.prefWidthProperty().bind(tl.widthProperty().add(0.9));
  985.      
  986.         mnBatPapo.getItems().add(miHistoric);
  987.               // mnbr.getMenus().add(mnMenu);
  988.                 mnMenu.getItems().addAll(MIPrint, MIClear, MIExit, MIprintEnv);
  989.                 mnbr.setVisible(true);
  990.                
  991.         MIprintEnv.setOnAction(new EventHandler<ActionEvent>() {
  992.                   @Override
  993.                    public void handle(ActionEvent event) {
  994.                    File str_prn = null;
  995.                    Date dt=new Date();
  996.                    File filexxx = null;
  997.                    try {
  998.                    
  999.                     WritableImage writableImage = gp1.snapshot(null, null);
  1000.                      filexxx = new File(
  1001.                   fldir,  "\\" + dt.getSeconds()+dt.getMinutes()+ ".jpg");
  1002.                     str_prn = filexxx.getAbsoluteFile();
  1003.                     ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "jpg", filexxx);
  1004.                     System.err.println(""+filexxx);
  1005.                     } catch (IOException ex) {
  1006.                     Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, ex);
  1007.                 }
  1008.                    try {
  1009.              System.out.println("preparando pra conectar");
  1010.                    ftp.connect("ftp.xpg.com.br");
  1011.          if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
  1012.              System.out.println("conectado logando");
  1013.           txStatus.setText("Status: On");
  1014.           txserv.setText("conectando. env. img");
  1015.            ftp.login("xxxxxxxx", "xxxxxxxxxxxx");
  1016.             ftp.changeWorkingDirectory("steelprint/IMGs/");
  1017.               txserv.setText("enviando foto");
  1018.              
  1019.               FTPFile ftpfilexx[]=ftp.listDirectories();
  1020.              try {
  1021.              for (int kp = 0; kp < ftpfilexx.length; kp++) {
  1022.                
  1023.                  System.out.println("file :"+kp+ftpfilexx[kp].getName());
  1024.                
  1025.              }
  1026.              }catch(Exception e){
  1027.              e.getMessage();
  1028.              }
  1029.                 FileInputStream arqEnvs = new FileInputStream(""+filexxx);
  1030.                 if (ftp.storeFile( filexxx.getName(), arqEnvs)) {
  1031.                 txEnvian.setText("Enviado ult.msg " + ftp.getBufferSize() + "Kb");
  1032.                 txserv.setText("Servidor:" + ftp.getSystemType());
  1033.                 System.out.println("arquivo enviadox" + ftp.getBufferSize());
  1034.                
  1035.         /*sysconectar*/try{ftp.disconnect();}catch(Exception e){e.getMessage();}
  1036.        
  1037.                 }
  1038.          }else{System.out.println("nao tem arquivo pronto");}
  1039.                       } catch (Exception e)
  1040.                       {System.out.println("error ftp de imagens"+e.getMessage());}
  1041.                    tl.getChildren().removeAll(img);
  1042.                       try {
  1043.                           max();
  1044.                       } catch (MalformedURLException ex) {
  1045.                    Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, ex);
  1046.                       }
  1047.                  
  1048.                    }
  1049.                });
  1050.                
  1051.           miHistoric.setOnAction(new EventHandler<ActionEvent>() {
  1052.            @Override
  1053.             public void handle(ActionEvent event) {
  1054.                Stage stageHistoric=new Stage(StageStyle.DECORATED);
  1055.                Group goHis=new Group();
  1056.                Scene scenehis=new Scene(goHis,300,300,Color.ALICEBLUE);
  1057.                stageHistoric.setTitle("...");
  1058.                stageHistoric.setScene(scenehis);
  1059.                
  1060.          ObservableList<String> names = FXCollections.observableArrayList("");
  1061.          ListView<String> listView = new ListView<String>(names);
  1062.        
  1063.                stageHistoric.show();
  1064.                
  1065.             }
  1066.         });
  1067.        
  1068.         go.getChildren().addAll(mbPrint, mbBP, mbSP);
  1069.         stage.setX(100);
  1070.         stage.setY(30);
  1071.  
  1072.         rect1.setFill(Color.WHITE);
  1073.         rect1.setArcHeight(20);
  1074.         rect1.setArcWidth(20);
  1075.  
  1076.         rect1.widthProperty().bind(scene.widthProperty().divide(2.1));
  1077.         rect1.heightProperty().bind(scene.heightProperty().divide(1.2));
  1078.  
  1079.         gp2.layoutXProperty().bind(scene.widthProperty().divide(2.05));
  1080.         gp2.setLayoutY(17);
  1081.  
  1082.         go.getChildren().add(gp1);
  1083.         go.getChildren().add(gp2);
  1084.  
  1085.         rect2.setArcHeight(10);
  1086.         rect2.setArcWidth(10);
  1087.         rect2.setFill(Color.WHITE);
  1088.         rect2.setStroke(Color.web("#FFCC00"));
  1089.         rect2.setStrokeWidth(10);
  1090.      
  1091.         rect2.widthProperty().bind(scene.widthProperty().divide(3.5));
  1092.         rect2.heightProperty().bind(scene.heightProperty().divide(1.2));
  1093.  
  1094.         gp2.getChildren().add(rect2);
  1095.         gp2.getChildren().add(ch);
  1096.         ch.layoutYProperty().bind(rect2.heightProperty().subtract(20));
  1097.         ch.layoutXProperty().bind(rect2.widthProperty()
  1098.                                   .subtract(rect2.widthProperty())
  1099.                                   .add(7));
  1100.          
  1101.         go.getChildren().add(gp3);
  1102.  
  1103.         gp3.layoutXProperty().bind(stage.widthProperty().divide(1.28));
  1104.         gp3.setLayoutY(17);
  1105.        
  1106.         rect3.setArcHeight(10);
  1107.         rect3.setArcWidth(10);
  1108.         rect3.setFill(Color.WHITE);
  1109.         rect3.setStroke(Color.web("#333366"));
  1110.         rect3.setStrokeWidth(10);
  1111.      
  1112.         rect3.setLayoutX(-4);
  1113.         rect3.widthProperty().bind(scene.widthProperty().divide(4.8));
  1114.         rect3.heightProperty().bind(scene.heightProperty().divide(1.2));
  1115.  
  1116.         gp3.getChildren().add(rect3);
  1117.         tl.prefHeightProperty().bind(scene.heightProperty().divide(1.2));
  1118.         tl.prefWidthProperty().bind(stage.widthProperty().divide(5.25));
  1119.         tl.setStyle("-fx-background-color: #333333;");
  1120.         tl.setAlignment(Pos.CENTER_LEFT);
  1121.         tl.setHgap(2);
  1122.         tl.setVgap(2);
  1123.         gp3.getChildren().add(tl);
  1124.         ScrollPane scp=new ScrollPane();
  1125.         scp.setPrefHeight(270);
  1126.         scp.prefWidthProperty().bind(rect3.widthProperty().subtract(6));
  1127.      
  1128.            gp3.getChildren().add(scp);
  1129.            scp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
  1130.            scp.setContent(tl);
  1131.        
  1132.         tfenvi.setPromptText("enviar mensagem");
  1133.  
  1134.         HBox hbx = new HBox(0.4);
  1135.         hbx.setLayoutX(5);
  1136.         hbx.setLayoutY(5);
  1137.         hbx.getChildren().addAll(btenvi, tfenvi);
  1138.         gp2.getChildren().add(hbx);
  1139.  
  1140.         listView.layoutXProperty().bind(
  1141.                 gp2.layoutXProperty().subtract(gp2.layoutXProperty().add(-8))
  1142.         );
  1143.         listView.setLayoutY(28);
  1144.         listView.prefHeightProperty().bind(stage.heightProperty().divide(1.9));
  1145.         listView.prefWidthProperty().bind(stage.widthProperty().divide(4));
  1146.  
  1147.         gp2.getChildren().add(listView);
  1148.  
  1149.         txEnvian = new Text("Parado/Enviando:");
  1150.         txStatus = new Text("Status: off");
  1151.         txserv = new Text("Servidor");
  1152.  
  1153.         txEnvian.layoutYProperty().bind(listView.heightProperty().add(40));
  1154.         /*txenvia herda */ txEnvian.setLayoutX(10);
  1155.         /*alguns elementos do gp2 */
  1156.         txStatus.layoutYProperty().bind(listView.heightProperty().add(40));
  1157.         txStatus.setLayoutX(120);
  1158.  
  1159.         //txserv;
  1160.         txserv.layoutYProperty().bind(listView.heightProperty().add(50));
  1161.         txserv.setLayoutX(11);
  1162.  
  1163.         gp2.getChildren().addAll(txEnvian, txStatus, txserv);
  1164.  
  1165.         try {
  1166.             max();
  1167.         } catch (MalformedURLException ex) {
  1168.             Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, ex);
  1169.         }
  1170.  
  1171.         btenvi.setOnAction(new javafx.event.EventHandler<ActionEvent>() {
  1172.  
  1173.             @Override
  1174.             public void handle(javafx.event.ActionEvent event) {
  1175.  
  1176.                 //gerar File fdSPTexto=new File(System.getProperty("user.home") + "\\Meus documentos\\printsteel");
  1177.                
  1178.                 if (fdSPTexto.exists()) {
  1179.                     txEnvian.setText("Enviando");
  1180.                     FileFilter ff = new FileFilter() {
  1181.                         public boolean accept(File b) {
  1182.                             return b.getName().endsWith(".txt");
  1183.                          }
  1184.                         };
  1185.  
  1186.                     File[] filextextos = fdSPTexto.listFiles(ff);
  1187.                     opx = filextextos.length;
  1188.                        
  1189.                     for (i = 1; i < filextextos.length; i++) {
  1190.                          System.out.println("opx" + opx + "i" + i);
  1191.                          }
  1192.                      opx++;
  1193.                      System.out.print("exite enviando texto");
  1194.                      names.add(" " + System.getProperty("user.name") + ":~  " + tfenvi.getText());
  1195.                      FileWriter fw;
  1196.                     BufferedWriter bw;
  1197.                     try {
  1198.                     fw = new FileWriter(fdSPTexto + "\\" + System.getProperty("user.name") + opx + ".txt", true);
  1199.                         bw = new BufferedWriter(fw);
  1200.                         //tfenvi.getrawText()/?
  1201.                     bw.write(":-:Nome:-:" + System.getProperty("user.name") + ":-:texto:-:" + tfenvi.getText());
  1202.                       //bw.newLine();
  1203.                         bw.close();
  1204.                         fw.close();
  1205.                    
  1206.         ftp.connect("ftp.xpg.com.br");
  1207.          if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
  1208.           txStatus.setText("Status: On");
  1209.           txserv.setText("conectando.");
  1210.            ftp.login("xxxxxxxx", "xxxxxxxxxx");
  1211.             ftp.changeWorkingDirectory("steelprint");
  1212.               txserv.setText("conectado!");
  1213.              try {
  1214.               ftp.makeDirectory(System.getProperty("user.name"));
  1215.                } catch (Exception e) {
  1216.                   System.err.println("provavel que ja tenha uma pasta no servidor");
  1217.                     Logger.getLogger(SteelPrint.class.getName()).log(Level.SEVERE, null, e);
  1218.                     }
  1219.  
  1220.                   ftp.changeWorkingDirectory(System.getProperty("user.name"));
  1221.                    System.err.println(" ftp.login( \"login\", \"senha\" );"
  1222.                     + "\n conexao=" + ftp.getReplyString());
  1223.  
  1224.    FileInputStream arqEnv = new FileInputStream(fdSPTexto + "\\" + System.getProperty("user.name") + opx + ".txt");
  1225.                 if (ftp.storeFile( opx + ".txt", arqEnv)) {
  1226.                 txEnvian.setText("Enviado ult.msg " + ftp.getBufferSize() + "Kb");
  1227.                 txserv.setText("Servidor:" + ftp.getSystemType());
  1228.                 System.out.println("arquivo enviado" + ftp.getBufferSize());
  1229.                 //######################################
  1230.          
  1231.         /*sysconectar*/try{ftp.disconnect();}catch(Exception e){e.getMessage();}
  1232.        
  1233.                 //img
  1234.                 if (ch.selectedProperty().getValue()==true){
  1235.                 System.out.println("pressed");
  1236.                 IMGreload();      
  1237.                
  1238.                
  1239.                 }else{
  1240.                    
  1241.                    
  1242.                     System.out.println("no pressed");
  1243.                
  1244.                
  1245.                 }
  1246.        
  1247.        
  1248.        
  1249.        
  1250.           try {
  1251.               System.out.println("==============================="
  1252.               +"\n preparando pra pra receber dados");
  1253.               receivers();
  1254.                System.out.println("\nFIM DE DADOS \n"
  1255.                        +"==============================="
  1256.               );
  1257.              
  1258.                         } catch (Exception e) {
  1259.                             e.printStackTrace();
  1260.                     }    } else {
  1261.                                 System.out.println("arquivo nao enviadoenviado"
  1262.                                         + "\n" + fdSPTexto + "\\" + opx + ".txt"
  1263.                                         + "\nlista files" + ftp.getListHiddenFiles()
  1264.                                         + ""
  1265.                                         + "");
  1266.                                 ftp.disconnect();
  1267.                             }
  1268.                
  1269.          } else {
  1270.                             System.out.println("restabelecendo conexao");
  1271.  
  1272.                             txStatus.setText("Status: off");
  1273.                             txserv.setText("Verifique a conexão+error+21" + Exception.class.getName());
  1274.                         }
  1275.                        
  1276.                     } catch (IOException e) {
  1277.                          System.err.println("primeira localizaçao de error verifique a conexao \n"
  1278.                                  + "\n");
  1279.                    names.add("MSG NÃO ENVIADA: " + "\""+tfenvi.getText()+"\"");
  1280.                    txEnvian.setText("Parado");
  1281.                    txStatus.setText("Off");
  1282.                    txserv.setText("Sem Conexao");
  1283.                     }
  1284.  
  1285.                 } else {
  1286.                     System.err.println("nao euste " + fldir.getPath());
  1287.  
  1288.                 }
  1289.  
  1290.          //receber
  1291.                 //enviar
  1292.                 //resolver
  1293.                 tfenvi.setText("");
  1294.                 tfenvi.setPromptText("enviar mensagem");
  1295.  
  1296.             }
  1297.         });
  1298.  
  1299.         //prints
  1300.        
  1301.         go.getChildren().add(mnbr);
  1302.         initializeconfigs();
  1303.         initializingConfigAll();
  1304.         InitializesgetChidrens();
  1305.        
  1306.         stage.show();
  1307.     }
  1308.     public static void main(String[] args) {
  1309.         launch(args);
  1310.     }
  1311.  
  1312. }
Advertisement
Add Comment
Please, Sign In to add comment