/** Prealoads all images from files. */ private void preLoadAllImagesFromFiles() { HwTypeEnum hwTypes[] = HwTypeEnum.values(); for (HwTypeEnum hwType : hwTypes) { String path = getImagePath(hwType); try { bufferedImageLoader.getImage(path); } catch (IOException ex) { // should never happen } } // PacketType packetType, PacketImageType packageImageType PacketType packetTypes[] = PacketType.values(); PacketImageType packetImageTypes[] = PacketImageType.values(); for (PacketType packetType : packetTypes) { for (PacketImageType packetImageType : packetImageTypes) { String path = getImagePath(packetType, packetImageType); try { bufferedImageLoader.getImage(path); } catch (IOException ex) { // should never happen } } } }
/** * Gets image icon from path. * * @param path * @return */ public ImageIcon getImageIcon(String path) { ImageIcon image = bufferedImageLoader.getImageIcon(path); return image; }
/** * Creates scaled image of image at path. Size will be size x size. * * @param path * @param width * @return scaled image * @throws IOException */ private Image getScaledImage(String path, int width) throws IOException { Image tmp = bufferedImageLoader.getImage(path); int height = (int) ((double) (tmp.getHeight(null) / (double) tmp.getWidth(null)) * width); tmp = tmp.getScaledInstance(width, height, Image.SCALE_SMOOTH); return tmp; }