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); }
/* Divide text to array of parts using serparator charaster */ public static String[] explode(String text, char separator) { if (StringUtils.isEmpty(text)) { return new String[0]; } Vector<String> tmp = new Vector<String>(); int start = 0; int end = text.indexOf(separator, start); while (end >= start) { tmp.addElement(text.substring(start, end)); start = end + 1; end = text.indexOf(separator, start); } tmp.addElement(text.substring(start)); String[] result = new String[tmp.size()]; tmp.copyInto(result); return result; }