Example usage for java.awt MediaTracker addImage

List of usage examples for java.awt MediaTracker addImage

Introduction

In this page you can find the example usage for java.awt MediaTracker addImage.

Prototype

public void addImage(Image image, int id) 

Source Link

Document

Adds an image to the list of images being tracked by this media tracker.

Usage

From source file:org.pmedv.core.gui.ApplicationWindowAdvisorImpl.java

@Override
public void preWindowCreate() {

    log.info("initializing.");

    String laf = (String) Preferences.values.get("org.pmedv.blackboard.BoardDesignerPerspective.lookAndFeel");

    try {/*from w  w w  .  j a va  2s  .c  o  m*/
        if (laf.equals("Nimbus")) {
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
        } else if (laf.equals("SkyBlue")) {
            Plastic3DLookAndFeel.setPlasticTheme(new SkyBluer());
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            com.jgoodies.looks.Options.setPopupDropShadowEnabled(true);
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    } catch (Exception e2) {
        log.info("failed to set look and feel.");
    }

    final Color blackboardLightBlue = new Color(225, 234, 242);
    final Color blackBoardDarkBlue = new Color(182, 191, 205);
    final Color blackboardLightGrey = new Color(220, 220, 222);

    UIManager.put("TaskPane.titleBackgroundGradientStart", Color.WHITE);
    UIManager.put("TaskPane.titleBackgroundGradientEnd", blackboardLightBlue);
    UIManager.put("TaksPane.specialTitleBackground", blackboardLightBlue);
    UIManager.put("TaskPane.titleBackground", blackboardLightBlue);
    UIManager.put("TaskPane.borderColor", blackboardLightBlue);
    UIManager.put("TaskPane.background", blackboardLightGrey);
    UIManager.put("TaskPaneContainer.backgroundPainter", new MattePainter(blackBoardDarkBlue));

    log.info("setting look and feel to: " + UIManager.getLookAndFeel());

    // construct app icon

    Image iconImage = resources.getIcon("icon.application").getImage();

    MediaTracker mt = new MediaTracker(win);
    mt.addImage(iconImage, 0);

    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        // Silently ignore
    }

    InputStream is = getClass().getClassLoader().getResourceAsStream("application.properties");
    Properties properties = new Properties();
    try {
        properties.load(is);
    } catch (IOException e1) {
        properties.setProperty("version", "not set");
    }

    win.setTitle(windowConfig.getConfig().getTitle() + " Version " + properties.get("version"));
    win.setIconImage(iconImage);
    win.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    win.addWindowListener(win);

    ToolTipManager.sharedInstance().setInitialDelay(100);
    ToolTipManager.sharedInstance().setDismissDelay(1000);

}

From source file:processing.app.Theme.java

/**
 * Return an Image object from inside the Processing lib folder.
 *///from w ww  . j a  va  2 s . c  o m
static public Image getLibImage(String filename, Component who, int width, int height) {
    Image image = null;

    // Use vector image when available
    Resource vectorFile = getThemeResource(filename + ".svg");
    if (vectorFile.exists()) {
        try {
            image = imageFromSVG(vectorFile.getUrl(), width, height);
        } catch (Exception e) {
            System.err.println("Failed to load " + vectorFile + ": " + e.getMessage());
        }
    }

    Resource bitmapFile = getThemeResource(filename + ".png");

    // Otherwise fall-back to PNG bitmaps, allowing user-defined bitmaps to
    // override built-in svgs
    if (image == null || bitmapFile.getPriority() > vectorFile.getPriority()) {
        Resource bitmap2xFile = getThemeResource(filename + "@2x.png");

        Resource imageFile;
        if (((getScale() > 125 && bitmap2xFile.exists()) || !bitmapFile.exists())
                && (bitmapFile.isUserDefined() && bitmap2xFile.isUserDefined())) {
            imageFile = bitmap2xFile;
        } else {
            imageFile = bitmapFile;
        }
        Toolkit tk = Toolkit.getDefaultToolkit();
        image = tk.getImage(imageFile.getUrl());
    }

    MediaTracker tracker = new MediaTracker(who);
    try {
        tracker.addImage(image, 0);
        tracker.waitForAll();
    } catch (InterruptedException e) {
    }

    if (image.getWidth(null) != width || image.getHeight(null) != height) {
        image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
        try {
            tracker.addImage(image, 1);
            tracker.waitForAll();
        } catch (InterruptedException e) {
        }
    }

    return image;
}

From source file:sim.model.entity.Category.java

/**
 * Prepare the entity image//from  w w  w.  j  a va 2s . c  om
 */
protected void prepareEntityImage(JComponent c, String path) {
    // Prepare the entity image
    super.prepareEntityImage(c, path);
    // Adjust the image
    ImageFilter filter = new WhiteFilter();
    FilteredImageSource filteredImage = new FilteredImageSource(display.getImage().getSource(), filter);
    Image image = Toolkit.getDefaultToolkit().createImage(filteredImage);
    MediaTracker tracker = new MediaTracker(c);
    try {
        tracker.addImage(image, 0);
        tracker.waitForAll();
    } catch (InterruptedException e) {
    }
    display.setImage(image);
    display.setImagePath(path);
}

From source file:unikn.dbis.univis.explorer.VSplashScreen.java

/**
 * Erzeugt eine neue <code>VSplashScreen</code> und sobald das Splashable gesetzt wurde
 * beendet sich die Screen von selbst./* www. ja  va2s .com*/
 *
 * @param inputStream Der Dateiname incl. des relativen Pfades des anzuzeigenden Images.
 */
public VSplashScreen(InputStream inputStream) {

    // Splash screen have to be always on top until the explorer
    // isn't loaded.
    setAlwaysOnTop(true);

    try {
        image = ImageIO.read(inputStream);
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

    MediaTracker mt = new MediaTracker(this);

    mt.addImage(image, 0);

    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getMessage(), e);
        }
    }

    thread = new Thread(this);
    thread.setPriority(Thread.MAX_PRIORITY);
    thread.start();

    center();

    setVisible(true);
}