public ResourceSource getRelativeSource(final String name) { try { final URL srcURL = UrlUtils.resolveRelativeURL(_url, "./" + name); if (srcURL != null) { // check if the URL can be opened // just force it to try to grab info srcURL.openStream().close(); // Ok satisfied... return return new URLResourceSource(srcURL); } } catch (final MalformedURLException ex) { } catch (final IOException ex) { } if (logger.isLoggable(Level.FINEST)) { logger.logp(Level.FINEST, getClass().getName(), "getRelativeSource(String)", "Unable to find relative file {0} from {1}.", new Object[] { name, _url }); } return null; }
/** * Creates the font. Font must exist in this bundle in images/fonts. * * @param fontName * @return */ public static BMFont newFont(final String fontName) { BMFont font = null; final URLResourceSource rs = new URLResourceSource(BMFontManager.class.getResource(fontName + ".fnt")); try { font = new BMFont(rs, false); } catch (final IOException e) { if (logger.isLoggable(Level.WARNING)) { logger.logp(Level.WARNING, "BMFontManager", "getFont(String)", "Unable to load font.", new Object[] { fontName }); } } return font; }
public ResourceSource getRelativeSource(final String name) { try { final URL srcURL = UrlUtils.resolveRelativeURL(_url, "./" + name); if (srcURL != null) { // check if the URL can be opened // just force it to try to grab info srcURL.openStream().close(); // Ok satisfied... return return new URLResourceSource(srcURL); } } catch (final MalformedURLException ex) { } catch (final IOException ex) { } if (logger.isLoggable(Level.FINEST)) { logger.logp(Level.FINEST, getClass().getName(), "getRelativeSource(String)", "Unable to find relative file {0} from {1}.", new Object[] { name, _url }); } return null; }
protected ResourceSource doRecursiveLocate(String resourceName) { // Trim off any prepended local dir. while (resourceName.startsWith("./") && resourceName.length() > 2) { resourceName = resourceName.substring(2); } while (resourceName.startsWith(".\\") && resourceName.length() > 2) { resourceName = resourceName.substring(2); } // Try to locate using resourceName as is. try { String spec = URLEncoder.encode(resourceName, "UTF-8"); // this fixes a bug in JRE1.5 (file handler does not decode "+" to spaces) spec = spec.replaceAll("\\+", "%20"); final URL rVal = new URL(_baseDir.toURL(), spec); // open a stream to see if this is a valid resource // XXX: Perhaps this is wasteful? Also, what info will determine validity? rVal.openStream().close(); return new URLResourceSource(rVal); } catch (final IOException e) { // URL wasn't valid in some way, so try up a path. } catch (final IllegalArgumentException e) { // URL wasn't valid in some way, so try up a path. } resourceName = trimResourceName(resourceName); if (resourceName == null) { return null; } else { return doRecursiveLocate(resourceName); } }
final URL u = ResourceLocatorTool.getClassPathResource(ResourceLocatorTool.class, resourceName); if (u != null) { return new URLResourceSource(u);
return new URLResourceSource(rVal); } catch (final IOException e) { return new URLResourceSource(rVal); } catch (final IOException e) {
final URL u = ResourceLocatorTool.getClassPathResource(ResourceLocatorTool.class, resourceName); if (u != null) { return new URLResourceSource(u);
private void loadApplyTexture() throws MalformedURLException { final TextureState ts = (TextureState) getEdittedParticles().getLocalRenderState(StateType.Texture); // XXX: Needed? // TextureManager.clearCache(); ts.setTexture(TextureManager.load(new URLResourceSource(_newTexture.toURI().toURL()), Texture.MinificationFilter.BilinearNearestMipMap, TextureStoreFormat.GuessCompressedFormat, true)); ts.getTexture().setWrap(WrapMode.BorderClamp); ts.setEnabled(true); getEdittedParticles().setRenderState(ts); _newTexture = null; }
closest.bmFont = new BMFont(new URLResourceSource(url), false);
closest.bmFont = new BMFont(new URLResourceSource(url), false);