diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/WhiteboardApplication.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/WhiteboardApplication.java index d520fb1d3a..19625be166 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/WhiteboardApplication.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/whiteboard/WhiteboardApplication.java @@ -115,7 +115,7 @@ public class WhiteboardApplication extends MultiThreadedApplicationAdapter imple String status = annotation.getStatus(); if("textCreated".equals(status) || "DRAW_START".equals(status)) { - annotation.setID(Integer.toString(roomManager.getRoom(getMeetingId()).getUniqueWBGraphicIdentifier())); + // annotation.setID(Integer.toString(roomManager.getRoom(getMeetingId()).getUniqueWBGraphicIdentifier())); roomManager.getRoom(getMeetingId()).addAnnotation(annotation); } else { if ("text".equals(annotation.getType())) { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as index 2ba27922f0..fa56a7c941 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasDisplayModel.as @@ -430,7 +430,7 @@ package org.bigbluebutton.modules.whiteboard var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_SELECTED); e.data = tobj; wbCanvas.dispatchEvent(e); - } + } wbCanvas.addGraphic(tobj); graphicList[objIndex] = tobj; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as index ec264a79ee..2f8f74bf74 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/WhiteboardCanvasModel.as @@ -12,11 +12,13 @@ package org.bigbluebutton.modules.whiteboard import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; import flash.text.TextFormat; - import flash.ui.Keyboard; + import flash.ui.Keyboard; + import mx.controls.TextInput; import mx.core.Application; import mx.core.UIComponent; - import mx.managers.CursorManager; + import mx.managers.CursorManager; + import org.bigbluebutton.common.IBbbCanvas; import org.bigbluebutton.common.LogUtil; import org.bigbluebutton.core.managers.UserManager; @@ -35,6 +37,7 @@ package org.bigbluebutton.modules.whiteboard import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardSettingResetEvent; import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate; + import org.bigbluebutton.modules.whiteboard.views.AnnotationIDGenerator; import org.bigbluebutton.modules.whiteboard.views.IDrawListener; import org.bigbluebutton.modules.whiteboard.views.PencilDrawListener; import org.bigbluebutton.modules.whiteboard.views.TextDrawListener; @@ -49,7 +52,7 @@ package org.bigbluebutton.modules.whiteboard private var drawListeners:Array = new Array(); private var wbTool:WhiteboardTool = new WhiteboardTool(); private var shapeFactory:ShapeFactory = new ShapeFactory(); - + private var idGenerator:AnnotationIDGenerator = new AnnotationIDGenerator(); /* represents the max number of 'points' enumerated in 'segment' before sending an update to server. Used to prevent spamming red5 with unnecessary packets */ @@ -63,8 +66,8 @@ package org.bigbluebutton.modules.whiteboard public function set wbCanvas(canvas:WhiteboardCanvas):void { _wbCanvas = canvas; - drawListeners.push(new PencilDrawListener(_wbCanvas, sendShapeFrequency, shapeFactory)); - drawListeners.push(new TextDrawListener(_wbCanvas, sendShapeFrequency, shapeFactory)); + drawListeners.push(new PencilDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory)); + drawListeners.push(new TextDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory)); } public function zoomCanvas(width:Number, height:Number):void { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/DrawAnnotation.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/DrawAnnotation.as index 95af48898e..c15cee4b15 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/DrawAnnotation.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/DrawAnnotation.as @@ -15,6 +15,6 @@ package org.bigbluebutton.modules.whiteboard.business.shapes _status = s; } - public function createAnnotation():Annotation {return null} + public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {return null} } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/IDrawAnnotation.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/IDrawAnnotation.as index c82b343a58..b69f526056 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/IDrawAnnotation.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/IDrawAnnotation.as @@ -4,6 +4,6 @@ package org.bigbluebutton.modules.whiteboard.business.shapes public interface IDrawAnnotation { - function createAnnotation():Annotation; + function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation; } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/PencilDrawAnnotation.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/PencilDrawAnnotation.as index 8505a351e6..295dc4b937 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/PencilDrawAnnotation.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/PencilDrawAnnotation.as @@ -21,7 +21,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes _transparent = trans; } - override public function createAnnotation():Annotation { + override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation { var ao:Object = new Object(); ao["type"] = _type; ao["points"] = _shape; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/Rectangle.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/Rectangle.as index b84a96f734..4a9a7cb751 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/Rectangle.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/Rectangle.as @@ -70,7 +70,13 @@ package org.bigbluebutton.modules.whiteboard.business.shapes var height:Number = denormalize((ao.points as Array)[arrayEnd-1], parentHeight) - startY; if (ao.fill) this.graphics.beginFill(ao.fillColor, ao.transparency ? 0.6 : 1.0); - this.graphics.drawRect(startX,startY,width,width); + + if (ao.square) { + this.graphics.drawRect(startX, startY, width, width); + } else { + this.graphics.drawRect(startX, startY, width, height); + } + } override public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void { diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/RectangleAnnotation.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/RectangleAnnotation.as new file mode 100755 index 0000000000..2d31ba0b83 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/RectangleAnnotation.as @@ -0,0 +1,57 @@ +package org.bigbluebutton.modules.whiteboard.business.shapes +{ + import org.bigbluebutton.modules.whiteboard.models.Annotation; + + public class RectangleAnnotation extends DrawAnnotation + { + private var _type:String = DrawObject.RECTANGLE; + private var _shape:Array; + private var _color:uint; + private var _fillColor:uint; + private var _thickness:uint; + private var _fill:Boolean; + private var _transparent:Boolean; + + public function RectangleAnnotation(segment:Array, color:uint, thickness:uint, trans:Boolean) + { + _shape = segment; + _color = color; + _thickness = thickness; + _transparent = trans; + } + + private function optimize(segment:Array):Array { + var x1:Number = segment[0]; + var y1:Number = segment[1]; + var x2:Number = segment[segment.length - 2]; + var y2:Number = segment[segment.length - 1]; + + var shape:Array = new Array(); + shape.push(x1); + shape.push(y1); + shape.push(x2); + shape.push(y2); + + return shape; + } + + override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation { + var ao:Object = new Object(); + ao["type"] = _type; + ao["points"] = optimize(_shape); + ao["color"] = _color; + ao["thickness"] = _thickness; + ao["id"] = _id; + ao["status"] = _status; + ao["transparency"] = _transparent; + + if (ctrlKeyPressed) { + ao["square"] = true; + } else { + ao["square"] = false; + } + + return new Annotation(_id, _type, ao); + } + } +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/ShapeFactory.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/ShapeFactory.as index 620e800908..144d90b698 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/ShapeFactory.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/ShapeFactory.as @@ -80,7 +80,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes private function createAnnotation(type:String, shape:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean):DrawAnnotation{ if (type == DrawObject.PENCIL){ return new PencilDrawAnnotation(shape, color, thickness, trans); - } + } else if (type == DrawObject.RECTANGLE){ + return new RectangleAnnotation(shape, color, thickness, trans); + } return null; // else if (type == DrawObject.RECTANGLE){ diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/TextDrawAnnotation.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/TextDrawAnnotation.as index 140850a4c5..56d21a375e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/TextDrawAnnotation.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/business/shapes/TextDrawAnnotation.as @@ -27,7 +27,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes _fontSize = fontSize; } - override public function createAnnotation():Annotation { + override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation { var ao:Object = new Object(); ao["type"] = DrawObject.TEXT; ao["id"] = _id; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as index cde71b0a79..20d2cf3682 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/services/MessageReceiver.as @@ -82,7 +82,7 @@ package org.bigbluebutton.modules.whiteboard.services } private function handleNewAnnotationCommand(message:Object):void { -// LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]"); + LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]"); if (message.type == undefined || message.type == null || message.type == "") return; if (message.id == undefined || message.id == null || message.id == "") return; if (message.status == undefined || message.status == null || message.status == "") return; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/AnnotationIDGenerator.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/AnnotationIDGenerator.as index 95bfc65c90..d8277fe805 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/AnnotationIDGenerator.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/AnnotationIDGenerator.as @@ -12,7 +12,7 @@ package org.bigbluebutton.modules.whiteboard.views _userid = UserManager.getInstance().getConference().getMyUserId(); } - public function generateID():uint { + public function generateID():String { var curTime:Number = new Date().getTime(); return _userid + "-" + count++ + "-" + curTime; } diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/PencilDrawListener.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/PencilDrawListener.as index 8e6bfe0fe9..26ef7eb7be 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/PencilDrawListener.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/PencilDrawListener.as @@ -19,9 +19,12 @@ package org.bigbluebutton.modules.whiteboard.views private var _sendFrequency:int; private var _shapeFactory:ShapeFactory; private var _ctrlKeyDown:Boolean = false; - - public function PencilDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory) + private var _idGenerator:AnnotationIDGenerator; + private var _curID:String; + + public function PencilDrawListener(idGenerator:AnnotationIDGenerator, wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory) { + _idGenerator = idGenerator; _wbCanvas = wbCanvas; _sendFrequency = sendShapeFrequency; _shapeFactory = shapeFactory; @@ -93,13 +96,17 @@ package org.bigbluebutton.modules.whiteboard.views switch (status) { case DrawObject.DRAW_START: dobj.status = DrawObject.DRAW_START; + _curID = _idGenerator.generateID(); + dobj.id = _curID; _drawStatus = DrawObject.DRAW_UPDATE; break; case DrawObject.DRAW_UPDATE: - dobj.status = DrawObject.DRAW_UPDATE; + dobj.status = DrawObject.DRAW_UPDATE; + dobj.id = _curID; break; case DrawObject.DRAW_END: dobj.status = DrawObject.DRAW_END; + dobj.id = _curID; _drawStatus = DrawObject.DRAW_START; break; } @@ -113,7 +120,7 @@ package org.bigbluebutton.modules.whiteboard.views _segment.push(xy[0], xy[1]); } - _wbCanvas.sendGraphicToServer(dobj.createAnnotation(), WhiteboardDrawEvent.SEND_SHAPE); + _wbCanvas.sendGraphicToServer(dobj.createAnnotation(_ctrlKeyDown), WhiteboardDrawEvent.SEND_SHAPE); } } } \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/TextDrawListener.as b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/TextDrawListener.as index d661ea5410..ebbfbdc21c 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/TextDrawListener.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/whiteboard/views/TextDrawListener.as @@ -17,11 +17,13 @@ package org.bigbluebutton.modules.whiteboard.views private var _textStatus:String = TextObject.TEXT_CREATED; private var _mouseXDown:Number = 0; private var _mouseYDown:Number = 0; - + private var _idGenerator:AnnotationIDGenerator; private var _mousedDown:Boolean = false; + private var _curID:String; - public function TextDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory) + public function TextDrawListener(idGenerator:AnnotationIDGenerator, wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory) { + _idGenerator = idGenerator; _wbCanvas = wbCanvas; _sendFrequency = sendShapeFrequency; _shapeFactory = shapeFactory; @@ -71,13 +73,17 @@ package org.bigbluebutton.modules.whiteboard.views case TextObject.TEXT_CREATED: tobj.status = TextObject.TEXT_CREATED; _textStatus = TextObject.TEXT_UPDATED; + _curID = _idGenerator.generateID(); + tobj.id = _curID; break; case TextObject.TEXT_UPDATED: tobj.status = TextObject.TEXT_UPDATED; + tobj.id = _curID; break; case TextObject.TEXT_PUBLISHED: tobj.status = TextObject.TEXT_PUBLISHED; _textStatus = TextObject.TEXT_CREATED; + tobj.id = _curID; break; }