Ejemplo n.º 1
0
 public static ImageList createImageList(String resName) {
   ImageList images = (ImageList) files.get(resName);
   if (null != images) {
     return images;
   }
   ImageList icons = new ImageList();
   try {
     icons.load(resName, -1, -1);
   } catch (Exception ignored) {
   }
   files.put(resName, icons);
   return icons;
 }
Ejemplo n.º 2
0
  public void load(String resName, int width, int height) throws IOException {
    Image resImage = ImageList.loadImage(resName);
    if (null == resImage) {
      return;
    }
    int imgHeight = resImage.getHeight();
    int imgWidth = resImage.getWidth();

    if (width == -1) {
      width = Math.min(imgHeight, imgWidth);
    }
    if (height == -1) {
      height = imgHeight;
    }

    this.width = width;
    this.height = height;

    Vector<Icon> tmpIcons = new Vector<Icon>();
    for (int y = 0; y < imgHeight; y += height) {
      for (int x = 0; x < imgWidth; x += width) {
        Icon icon = new Icon(resImage, x, y, width, height);
        tmpIcons.addElement(icon);
      }
    }
    icons = new Icon[tmpIcons.size()];
    tmpIcons.copyInto(icons);
  }