当前位置: 首页>>代码示例>>Java>>正文


Java AssetKey类代码示例

本文整理汇总了Java中com.jme3.asset.AssetKey的典型用法代码示例。如果您正苦于以下问题:Java AssetKey类的具体用法?Java AssetKey怎么用?Java AssetKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AssetKey类属于com.jme3.asset包,在下文中一共展示了AssetKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的com.jme3.asset.AssetKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。