java.awt.MediaTracker Java Examples
The following examples show how to use
java.awt.MediaTracker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwAOutInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } // Wait until the image is completely loaded MediaTracker tracker = new MediaTracker(new Component() { private static final long serialVersionUID = 6412221228374321325L; }); tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new Fault(e); } // Create a BufferedImage so we can write it out later BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; }
Example #2
Source File: right_TilesetManager_1.23.java From gumtree-spoon-ast-diff with Apache License 2.0 | 6 votes |
public void loadPreviewImage(Entity entity, Image camo, int tint, BufferedPanel bp) { Image base = mechTileset.imageFor(entity, comp); EntityImage entityImage = new EntityImage(base, tint, camo, bp); Image preview = entityImage.loadPreviewImage(); BackGroundDrawer bgdPreview = new BackGroundDrawer(preview); bp.removeBgDrawers(); bp.addBgDrawer(bgdPreview); MediaTracker tracker = new MediaTracker(comp); tracker.addImage(preview, 0); try { tracker.waitForID(0); } catch (InterruptedException e) { ; } }
Example #3
Source File: JasperApp.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public void run() throws JRException { long start = System.currentTimeMillis(); //Preparing parameters Image image = Toolkit.getDefaultToolkit().createImage("dukesign.jpg"); MediaTracker traker = new MediaTracker(new Panel()); traker.addImage(image, 0); try { traker.waitForID(0); } catch (Exception e) { e.printStackTrace(); } Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("ReportTitle", "The First Jasper Report Ever"); parameters.put("MaxOrderID", 10500); parameters.put("SummaryImage", image); JasperRunManager.runReportToPdfFile("build/reports/FirstJasper.jasper", parameters, getDemoHsqldbConnection()); System.err.println("PDF running time : " + (System.currentTimeMillis() - start)); }
Example #4
Source File: GameFrame.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
void setIcon() { String iconName = "cloud32x32.gif"; if (Util.isWindows()) { iconName = "cloud16x16.gif"; } String strURL = "/data/" + iconName; try { MediaTracker tracker = new MediaTracker(frame); URL url = getClass().getResource(strURL); if(url != null) { Image image = frame.getToolkit().getImage(url); tracker.addImage(image, 0); tracker.waitForID(0); frame.setIconImage(image); } else { } } catch (Exception e) { } }
Example #5
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } else { MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do. tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; } }
Example #6
Source File: left_TilesetManager_1.22.java From gumtree-spoon-ast-diff with Apache License 2.0 | 6 votes |
public void loadPreviewImage(Entity entity, Image camo, int tint, BufferedPanel bp) { Image base = mechTileset.imageFor(entity, comp); EntityImage entityImage = new EntityImage(base, tint, camo, bp); Image preview = entityImage.loadPreviewImage(); BackGroundDrawer bgdPreview = new BackGroundDrawer(preview); bp.removeBgDrawers(); bp.addBgDrawer(bgdPreview); MediaTracker tracker = new MediaTracker(comp); tracker.addImage(preview, 0); try { tracker.waitForID(0); } catch (InterruptedException e) { ; } }
Example #7
Source File: ImageHelper.java From cxf with Apache License 2.0 | 6 votes |
private static BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } /*not sure how this is used*/ MediaTracker tracker = new MediaTracker(null); tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; }
Example #8
Source File: MultiResolutionImageTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception { MediaTracker tracker = new MediaTracker(new JPanel()); tracker.addImage(image, 0); tracker.waitForID(0); if (tracker.isErrorAny()) { throw new RuntimeException("Error during image loading"); } tracker.removeImage(image, 0); testImageLoaded(image); int w = image.getWidth(null); int h = image.getHeight(null); Image resolutionVariant = ((MultiResolutionImage) image) .getResolutionVariant(2 * w, 2 * h); if (image == resolutionVariant) { throw new RuntimeException("Resolution variant is not loaded"); } testImageLoaded(resolutionVariant); }
Example #9
Source File: RuntimeBuiltinLeafInfoImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
private BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } else { MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do. tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; } }
Example #10
Source File: JpegEncoder.java From openbd-core with GNU General Public License v3.0 | 6 votes |
public JpegEncoder(Image image, int quality, OutputStream out) { MediaTracker tracker = new MediaTracker(this); tracker.addImage(image, 0); try { tracker.waitForID(0); } catch (InterruptedException e) { // Got to do something? } /* * Quality of the image. 0 to 100 and from bad image quality, high * compression to good image quality low compression */ Quality = quality; /* * Getting picture information It takes the Width, Height and RGB scans of * the image. */ JpegObj = new JpegInfo(image); imageHeight = JpegObj.imageHeight; imageWidth = JpegObj.imageWidth; outStream = new BufferedOutputStream(out); dct = new DCT(Quality); Huf = new Huffman(imageWidth, imageHeight); }
Example #11
Source File: MultiResolutionImageTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception { MediaTracker tracker = new MediaTracker(new JPanel()); tracker.addImage(image, 0); tracker.waitForID(0); if (tracker.isErrorAny()) { throw new RuntimeException("Error during image loading"); } tracker.removeImage(image, 0); testImageLoaded(image); int w = image.getWidth(null); int h = image.getHeight(null); Image resolutionVariant = ((MultiResolutionImage) image) .getResolutionVariant(2 * w, 2 * h); if (image == resolutionVariant) { throw new RuntimeException("Resolution variant is not loaded"); } testImageLoaded(resolutionVariant); }
Example #12
Source File: MultiResolutionImageTest.java From hottub with GNU General Public License v2.0 | 6 votes |
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception { MediaTracker tracker = new MediaTracker(new JPanel()); tracker.addImage(image, 0); tracker.waitForID(0); if (tracker.isErrorAny()) { throw new RuntimeException("Error during image loading"); } tracker.removeImage(image, 0); testImageLoaded(image); int w = image.getWidth(null); int h = image.getHeight(null); Image resolutionVariant = ((MultiResolutionImage) image) .getResolutionVariant(2 * w, 2 * h); if (image == resolutionVariant) { throw new RuntimeException("Resolution variant is not loaded"); } testImageLoaded(resolutionVariant); }
Example #13
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } else { MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do. tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; } }
Example #14
Source File: CommonAboutDialog.java From megamek with GNU General Public License v2.0 | 6 votes |
/** * Get the single title image in a threadsafe way. * * @param frame - a <code>JFrame</code> object to instantiate the image. * @return the title <code>Image</code> common to all "about" dialogs. * This value should <b>not</b> be <code>null</code>. */ private static synchronized Image getTitleImage(JFrame frame) { // Have we loaded our image yet? if (imgTitleImage == null) { // Nope. Load it. Image image = frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_MEGAMEK_SPLASH2).toString() ); MediaTracker tracker = new MediaTracker(frame); tracker.addImage(image, 0); try { tracker.waitForID(0); imgTitleImage = image; } catch (InterruptedException exp) { exp.printStackTrace(); } } // End load-imgTitleImage return imgTitleImage; }
Example #15
Source File: ImageModeCanvas.java From niftyeditor with Apache License 2.0 | 6 votes |
/** * Creates new form ImageModeCanvas */ public ImageModeCanvas(ImageModeModel model) { initComponents(); this.model = model; MediaTracker tracker = new MediaTracker(this); this.image = Toolkit.getDefaultToolkit().createImage(this.model.getImage()); tracker.addImage(image, 0); try { tracker.waitForID(0); } catch (InterruptedException ex) { Logger.getLogger(ImageModeCanvas.class.getName()).log(Level.SEVERE, null, ex); } this.painter = new ResizePainter((ResizeImageMode)model, image.getWidth(null), image.getHeight(null)); this.addMouseListener(painter); this.addMouseMotionListener(painter); }
Example #16
Source File: MarsMap.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * Constructs a MarsMap object * * @param globeType the type of globe: surface, topo or geo * @param displayArea the display component for the map */ public MarsMap(MarsMapType globeType, JComponent displayArea) { // Initialize Variables // this.globeType = globeType; this.displayArea = displayArea; centerCoords = new Coordinates(PI_half, PI_half); // Load Surface Map Image, which is now part of the globe enum String imageName = globeType.getPath(); MediaTracker mtrack = new MediaTracker(displayArea); marsMap = ImageLoader.getImage(imageName); mtrack.addImage(marsMap, 0); try { mtrack.waitForAll(); } catch (InterruptedException e) { logger.log(Level.SEVERE, Msg.getString("MarsMap.log.mediaTrackerError", e.toString())); //$NON-NLS-1$ } // Prepare Sphere setupSphere(); }
Example #17
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } else { MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do. tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; } }
Example #18
Source File: ReliefImageBreaker.java From triplea with GNU General Public License v3.0 | 6 votes |
/** * Asks the user to select an image and then it loads it up into an Image object and returns it to * the calling class. * * @return The loaded image. */ private Image loadImage() { log.info("Select the map"); final String mapName = new FileOpen("Select The Map", mapFolderLocation, ".gif", ".png").getPathString(); if (mapName != null) { final Image img = Toolkit.getDefaultToolkit().createImage(mapName); final MediaTracker tracker = new MediaTracker(new Panel()); tracker.addImage(img, 1); try { tracker.waitForAll(); return img; } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } } return null; }
Example #19
Source File: MultiResolutionImageTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception { MediaTracker tracker = new MediaTracker(new JPanel()); tracker.addImage(image, 0); tracker.waitForID(0); if (tracker.isErrorAny()) { throw new RuntimeException("Error during image loading"); } tracker.removeImage(image, 0); testImageLoaded(image); int w = image.getWidth(null); int h = image.getHeight(null); Image resolutionVariant = ((MultiResolutionImage) image) .getResolutionVariant(2 * w, 2 * h); if (image == resolutionVariant) { throw new RuntimeException("Resolution variant is not loaded"); } testImageLoaded(resolutionVariant); }
Example #20
Source File: Util.java From beanshell with Apache License 2.0 | 6 votes |
public static void startSplashScreen() { int width=275,height=148; Window win=new Window( new Frame() ); win.pack(); BshCanvas can=new BshCanvas(); can.setSize( width, height ); // why is this necessary? Toolkit tk=Toolkit.getDefaultToolkit(); Dimension dim=tk.getScreenSize(); win.setBounds( dim.width/2-width/2, dim.height/2-height/2, width, height ); win.add("Center", can); Image img=tk.getImage( Interpreter.class.getResource("/bsh/util/lib/splash.gif") ); MediaTracker mt=new MediaTracker(can); mt.addImage(img,0); try { mt.waitForAll(); } catch ( Exception e ) { } Graphics gr=can.getBufferedGraphics(); gr.drawImage(img, 0, 0, can); win.setVisible(true); win.toFront(); splashScreen = win; }
Example #21
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private BufferedImage convertToBufferedImage(Image image) throws IOException { if (image instanceof BufferedImage) { return (BufferedImage)image; } else { MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do. tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } BufferedImage bufImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufImage; } }
Example #22
Source File: TilesetManager.java From megamek with GNU General Public License v2.0 | 6 votes |
/** * Loads a preview image of the unit into the BufferedPanel. */ public Image loadPreviewImage(Entity entity, Image camo, int tint, Component bp) { Image base = mechTileset.imageFor(entity, boardview, -1); EntityImage entityImage = new EntityImage(base, tint, camo, bp); entityImage.loadFacings(); Image preview = entityImage.getFacing(entity.getFacing()); MediaTracker loadTracker = new MediaTracker(boardview); loadTracker.addImage(preview, 0); try { loadTracker.waitForID(0); } catch (InterruptedException e) { // should never come here } return preview; }
Example #23
Source File: GraphicUtils.java From Spark with Apache License 2.0 | 5 votes |
/** * Loading an image via a MediaTracker * * @param image * @throws InterruptedException * @throws IOException */ public static void load(Image image) throws InterruptedException, IOException { MediaTracker tracker = new MediaTracker(new Label()); // any component // will do tracker.addImage(image, 0); tracker.waitForID(0); if (tracker.isErrorID(0)) throw new IOException("error loading image"); }
Example #24
Source File: FixedImagePanel.java From visualvm with GNU General Public License v2.0 | 5 votes |
public FixedImagePanel(Image img) { try { image = loadImage(img, new MediaTracker(this)); imageSize = new Dimension(image.getWidth(null), image.getHeight(null)); setOpaque(false); } catch (InterruptedException e) { throw new RuntimeException("Failed to load image: " + e.getMessage()); // NOI18N } }
Example #25
Source File: MultiResolutionDisabledImageTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void testMRDisabledImage(Image image) throws Exception { Image disabledImage = GrayFilter.createDisabledImage(image); MediaTracker mediaTracker = new MediaTracker(new JLabel()); mediaTracker.addImage(disabledImage, 0); mediaTracker.waitForID(0); BufferedImage buffImage = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_INT_RGB); int x = IMAGE_SIZE / 2; int y = IMAGE_SIZE / 2; Graphics2D g = buffImage.createGraphics(); g.scale(1, 1); g.drawImage(disabledImage, 0, 0, null); int rgb1x = buffImage.getRGB(x, y); g.scale(2, 2); g.drawImage(disabledImage, 0, 0, null); int rgb2x = buffImage.getRGB(x, y); g.dispose(); if (rgb1x == rgb2x) { throw new RuntimeException("Disabled image is the same for the base" + "image and the resolution variant"); } }
Example #26
Source File: WhiteRabbitMain.java From WhiteRabbit with Apache License 2.0 | 5 votes |
private Image loadIcon(String name, JFrame f) { Image icon = Toolkit.getDefaultToolkit().getImage(WhiteRabbitMain.class.getResource(name)); MediaTracker mediaTracker = new MediaTracker(f); mediaTracker.addImage(icon, 0); try { mediaTracker.waitForID(0); return icon; } catch (Exception e1) { e1.printStackTrace(); } return null; }
Example #27
Source File: JRJdk13ImageReader.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Image readImage(byte[] bytes) throws JRException { Image image = Toolkit.getDefaultToolkit().createImage(bytes); MediaTracker tracker = new MediaTracker(new Panel()); tracker.addImage(image, 0); try { tracker.waitForID(0); } catch (Exception e) { //image = null; throw new JRException(e); } if(tracker.isErrorID(0)) { throw new JRException( EXCEPTION_MESSAGE_KEY_IMAGE_READ_FAILED, (Object[])null); } return image; }
Example #28
Source File: JavaImageFactory.java From pdfxtk with Apache License 2.0 | 5 votes |
public iiuf.xmillum.Image getImage(URL imageURL) throws IOException { ImageIcon icon = new ImageIcon(imageURL); if (icon.getImageLoadStatus() == MediaTracker.ERRORED) { context.setStatus("Unable to load image "+imageURL); return null; } return new JavaImage(icon.getImage()); }
Example #29
Source File: TilesetManager.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Resets the started and loaded flags */ public synchronized void reset() { loaded = false; started = false; tracker = new MediaTracker(boardview); mechImageList.clear(); mechImages.clear(); hexTileset.clearAllHexes(); }
Example #30
Source File: JasperApp.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void fill() throws JRException { long start = System.currentTimeMillis(); //Preparing parameters Image image = Toolkit.getDefaultToolkit().createImage( JRLoader.loadBytesFromResource("dukesign.jpg") ); MediaTracker traker = new MediaTracker(new Panel()); traker.addImage(image, 0); try { traker.waitForID(0); } catch (Exception e) { e.printStackTrace(); } Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("ReportTitle", "The First Jasper Report Ever"); parameters.put("MaxOrderID", 10500); parameters.put("SummaryImage", image); JasperFillManager.fillReportToFile("build/reports/FirstJasper.jasper", parameters, getDemoHsqldbConnection()); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); }