本文整理汇总了Java中com.jme3.asset.AssetKey类的典型用法代码示例。如果您正苦于以下问题:Java AssetKey类的具体用法?Java AssetKey怎么用?Java AssetKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssetKey类属于com.jme3.asset包,在下文中一共展示了AssetKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: reloadList
import com.jme3.asset.AssetKey; //导入依赖的package包/类
public void reloadList() throws IOException{
clear();
AssetInfo info=_AM.locateAsset(new AssetKey(_AM_PATH+"substances.json"));
if(info!=null){
InputStream is=info.openStream();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
byte chunk[]=new byte[1024*1024];
int readed;
while((readed=is.read(chunk))!=-1)bos.write(chunk,0,readed);
String json=bos.toString("UTF-8");
Map<Object,Object> map=(Map)_JSON.parse(json);
for(java.util.Map.Entry<Object,Object> e:map.entrySet()){
Substance s=new Substance();
s.setSubstancesList(this);
s.putAll((Map)e.getValue());
put((String)e.getKey(),s);
}
}else{
LOGGER.log(Level.FINE,"substances.json not found");
}
}
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:22,代码来源:SubstancesList.java
示例2: processEdit
import com.jme3.asset.AssetKey; //导入依赖的package包/类
@FXThread
@Override
protected void processEdit() {
final ParticlesMaterial element = getPropertyValue();
if (element == null) return;
final Material material = element.getMaterial();
final AssetKey<?> key = material.getKey();
if (key == null) return;
final Path assetFile = Paths.get(key.getName());
final Path realFile = getRealFile(assetFile);
if (realFile == null || !Files.exists(realFile)) return;
final RequestedOpenFileEvent event = new RequestedOpenFileEvent();
event.setFile(realFile);
FX_EVENT_MANAGER.notify(event);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:MaterialEmitterPropertyControl.java
示例3: processSave
import com.jme3.asset.AssetKey; //导入依赖的package包/类
/**
* The process of saving the file.
*
* @param file the file to save
*/
@FXThread
private void processSave(@NotNull final Path file) {
final TreeNode<?> node = getNode();
final Material material = (Material) node.getElement();
final String materialContent = MaterialSerializer.serializeToString(material);
try (final PrintWriter out = new PrintWriter(Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE))) {
out.print(materialContent);
} catch (final IOException e) {
EditorUtil.handleException(LOGGER, this, e);
return;
}
final Path assetFile = notNull(getAssetFile(file));
final AssetManager assetManager = EDITOR.getAssetManager();
final Material savedMaterial = assetManager.loadMaterial(notNull(toAssetPath(assetFile)));
final PropertyOperation<ChangeConsumer, Material, AssetKey> operation =
new PropertyOperation<>(material, "AssetKey", savedMaterial.getKey(), null);
operation.setApplyHandler(Material::setKey);
final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer());
changeConsumer.execute(operation);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:31,代码来源:SaveAsMaterialAction.java
示例4: saveIfNeedTexture
import com.jme3.asset.AssetKey; //导入依赖的package包/类
/**
* Save if need a texture.
*
* @param texture the texture.
*/
private static void saveIfNeedTexture(@NotNull final Texture texture) {
final Image image = texture.getImage();
if (!image.isChanged()) return;
final AssetKey key = texture.getKey();
final Path file = notNull(getRealFile(key.getName()));
final BufferedImage bufferedImage = ImageToAwt.convert(image, false, true, 0);
try (final OutputStream out = Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE)) {
ImageIO.write(bufferedImage, "png", out);
} catch (final IOException e) {
e.printStackTrace();
}
image.clearChanges();
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:MaterialUtils.java
示例5: addSpatialWithAssetPath
import com.jme3.asset.AssetKey; //导入依赖的package包/类
/**
* Collect all geometries from the asset path.
*
* @param spatial the spatial
* @param container the container
* @param assetPath the asset path
*/
public static void addSpatialWithAssetPath(@NotNull final Spatial spatial, @NotNull final Array<Spatial> container,
@NotNull final String assetPath) {
if (StringUtils.isEmpty(assetPath)) return;
final AssetKey key = spatial.getKey();
if (key != null && StringUtils.equals(key.getName(), assetPath)) {
container.add(spatial);
}
if (!(spatial instanceof Node)) {
return;
}
final Node node = (Node) spatial;
for (final Spatial children : node.getChildren()) {
addSpatialWithAssetPath(children, container, assetPath);
}
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:NodeUtils.java
示例6: locate
import com.jme3.asset.AssetKey; //导入依赖的package包/类
@Override
@JMEThread
public AssetInfo locate(@NotNull final AssetManager manager, @NotNull final AssetKey key) {
if (IGNORE_LOCAL.get() == Boolean.TRUE) return null;
final Path absoluteFile = Paths.get(key.getName());
if (Files.exists(absoluteFile)) return null;
final EditorConfig editorConfig = EditorConfig.getInstance();
final Path currentAsset = editorConfig.getCurrentAsset();
if (currentAsset == null) return null;
final String name = key.getName();
final Path resolve = currentAsset.resolve(name);
if (!Files.exists(resolve)) return null;
return new PathAssetInfo(manager, key, resolve);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:19,代码来源:FolderAssetLocator.java
示例7: downloadStarting
import com.jme3.asset.AssetKey; //导入依赖的package包/类
@Override
public void downloadStarting(final AssetKey key, final long size) {
app.enqueue(new Callable<Void>() {
@Override
public Void call() throws Exception {
if (autoShowOnDownloads && !showing) {
show();
}
LOG.info(String.format("Download of %s started for size of %d", key, size));
downloading.put(key.getName(), new Download(key, size));
if (loadText != null) {
String n = key.toString();
int idx = n.lastIndexOf("/");
if (idx != -1) {
n = n.substring(idx + 1);
}
loadText.setText(n);
}
setProgressValues();
return null;
}
});
}
开发者ID:rockfireredmoon,项目名称:iceclient,代码行数:26,代码来源:LoadScreenAppState.java
示例8: downloadProgress
import com.jme3.asset.AssetKey; //导入依赖的package包/类
@Override
public void downloadProgress(final AssetKey key, final long progress) {
app.enqueue(new Callable<Void>() {
@Override
public Void call() throws Exception {
Download d = downloading.get(key.getName());
if (d == null) {
LOG.warning(String.format("Got download progress event without a download started event ",
key.getName()));
d = new Download(key, -1);
downloading.put(key.getName(), d);
}
d.progress = progress;
setProgressValues();
return null;
}
});
}
开发者ID:rockfireredmoon,项目名称:iceclient,代码行数:19,代码来源:LoadScreenAppState.java
示例9: downloadComplete
import com.jme3.asset.AssetKey; //导入依赖的package包/类
@Override
public void downloadComplete(final AssetKey key) {
app.enqueue(new Callable<Void>() {
@Override
public Void call() throws Exception {
LOG.info(String.format("Download of %s complete", key));
setProgressValues();
downloading.remove(key.getName());
LOG.info(String.format("downloadComplete(%s, %d, %d)", showing, downloading.size(),
app.getWorldLoaderExecutorService().getTotal()));
if ((autoShowOnDownloads || autoShowOnTasks) && showing && downloading.isEmpty()
&& app.getWorldLoaderExecutorService().getTotal() == 0) {
maybeHide();
}
return null;
}
});
}
开发者ID:rockfireredmoon,项目名称:iceclient,代码行数:19,代码来源:LoadScreenAppState.java
示例10: applyMaterial
import com.jme3.asset.AssetKey; //导入依赖的package包/类
private void applyMaterial(Geometry geom, String matName) {
Material mat = null;
if (matName.endsWith(".j3m")) {
// load as native jme3 material instance
mat = assetManager.loadMaterial(matName);
} else {
if (materialList != null) {
mat = materialList.get(matName);
}
if (mat == null) {
logger.log(Level.WARNING, "Material {0} not found. Applying default material", matName);
mat = (Material) assetManager.loadAsset(new AssetKey("Common/Materials/RedColor.j3m"));
}
}
if (mat == null) {
throw new RuntimeException("Cannot locate material named " + matName);
}
if (mat.isTransparent()) {
geom.setQueueBucket(Bucket.Transparent);
}
geom.setMaterial(mat);
}
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:MeshLoader.java
示例11: locate
import com.jme3.asset.AssetKey; //导入依赖的package包/类
public AssetInfo locate(AssetManager manager, AssetKey key){
final ZipEntry2 entry = entries.get(key.getName());
if (entry == null)
return null;
return new AssetInfo(manager, key){
@Override
public InputStream openStream() {
try {
return HttpZipLocator.this.openStream(entry);
} catch (IOException ex) {
logger.log(Level.WARNING, "Error retrieving "+entry.name, ex);
return null;
}
}
};
}
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:HttpZipLocator.java
示例12: importCursors
import com.jme3.asset.AssetKey; //导入依赖的package包/类
protected void importCursors() {
for (CursorType t : CursorType.values()) {
Element el = new Element(null, "cursor-" + t.name().toLowerCase().replace("_", "-"), null,
null) {
{
getDimensions().set(999, 999);
}
};
el.setThemeInstance(this);
String cursorPath = el.getLayoutData();
if (cursorPath != null) {
JmeCursor cursor = ToolKit.get().getApplication().getAssetManager()
.loadAsset(new AssetKey<JmeCursor>(cursorPath));
if (el.getPosition().x != 999 && el.getPosition().y != 999) {
cursor.setxHotSpot((int) el.getPosition().x);
cursor.setyHotSpot((int) el.getPosition().y);
}
cursors.put(t, cursor);
LOG.fine(String.format("Cursor %s is %s (%d,%d)", t, cursorPath, (int) el.getPosition().x,
(int) el.getPosition().y));
} else if (t.isRequired())
LOG.warning(String.format("No cursor definition for %s", t));
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:26,代码来源:StyleManager.java
示例13: StyleManager
import com.jme3.asset.AssetKey; //导入依赖的package包/类
public StyleManager() {
// Add any themes on theme classpath
try {
Enumeration<URL> e = getClass().getClassLoader().getResources("META-INF/themes.list");
while (e.hasMoreElements()) {
BufferedReader r = new BufferedReader(new InputStreamReader(e.nextElement().openStream()));
try {
String line = null;
while ((line = r.readLine()) != null) {
line = line.trim();
if (!line.startsWith("#") && !line.equals(""))
addTheme(ToolKit.get().getApplication().getAssetManager()
.loadAsset(new AssetKey<Theme>(line)));
}
} finally {
r.close();
}
}
} catch (IOException ioe) {
throw new IllegalStateException("Failed to read theme list.", ioe);
}
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:24,代码来源:StyleManager.java
示例14: load
import com.jme3.asset.AssetKey; //导入依赖的package包/类
protected void load(ThemeInstance inst) {
List<Stylesheet> allMainSheets = new ArrayList<>();
// Any contributed sheets from extension modules
for (Theme t : themes) {
if (t != selectedTheme && matches(t.getParent(), selectedTheme.getName())) {
allMainSheets
.add(ToolKit.get().getApplication().getAssetManager().loadAsset(new AssetKey<>(t.getPath())));
}
}
// The primary sheet
allMainSheets.add(
ToolKit.get().getApplication().getAssetManager().loadAsset(new AssetKey<>(selectedTheme.getPath())));
inst.load(allMainSheets);
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:19,代码来源:StyleManager.java
示例15: getInputStream
import com.jme3.asset.AssetKey; //导入依赖的package包/类
protected InputStream getInputStream(String uri) {
try {
int l = uri.lastIndexOf('#');
if (l != -1) {
uri = uri.substring(0, l);
}
while (uri.startsWith("/")) {
uri = uri.substring(1);
}
AssetInfo info = ToolKit.get().getApplication().getAssetManager().locateAsset(new AssetKey<String>(uri));
if (info == null)
throw new AssetNotFoundException(uri);
return info.openStream();
} catch (AssetNotFoundException anfe) {
XRLog.exception(String.format("Item at URI %s not found", uri));
} catch (Exception e) {
XRLog.exception(String.format("Failed to load %s", uri), e);
}
return null;
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:21,代码来源:XHTMLUserAgent.java
示例16: getStylesheets
import com.jme3.asset.AssetKey; //导入依赖的package包/类
@Override
public Collection<Stylesheet> getStylesheets() {
// Try to locate a stylesheet for this layout
String cn = loader.getName();
String ext = loader.getExtension();
if (ext == null || ext.equals(""))
throw new IllegalArgumentException("Layout path must have an extension.");
cn = cn.substring(0, cn.length() - ext.length()) + "css";
AssetKey<Stylesheet> ss = new AssetKey<>(cn);
/// TODO probably wrong now?
List<Stylesheet> all = new ArrayList<Stylesheet>(screen.getStylesheets());
try {
Stylesheet sheet = screen.getApplication().getAssetManager().loadAsset(ss);
if (sheet != null)
all.add(sheet);
} catch (AssetNotFoundException anfe) {
// Don't care?
}
return all;
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:21,代码来源:DefaultLayoutContent.java
示例17: buildExample
import com.jme3.asset.AssetKey; //导入依赖的package包/类
protected void buildExample(ElementContainer<?, ?> screen) {
/*
* The "Icetone Emitter" packages requires the OGRE particle script
* compatibility library. So we need to register the loader for this. We
* do this manually here, but of course you can also register it in the
* usual JME3 way
*/
assetManager.registerLoader(OGREParticleLoader.class, "particle");
stateManager.attach(new ParticleViewportAppstate());
OGREParticleConfiguration opc = assetManager
.loadAsset(new AssetKey<OGREParticleConfiguration>("Effects.particle"));
OGREParticleScript script = opc.getScript("Burst");
frm = new Frame();
frm.getContentArea().addElement(new Label("Test Label"))
.addElement(new PushButton("Go!").onMouseReleased(evt -> runScript(script)));
/* Build screen */
screen.showElement(frm);
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:25,代码来源:EffectsExample.java
示例18: getInfo
import com.jme3.asset.AssetKey; //导入依赖的package包/类
public static UberAssetInfo getInfo(AssetKey key) {
if (locatedAssets.isEmpty()) {
logger.log(Level.INFO, "Looking in empty list for {0}", key.getName());
}
for (UberAssetInfo uberAssetInfo : locatedAssets) {
String normalName = uberAssetInfo.getKey().getName();
if (assetBaseFolder != null) {
//sanitize filename by creating new asset key
String extendedName = new AssetKey(assetBaseFolder + normalName).getName();
logger.log(Level.INFO, "Looking for extended name {0}", extendedName);
if (extendedName.equals(key.getName())) {
logger.log(Level.INFO, "Found extended name {0}", extendedName);
return uberAssetInfo;
}
}
logger.log(Level.INFO, "Looking for normal name {0}", normalName);
if (normalName.equals(key.getName())) {
logger.log(Level.INFO, "Found normal name {0}", normalName);
return uberAssetInfo;
}
}
return null;
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:24,代码来源:UberAssetLocator.java
示例19: locate
import com.jme3.asset.AssetKey; //导入依赖的package包/类
public AssetInfo locate(AssetManager manager, AssetKey key) {
//we only locate texture keys atm
if (!(key instanceof TextureKey)) {
return null;
}
AssetInfo existing = getInfo(key);
if (existing != null) {
return existing;
}
if (findMode) {
FileObject file = findFile(key);
if (file == null) {
return null;
}
logger.log(Level.INFO, "Storing location for {0}", key.getName());
UberAssetInfo info = new UberAssetInfo(file, manager, key);
locatedAssets.add(info);
return info;
}
return null;
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:22,代码来源:UberAssetLocator.java
示例20: loadSettings
import com.jme3.asset.AssetKey; //导入依赖的package包/类
public void loadSettings(WizardDescriptor wiz) {
logger.log(Level.INFO, "Start offview panel");
offPanel.startPreview();
jList1.setListData(new Object[0]);
jList2.setListData(new Object[0]);
manager = (ProjectAssetManager) wiz.getProperty("manager");
mainKey = (AssetKey) wiz.getProperty("mainkey");
data = (AssetData) wiz.getProperty("assetdata");
loadModel();
offPanel.detachAll();
if (currentModel != null) {
logger.log(Level.INFO, "Attaching model {0}", currentModel);
offPanel.attach(currentModel);
} else {
jList2.setListData(new Object[]{mainKey});
}
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:18,代码来源:ModelImporterVisualPanel3.java
注:本文中的com.jme3.asset.AssetKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论