public static RenderMaterial loadChecked(final ResourceSource source) throws IOException { if (source == null) { if (logger.isLoggable(Level.WARNING)) { logger.logp(Level.WARNING, YamlMaterialReader.class.getName(), "load(ResourceSource)", "source was null. Returning null."); } return null; } final Yaml yamlDoc = new Yaml(); final Object doc = yamlDoc.load(new UnicodeReader(source.openStream())); return readMaterial(doc); }
public ResourceSource locateResource(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); } return _baseSource.getRelativeSource(resourceName); }
public static Image loadImage(final ResourceSource src, final boolean flipped) { if (src == null) { logger.warning("loadImage(ResourceSource, boolean): file is null, defaultTexture used."); return TextureState.getDefaultTextureImage(); } final String type = src.getType(); if (type == null) { logger.warning("loadImage(ResourceSource, boolean): type is null, defaultTexture used."); return TextureState.getDefaultTextureImage(); } InputStream is = null; try { is = src.openStream(); logger.log(Level.FINER, "loadImage(ResourceSource, boolean) opened stream: {0}", src); return loadImage(type, is, flipped); } catch (final IOException e) { logger.log(Level.WARNING, "loadImage(ResourceSource, boolean): defaultTexture used", e); return TextureState.getDefaultTextureImage(); } finally { if (is != null) { try { is.close(); } catch (final IOException ioe) { } // ignore } } }
final InputStream md2Stream = resource.openStream(); if (md2Stream == null) { throw new NullPointerException("Unable to load null streams"); mesh.setName(resource.getName()); tex = loadTexture(resource.getName());
if (textureState.isEnabled() && textureState.getTexture() != null) { final TextureKey tKey = textureState.getTexture().getTextureKey(); final String tmpTextureName = tKey.getSource().getName(); final int lastIndexOfUnixPathSeparator = tmpTextureName.lastIndexOf('/'); final int lastIndexOfWindowsPathSeparator = tmpTextureName.lastIndexOf('\\');
/** * * @param fontUrl * @throws IOException */ protected void parseFontFile(final ResourceSource source) throws IOException { _maxCharAdv = 0; _charMap.clear(); _pages.clear(); try { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final DocumentBuilder db = dbf.newDocumentBuilder(); final Document doc = db.parse(source.openStream()); doc.getDocumentElement().normalize(); recurse(doc.getElementsByTagName("font").item(0)); // db.reset(); } catch (final Throwable t) { final IOException ex = new IOException("Error loading font file " + source.toString()); ex.initCause(t); throw ex; } }
public static Image loadImage(final ResourceSource src, final boolean flipped) { if (src == null) { logger.warning("loadImage(ResourceSource, boolean): file is null, defaultTexture used."); return TextureState.getDefaultTextureImage(); } final String type = src.getType(); if (type == null) { logger.warning("loadImage(ResourceSource, boolean): type is null, defaultTexture used."); return TextureState.getDefaultTextureImage(); } InputStream is = null; try { is = src.openStream(); logger.log(Level.FINER, "loadImage(ResourceSource, boolean) opened stream: {0}", src); return loadImage(type, is, flipped); } catch (final IOException e) { logger.log(Level.WARNING, "loadImage(ResourceSource, boolean): defaultTexture used", e); return TextureState.getDefaultTextureImage(); } finally { if (is != null) { try { is.close(); } catch (final IOException ioe) { } // ignore } } }
public ResourceSource locateResource(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); } return _baseSource.getRelativeSource(resourceName); }
/** * * @param fontUrl * @throws IOException */ protected void parseFontFile(final ResourceSource source) throws IOException { _maxCharAdv = 0; _charMap.clear(); _pages.clear(); try { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final DocumentBuilder db = dbf.newDocumentBuilder(); final Document doc = db.parse(source.openStream()); doc.getDocumentElement().normalize(); recurse(doc.getFirstChild()); db.reset(); } catch (final Throwable t) { final IOException ex = new IOException("Error loading font file " + source.toString()); ex.initCause(t); throw ex; } }
/** * Load a .mtl resource * * @param fileName * the name of the mtl resource to load. * @param modelSource * a source to pull the mtl relatively. Used only if a material locator was not set on this importer. * @param store * our material store to place the contents of the file in. */ private void loadMaterialLibrary(final String fileName, final ResourceSource modelSource, final Map<String, ObjMaterial> store) { final ResourceSource source; if (_materialLocator == null) { source = modelSource.getRelativeSource(fileName); } else { source = _materialLocator.locateResource(fileName); } if (source == null) { throw new Error("Unable to locate mtllib '" + fileName + "'"); } loadMaterialLibrary(source, store); }
public static Map<String, RenderMaterial> loadAll(final ResourceSource source) throws IOException { final Map<String, RenderMaterial> rVal = new HashMap<>(); if (source == null) { if (logger.isLoggable(Level.WARNING)) { logger.logp(Level.WARNING, YamlMaterialReader.class.getName(), "loadAll(ResourceSource)", "source was null. Returning empty map."); } return rVal; } final Yaml yamlDoc = new Yaml(); for (final Object doc : yamlDoc.loadAll(new UnicodeReader(source.openStream()))) { final RenderMaterial material = readMaterial(doc); if (material != null) { rVal.put(material.getName(), material); } } return rVal; }
final ResourceSource texSrc = source.getRelativeSource(page.file);
try (final Reader reader = new InputStreamReader(src.openStream())) { final StringBuilder build = new StringBuilder(); while (reader.read(buf) != -1) {
final Page page = _pages.get(0); final ResourceSource texSrc = source.getRelativeSource("./" + page.file);
jsEngine.eval(new InputStreamReader(layersFile.openStream()));
jsEngine.eval(new InputStreamReader(layersFile.openStream()));
final BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream())); String line; ObjMaterial currentMaterial = null;
/** * Reads the whole Collada DOM tree from the given resource and returns its root element. Exceptions may be thrown * by underlying tools; these will be wrapped in a RuntimeException and rethrown. * * @param resource * the ResourceSource to read the resource from * @return the Collada root element */ private Element readCollada(final ResourceSource resource, final DataCache dataCache) { try { final JDOMFactory jdomFac = new ArdorFactory(dataCache); final SAXBuilder builder = new SAXBuilder(null, new SAXHandlerFactory() { @Override public SAXHandler createSAXHandler(final JDOMFactory factory) { return new SAXHandler(jdomFac) { @Override public void startPrefixMapping(final String prefix, final String uri) throws SAXException { // Just kill what's usually done here... } }; } }, jdomFac); final Document doc = builder.build(resource.openStream()); final Element collada = doc.getRootElement(); // ColladaDOMUtil.stripNamespace(collada); return collada; } catch (final Exception e) { throw new RuntimeException("Unable to load collada resource from source: " + resource, e); } }
long currentSmoothGroup = -1; final BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream())); String line; int lineNo = 0;