@Override
 protected void repaint() {
   if (SwingUtilities.isEventDispatchThread()) {
     component.repaint();
   } else {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             component.repaint();
           }
         });
   }
 }
 public synchronized void actionPerformed(ActionEvent e) {
   java.util.List<JComponent> componentsToRemove = null;
   java.util.List<Part> partsToRemove = null;
   for (JComponent component : animationStateMap.keySet()) {
     component.repaint();
     if (partsToRemove != null) {
       partsToRemove.clear();
     }
     Map<Part, AnimationState> map = animationStateMap.get(component);
     if (!component.isShowing() || map == null || map.size() == 0) {
       if (componentsToRemove == null) {
         componentsToRemove = new ArrayList<JComponent>();
       }
       componentsToRemove.add(component);
       continue;
     }
     for (Part part : map.keySet()) {
       if (map.get(part).isDone()) {
         if (partsToRemove == null) {
           partsToRemove = new ArrayList<Part>();
         }
         partsToRemove.add(part);
       }
     }
     if (partsToRemove != null) {
       if (partsToRemove.size() == map.size()) {
         // animation is done for the component
         if (componentsToRemove == null) {
           componentsToRemove = new ArrayList<JComponent>();
         }
         componentsToRemove.add(component);
       } else {
         for (Part part : partsToRemove) {
           map.remove(part);
         }
       }
     }
   }
   if (componentsToRemove != null) {
     for (JComponent component : componentsToRemove) {
       animationStateMap.remove(component);
     }
   }
   if (animationStateMap.size() == 0) {
     timer.stop();
   }
 }
Esempio n. 3
0
  /**
   * Creates preview for the device(video) in the video container.
   *
   * @param device the device
   * @param videoContainer the container
   * @throws IOException a problem accessing the device.
   * @throws MediaException a problem getting preview.
   */
  private static void createPreview(MediaDevice device, final JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    Component c =
        (Component)
            GuiActivator.getMediaService()
                .getVideoPreviewComponent(
                    device, videoContainer.getSize().width, videoContainer.getSize().height);

    videoContainer.add(c);
  }
    public void setText(String txt) {
      text = txt;
      textlabel.repaint();
      if (!text.equals("")) {
        if (!isVisible()) {
          // Only setVisible if its needed
          // or the focus window will change
          toFront();
          setVisible(true);
        }

        // Give focus to capture window if its there
        if (cw.isVisible()) cw.requestFocus();
      } else {
        // Hide window
        setVisible(false);
      }
    }
 private void dispatchEvent(MouseEvent me) {
   if (rect != null && rect.contains(me.getX(), me.getY())) {
     Point pt = me.getPoint();
     pt.translate(-offset, 0);
     comp.setBounds(rect);
     comp.dispatchEvent(
         new MouseEvent(
             comp,
             me.getID(),
             me.getWhen(),
             me.getModifiers(),
             pt.x,
             pt.y,
             me.getClickCount(),
             me.isPopupTrigger(),
             me.getButton()));
     if (!comp.isValid()) container.repaint();
   }
 }
Esempio n. 6
0
  /**
   * Creates preview for the (video) device in the video container.
   *
   * @param device the device
   * @param videoContainer the video container
   * @throws IOException a problem accessing the device
   * @throws MediaException a problem getting preview
   */
  private static void createVideoPreview(CaptureDeviceInfo device, JComponent videoContainer)
      throws IOException, MediaException {
    videoContainer.removeAll();

    videoContainer.revalidate();
    videoContainer.repaint();

    if (device == null) return;

    for (MediaDevice mediaDevice : mediaService.getDevices(MediaType.VIDEO, MediaUseCase.ANY)) {
      if (((MediaDeviceImpl) mediaDevice).getCaptureDeviceInfo().equals(device)) {
        Dimension videoContainerSize = videoContainer.getPreferredSize();
        Component preview =
            (Component)
                mediaService.getVideoPreviewComponent(
                    mediaDevice, videoContainerSize.width, videoContainerSize.height);

        if (preview != null) videoContainer.add(preview);
        break;
      }
    }
  }
Esempio n. 7
0
 private void doRepaint() {
   super.repaint();
 }
 private void fireEvent(String type, Object key, Object e) {
   window.core.fireEvent(type, key, e);
   canvas.repaint();
 }