public void removePage(BPageModel model) { if (model != null) { pageModels.remove(model.getName()); for (BShape shape : model.getShapes()) removeShape(shape.getModel()); model = null; } }
public void playAudio(String key) { ResourceModel r = resources.get(key); if (r != null && r.getDataType().equals(ResourceModel.AUDIOSTREAM)) { AudioStream as = r.getAudioStream(); AudioPlayer.player.start(as); r.setAudioStream(loadAudio(r.getFilePath())); } }
/** * clones the datamodel doing a deep copy of the pages and shapes * * @return clone */ public BDataModel clone() { BDataModel clone = new BDataModel(); for (String page : this.pageModels.keySet()) { BPageModel pgclone = pageModels.get(page).clone(); clone.addPage(pgclone); for (BShape shape : pgclone.getShapes()) { clone.addShape(shape.getModel()); } pgclone.setData(clone); } for (String resource : this.resources.keySet()) { ResourceModel rmclone = resources.get(resource); clone.addResource(rmclone); } clone.setResourceNames(this.resourceNames); clone.setPageCounter(pageCounter); clone.setShapeCounter(shapeCounter); clone.documentDirectory = this.documentDirectory; return clone; }
public void addResource(File object) { ResourceModel rm = new ResourceModel(); rm.setName(object.getName()); rm.setFilePath(object.getAbsolutePath()); String filePath = rm.getFilePath(); if (filePath.endsWith(".jpeg") || filePath.endsWith(".gif")) rm.setDataType("Image"); else if (filePath.endsWith(".au")) rm.setDataType("AudioStream"); if (rm.getDataType().equals("Image")) rm.setImage(loadImage(object.getAbsolutePath())); else if (rm.getDataType().equals("AudioStream")) rm.setAudioStream(loadAudio(object.getAbsolutePath())); resources.put(rm.getName(), rm); }
public Image getImage(String resourceName) { ResourceModel rm = resources.get(resourceName); if (rm == null) return null; return rm.getImage(); }
public boolean resourceIsInUse(String resourceName) { for (BShapeModel shapeModel : shapeModels.values()) if (shapeModel.getImageName().equals(resourceName)) return true; return false; }
public void removeResource(String resourceName) { for (BShapeModel shapeModel : shapeModels.values()) if (shapeModel.getImageName().equals(resourceName)) shapeModel.setImageName(""); resources.remove(resourceName); resourceNames.remove(resourceName); }
public void addResource(ResourceModel rm) { resources.put(rm.getName(), rm); }
public void addPage(BPageModel model) { if (model.getName() == null) model.setName(pageCounter.getPageName()); pageModels.put(model.getName(), model); model.setData(this); }
public void removeShape(BShapeModel model) { if (model != null) shapeModels.remove(model.getName()); }
public void addShape(BShapeModel model) { if (model.getName() == null) model.setName(shapeCounter.getShapeName()); shapeModels.put(model.getName(), model); model.setData(this); }
public boolean hasShape(String shapeName) { return shapeModels.containsKey(shapeName); }
public BPageModel getPage(String pageName) { return pageModels.get(pageName); }
public BShapeModel getShape(String shapeName) { return shapeModels.get(shapeName); }
public AudioStream getAudioStream(String resourceName) { ResourceModel rm = resources.get(resourceName); if (rm == null) return null; return rm.getAudioStream(); }