Package java.awt

Examples of java.awt.Robot


  public static Robot createRobot(final Component component) {
    try {
      return AccessController.doPrivileged(new PrivilegedExceptionAction<Robot>() {
        public Robot run() throws Exception {
          return new Robot(component.getGraphicsConfiguration().getDevice());
        }
      });
    } catch (PrivilegedActionException e) {
      LWJGLUtil.log("Got exception while creating robot: " + e.getCause());
      return null;
View Full Code Here


        Rectangle windowRect = getBounds();
        splashBufferedImage = new BufferedImage(width , height + extra, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = (Graphics2D) splashBufferedImage.getGraphics();

        try {
            Robot robot = new Robot(getGraphicsConfiguration().getDevice());
            BufferedImage capture = robot.createScreenCapture(new Rectangle(windowRect.x, windowRect.y, windowRect.width + extra, windowRect.height + extra));
            g2.drawImage(capture, null, 0, 0);
        } catch (AWTException e) { }

        g2.drawImage(image, 0, 0, this);
    }
View Full Code Here

      System.err.println(e);
  }
  //size = Toolkit.getDefaultToolkit().getScreenSize();
  size = new Dimension(width, height);
  try {
      robot = new Robot();
  } catch (AWTException awe) {
      throw new RuntimeException("");
  }
  maxDataLength = size.width * size.height * 3;
  rgbFormat = new RGBFormat(size, maxDataLength,
View Full Code Here

        splash = new BufferedImage(width + extra, height + extra,
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = (Graphics2D) splash.getGraphics();

        try {
            Robot robot = new Robot(getGraphicsConfiguration().getDevice());
            BufferedImage capture = robot.createScreenCapture(new Rectangle(
                    windowRect.x, windowRect.y, windowRect.width + extra,
                    windowRect.height + extra));
            g2.drawImage(capture, null, 0, 0);
        } catch (AWTException e) {
        }
View Full Code Here

      // Instead of using off screen images that may cause some problems
      // use Robot to capture canvas 3D image instead of
      Point canvas3DOrigin = new Point();
      SwingUtilities.convertPointToScreen(canvas3DOrigin, this.canvas3D);
     
      Robot robot = new Robot();
      // Render scene with a white background
      if (this.iconImageLock != null) {
        synchronized (this.iconImageLock) {
          setBackground(Color.WHITE);
          try {
            this.iconImageLock.wait(maxWaitingDelay / 2);
          } catch (InterruptedException ex) {
            ex.printStackTrace();
          }
        }
      }
      imageWithWhiteBackgound = robot.createScreenCapture(
          new Rectangle(canvas3DOrigin, this.canvas3D.getSize()));
     
      // Render scene with a black background
      if (this.iconImageLock != null) {
        synchronized (this.iconImageLock) {
          setBackground(Color.BLACK);
          try {
            this.iconImageLock.wait(maxWaitingDelay / 2);
          } catch (InterruptedException ex) {
            ex.printStackTrace();
          }
        }
      }
      imageWithBlackBackgound = robot.createScreenCapture(
          new Rectangle(canvas3DOrigin, this.canvas3D.getSize()));
    } catch (AWTException ex) {
      throw new RuntimeException(ex);
    } finally {
      this.iconImageLock = null;
View Full Code Here

   
    public robot() {
        tk = Toolkit.getDefaultToolkit();
        screenRect = new Rectangle(tk.getScreenSize());
        try {              
            rt = new Robot();
        }
        catch (AWTException awte) {
            awte.getStackTrace();
        }    
    }
View Full Code Here

                int orig_width = width;
                int orig_height = height;
              
                try {
                    Robot robot = new Robot();

                    this.previousItems = null;
                   
                    while (active) {
                     
                        final long ctime = System.currentTimeMillis();
                       
                        width = orig_width;
                        height = orig_height;
                       
                        BufferedImage image = robot.createScreenCapture(new Rectangle(x, y, width, height));
                       
                        int width_new = resizeX;
                      int height_new = resizeY;
                        width = resizeX;
                        height = resizeY;
View Full Code Here

                int orig_height = height;
              
              
                try
                {
                        Robot robot = new Robot();

                        this.previousItems = null;
                       
                        while (active)
                        {
                                final long ctime = System.currentTimeMillis();
                               
                               
                                width = orig_width;
                                height = orig_height;
                               
                                BufferedImage image = robot.createScreenCapture(new Rectangle(x, y, width, height));
                               
                                int width_new = resizeX;
                              int height_new = resizeY;
                                width = resizeX;
                                height = resizeY;
View Full Code Here

           
            String action = returnMap.get("action").toString();
           
            if (action.equals("onmouseup")) {
             
               Robot robot = new Robot();
               
               //VirtualScreenBean
               
  //          Integer x = Math.round ( ( ( Float.valueOf(returnMap.get("x").toString()).floatValue() *VirtualScreenBean.vScreenResizeX )/VirtualScreenBean.vScreenSpinnerWidth) / Ampl_factor) ;
  //          Integer y = Math.round ( ( ( Float.valueOf(returnMap.get("y").toString()).floatValue() *VirtualScreenBean.vScreenResizeY )/VirtualScreenBean.vScreenSpinnerHeight)/ Ampl_factor) ;
  //           
              
               //logger.debug("x 1 "+returnMap.get("x"));
              
               Float scaleFactor = Float.valueOf(VirtualScreenBean.vScreenSpinnerWidth) / Float.valueOf(VirtualScreenBean.vScreenResizeX);
              
               //logger.debug("x 1 scaleFactor "+scaleFactor);
              
               Float part_x1 = ( ( Float.valueOf(returnMap.get("x").toString()).floatValue() * scaleFactor  ) / Float.valueOf(Ampl_factor) );
              
               //logger.debug("x 1 part_x1 "+part_x1);
              
               Integer x = Math.round ( part_x1 + VirtualScreenBean.vScreenSpinnerX  );

              
               Integer y = Math.round ( ( ( Float.valueOf(returnMap.get("y").toString()).floatValue() * VirtualScreenBean.vScreenSpinnerHeight / VirtualScreenBean.vScreenResizeY) / Ampl_factor) + VirtualScreenBean.vScreenSpinnerY;
           
            
               //logger.debug("x|y "+x+" || "+y);
             
                robot.mouseMove(x, y);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);
             
            } else if (action.equals("onmousedown")) {
             
               Robot robot = new Robot();
              
               Float scaleFactor = Float.valueOf(VirtualScreenBean.vScreenSpinnerWidth) / Float.valueOf(VirtualScreenBean.vScreenResizeX);
               Float part_x1 = ( ( Float.valueOf(returnMap.get("x").toString()).floatValue() * scaleFactor  ) / Float.valueOf(Ampl_factor) );
               Integer x = Math.round ( part_x1 + VirtualScreenBean.vScreenSpinnerX  );
               Integer y = Math.round ( ( ( Float.valueOf(returnMap.get("y").toString()).floatValue() * VirtualScreenBean.vScreenSpinnerHeight / VirtualScreenBean.vScreenResizeY) / Ampl_factor) + VirtualScreenBean.vScreenSpinnerY;
             
                robot.mouseMove(x, y);
                robot.mousePress(InputEvent.BUTTON1_MASK);
             
            } else if (action.equals("mousePos")) {
             
              Robot robot = new Robot();
               
               Float scaleFactor = Float.valueOf(VirtualScreenBean.vScreenSpinnerWidth) / Float.valueOf(VirtualScreenBean.vScreenResizeX);
              
               Float part_x1 = ( ( Float.valueOf(returnMap.get("x").toString()).floatValue() * scaleFactor  ) / Float.valueOf(Ampl_factor) );
              
               Integer x = Math.round ( part_x1 + VirtualScreenBean.vScreenSpinnerX  );
              
               Integer y = Math.round ( ( ( Float.valueOf(returnMap.get("y").toString()).floatValue() * VirtualScreenBean.vScreenSpinnerHeight / VirtualScreenBean.vScreenResizeY) / Ampl_factor) + VirtualScreenBean.vScreenSpinnerY;
           
                robot.mouseMove(x, y);
             
            } else if (action.equals("onkeydown")) {
             
              Robot robot = new Robot();
             
              Integer key = Integer.valueOf(returnMap.get("k").toString()).intValue();
           
              //logger.debug("key onkeydown -1 "+key);
              boolean doAction = true;
             
              if (key == 221) {
                key = 61;
              } else if (key == -1) {
               
                String charValue = returnMap.get("c").toString();
               
                //key = KeyEvent.VK_ADD;
                doAction = false;
               
                for (Iterator<Integer> iter = this.currentPressedKeys.keySet().iterator();iter.hasNext();) {
                  Integer storedKey = iter.next();
                 
                  robot.keyRelease(storedKey);
                 
                }
               
                this.currentPressedKeys = new HashMap<Integer,Boolean>();
               
                this.pressSpecialSign(charValue, robot);
              } else if (key == 188) {
                key = 44;
              } else if (key == 189) {
                key = 109;
              } else if (key == 190) {
                key = 46;
              } else if (key == 191) {
                key = 47;
              }
             
              //logger.debug("key onkeydown -2 "+key);
             
              if (doAction) {
               
                this.currentPressedKeys.put(key, true);
               
                robot.keyPress(key);
              }
             
            } else if (action.equals("onkeyup")) {
             
              Robot robot = new Robot();
             
              Integer key = Integer.valueOf(returnMap.get("k").toString()).intValue();
           
              //logger.debug("key onkeyup 1- "+key);
             
              boolean doAction = true;
             
              if (key == 221) {
                key = 61;
              } else if (key == -1) {
                doAction = false;
              } else if (key == 188) {
                key = 44;
              } else if (key == 189) {
                key = 109;
              } else if (key == 190) {
                key = 46;
              } else if (key == 191) {
                key = 47;
              }
             
              //logger.debug("key onkeyup 2- "+key);
             
              if (doAction) {
               
                if (this.currentPressedKeys.containsKey(key)) {
                  this.currentPressedKeys.remove(key);
                 
                  robot.keyRelease(key);
                 
                }
               
              }
             
            } else if (action.equals("paste")) {
             
              Robot robot = new Robot();
             
              String paste = returnMap.get("paste").toString();
           
              this.pressSpecialSign(paste, robot);
             
            } else if (action.equals("copy")) {
             
              Robot robot = new Robot();
             
              String paste = this.getHighlightedText(robot);
             
              HashMap<Integer,String> map = new HashMap<Integer,String>();
              map.put(0,"copiedText");
              map.put(1,paste);
             
              String clientId = returnMap.get("clientId").toString();
           
              //public synchronized int sendMessageWithClientById(Object newMessage, String clientId)
             
              invoke("sendMessageWithClientById",new Object[] { map, clientId }, this);
             
            } else if (action.equals("show")) {
             
              Robot robot = new Robot();
             
              String paste = this.getClipboardText();
             
              HashMap<Integer,String> map = new HashMap<Integer,String>();
              map.put(0,"copiedText");
View Full Code Here

    ScreenShare.instance.virtualScreen.addMouseListener(vListener);
    ScreenShare.instance.virtualScreen.addMouseMotionListener(vListener);
    ScreenShare.instance.t.add(ScreenShare.instance.virtualScreen);

    Rectangle screenRectangle = new Rectangle(screenSize);
    Robot robot = new Robot();
    BufferedImage imageScreen = robot.createScreenCapture(screenRectangle);

    Image img = imageScreen.getScaledInstance(width, height ,Image.SCALE_SMOOTH);
    //imageScreen.
    System.out.println("img"+img);
    ImageIcon image = new ImageIcon(img);
View Full Code Here

TOP

Related Classes of java.awt.Robot

Copyright © 2018 www.massapicom. 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.