/** * Constructor. * * @param urlReciverService * url reciver service */ public TextureLibraryService(ResourceService urlReciverService) { super(); this.urlReciverService = urlReciverService; init(); }
public TextureData getWaterTextureData() { String keyStr = textureLibraryStorageService.getKey(TextureLibraryKey.WATER, (String) null); return textureLibraryStorageService.getTextureDefault(keyStr); }
boolean colorable = pTextureFindCriteria.isColorable(); Type type = pTextureFindCriteria.getType(); if (Type.WINDOW.equals(type)) { key = TextureLibraryKey.BUILDING_WINDOW; } else if (Type.WINDOWS.equals(type)) { key = TextureLibraryKey.BUILDING_WINDOWS; } else if (Type.ENTERENCE.equals(type)) { key = TextureLibraryKey.BUILDING_ENTRANCE; } else if (Type.FACADE.equals(type)) { key = TextureLibraryKey.BUILDING_FACADE; } else if (Type.ROOF.equals(type)) { key = TextureLibraryKey.BUILDING_ROOF; } else if (Type.FLOOR.equals(type)) { key = TextureLibraryKey.BUILDING_FLOOR; String keyStr = this.textureLibraryStorageService.getKey(key, pTextureFindCriteria.getTypeName()/*, pTextureFindCriteria.getSubTypeName()*/); List<TextureData> textureSet = this.textureLibraryStorageService.findTextureData(keyStr); boolean findColorable = false; if (colorable) { List<TextureData> filterByColorable = filterByColorable(colorable, textureSet); if ( pTextureFindCriteria.getHeight() != null || pTextureFindCriteria.getWidth() != null) { textureSet = filterByBestSizeMatch(pTextureFindCriteria, textureSet); TextureData textureData = getRadnomTextureFromSet(textureSet, pTextureFindCriteria.getId()); textureData = colorableTextureData(textureData);
/** * Gets wall texture data. * * @param wallType * wall type * @param wallColor * wall color * @param osmPrimitive * primitive * @param TextureLibraryStorageService * texture library service * @return texture data */ public static TextureData takeWallTexture(String wallType, Color wallColor, OsmPrimitive osmPrimitive, TextureLibraryStorageService TextureLibraryStorageService) { String textureKey = TextureLibraryStorageService.getKey(TextureLibraryKey.BARRIER_WALL, wallType); TextureData textureData = TextureLibraryStorageService.getTextureDefault(textureKey); if (!Boolean.FALSE.equals(textureData.isColorable()) && wallColor != null) { return OsmBuildingElementsTextureMenager.colorableTextureData(textureData); } return textureData; }
public static TextureData takeWindowsColumnsTextureData(BuildingModel buildingModel, BuildingPart bp, Wall w, WallPart wp, BuildingElementsTextureManager tm) { String mt = null; TextureData td = tm.findTexture(new TextureFindCriteria(Type.WINDOWS, mt, null, null, null, false)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
@Override public void loadUserFile(UrlTextureLibrary pUrlTextureLibrary) throws FileNotFoundException, JAXBException, MalformedURLException { if (pUrlTextureLibrary == null) { return; } if (pUrlTextureLibrary.isOverwrite()) { this.textureMap.clear(); } loadUrl(pUrlTextureLibrary.getUrl()); this.userTextureLibraryUrl = pUrlTextureLibrary; }
private void loadUrl(URL pUrl) throws JAXBException, FileNotFoundException { List<TextureSet> pointModelsInternalList = loadXml(pUrl); for (TextureSet p : pointModelsInternalList) { for (org.kendzi3d.TextureData td : p.getTextureData()) { TextureData td2 = convert(td); addTexture(p.getKey(), td2); } } }
@Provides @Singleton TextureLibraryStorageService provideTextureLibraryStorageService(ResourceService pUrlReciverService) { TextureLibraryService textureLibraryService = new TextureLibraryService(pUrlReciverService); return textureLibraryService; }
@Deprecated private String getKey(String pPattern, String... pKeyParts) { return getKey(pPattern, true, pKeyParts); }
@Override public TextureData findTexture(TextureFindCriteria pTextureFindCriteria) { TextureData textureData = cache.get(pTextureFindCriteria); if (textureData == null) { textureData = super.findTexture(pTextureFindCriteria); cache.put(pTextureFindCriteria, textureData); } return textureData; } }
/** * Return random texture for key. * * @param key * texture key * @return is texture exist */ @Deprecated public TextureData getRadnomTextureForKey(String key) { ArrayList<TextureData> set = this.textureMap.get(key); return getRadnomTextureFromSet(set); }
/** * {@inheritDoc} * * @see kendzi.josm.kendzi3d.service.TextureLibrary#getTextureDefault(java.lang.String) */ @Override public TextureData getTextureDefault(String key) { TextureData texture = getRadnomTextureForKey(key); if (texture == null) { return new TextureData(null, 1, 1); } return texture; }
private void createAndSaveWikiTextureLiblary(List<WikiTextures> wikiTextures) throws FileNotFoundException, JAXBException { TextureLibrary textureLiblary = createWikiTextureLiblary(wikiTextures); File textureFile = new File(this.pluginDir + TextureLibraryService.TEXTURE_LIBRARY_WIKI_XML); TextureLibraryService.saveXml(textureFile, textureLiblary); }
private void load(String url) throws FileNotFoundException, JAXBException { // this.textureMap.clear(); URL pointModelConf = this.urlReciverService.resourceToUrl(url); if (!UrlUtil.existUrl(pointModelConf)) { log.warn("cant load texture configuration from: " + url + " url don't exist: " + pointModelConf); return; } loadUrl(pointModelConf); }
/** * Gets facade texture. * * @param facadeMaterialName facade material name * @param textureLibraryStorageService texture library storage service * @return facade texture data */ public static TextureData parseFacadeTexture(String facadeMaterialName, TextureLibraryStorageService textureLibraryStorageService) { String facadeMaterial = facadeMaterialName; if (!StringUtil.isBlankOrNull(facadeMaterial)) { String textureKey = textureLibraryStorageService.getKey(TextureLibraryKey.BUILDING_FACADE, facadeMaterial); return textureLibraryStorageService.getTextureDefault(textureKey); } return null; }
public static TextureData takeFloorTextureData(BuildingModel buildingModel, BuildingPart bp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (bp.getFloorMaterialType() != null) { mt = bp.getFloorMaterialType(); } else if (buildingModel.getFloorMaterialType() != null) { mt = buildingModel.getFloorMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FLOOR, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
@Override public void reload() { this.textureMap.clear(); init(); }
public static TextureData takeFacadeTextureData(BuildingModel buildingModel, NodeBuildingPart bp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (bp.getFacadeMaterialType() != null) { mt = bp.getFacadeMaterialType(); } else if (buildingModel.getFacadeMaterialType() != null) { mt = buildingModel.getFacadeMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FACADE, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
private static TextureData takeRoofTextureData(BuildingModel buildingModel, BuildingPart bp, Wall w, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (w.getRoofMaterialType() != null) { mt = w.getRoofMaterialType(); } else if (bp.getRoofMaterialType() != null) { mt = bp.getRoofMaterialType(); } else if (buildingModel.getRoofMaterialType() != null) { mt = buildingModel.getRoofMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.ROOF, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }