- add method to delete annotation

This commit is contained in:
Richard Alam 2012-07-13 21:53:00 +00:00
parent 5c3e6888f4
commit 0b78831ffa
2 changed files with 22 additions and 36 deletions

View File

@ -25,37 +25,23 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.red5.compatibility.flex.messaging.io.ArrayCollection;
public class Page {
private ArrayCollection<Shape> shapes;
private ArrayList<Map<String, Object>> annotations;
private ArrayList<Map<String, Object>> annotations;
private int pageIndex;
public Page(int pageIndex){
annotations = new ArrayList<Map<String, Object>>();
this.shapes = new ArrayCollection<Shape>();
this.setPageIndex(pageIndex);
}
// public void addShape(Shape shape){
// shapes.add(shape);
// }
public void addAnnotation(Map<String, Object> annotation) {
annotations.add(annotation);
}
public List<Map<String, Object>> getShapes() {
/*
List<Object[]> shapesCollection = new ArrayList<Object[]>();
for (int i = 0; i<shapes.size(); i++){
shapesCollection.add(shapes.get(i).toObjectArray());
}
return shapesCollection;
*/
public List<Map<String, Object>> getAnnotations() {
List<Map<String, Object>> a = new ArrayList<Map<String, Object>>();
for (Map<String, Object> v : annotations) {
a.add(v);
@ -64,24 +50,29 @@ public class Page {
return a;
}
public void clear(){
shapes.clear();
public void deleteAnnotation(String id) {
int foundIndex = -1;
for (int i=0; i < annotations.size(); i++) {
Map<String, Object> annotation = annotations.get(i);
if (annotation.get("id").equals(id)) {
foundIndex = i;
break;
}
}
if (foundIndex >= 0) annotations.remove(foundIndex);
}
public void clear() {
annotations.clear();
}
public void undo(){
// if(shapes.size() > 0)
// shapes.remove(shapes.size()-1);
public void undo() {
if (annotations.isEmpty()) {
annotations.remove(annotations.size() - 1);
}
}
public int getNumShapesOnPage(){
//return this.shapes.size();
public int getNumShapesOnPage() {
return annotations.size();
}

View File

@ -50,7 +50,7 @@ public class WhiteboardRoom {
* @param name
* @param numPages
*/
public void addPresentation(String name, int numPages){
public void addPresentation(String name, int numPages) {
activePresentation = new Presentation(name, numPages);
presentations.add(activePresentation);
}
@ -80,19 +80,14 @@ public class WhiteboardRoom {
}
return exists;
}
// public void addShape(Shape shape){
// activePresentation.getActivePage().addShape(shape);
// notifyAddShape(activePresentation, shape);
// }
public void addAnnotation(Map<String, Object> annotation){
activePresentation.getActivePage().addAnnotation(annotation);
notifyAddShape(activePresentation, annotation);
}
public List<Map<String, Object>> getAnnotations(){
return activePresentation.getActivePage().getShapes();
return activePresentation.getActivePage().getAnnotations();
}
public void clear(){