- fix storing annotations into page

This commit is contained in:
Richard Alam 2012-07-23 18:33:47 +00:00
parent 7c8aa4a671
commit 068d2b0fc9
5 changed files with 46 additions and 13 deletions

View File

@ -141,8 +141,7 @@ package org.bigbluebutton.modules.whiteboard
} }
} else { } else {
sendShapeToServer(DrawObject.DRAW_END); sendShapeToServer(DrawObject.DRAW_END);
} }
} }
} }
} }
@ -283,6 +282,7 @@ package org.bigbluebutton.modules.whiteboard
} }
public function drawGraphic(event:WhiteboardUpdate):void{ public function drawGraphic(event:WhiteboardUpdate):void{
LogUtil.debug("**** Drawing graphic *****");
var o:GraphicObject = event.data; var o:GraphicObject = event.data;
var recvdShapes:Boolean = event.recvdShapes; var recvdShapes:Boolean = event.recvdShapes;

View File

@ -18,11 +18,11 @@ package org.bigbluebutton.modules.whiteboard.models
} }
public function undo():void { public function undo():void {
// TODO _annotations.removeItemAt(_annotations.length - 1);
} }
public function clear():void { public function clear():void {
// TODO _annotations.removeAll();
} }
public function get number():int { public function get number():int {

View File

@ -1,8 +1,11 @@
package org.bigbluebutton.modules.whiteboard.models package org.bigbluebutton.modules.whiteboard.models
{ {
import mx.collections.ArrayCollection; import mx.collections.ArrayCollection;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject; import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
public class Presentation public class Presentation
{ {
private var _id:String; private var _id:String;
@ -15,18 +18,35 @@ package org.bigbluebutton.modules.whiteboard.models
{ {
_id = id; _id = id;
_numPages = numPages; _numPages = numPages;
createPages(numPages);
} }
private function createPages(numPages:int):void { private function createPages(numPages:int):void {
LogUtil.debug("**** Creating presentation " + _id + " with pages [" + numPages + "]");
for (var i:int = 1; i <= numPages; i++) { for (var i:int = 1; i <= numPages; i++) {
LogUtil.debug("**** Creating page [" + i + "]");
_pages.addItem(new Page(i)); _pages.addItem(new Page(i));
} }
} }
public function setCurrentPage(num:int):void { public function setCurrentPage(num:int):void {
for (var i:int = 1; i <= _numPages; i++) { LogUtil.debug("**** Setting current page to [" + num + "]. Num page = [" + _pages.length + "]");
_pages.addItem(new Page(i)); var found:Boolean = false;
var idx:int = -1;
for (var i:int = 0; i < _numPages && !found; i++) {
var p:Page = _pages.getItemAt(i) as Page;
if (p.number == num) {
idx = i;
found = true;
}
} }
if (found) {
_currentPage = _pages.getItemAt(idx) as Page;
LogUtil.debug("**** Current page to [" + _currentPage.number + "]");
} else {
LogUtil.error("Cannot find page [" + num + "] in presentation [" + _id + "]");
}
} }
public function addAnnotation(annotation:GraphicObject):void { public function addAnnotation(annotation:GraphicObject):void {

View File

@ -7,6 +7,7 @@ package org.bigbluebutton.modules.whiteboard.models
import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject; import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
public class WhiteboardModel public class WhiteboardModel
{ {
@ -16,13 +17,14 @@ package org.bigbluebutton.modules.whiteboard.models
private var _dispatcher:IEventDispatcher; private var _dispatcher:IEventDispatcher;
public function WhiteboardModel(dispatcher:IEventDispatcher) { public function WhiteboardModel(dispatcher:IEventDispatcher) {
LogUtil.debug("****** WHITEBOARD MODEL INIT ******");
_dispatcher = dispatcher; _dispatcher = dispatcher;
} }
public function addAnnotation(annotation:GraphicObject):void { public function addAnnotation(annotation:GraphicObject):void {
_currentPresentation.addAnnotation(annotation); _currentPresentation.addAnnotation(annotation);
_dispatcher.dispatchEvent(new WhiteboardDrawEvent(WhiteboardDrawEvent.NEW_SHAPE)); // _dispatcher.dispatchEvent(new WhiteboardDrawEvent(WhiteboardDrawEvent.NEW_SHAPE));
LogUtil.debug("*** Adding annotation ****");
_dispatcher.dispatchEvent(new WhiteboardUpdate(WhiteboardUpdate.BOARD_UPDATED));
} }
public function removeAnnotation(id:String):void { public function removeAnnotation(id:String):void {
@ -40,10 +42,17 @@ package org.bigbluebutton.modules.whiteboard.models
} }
public function changePresentation(presentationID:String, numberOfPages:int):void { public function changePresentation(presentationID:String, numberOfPages:int):void {
LogUtil.debug("*** Changing presentation to " + presentationID + " ****");
var pres:Presentation = findPresentation(presentationID);
if (pres == null) {
pres = new Presentation(presentationID, numberOfPages);
_presentations.addItem(pres);
}
LogUtil.debug("*** Current presentation is [ " + presentationID + " ] ****");
_currentPresentation = pres;
} }
public function findPresentation(presentationID:String):Presentation { private function findPresentation(presentationID:String):Presentation {
for (var i:int = 0; i < _presentations.length; i++) { for (var i:int = 0; i < _presentations.length; i++) {
var p:Presentation = _presentations.getItemAt(i) as Presentation; var p:Presentation = _presentations.getItemAt(i) as Presentation;
if (presentationID == p.id) return p; if (presentationID == p.id) return p;
@ -52,7 +61,10 @@ package org.bigbluebutton.modules.whiteboard.models
} }
public function changePage(pageNum:int, numAnnotations:int):void { public function changePage(pageNum:int, numAnnotations:int):void {
_current /* Need to increment the page by 1 as what is passed is zero-based while we store the pages as 1-based.*/
var curPage:int = pageNum + 1;
LogUtil.debug("*** Switching to page [ " + curPage + " ] ****");
_currentPresentation.setCurrentPage(curPage);
} }
public function enable(enabled:Boolean):void { public function enable(enabled:Boolean):void {

View File

@ -95,8 +95,9 @@ package org.bigbluebutton.modules.whiteboard.services
private function addText(message:Object):void { private function addText(message:Object):void {
LogUtil.debug("Rx add text **** with ID of " + message.id + " " + message.x + "," + message.y); LogUtil.debug("Rx add text **** with ID of " + message.id + " " + message.x + "," + message.y);
var t:TextObject = new TextObject(message.text, message.fontColor, message.backgroundColor, message.background, message.x, message.y, message.fontSize); var t:TextObject = new TextObject(message.text, message.fontColor, message.backgroundColor, message.background, message.x, message.y, message.fontSize);
t.setGraphicID(message.id); // t.setGraphicID(message.id);
t.status = message.status; // t.status = message.status;
whiteboardModel.addAnnotation(t);
} }
/** /**