/**
   * Instantiates a new LookupTable with the specified offset value and number of components.
   *
   * @param offset the offset value.
   * @param numComponents the number of components.
   */
  protected LookupTable(int offset, int numComponents) {
    if (offset < 0) {
      // awt.232=Offset should be not less than zero
      throw new IllegalArgumentException(Messages.getString("awt.232")); // $NON-NLS-1$
    }
    if (numComponents < 1) {
      // awt.233=Number of components should be positive
      throw new IllegalArgumentException(Messages.getString("awt.233")); // $NON-NLS-1$
    }

    this.offset = offset;
    this.numComponents = numComponents;
  }
  public final BufferedImage filter(BufferedImage src, BufferedImage dst) {
    if (src == dst) {
      // awt.252=Source can't be same as the destination
      throw new IllegalArgumentException(Messages.getString("awt.252")); // $NON-NLS-1$
    }

    ColorModel srcCM = src.getColorModel();
    BufferedImage finalDst = null;

    if (srcCM instanceof IndexColorModel
        && (iType != TYPE_NEAREST_NEIGHBOR || srcCM.getPixelSize() % 8 != 0)) {
      src = ((IndexColorModel) srcCM).convertToIntDiscrete(src.getRaster(), true);
      srcCM = src.getColorModel();
    }

    if (dst == null) {
      dst = createCompatibleDestImage(src, srcCM);
    } else {
      if (!srcCM.equals(dst.getColorModel())) {
        // Treat BufferedImage.TYPE_INT_RGB and
        // BufferedImage.TYPE_INT_ARGB as same
        if (!((src.getType() == BufferedImage.TYPE_INT_RGB
                || src.getType() == BufferedImage.TYPE_INT_ARGB)
            && (dst.getType() == BufferedImage.TYPE_INT_RGB
                || dst.getType() == BufferedImage.TYPE_INT_ARGB))) {
          finalDst = dst;
          dst = createCompatibleDestImage(src, srcCM);
        }
      }
    }

    // Skip alpha channel for TYPE_INT_RGB images
    if (slowFilter(src.getRaster(), dst.getRaster()) != 0) {
      // awt.21F=Unable to transform source
      throw new ImagingOpException(Messages.getString("awt.21F")); // $NON-NLS-1$
      // TODO - uncomment
      // if (ippFilter(src.getRaster(), dst.getRaster(), src.getType()) !=
      // 0)
      // throw new ImagingOpException ("Unable to transform source");
    }

    if (finalDst != null) {
      Graphics2D g = finalDst.createGraphics();
      g.setComposite(AlphaComposite.Src);
      g.drawImage(dst, 0, 0, null);
    } else {
      finalDst = dst;
    }

    return finalDst;
  }
예제 #3
0
  /**
   * Gets the size of the desired component of this color model.
   *
   * @param componentIdx the index that determines which component size to get.
   * @return the component size corresponding to the index.
   * @throws NullPointerException if this color model doesn't support an array of separate
   *     components.
   * @throws ArrayIndexOutOfBoundsException if the index is negative or greater than or equal to the
   *     number of components.
   */
  public int getComponentSize(int componentIdx) {
    if (bits == null) {
      // awt.26C=bits is null
      throw new NullPointerException(Messages.getString("awt.26C")); // $NON-NLS-1$
    }

    if (componentIdx < 0 || componentIdx >= bits.length) {
      // awt.274=componentIdx is greater than the number of components or
      // less than zero
      throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.274")); // $NON-NLS-1$
    }

    return bits[componentIdx];
  }
  /**
   * Instantiates a new AffineTransformOp with the specified AffineTransform and a specified
   * interpolation type from the list of predefined interpolation types.
   *
   * @param xform the AffineTransform.
   * @param interp the one of predefined interpolation types: TYPE_NEAREST_NEIGHBOR, TYPE_BILINEAR,
   *     or TYPE_BICUBIC.
   */
  public AffineTransformOp(AffineTransform xform, int interp) {
    if (Math.abs(xform.getDeterminant()) <= Double.MIN_VALUE) {
      // awt.24F=Unable to invert transform {0}
      throw new ImagingOpException(Messages.getString("awt.24F", xform)); // $NON-NLS-1$
    }

    this.at = (AffineTransform) xform.clone();

    if (interp != TYPE_NEAREST_NEIGHBOR && interp != TYPE_BILINEAR && interp != TYPE_BICUBIC) {
      // awt.250=Unknown interpolation type: {0}
      throw new IllegalArgumentException(Messages.getString("awt.250", interp)); // $NON-NLS-1$
    }

    this.iType = interp;
  }
예제 #5
0
  /**
   * Gets the normalized components corresponding to the specified unnormalized components.
   *
   * @param components the array of unnormalized components.
   * @param offset the offset where the components should be read from the array of unnormalized
   *     components.
   * @param normComponents the array where the resulting normalized components are written (or null
   *     to prompt the method to create the return array).
   * @param normOffset the offset that tells where the results should be written in the return
   *     array.
   * @return the normalized components.
   */
  public float[] getNormalizedComponents(
      int[] components, int offset, float normComponents[], int normOffset) {
    if (bits == null) {
      // awt.26C=bits is null
      throw new UnsupportedOperationException(Messages.getString("awt.26C")); // $NON-NLS-1$
    }

    if (normComponents == null) {
      normComponents = new float[numComponents + normOffset];
    }

    if (hasAlpha && isAlphaPremultiplied) {
      float normAlpha =
          (float) components[offset + numColorComponents] / maxValues[numColorComponents];
      if (normAlpha != 0.0f) {
        for (int i = 0; i < numColorComponents; i++) {
          normComponents[normOffset + i] = components[offset + i] / (normAlpha * maxValues[i]);
        }
        normComponents[normOffset + numColorComponents] = normAlpha;
      } else {
        for (int i = 0; i < numComponents; i++) {
          normComponents[normOffset + i] = 0.0f;
        }
      }
    } else {
      for (int i = 0; i < numComponents; i++) {
        normComponents[normOffset + i] = (float) components[offset + i] / maxValues[i];
      }
    }

    return normComponents;
  }
예제 #6
0
  public MouseEvent(
      Component source,
      int id,
      long when,
      int modifiers,
      int x,
      int y,
      int clickCount,
      boolean popupTrigger,
      int button) {
    super(source, id, when, modifiers);

    if ((button < NOBUTTON) || (button > BUTTON3)) {
      // awt.18B=Invalid button value
      throw new IllegalArgumentException(Messages.getString("awt.18B")); // $NON-NLS-1$
    }

    this.popupTrigger = popupTrigger;
    this.clickCount = clickCount;
    this.button = button;
    this.x = x;
    this.y = y;

    if (getModifiers() != 0) {
      setModifiersEx();
    } else if (getModifiersEx() != 0) {
      setModifiers();
    } else if ((button != NOBUTTON) && ((id >= MOUSE_CLICKED) && (id <= MOUSE_RELEASED))) {
      setButtonModifiers();
    }
  }
  protected InvocationEvent(
      Object source, int id, Runnable runnable, Object notifier, boolean catchExceptions) {
    super(source, id);

    // awt.18C=Cannot invoke null runnable
    assert runnable != null : Messages.getString("awt.18C"); // $NON-NLS-1$

    if (source == null) {
      // awt.18D=Source is null
      throw new IllegalArgumentException(Messages.getString("awt.18D")); // $NON-NLS-1$
    }
    this.runnable = runnable;
    this.notifier = notifier;
    this.catchExceptions = catchExceptions;

    throwable = null;
    when = System.currentTimeMillis();
  }
예제 #8
0
  /**
   * Construct pixel.
   *
   * @param obj the obj.
   * @return the int.
   */
  private int constructPixel(Object obj) {
    int pixel = 0;

    switch (getTransferType()) {
      case DataBuffer.TYPE_BYTE:
        byte[] bPixel = (byte[]) obj;
        if (bPixel.length > 1) {
          // awt.275=This pixel representation is not suuported by tis
          // Color Model
          throw new UnsupportedOperationException(Messages.getString("awt.275")); // $NON-NLS-1$
        }
        pixel = bPixel[0] & 0xff;
        break;

      case DataBuffer.TYPE_USHORT:
        short[] sPixel = (short[]) obj;
        if (sPixel.length > 1) {
          // awt.275=This pixel representation is not suuported by tis
          // Color Model
          throw new UnsupportedOperationException(Messages.getString("awt.275")); // $NON-NLS-1$
        }
        pixel = sPixel[0] & 0xffff;
        break;

      case DataBuffer.TYPE_INT:
        int[] iPixel = (int[]) obj;
        if (iPixel.length > 1) {
          // awt.275=This pixel representation is not suuported by tis
          // Color Model
          throw new UnsupportedOperationException(Messages.getString("awt.275")); // $NON-NLS-1$
        }
        pixel = iPixel[0];
        break;

      default:
        // awt.22D=This transferType ( {0} ) is not supported by this
        // color model
        throw new UnsupportedOperationException(
            Messages.getString(
                "awt.22D", //$NON-NLS-1$
                transferType));
    }
    return pixel;
  }
예제 #9
0
  /**
   * Gets the normalized components of the pixel determined by the data array.
   *
   * @param pixel the data array that defines the pixel (whose primitive type corresponds to the
   *     pixel length in bits.
   * @see ColorModel#getTransferType()
   * @param normComponents the array where the resulting normalized components are written (or null
   *     to prompt the method to create the return array).
   * @param normOffset the offset that tells where the results should be written in the return
   *     array.
   * @return the array of normalized components.
   */
  public float[] getNormalizedComponents(Object pixel, float[] normComponents, int normOffset) {

    if (pixel == null) {
      // awt.294=pixel is null
      throw new NullPointerException(Messages.getString("awt.294")); // $NON-NLS-1$
    }

    int unnormComponents[] = getComponents(pixel, null, 0);
    return getNormalizedComponents(unnormComponents, 0, normComponents, normOffset);
  }
예제 #10
0
  /**
   * Gets the unnormalized components corresponding to the specified normalized components.
   *
   * @param normComponents the array of normalized components.
   * @param normOffset the offset where the components should be read from the array of normalized
   *     components.
   * @param components the array where the resulting unnormalized components are written (or null to
   *     prompt the method to create the return array).
   * @param offset the offset that tells where the results should be written in the return array.
   * @return the unnormalized components.
   */
  public int[] getUnnormalizedComponents(
      float normComponents[], int normOffset, int components[], int offset) {

    if (bits == null) {
      // awt.26C=bits is null
      throw new UnsupportedOperationException(Messages.getString("awt.26C")); // $NON-NLS-1$
    }

    if (normComponents.length - normOffset < numComponents) {
      // awt.273=The length of normComponents minus normOffset is less
      // than numComponents
      throw new IllegalArgumentException(Messages.getString("awt.273")); // $NON-NLS-1$
    }

    if (components == null) {
      components = new int[numComponents + offset];
    } else {
      if (components.length - offset < numComponents) {
        // awt.272=The length of components minus offset is less than
        // numComponents
        throw new IllegalArgumentException(Messages.getString("awt.272")); // $NON-NLS-1$
      }
    }

    if (hasAlpha && isAlphaPremultiplied) {
      float alpha = normComponents[normOffset + numColorComponents];
      for (int i = 0; i < numColorComponents; i++) {
        components[offset + i] =
            (int) (normComponents[normOffset + i] * maxValues[i] * alpha + 0.5f);
      }
      components[offset + numColorComponents] =
          (int)
              (normComponents[normOffset + numColorComponents] * maxValues[numColorComponents]
                  + 0.5f);
    } else {
      for (int i = 0; i < numComponents; i++) {
        components[offset + i] = (int) (normComponents[normOffset + i] * maxValues[i] + 0.5f);
      }
    }

    return components;
  }
예제 #11
0
 /**
  * *************************************************************************
  *
  * <p>Constructors
  *
  * <p>*************************************************************************
  */
 public WinVolatileImage(NativeWindow nw, int width, int height) {
   if (width <= 0 || height <= 0) {
     // awt.19=Illegal size of volatile image.
     throw new IllegalArgumentException(Messages.getString("awt.19")); // $NON-NLS-1$
   }
   hwnd = nw.getId();
   this.width = width;
   this.height = height;
   if (WinGraphicsDevice.useGDI)
     gi = WinGDIGraphics2D.createCompatibleImageInfo(hwnd, width, height);
   else gi = WinGDIPGraphics2D.createCompatibleImageInfo(hwnd, width, height);
   surface = new BitmapSurface(gi, width, height);
 }
예제 #12
0
 public void remove(String item) {
   toolkit.lockAWT();
   try {
     int index = items.indexOf(item);
     if (index < 0) {
       // awt.73=no such item
       throw new IllegalArgumentException(Messages.getString("awt.73")); // $NON-NLS-1$
     }
     remove(index);
   } finally {
     toolkit.unlockAWT();
   }
 }
  public final WritableRaster filter(Raster src, WritableRaster dst) {
    if (src == dst) {
      // awt.252=Source can't be same as the destination
      throw new IllegalArgumentException(Messages.getString("awt.252")); // $NON-NLS-1$
    }

    if (dst == null) {
      dst = createCompatibleDestRaster(src);
    } else if (src.getNumBands() != dst.getNumBands()) {
      // awt.253=Different number of bands in source and destination
      throw new IllegalArgumentException(Messages.getString("awt.253")); // $NON-NLS-1$
    }

    if (slowFilter(src, dst) != 0) {
      // awt.21F=Unable to transform source
      throw new ImagingOpException(Messages.getString("awt.21F")); // $NON-NLS-1$
      // TODO - uncomment
      // if (ippFilter(src, dst, BufferedImage.TYPE_CUSTOM) != 0)
      // throw new ImagingOpException("Unable to transform source");
    }

    return dst;
  }
예제 #14
0
 public void keyPressed(KeyEvent e) {
   // awt.72=Key event for unfocused component
   assert isFocusOwner() : Messages.getString("awt.72"); // $NON-NLS-1$
   int keyCode = e.getKeyCode();
   switch (keyCode) {
     case KeyEvent.VK_UP:
       scrollByUnit(vAdjustable, -1);
       break;
     case KeyEvent.VK_LEFT:
       scrollByUnit(hAdjustable, -1);
       break;
     case KeyEvent.VK_DOWN:
       scrollByUnit(vAdjustable, 1);
       break;
     case KeyEvent.VK_RIGHT:
       scrollByUnit(hAdjustable, 1);
       break;
     case KeyEvent.VK_PAGE_UP:
       scrollByBlock(-1);
       break;
     case KeyEvent.VK_PAGE_DOWN:
       scrollByBlock(1);
       break;
     case KeyEvent.VK_HOME:
       selectVisible(0);
       break;
     case KeyEvent.VK_END:
       int lastIdx = getItemCount() - 1;
       selectVisible(lastIdx);
       break;
     case KeyEvent.VK_ENTER:
       fireActionEvent(e.getWhen(), e.getModifiers());
       break;
     case KeyEvent.VK_SPACE:
       if (isMultipleMode()) {
         boolean deselect = isIndexSelected(currentIndex);
         if (deselect) {
           deselect(currentIndex);
         } else {
           select(currentIndex);
         }
         fireItemEvent(deselect ? ItemEvent.DESELECTED : ItemEvent.SELECTED);
       }
       break;
   }
 }
예제 #15
0
  /**
   * Instantiates a new color model with the specified pixel bit depth. The transferType is chosen
   * based on the pixel bits, and the other data fields are given default values.
   *
   * @param bits the array of component masks.
   */
  public ColorModel(int bits) {

    if (bits < 1) {
      // awt.271=The number of bits in bits is less than 1
      throw new IllegalArgumentException(Messages.getString("awt.271")); // $NON-NLS-1$
    }

    pixel_bits = bits;
    transferType = getTransferType(bits);
    cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    hasAlpha = true;
    isAlphaPremultiplied = false;
    transparency = Transparency.TRANSLUCENT;

    numColorComponents = 3;
    numComponents = 4;

    this.bits = null;
  }
예제 #16
0
  public WinVolatileImage(WinGraphicsConfiguration gc, int width, int height) {
    if (width <= 0 || height <= 0) {
      // awt.19=Illegal size of volatile image.
      throw new IllegalArgumentException(Messages.getString("awt.19")); // $NON-NLS-1$
    }

    hwnd = 0;
    this.gc = gc;
    this.width = width;
    this.height = height;
    if (WinGraphicsDevice.useGDI)
      gi =
          WinGDIGraphics2D.createCompatibleImageInfo(
              ((WinGraphicsDevice) gc.getDevice()).getIDBytes(), width, height);
    else
      gi =
          WinGDIPGraphics2D.createCompatibleImageInfo(
              ((WinGraphicsDevice) gc.getDevice()).getIDBytes(), width, height);
    surface = new BitmapSurface(gi, width, height);
  }
  public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
    Rectangle2D newBounds = getBounds2D(src);

    // Destination image should include (0,0) + positive part
    // of the area bounded by newBounds (in source coordinate system).
    double dstWidth = newBounds.getX() + newBounds.getWidth();
    double dstHeight = newBounds.getY() + newBounds.getHeight();

    if (dstWidth <= 0 || dstHeight <= 0) {
      // awt.251=Transformed width ({0}) and height ({1}) should be
      // greater than 0
      throw new RasterFormatException(
          Messages.getString("awt.251", dstWidth, dstHeight)); // $NON-NLS-1$
    }

    if (destCM != null) {
      return new BufferedImage(
          destCM,
          destCM.createCompatibleWritableRaster((int) dstWidth, (int) dstHeight),
          destCM.isAlphaPremultiplied(),
          null);
    }

    ColorModel cm = src.getColorModel();

    // Interpolation other than NN doesn't make any sense for index color
    if (iType != TYPE_NEAREST_NEIGHBOR && cm instanceof IndexColorModel) {
      return new BufferedImage((int) dstWidth, (int) dstHeight, BufferedImage.TYPE_INT_ARGB);
    }

    // OK, we can get source color model
    return new BufferedImage(
        cm,
        src.getRaster().createCompatibleWritableRaster((int) dstWidth, (int) dstHeight),
        cm.isAlphaPremultiplied(),
        null);
  }
예제 #18
0
  /**
   * Instantiates a new color model with the specified values.
   *
   * @param pixel_bits the pixel length in bits.
   * @param bits the array of component masks.
   * @param cspace the color space.
   * @param hasAlpha whether the color model has alpha.
   * @param isAlphaPremultiplied whether the alpha is pre-multiplied.
   * @param transparency the transparency strategy, @see java.awt.Transparency.
   * @param transferType the transfer type (primitive java type to use for the components).
   */
  protected ColorModel(
      int pixel_bits,
      int[] bits,
      ColorSpace cspace,
      boolean hasAlpha,
      boolean isAlphaPremultiplied,
      int transparency,
      int transferType) {

    if (pixel_bits < 1) {
      // awt.26B=The number of bits in the pixel values is less than 1
      throw new IllegalArgumentException(Messages.getString("awt.26B")); // $NON-NLS-1$
    }

    if (bits == null) {
      // awt.26C=bits is null
      throw new NullPointerException(Messages.getString("awt.26C")); // $NON-NLS-1$
    }

    int sum = 0;
    for (int element : bits) {
      if (element < 0) {
        // awt.26D=The elements in bits is less than 0
        throw new IllegalArgumentException(Messages.getString("awt.26D")); // $NON-NLS-1$
      }
      sum += element;
    }

    if (sum < 1) {
      // awt.26E=The sum of the number of bits in bits is less than 1
      throw new NullPointerException(Messages.getString("awt.26E")); // $NON-NLS-1$
    }

    if (cspace == null) {
      // awt.26F=The cspace is null
      throw new IllegalArgumentException(Messages.getString("awt.26F")); // $NON-NLS-1$
    }

    if (transparency < Transparency.OPAQUE || transparency > Transparency.TRANSLUCENT) {
      // awt.270=The transparency is not a valid value
      throw new IllegalArgumentException(Messages.getString("awt.270")); // $NON-NLS-1$
    }

    this.pixel_bits = pixel_bits;
    this.bits = bits.clone();

    maxValues = new int[bits.length];
    maxBitLength = 0;
    for (int i = 0; i < maxValues.length; i++) {
      maxValues[i] = (1 << bits[i]) - 1;
      if (bits[i] > maxBitLength) {
        maxBitLength = bits[i];
      }
    }

    cs = cspace;
    this.hasAlpha = hasAlpha;
    this.isAlphaPremultiplied = isAlphaPremultiplied;
    numColorComponents = cs.getNumComponents();

    if (hasAlpha) {
      numComponents = numColorComponents + 1;
    } else {
      numComponents = numColorComponents;
    }

    this.transparency = transparency;
    this.transferType = transferType;
  }
예제 #19
0
 public void setVisibleAmount(int vis) {
   // awt.144=Can be set by scrollpane only
   throw new AWTError(Messages.getString("awt.144")); // $NON-NLS-1$
 }
예제 #20
0
 public void setMinimum(int min) {
   // awt.144=Can be set by scrollpane only
   throw new AWTError(Messages.getString("awt.144")); // $NON-NLS-1$
 }