public void setInput(Input input) throws IOException { super.setInput(input); Object stuff; XStream xstr = XStreamFactory.forVersion(0.2); try { stuff = xstr.fromXML(input.getReader()); } catch (Exception e) { xstr = XStreamFactory.forVersion(0.1); try { System.out.println("trying to read JRS v0.1"); stuff = xstr.fromXML(input.copy().getReader()); System.out.println("JRS v0.1 success."); } catch (Exception e2) { throw new IOException("illegal JRS file"); } } if (stuff instanceof JrScene) { read = (JrScene) stuff; root = read.getSceneRoot(); } else { if (stuff instanceof SceneGraphComponent) root = (SceneGraphComponent) stuff; else { root = new SceneGraphComponent(); root.setName("jrs"); SceneGraphUtility.addChildNode(root, (SceneGraphNode) stuff); } } }
public TextureJButton(String texResource) { if (texResource == null) { setText(""); return; } else { try { Input texInput = Input.getInput(texResource); texImage = ImageIO.read(texInput.getInputStream()); int w = texImage.getWidth(this); int h = texImage.getHeight(this); ratio = w / (double) h; texImage = ImageHook.scaleImage(texImage, 100, (int) (100 / ratio)); } catch (IOException e) { } } }
/** * ******************************************************************************* * initializeAppearance * * <p>This method is used to load each texture from disk the first time it is needed. It should * only be called once (and the results stored) which is why this method is private. * ******************************************************************************* */ private static Appearance initializeAppearance(TextureDescriptor td) { Appearance app = new Appearance(); initializeShaders(app, Color.white); ImageData id = null; try { File ff = null; switch (td) { case WATER: ff = AssetManager.getAssetFile("textures/water.jpg"); break; case GRASS: ff = AssetManager.getAssetFile("textures/grass.jpg"); break; case BATHROOMTILE: ff = AssetManager.getAssetFile("textures/bathroomtile.jpg"); break; case CHECKER: ff = AssetManager.getAssetFile("textures/checker.jpg"); break; case CLAY: ff = AssetManager.getAssetFile("textures/clay.jpg"); break; case COBBLESTONE: ff = AssetManager.getAssetFile("textures/cobblestone.jpg"); break; case DOTS: ff = AssetManager.getAssetFile("textures/dots.jpg"); break; case GRID: ff = AssetManager.getAssetFile("textures/grid.jpg"); break; case LIGHTHOUSE: ff = AssetManager.getAssetFile("textures/lighthouse.jpg"); break; case MARBLE: ff = AssetManager.getAssetFile("textures/marble.jpg"); break; case PLAID: ff = AssetManager.getAssetFile("textures/plaid.jpg"); break; case STUCCO: ff = AssetManager.getAssetFile("textures/stucco.jpg"); break; case SWIRLS: ff = AssetManager.getAssetFile("textures/swirls.jpg"); break; case ZIGZAG: ff = AssetManager.getAssetFile("textures/zigzag.jpg"); break; case WORLDCUBE0: ff = AssetManager.getAssetFile("textures/worldcube0.png"); break; case WORLDCUBE1: ff = AssetManager.getAssetFile("textures/worldcube1.png"); break; case WORLDCUBE2: ff = AssetManager.getAssetFile("textures/worldcube2.png"); break; case WORLDCUBE3: ff = AssetManager.getAssetFile("textures/worldcube3.png"); break; case WORLDCUBE4: ff = AssetManager.getAssetFile("textures/worldcube4.png"); break; case WORLDCUBE5: ff = AssetManager.getAssetFile("textures/worldcube5.png"); break; case WORLDCUBE6: ff = AssetManager.getAssetFile("textures/worldcube6.png"); break; case WORLDCUBE7: ff = AssetManager.getAssetFile("textures/worldcube7.png"); break; case WORLDCUBE8: ff = AssetManager.getAssetFile("textures/worldcube8.png"); break; case WORLDCUBE9: ff = AssetManager.getAssetFile("textures/worldcube9.png"); break; case WORLDCUBE10: ff = AssetManager.getAssetFile("textures/worldcube10.png"); break; case WORLDCUBE11: ff = AssetManager.getAssetFile("textures/worldcube11.png"); break; } id = ImageData.load(Input.getInput(ff)); } catch (Exception ee) { System.err.println("Error: Unable to load texture " + td); ee.printStackTrace(); } Texture2D tex = TextureUtility.createTexture(app, POLYGON_SHADER, id); tex.setTextureMatrix(MatrixBuilder.euclidean().scale(0.5).getMatrix()); return app; }