Example #1
0
 public void createCaptcha(final String key, final Color bgColor) {
   final CaptchaKeyGenerator ci = new CaptchaKeyGenerator();
   if (key == null) {
     setKey(ci.createCaptchaKey(charLen));
   } else {
     setKey(key);
   }
   final ImageProducer ip = new ImageProducer(this.key);
   setImage(ip.createImage(bgColor));
 }
Example #2
0
  private void viewerResized() {
    width = getSize().x;
    height = getSize().y;
    logger.debug("Tamaño del viewer: " + width + "x" + height);

    if (svgImage != null && !svgImage.isDisposed()) svgImage.dispose();

    if (offscreenImage != null && !offscreenImage.isDisposed()) {
      offscreenImage.dispose();
    }
    offscreenImage = new Image(getDisplay(), width, height);

    // Crea el raster SVG
    TinyPixbuf buffer = new TinyPixbuf(width, height);
    raster = new SVGRaster(buffer);
    imageProducer = new ImageProducer(raster);
    imageProducer.setConsumer(this);
    raster.setSVGImageProducer(imageProducer);

    // Antialiasing
    raster.setAntialiased(antialiased);

    // Poner fondo transparente
    raster.setBackground(0x00FFFFFF);

    // Avisar al manejador de eventos de que el tamaño ha cambiado
    if (mouseHandler != null) {
      mouseHandler.viewerResized();
    }

    // Cargar el documento pendiente, si existe
    if (pendingSVG != null) {
      loadSVGUrl(pendingSVG);
      pendingSVG = null;
    } else {
      if (currentSVG != null) {
        loadSVGUrl(currentSVG);
      }
    }
  }
Example #3
0
 /**
  * Responds to a request for a TopDownLeftRight (TDLR) ordered resend of the pixel data from an
  * <code>ImageConsumer</code>. When an <code>ImageConsumer</code> being fed by an instance of this
  * <code>ImageFilter</code> requests a resend of the data in TDLR order, the <code>
  * FilteredImageSource</code> invokes this method of the <code>ImageFilter</code>.
  *
  * <p>An <code>ImageFilter</code> subclass might override this method or not, depending on if and
  * how it can send data in TDLR order. Three possibilities exist:
  *
  * <ul>
  *   <li>Do not override this method. This makes the subclass use the default implementation,
  *       which is to forward the request to the indicated <code>ImageProducer</code> using this
  *       filter as the requesting <code>ImageConsumer</code>. This behavior is appropriate if the
  *       filter can determine that it will forward the pixels in TDLR order if its upstream
  *       producer object sends them in TDLR order.
  *   <li>Override the method to simply send the data. This is appropriate if the filter can handle
  *       the request itself &#151; for example, if the generated pixels have been saved in some
  *       sort of buffer.
  *   <li>Override the method to do nothing. This is appropriate if the filter cannot produce
  *       filtered data in TDLR order.
  * </ul>
  *
  * @see ImageProducer#requestTopDownLeftRightResend
  * @param ip the ImageProducer that is feeding this instance of the filter - also the
  *     ImageProducer that the request should be forwarded to if necessary
  * @exception NullPointerException if <code>ip</code> is null
  */
 public void resendTopDownLeftRight(ImageProducer ip) {
   ip.requestTopDownLeftRightResend(this);
 }