Java Code Examples for javax.imageio.ImageIO#getUseCache()
The following examples show how to use
javax.imageio.ImageIO#getUseCache() .
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: MBTilesHelper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Get a Tile image from the database. * * @param x * @param y * @param z * @return * @throws Exception */ public BufferedImage getTile( int x, int y, int z ) throws Exception { try (PreparedStatement statement = connection.prepareStatement(SELECTQUERY)) { statement.setInt(1, z); statement.setInt(2, x); statement.setInt(3, y); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { byte[] imageBytes = resultSet.getBytes(1); boolean orig = ImageIO.getUseCache(); ImageIO.setUseCache(false); InputStream in = new ByteArrayInputStream(imageBytes); BufferedImage bufferedImage = ImageIO.read(in); ImageIO.setUseCache(orig); return bufferedImage; } } return null; }
Example 2
Source File: AppContextTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void run() { // System.out.println("Thread " + threadName + " in thread group " + // getThreadGroup().getName()); // Create a new AppContext as though we were an applet SunToolkit.createNewAppContext(); // Get default registry and store reference this.registry = IIORegistry.getDefaultInstance(); for (int i = 0; i < 10; i++) { // System.out.println(threadName + // ": setting cache parameters to " + // useCache + ", " + cacheDirectory); ImageIO.setUseCache(useCache); ImageIO.setCacheDirectory(cacheDirectory); try { sleep(1000L); } catch (InterruptedException e) { } // System.out.println(threadName + ": reading cache parameters"); boolean newUseCache = ImageIO.getUseCache(); File newCacheDirectory = ImageIO.getCacheDirectory(); if (newUseCache != useCache || newCacheDirectory != cacheDirectory) { // System.out.println(threadName + ": got " + // newUseCache + ", " + // newCacheDirectory); // System.out.println(threadName + ": crosstalk encountered!"); gotCrosstalk = true; } } }
Example 3
Source File: AppContextTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void run() { // System.out.println("Thread " + threadName + " in thread group " + // getThreadGroup().getName()); // Create a new AppContext as though we were an applet SunToolkit.createNewAppContext(); // Get default registry and store reference this.registry = IIORegistry.getDefaultInstance(); for (int i = 0; i < 10; i++) { // System.out.println(threadName + // ": setting cache parameters to " + // useCache + ", " + cacheDirectory); ImageIO.setUseCache(useCache); ImageIO.setCacheDirectory(cacheDirectory); try { sleep(1000L); } catch (InterruptedException e) { } // System.out.println(threadName + ": reading cache parameters"); boolean newUseCache = ImageIO.getUseCache(); File newCacheDirectory = ImageIO.getCacheDirectory(); if (newUseCache != useCache || newCacheDirectory != cacheDirectory) { // System.out.println(threadName + ": got " + // newUseCache + ", " + // newCacheDirectory); // System.out.println(threadName + ": crosstalk encountered!"); gotCrosstalk = true; } } }