本文整理汇总了Java中hmi.util.Resources.getReader方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.getReader方法的具体用法?Java Resources.getReader怎么用?Java Resources.getReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hmi.util.Resources
的用法示例。
在下文中一共展示了Resources.getReader方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadShaderText
import hmi.util.Resources; //导入方法依赖的package包/类
/**
* Loads a shader text from file, and returns the shader program text.
* The shader is searched for inside a resource directory.
*/
public static String loadShaderText(Resources resources, String shaderName) {
BufferedReader br = resources.getReader(shaderName);
if (br == null) {
log.warn("GLSL: Could not find shader file: " + shaderName + " in resources: " + resources);
return null;
}
StringBuilder buf = new StringBuilder();
try {
String line = br.readLine();
while (line != null) {
buf.append(line);
buf.append('\n');
line = br.readLine();
}
return buf.toString();
} catch (IOException e) {
logger.error("GLSL.loadShaderText: " + e);
return null;
}
}
示例2: xmlTest0
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void xmlTest0() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial0.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String encoding = gmat1.toXMLString();
//System.out.println("gmat1:\n" + encoding);
XMLTokenizer tokenizer2 = new XMLTokenizer(encoding);
GMaterial gmat2 = new GMaterial(tokenizer2);
assertTrue(gmat2.getName() == "");
assertTrue(gmat2.getShader().equals(""));
assertTrue(gmat2.getShader() == "");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
}
示例3: diffTest
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void diffTest() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial3.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String encoding = gmat1.toXMLString();
XMLTokenizer tokenizer2 = new XMLTokenizer(encoding);
GMaterial gmat2 = new GMaterial(tokenizer2);
String diff1 = gmat1.showDiff(gmat2);
//System.out.println("diff1=" + diff1);
assertTrue(diff1 == "");
gmat2.getDiffuseTexture().setImageFileName("XX");
String diff2 = gmat1.showDiff(gmat2);
//System.out.println("diff2=" + diff2);
assertTrue(diff2 != "");
}
示例4: binaryTest0
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void binaryTest0() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial0.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String tmpdir = System.getProperty("java.io.tmpdir");
// System.out.println("userdir=" + userdir + " tmpdir=" + tmpdir);
DataOutputStream dataOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(tmpdir+"/gmatbintest.dat")));
gmat1.writeBinary(dataOut);
dataOut.close();
DataInputStream dataIn = new DataInputStream(new BufferedInputStream(new FileInputStream(tmpdir+"/gmatbintest.dat")));
GMaterial gmat2 = new GMaterial();
gmat2.readBinary(dataIn);
dataIn.close();
assertTrue(gmat2.getName() == "");
assertTrue(gmat2.getShader() == "");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
}
示例5: readTestFile
import hmi.util.Resources; //导入方法依赖的package包/类
protected String readTestFile(String filename) throws IOException
{
Resources res = new Resources(getTestDirectory());
BufferedReader reader = res.getReader(filename);
StringBuffer fileData = new StringBuffer(1000);
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1)
{
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
reader.close();
return fileData.toString();
}
示例6: read
import hmi.util.Resources; //导入方法依赖的package包/类
/**
* Creates a new SkeletonInterpolator from an XML encoded file. The first argument must be a
* Resources object that determines the resource directory, whereas the seond argument must be
* the filename relative to the resource directory.
*/
public static SkeletonInterpolator read(Resources resources, String fileName) throws IOException
{
Reader reader = resources.getReader(fileName);
XMLTokenizer tk = new XMLTokenizer(reader);
SkeletonInterpolator ip = new SkeletonInterpolator(tk);
reader.close();
return ip;
}
示例7: readShaderFromResourceFile
import hmi.util.Resources; //导入方法依赖的package包/类
/**
* Loads a shader text from file, and returns the shader program text. The shader is searched for inside a resources directory.
*/
private static String readShaderFromResourceFile(Resources resources, String shaderName)
{
BufferedReader br = resources.getReader(shaderName);
if (br == null)
{
logger.info("GLShaderProgramLoader: Could not find shader file: " + shaderName + " in resources: " + resources);
return null;
}
StringBuilder buf = new StringBuilder();
try
{
String line = br.readLine();
while (line != null)
{
buf.append(line);
buf.append('\n');
line = br.readLine();
}
return buf.toString();
}
catch (IOException e)
{
logger.error("GLShaderLoader.loadShaderText: " + e);
return null;
}
}
示例8: xmlTest1
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void xmlTest1() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial1.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String encoding = gmat1.toXMLString();
//System.out.println("gmat1:\n" + encoding);
XMLTokenizer tokenizer2 = new XMLTokenizer(encoding);
GMaterial gmat2 = new GMaterial(tokenizer2);
assertTrue(gmat2.getName() == "coinoeil");
assertTrue(gmat2.getShader().equals(""));
assertTrue(gmat2.getShader() == "");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
assertTrue(gmat2.getEmissionColor()[0] == 0.0f);
assertTrue(gmat2.getEmissionColor()[3] == 1.0f);
assertTrue(gmat2.getAmbientColor()[0] == 0.0f);
assertTrue(gmat2.getAmbientColor()[1] == 0.0f);
assertTrue(gmat2.getAmbientColor()[2] == 0.0f);
assertTrue(gmat2.getAmbientColor()[3] == 1.0f);
assertTrue(gmat2.getSpecularColor()[0] == 0.0f);
assertTrue(gmat2.getShininess() == 0.0f);
assertTrue( ! gmat2.isTransparencyEnabled() );
}
示例9: xmlTest2
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void xmlTest2() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial2.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String encoding = gmat1.toXMLString();
//System.out.println("gmat1:\n" + encoding);
XMLTokenizer tokenizer2 = new XMLTokenizer(encoding);
GMaterial gmat2 = new GMaterial(tokenizer2);
//System.out.println("gmaterial decoded:\n" + gmat2);
assertTrue(gmat2.getName() == "coinoeil");
assertTrue(gmat2.getShader() == "blinnTextured1");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
assertTrue(gmat2.getEmissionColor()[0] == 0.0f);
assertTrue(gmat2.getEmissionColor()[3] == 1.0f);
assertTrue(gmat2.getAmbientColor()[0] == 0.588f);
assertTrue(gmat2.getAmbientColor()[1] == 0.6f);
assertTrue(gmat2.getAmbientColor()[2] == 0.7f);
assertTrue(gmat2.getAmbientColor()[3] == 1.0f);
assertTrue(gmat2.getSpecularColor()[0] == 0.9f);
assertTrue(gmat2.getShininess() == 79.0f);
assertTrue( ! gmat2.isTransparencyEnabled() );
}
示例10: FACSConverter
import hmi.util.Resources; //导入方法依赖的package包/类
public FACSConverter(Resources r, String filename)
{
// We're going to read influences from a file.
try
{
BufferedReader br = r.getReader(filename);
String line;
ActionUnit au = null;
Side side = Side.NONE;
while ((line = br.readLine()) != null)
{
if (line.startsWith("#") || line.equals("")) continue;
String[] elts = line.split("\t");
if (elts.length == 1)
{
// We got a line with an AU-index, single sided.
side = Side.NONE;
au = FACS.getActionUnit(Integer.parseInt(elts[0]));
}
if (elts.length == 2)
{
// We got a line with an AU-index, double sided.
au = FACS.getActionUnit(Integer.parseInt(elts[0]));
if (elts[1].equals("L")) side = Side.LEFT;
else if (elts[1].equals("R")) side = Side.RIGHT;
}
else if (elts.length == 5)
{
// We got a line with an influence.
if (au == null) continue;
FAP fap = MPEG4.getFAP(Integer.parseInt(elts[0]));
float auBegin = Float.parseFloat(elts[1]);
float auEnd = Float.parseFloat(elts[2]);
int fapBegin = Integer.parseInt(elts[3]);
int fapEnd = Integer.parseInt(elts[4]);
Influence influence = new Influence(au, side, fap, auBegin, auEnd, fapBegin, fapEnd);
if (!influencesByFAP.containsKey(fap)) influencesByFAP.put(fap, new ArrayList<Influence>());
influencesByFAP.get(fap).add(influence);
if (!influencesByAU.containsKey(au)) influencesByAU.put(au, new ArrayList<Influence>());
influencesByAU.get(au).add(influence);
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
示例11: xmlTest3
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void xmlTest3() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial3.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String encoding = gmat1.toXMLString();
//System.out.println("gmat1:\n" + encoding);
XMLTokenizer tokenizer2 = new XMLTokenizer(encoding);
GMaterial gmat2 = new GMaterial(tokenizer2);
//System.out.println("gmaterial decoded:\n" + gmat2);
assertTrue(gmat2.getName() == "coinoeil");
assertTrue(gmat2.getShader() == "blinnTextured1");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
assertTrue(gmat2.getEmissionColor()[0] == 0.0f);
assertTrue(gmat2.getEmissionColor()[3] == 1.0f);
assertTrue(gmat2.getAmbientColor()[0] == 0.588f);
assertTrue(gmat2.getAmbientColor()[1] == 0.6f);
assertTrue(gmat2.getAmbientColor()[2] == 0.7f);
assertTrue(gmat2.getAmbientColor()[3] == 1.0f);
assertTrue(gmat2.getSpecularColor()[0] == 0.9f);
assertTrue(gmat2.getShininess() == 79.0f);
assertTrue( gmat2.isTransparencyEnabled() );
GTexture gtex1 = gmat2.getDiffuseTexture();
assertTrue(gtex1 != null);
GTexture gtex2 = gmat2.getTransparentTexture();
assertTrue(gtex2 != null);
assertTrue(gtex1.getImageFileName() == "visage_2008_low.jpg");
assertTrue(gtex1.getWrapS().equals("REPEAT"));
assertTrue(gtex1.getRepeatS() == 3.0f);
assertTrue(gtex1.getRepeatT() == 1.0f);
assertTrue(gtex1.getOffsetS() == 0.0f);
assertTrue(gtex2.getImageFileName() == "visage_2008_trans.jpg");
assertTrue(gtex2.getWrapS().equals("REPEAT"));
assertTrue(gtex2.getRepeatS() == 1.0f);
assertTrue(gtex2.getRepeatT() == 1.0f);
assertTrue(gtex2.getOffsetS() == 0.5f);
}
示例12: binaryTest1
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void binaryTest1() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial1.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String tmpdir = System.getProperty("java.io.tmpdir");
// System.out.println("userdir=" + userdir + " tmpdir=" + tmpdir);
DataOutputStream dataOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(tmpdir+"/gmatbintest.dat")));
gmat1.writeBinary(dataOut);
dataOut.close();
DataInputStream dataIn = new DataInputStream(new BufferedInputStream(new FileInputStream(tmpdir+"/gmatbintest.dat")));
GMaterial gmat2 = new GMaterial();
gmat2.readBinary(dataIn);
dataIn.close();
assertTrue(gmat2.getName() == "coinoeil");
assertTrue(gmat2.getShader() == "");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
assertTrue(gmat2.getEmissionColor()[0] == 0.0f);
assertTrue(gmat2.getEmissionColor()[3] == 1.0f);
assertTrue(gmat2.getAmbientColor()[0] == 0.0f);
assertTrue(gmat2.getAmbientColor()[1] == 0.0f);
assertTrue(gmat2.getAmbientColor()[2] == 0.0f);
assertTrue(gmat2.getAmbientColor()[3] == 1.0f);
assertTrue(gmat2.getSpecularColor()[0] == 0.0f);
assertTrue(gmat2.getShininess() == 0.0f);
assertTrue( ! gmat2.isTransparencyEnabled() );
GTexture gtex1 = gmat2.getDiffuseTexture();
assertTrue(gtex1 == null);
GTexture gtex2 = gmat2.getTransparentTexture();
assertTrue(gtex2 == null);
}
示例13: binaryTest3
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void binaryTest3() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial3.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String tmpdir = System.getProperty("java.io.tmpdir");
// System.out.println("userdir=" + userdir + " tmpdir=" + tmpdir);
DataOutputStream dataOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(tmpdir+"/gmatbintest.dat")));
gmat1.writeBinary(dataOut);
dataOut.close();
DataInputStream dataIn = new DataInputStream(new BufferedInputStream(new FileInputStream(tmpdir+"/gmatbintest.dat")));
GMaterial gmat2 = new GMaterial();
gmat2.readBinary(dataIn);
dataIn.close();
assertTrue(gmat2.getName() == "coinoeil");
assertTrue(gmat2.getShader() == "blinnTextured1");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
assertTrue(gmat2.getEmissionColor()[0] == 0.0f);
assertTrue(gmat2.getEmissionColor()[3] == 1.0f);
assertTrue(gmat2.getAmbientColor()[0] == 0.588f);
assertTrue(gmat2.getAmbientColor()[1] == 0.6f);
assertTrue(gmat2.getAmbientColor()[2] == 0.7f);
assertTrue(gmat2.getAmbientColor()[3] == 1.0f);
assertTrue(gmat2.getSpecularColor()[0] == 0.9f);
assertTrue(gmat2.getShininess() == 79.0f);
assertTrue( gmat2.isTransparencyEnabled() );
GTexture gtex1 = gmat2.getDiffuseTexture();
assertTrue(gtex1 != null);
GTexture gtex2 = gmat2.getTransparentTexture();
assertTrue(gtex2 != null);
assertTrue(gtex1.getImageFileName() == "visage_2008_low.jpg");
assertTrue(gtex1.getWrapS().equals("REPEAT"));
assertTrue(gtex1.getRepeatS() == 3.0f);
assertTrue(gtex1.getRepeatT() == 1.0f);
assertTrue(gtex1.getOffsetS() == 0.0f);
assertTrue(gtex2.getImageFileName() == "visage_2008_trans.jpg");
assertTrue(gtex2.getWrapS().equals("REPEAT"));
assertTrue(gtex2.getRepeatS() == 1.0f);
assertTrue(gtex2.getRepeatT() == 1.0f);
assertTrue(gtex2.getOffsetS() == 0.5f);
}
示例14: binaryTest4
import hmi.util.Resources; //导入方法依赖的package包/类
@Test
public void binaryTest4() throws IOException {
Resources res = new Resources("scenegraph");
Reader reader = res.getReader("gmaterial4.xml");
XMLTokenizer tokenizer = new XMLTokenizer(reader);
GMaterial gmat1 = new GMaterial(tokenizer);
String tmpdir = System.getProperty("java.io.tmpdir");
// System.out.println("userdir=" + userdir + " tmpdir=" + tmpdir);
DataOutputStream dataOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(tmpdir+"/gmatbintest.dat")));
gmat1.writeBinary(dataOut);
dataOut.close();
DataInputStream dataIn = new DataInputStream(new BufferedInputStream(new FileInputStream(tmpdir+"/gmatbintest.dat")));
GMaterial gmat2 = new GMaterial();
gmat2.readBinary(dataIn);
dataIn.close();
assertTrue(gmat2.getName() == "coinoeil");
assertTrue(gmat2.getShader() == "blinnTextured1");
assertTrue(gmat2.getDiffuseColor()[0] == 0.0f);
assertTrue(gmat2.getDiffuseColor()[3] == 1.0f);
assertTrue(gmat2.getEmissionColor()[0] == 0.0f);
assertTrue(gmat2.getEmissionColor()[3] == 1.0f);
assertTrue(gmat2.getAmbientColor()[0] == 0.0f);
assertTrue(gmat2.getAmbientColor()[1] == 0.0f);
assertTrue(gmat2.getAmbientColor()[2] == 0.0f);
assertTrue(gmat2.getAmbientColor()[3] == 1.0f);
assertTrue(gmat2.getSpecularColor()[0] == 0.0f);
assertTrue(gmat2.getShininess() == 0.0f);
assertTrue( ! gmat2.isTransparencyEnabled() );
GTexture gtex1 = gmat2.getDiffuseTexture();
assertTrue(gtex1 == null);
GTexture gtex2 = gmat2.getTransparentTexture();
assertTrue(gtex2 != null);
assertTrue(gtex2.getImageFileName() == "visage_2008_trans.jpg");
assertTrue(gtex2.getWrapS().equals("REPEAT"));
assertTrue(gtex2.getRepeatS() == 1.0f);
assertTrue(gtex2.getRepeatT() == 1.0f);
assertTrue(gtex2.getOffsetS() == 0.5f);
}