Example #1
0
  public void generarFondo(Component componente) {
    boolean dibujarFondo = false;
    Rectangle med = this.getBounds();
    Rectangle areaDibujo = this.getBounds();
    BufferedImage tmp;
    GraphicsConfiguration gc =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();

    if (Principal.fondoBlur) {
      dibujarFondo = true;
    }
    if (dibujarFondo) {
      JRootPane root = SwingUtilities.getRootPane(this);
      blurBuffer = GraphicsUtilities.createCompatibleImage(Principal.sysAncho, Principal.sysAlto);
      Graphics2D g2 = blurBuffer.createGraphics();
      g2.setClip(med);
      blurBuffer = blurBuffer.getSubimage(med.x, med.y, med.width, med.height);
      ((Escritorio) Principal.getEscritorio()).getFrameEscritorio().paint(g2);
      g2.dispose();
      backBuffer = blurBuffer;
      // blurBuffer = toGrayScale(blurBuffer);
      blurBuffer = GraphicsUtilities.createThumbnailFast(blurBuffer, getWidth() / 2);
      blurBuffer = new GaussianBlurFilter(4).filter(blurBuffer, null);
      g2 = (Graphics2D) blurBuffer.getGraphics();
      g2.setColor(new Color(0, 0, 0, 195));
      g2.fillRect(0, 0, Principal.sysAncho, Principal.sysAlto);
      listo = true;
    }
  }
Example #2
0
  public void setActivo(boolean val) {
    glass.setVisible(val);
    setVisible(val);
    JLayeredPane.getLayeredPaneAbove(glass).moveToFront(glass);

    if (val) {
      synchronized (syncMonitor) {
        try {
          if (SwingUtilities.isEventDispatchThread()) {
            EventQueue theQueue = getToolkit().getSystemEventQueue();
            while (isVisible()) {
              AWTEvent event = theQueue.getNextEvent();
              Object source = event.getSource();

              if (event instanceof ActiveEvent) {
                ((ActiveEvent) event).dispatch();
              } else if (source instanceof Component) {
                ((Component) source).dispatchEvent(event);
              } else if (source instanceof MenuComponent) {
                ((MenuComponent) source).dispatchEvent(event);
              } else {
                System.out.println("No se puede despachar: " + event);
              }
            }
          } else {
            while (isVisible()) {
              syncMonitor.wait();
            }
          }
        } catch (InterruptedException ignored) {
          System.out.println("Excepción de interrupción: " + ignored.getMessage());
        }
      }
    } else {
      synchronized (syncMonitor) {
        setVisible(false);
        glass.setVisible(false);
        syncMonitor.notifyAll();

        eliminarDelContenedor();
      }
    }
  }
Example #3
0
  public void fadeIn() {
    final float acel = 0.1f;
    generarFondo(this);
    super.setVisible(true);

    try {
      while (BlurGlass.this.getAlpha() + acel <= 1.0f) {
        SwingUtilities.invokeAndWait(
            new Runnable() {
              public void run() {
                BlurGlass.this.setAlpha(BlurGlass.this.getAlpha() + acel);
              }
            });
        Thread.sleep(50);
      }
    } catch (Exception e) {
      Dialogos.error("Error en fadein", e);
    }
  }
Example #4
0
  public void fadeOut() {
    super.setVisible(true);

    try {
      final float desacel = 0.1f;
      while (BlurGlass.this.getAlpha() - desacel >= 0.0f) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                BlurGlass.this.setAlpha(BlurGlass.this.getAlpha() - desacel);
              }
            });
        Thread.sleep(50);
      }
      BlurGlass.this.setAlpha(0.0f);
    } catch (Exception e) {
      Dialogos.error("Error en fadeout", e);
    }
    // super.setVisible(false);
    // BlurGlass.this.setAlpha(0.2f);
    // setAlpha(0.2f);
    super.setVisible(false);
  }