Merge remote branch 'upstream/master'

This commit is contained in:
Chad Pilkey 2012-08-15 19:09:43 +00:00
commit 154c319cbc
51 changed files with 1280 additions and 2207 deletions

View File

@ -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())) {

View File

@ -338,7 +338,7 @@
</views:MainCanvas>
<mx:ControlBar width="100%" height="20" paddingTop="0">
<mx:Label text="{ResourceUtil.getInstance().getString('bbb.mainshell.copyrightLabel2',[appVersion]) + '-- The Learn To Be Foundation'}" id="copyrightLabel2"/>
<mx:Label text="{ResourceUtil.getInstance().getString('bbb.mainshell.copyrightLabel2',[appVersion])}" id="copyrightLabel2"/>
<mx:Spacer width="20"/>
<mx:Spacer width="100%"/>
<mx:Button width="20" height="20" visible="{layoutOptions.showLogButton}" toolTip="{ResourceUtil.getInstance().getString('bbb.mainshell.logBtn.toolTip')}" id="logBtn" icon="{logs_icon}" click="openLogWindow()" />

View File

@ -3,6 +3,7 @@ package org.bigbluebutton.modules.whiteboard
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
@ -26,13 +27,12 @@ package org.bigbluebutton.modules.whiteboard
import org.bigbluebutton.main.events.MadePresenterEvent;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawGrid;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObjectFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.Pencil;
import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextBox;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextDrawAnnotation;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextDrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.GraphicObjectFocusEvent;
@ -51,198 +51,215 @@ package org.bigbluebutton.modules.whiteboard
public class WhiteboardCanvasDisplayModel {
public var whiteboardModel:WhiteboardModel;
public var wbCanvas:WhiteboardCanvas;
private var graphicList:Array = new Array();
private var _annotationsList:Array = new Array();
private var shapeFactory:ShapeFactory = new ShapeFactory();
private var currentlySelectedTextObject:TextObject;
private var currentlySelectedTextObject:TextObject = null;
private var bbbCanvas:IBbbCanvas;
private var width:Number;
private var height:Number;
public function doMouseDown(mouseX:Number, mouseY:Number):void {
/**
* Check if the presenter is starting a new text annotation without committing the last one.
* If so, publish the last text annotation.
*/
if (currentlySelectedTextObject != null && currentlySelectedTextObject.status != TextObject.TEXT_PUBLISHED) {
sendTextToServer(TextObject.TEXT_PUBLISHED, currentlySelectedTextObject);
}
}
public function drawGraphic(event:WhiteboardUpdate):void{
var o:Annotation = event.annotation;
var recvdShapes:Boolean = event.recvdShapes;
LogUtil.debug("**** Drawing graphic [" + o.type + "] *****");
if(o.type != DrawObject.TEXT) {
var dobj:DrawObject = drawObjectFactory(o.annotation);
drawShape(dobj, recvdShapes);
} else {
drawText(o, recvdShapes);
}
// LogUtil.debug("**** Drawing graphic [" + o.type + "] *****");
if(o.type != DrawObject.TEXT) {
var dobj:DrawObject;
switch (o.status) {
case DrawObject.DRAW_START:
dobj = shapeFactory.makeDrawObject(o, whiteboardModel);
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
break;
case DrawObject.DRAW_UPDATE:
case DrawObject.DRAW_END:
var gobj:DrawObject = _annotationsList.pop();
wbCanvas.removeGraphic(gobj as DisplayObject);
dobj = shapeFactory.makeDrawObject(o, whiteboardModel);
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
break;
}
} else {
drawText(o);
}
}
private function drawObjectFactory(a:Object):DrawObject {
var drawFactory:DrawObjectFactory = new DrawObjectFactory();
var d:DrawObject = drawFactory.makeDrawObject(a.type, a.points, a.color, a.thickness, a.fill, a.fillColor, a.transparency);
d.setGraphicID(a.id);
d.status = a.status;
return d;
}
// Draws a DrawObject when/if it is received from the server
private function drawShape(o:DrawObject, recvdShapes:Boolean):void {
switch (o.status) {
case DrawObject.DRAW_START:
addNewShape(o);
break;
case DrawObject.DRAW_UPDATE:
case DrawObject.DRAW_END:
if (graphicList.length == 0 || o.getType() == DrawObject.PENCIL || o.getType() == DrawObject.ERASER || recvdShapes) {
addNewShape(o);
} else {
removeLastGraphic();
addNewShape(o);
}
break;
}
}
private function addNewShape(o:DrawObject):void {
// LogUtil.debug("Adding new shape [" + o.getType() + "," + o.getGraphicID() + "," + o.status + "]");
if (o.getType() == DrawObject.TEXT) return;
var dobj:DrawObject = shapeFactory.makeShape(o);
// LogUtil.debug("Adding new shape 1 [" + dobj.getType() + "," + dobj.getGraphicID() + "," + dobj.status + "]");
wbCanvas.addGraphic(dobj);
// LogUtil.debug("Adding new shape 2 [" + dobj.getGraphicID() + ", [" + dobj.x + "," + dobj.y + "]");
/*
var points:String = "{type=" + dobj.getType() + ",points=";
for (var p:int = 0; p < dobj.getShapeArray().length; p++) {
points += dobj.getShapeArray()[p] + ",";
}
points += "]}";
LogUtil.debug("PencilDrawListener sendShapeToServer - Got here 2 [" + points + "]");
LogUtil.debug("Adding new shape 3 [" + points + "]");
*/ graphicList.push(dobj);
}
// Draws a TextObject when/if it is received from the server
private function drawText(o:Annotation, recvdShapes:Boolean):void {
if (recvdShapes) {
LogUtil.debug("RX: Got text [" + o.type + " " + o.status + " " + o.id + "]");
}
private function drawText3(o:Annotation):void {
var dobj:TextDrawObject;
switch (o.status) {
case TextObject.TEXT_CREATED:
if (isPresenter)
addPresenterText(o, true);
else
addNormalText(o);
dobj = shapeFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
if (isPresenter) {
dobj.displayForPresenter();
wbCanvas.stage.focus = dobj.textField;
dobj.registerListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextChangeListener, textObjSpecialListener);
} else {
dobj.displayNormally();
}
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
break;
case TextObject.TEXT_UPDATED:
if (isPresenter) {
if (recvdShapes) addPresenterText(o, true);
} else {
if(graphicList.length == 0 || recvdShapes) {
addNormalText(o);
} else modifyText(o);
}
var gobj1:DrawObject = _annotationsList.pop();
wbCanvas.removeGraphic(gobj1 as DisplayObject);
dobj = shapeFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
if (!isPresenter) {
dobj.displayNormally();
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
}
break;
case TextObject.TEXT_PUBLISHED:
if (isPresenter) {
if (recvdShapes) addPresenterText(o);
var gobj:DrawObject = _annotationsList.pop();
wbCanvas.removeGraphic(gobj as DisplayObject);
/**
* Check if the text is empty. The presenter might have started a new text annotation without
* entering text on the previous text annoation.
*/
if (o.annotation.text != "") {
dobj = shapeFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
dobj.displayNormally();
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
} else {
if(graphicList.length == 0 || recvdShapes) {
addNormalText(o);
} else modifyText(o);
}
/**
* Published an empty text annotation. Do nothing. The above remove graphic will remove the empty
* annotation from the display.
*/
}
break;
}
}
private function calibrateNewTextWith(o:Annotation):TextObject {
var tobj:TextObject = shapeFactory.makeTextObject(o);
tobj.setGraphicID(o.id);
tobj.status = o.status;
// LogUtil.debug("Created text object [" + tobj.getGraphicID() + "] in [" + tobj.text + "," + tobj.x + "," + tobj.y + "," + tobj.textSize + "]");
return tobj;
// Draws a TextObject when/if it is received from the server
private function drawText(o:Annotation):void {
switch (o.status) {
case TextObject.TEXT_CREATED:
if (isPresenter)
addPresenterText(o, true);
else
addNormalText(o);
break;
case TextObject.TEXT_UPDATED:
if (!isPresenter) {
modifyText(o);
}
break;
case TextObject.TEXT_PUBLISHED:
modifyText(o);
break;
}
}
/* adds a new TextObject that is suited for a presenter. For example, it will be made editable and the appropriate listeners will be registered so that
the required events will be dispatched */
the required events will be dispatched */
private function addPresenterText(o:Annotation, background:Boolean=false):void {
if(!isPresenter) return;
var tobj:TextObject = calibrateNewTextWith(o);
if (!isPresenter) return;
var tobj:TextObject = shapeFactory.makeTextObject(o);
tobj.setGraphicID(o.id);
tobj.status = o.status;
tobj.multiline = true;
tobj.wordWrap = true;
tobj.makeEditable(true);
tobj.border = true;
if (!background) {
tobj.background = false;
tobj.backgroundColor = 0x00FF00;
}
// LogUtil.debug("Putting text object [" + tobj.getGraphicID() + "] in [" + tobj.x + "," + tobj.y + "]");
tobj.registerListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextListener, textObjSpecialListener);
if (background) {
tobj.makeEditable(true);
tobj.border = true;
tobj.background = true;
tobj.backgroundColor = 0xFFFFFF;
}
tobj.registerListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextChangeListener, textObjSpecialListener);
wbCanvas.addGraphic(tobj);
wbCanvas.stage.focus = tobj;
graphicList.push(tobj);
_annotationsList.push(tobj);
}
/* adds a new TextObject that is suited for a viewer. For example, it will not
be made editable and no listeners need to be attached because the viewers
should not be able to edit/modify the TextObject
be made editable and no listeners need to be attached because the viewers
should not be able to edit/modify the TextObject
*/
private function addNormalText(o:Annotation):void {
if (isPresenter) return;
var tobj:TextObject = calibrateNewTextWith(o);
//LogUtil.debug("TEXT ADDED: " + tobj.getGraphicID());
var tobj:TextObject = shapeFactory.makeTextObject(o);
tobj.setGraphicID(o.id);
tobj.status = o.status;
tobj.multiline = true;
tobj.wordWrap = true;
tobj.background = false;
tobj.background = false;
tobj.makeEditable(false);
wbCanvas.addGraphic(tobj);
graphicList.push(tobj);
_annotationsList.push(tobj);
}
private function removeText(id:String):void {
var tobjData:Array = getGobjInfoWithID(id);
var removeIndex:int = tobjData[0];
var tobjToRemove:TextObject = tobjData[1] as TextObject;
wbCanvas.removeGraphic(tobjToRemove);
graphicList.splice(removeIndex, 1);
}
private function removeText(id:String):void {
var tobjData:Array = getGobjInfoWithID(id);
var removeIndex:int = tobjData[0];
var tobjToRemove:TextObject = tobjData[1] as TextObject;
wbCanvas.removeGraphic(tobjToRemove);
_annotationsList.splice(removeIndex, 1);
}
/* method to modify a TextObject that is already present on the whiteboard, as opposed to adding a new TextObject to the whiteboard */
private function modifyText(o:Annotation):void {
// var tobj:TextObject = calibrateNewTextWith(o);
// var id:String = tobj.getGraphicID();
removeText(o.id);
// LogUtil.debug("Text modified to " + tobj.text);
addNormalText(o);
}
/* the following three methods are used to remove any GraphicObjects (and its subclasses) if the id of the object to remove is specified. The latter
two are convenience methods, the main one is the first of the three.
two are convenience methods, the main one is the first of the three.
*/
private function removeGraphic(id:String):void {
var gobjData:Array = getGobjInfoWithID(id);
var removeIndex:int = gobjData[0];
var gobjToRemove:GraphicObject = gobjData[1] as GraphicObject;
wbCanvas.removeGraphic(gobjToRemove as DisplayObject);
graphicList.splice(removeIndex, 1);
_annotationsList.splice(removeIndex, 1);
}
private function removeShape(id:String):void {
var dobjData:Array = getGobjInfoWithID(id);
var removeIndex:int = dobjData[0];
var dobjToRemove:DrawObject = dobjData[1] as DrawObject;
wbCanvas.removeGraphic(dobjToRemove);
graphicList.splice(removeIndex, 1);
_annotationsList.splice(removeIndex, 1);
}
/* returns an array of the GraphicObject that has the specified id,
and the index of that GraphicObject (if it exists, of course)
and the index of that GraphicObject (if it exists, of course)
*/
private function getGobjInfoWithID(id:String):Array {
var data:Array = new Array();
for(var i:int = 0; i < graphicList.length; i++) {
var currObj:GraphicObject = graphicList[i] as GraphicObject;
if(currObj.getGraphicID() == id) {
for(var i:int = 0; i < _annotationsList.length; i++) {
var currObj:GraphicObject = _annotationsList[i] as GraphicObject;
if(currObj.id == id) {
data.push(i);
data.push(currObj);
return data;
@ -250,22 +267,22 @@ package org.bigbluebutton.modules.whiteboard
}
return null;
}
private function removeLastGraphic():void {
var gobj:GraphicObject = graphicList.pop();
if(gobj.getGraphicType() == WhiteboardConstants.TYPE_TEXT) {
var gobj:GraphicObject = _annotationsList.pop();
if(gobj.type == WhiteboardConstants.TYPE_TEXT) {
(gobj as TextObject).makeEditable(false);
(gobj as TextObject).deregisterListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextListener, textObjSpecialListener);
(gobj as TextObject).deregisterListeners(textObjGainedFocusListener, textObjLostFocusListener, textObjTextChangeListener, textObjSpecialListener);
}
wbCanvas.removeGraphic(gobj as DisplayObject);
}
// returns all DrawObjects in graphicList
private function getAllShapes():Array {
var shapes:Array = new Array();
for(var i:int = 0; i < graphicList.length; i++) {
var currGobj:GraphicObject = graphicList[i];
if(currGobj.getGraphicType() == WhiteboardConstants.TYPE_SHAPE) {
for(var i:int = 0; i < _annotationsList.length; i++) {
var currGobj:GraphicObject = _annotationsList[i];
if(currGobj.type == WhiteboardConstants.TYPE_SHAPE) {
shapes.push(currGobj as DrawObject);
}
}
@ -275,9 +292,9 @@ package org.bigbluebutton.modules.whiteboard
// returns all TextObjects in graphicList
private function getAllTexts():Array {
var texts:Array = new Array();
for(var i:int = 0; i < graphicList.length; i++) {
var currGobj:GraphicObject = graphicList[i];
if(currGobj.getGraphicType() == WhiteboardConstants.TYPE_TEXT) {
for(var i:int = 0; i < _annotationsList.length; i++) {
var currGobj:GraphicObject = _annotationsList[i];
if(currGobj.type == WhiteboardConstants.TYPE_TEXT) {
texts.push(currGobj as TextObject)
}
}
@ -285,7 +302,7 @@ package org.bigbluebutton.modules.whiteboard
}
public function clearBoard(event:WhiteboardUpdate = null):void {
var numGraphics:int = this.graphicList.length;
var numGraphics:int = this._annotationsList.length;
for (var i:Number = 0; i < numGraphics; i++){
removeLastGraphic();
}
@ -293,7 +310,7 @@ package org.bigbluebutton.modules.whiteboard
public function undoAnnotation(id:String):void {
/** We'll just remove the last annotation for now **/
if (this.graphicList.length > 0) {
if (this._annotationsList.length > 0) {
removeLastGraphic();
}
}
@ -306,17 +323,22 @@ package org.bigbluebutton.modules.whiteboard
var an:Annotation = annotations[i] as Annotation;
// LogUtil.debug("**** Drawing graphic from history [" + an.type + "] *****");
if(an.type != DrawObject.TEXT) {
var dobj:DrawObject = drawObjectFactory(an.annotation);
drawShape(dobj, true);
var dobj:DrawObject = shapeFactory.makeDrawObject(an, whiteboardModel);
if (dobj != null) {
dobj.draw(an, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
} else {
drawText(an, true);
}
drawText(an);
}
}
}
public function changePage():void{
// LogUtil.debug("**** CanvasDisplay changePage. Cearing page *****");
clearBoard();
var annotations:Array = whiteboardModel.getAnnotations();
// LogUtil.debug("**** CanvasDisplay changePage [" + annotations.length + "] *****");
if (annotations.length == 0) {
@ -324,12 +346,16 @@ package org.bigbluebutton.modules.whiteboard
} else {
for (var i:int = 0; i < annotations.length; i++) {
var an:Annotation = annotations[i] as Annotation;
// LogUtil.debug("**** Drawing graphic from changePage [" + an.type + "] *****");
if(an.type != "text") {
var dobj:DrawObject = drawObjectFactory(an.annotation);
drawShape(dobj, true);
// LogUtil.debug("**** Drawing graphic from changePage [" + an.type + "] *****");
if(an.type != DrawObject.TEXT) {
var dobj:DrawObject = shapeFactory.makeDrawObject(an, whiteboardModel);
if (dobj != null) {
dobj.draw(an, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
_annotationsList.push(dobj);
}
} else {
drawText(an, true);
drawText(an);
}
}
}
@ -340,9 +366,9 @@ package org.bigbluebutton.modules.whiteboard
this.width = width;
this.height = height;
for (var i:int = 0; i < this.graphicList.length; i++){
redrawGraphic(this.graphicList[i] as GraphicObject, i);
}
for (var i:int = 0; i < this._annotationsList.length; i++){
redrawGraphic(this._annotationsList[i] as GraphicObject, i);
}
}
/* called when a user is made presenter, automatically make all the textfields currently on the page editable, so that they can edit it. */
@ -367,150 +393,149 @@ package org.bigbluebutton.modules.whiteboard
}
private function redrawGraphic(gobj:GraphicObject, objIndex:int):void {
if(gobj.getGraphicType() == WhiteboardConstants.TYPE_SHAPE) {
var origDobj:DrawObject = gobj as DrawObject;
wbCanvas.removeGraphic(origDobj);
origDobj.graphics.clear();
var dobj:DrawObject = shapeFactory.makeShape(origDobj);
dobj.setGraphicID(origDobj.getGraphicID());
dobj.status = origDobj.status;
wbCanvas.addGraphic(dobj);
graphicList[objIndex] = dobj;
} else if(gobj.getGraphicType() == WhiteboardConstants.TYPE_TEXT) {
var o:Annotation;
if (gobj.type != DrawObject.TEXT) {
wbCanvas.removeGraphic(gobj as DisplayObject);
o = whiteboardModel.getAnnotation(gobj.id);
if (o != null) {
var dobj:DrawObject = shapeFactory.makeDrawObject(o, whiteboardModel);
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
_annotationsList[objIndex] = dobj;
}
}
} else if(gobj.type == WhiteboardConstants.TYPE_TEXT) {
var origTobj:TextObject = gobj as TextObject;
var an:Annotation = whiteboardModel.getAnnotation(origTobj.getGraphicID());
var an:Annotation = whiteboardModel.getAnnotation(origTobj.id);
if (an == null) {
LogUtil.error("Text with id [" + origTobj.getGraphicID() + "] is missing.");
LogUtil.error("Text with id [" + origTobj.id + "] is missing.");
} else {
wbCanvas.removeGraphic(origTobj);
var tobj:TextObject = shapeFactory.redrawTextObject(an, origTobj);
tobj.setGraphicID(origTobj.getGraphicID());
tobj.status = origTobj.status;
tobj.multiline = true;
tobj.wordWrap = true;
tobj.background = false;
// tobj.backgroundColor = 0xFF0000;
tobj.makeEditable(false);
tobj.background = false;
if (currentlySelectedTextObject != null) {
currentlySelectedTextObject = tobj;
var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_SELECTED);
e.data = tobj;
wbCanvas.dispatchEvent(e);
}
wbCanvas.addGraphic(tobj);
graphicList[objIndex] = tobj;
wbCanvas.removeGraphic(origTobj as DisplayObject);
var tobj:TextObject = shapeFactory.redrawTextObject(an, origTobj);
tobj.setGraphicID(origTobj.id);
tobj.status = origTobj.status;
tobj.multiline = true;
tobj.wordWrap = true;
tobj.background = false;
tobj.makeEditable(false);
tobj.background = false;
wbCanvas.addGraphic(tobj);
_annotationsList[objIndex] = tobj;
}
}
}
/* the following four methods are listeners that handle events that occur on TextObjects, such as text being typed, which causes the textObjTextListener
to send text to the server. */
public function textObjSpecialListener(event:KeyboardEvent):void {
// check for special conditions
if(event.charCode == 127 || // 'delete' key
event.charCode == 8 || // 'bkspace' key
event.charCode == 13) { // 'enter' key
var sendStatus:String = TextObject.TEXT_UPDATED;
var tobj:TextObject = event.target as TextObject;
// if the enter key is pressed, remove focus from the TextObject so that it is sent to the server.
if(event.charCode == 13) {
wbCanvas.stage.focus = null;
tobj.stage.focus = null;
return;
}
sendTextToServer(sendStatus, tobj);
}
}
public function textObjTextListener(event:TextEvent):void {
/**************************************************************************************************************************************
* The following methods handles the presenter typing text into the textbox. The challenge here is how to maintain focus
* on the textbox while the presenter changes the size of the font and color.
*
* The text annotation will have 3 states (CREATED, EDITED, PUBLISHED). When the presenter creates a textbox, the other
* users are notified and the text annotation is in the CREATED state. The presenter can then type text, change size, font and
* the other users are updated. This is the EDITED state. When the presented hits the ENTER/RETURN key, the text is committed/published.
*
*/
public function textObjSpecialListener(event:KeyboardEvent):void {
// check for special conditions
if (event.keyCode == Keyboard.DELETE || event.keyCode == Keyboard.BACKSPACE || event.keyCode == Keyboard.ENTER) {
var sendStatus:String = TextObject.TEXT_UPDATED;
var tobj:TextObject = event.target as TextObject;
// if the enter key is pressed, commit the text
if (event.keyCode == Keyboard.ENTER) {
wbCanvas.stage.focus = null;
tobj.stage.focus = null;
// The ENTER/RETURN key has been pressed. Publish the text.
sendStatus = TextObject.TEXT_PUBLISHED;
}
sendTextToServer(sendStatus, tobj);
}
}
public function textObjTextChangeListener(event:Event):void {
// The text is being edited. Notify others to update the text.
var sendStatus:String = TextObject.TEXT_UPDATED;
var tf:TextObject = event.target as TextObject;
LogUtil.debug("ID " + tf.getGraphicID() + " modified to " + tf.text);
sendTextToServer(sendStatus, tf);
}
public function textObjGainedFocusListener(event:FocusEvent):void {
LogUtil.debug("### GAINED FOCUS ");
public function textObjGainedFocusListener(event:FocusEvent):void {
//LogUtil.debug("### GAINED FOCUS ");
// The presenter is ready to type in the text. Maintain focus to this textbox until the presenter hits the ENTER/RETURN key.
maintainFocusToTextBox(event);
}
public function textObjLostFocusListener(event:FocusEvent):void {
//LogUtil.debug("### LOST FOCUS ");
// The presenter is moving the mouse away from the textbox. Perhaps to change the size and color of the text.
// Maintain focus to this textbox until the presenter hits the ENTER/RETURN key.
maintainFocusToTextBox(event);
}
private function maintainFocusToTextBox(event:FocusEvent):void {
var tf:TextObject = event.currentTarget as TextObject;
wbCanvas.stage.focus = tf;
tf.stage.focus = tf;
currentlySelectedTextObject = tf;
var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_SELECTED);
e.data = tf;
wbCanvas.dispatchEvent(e);
wbCanvas.dispatchEvent(e);
}
public function textObjLostFocusListener(event:FocusEvent):void {
LogUtil.debug("### LOST FOCUS ");
var tf:TextObject = event.target as TextObject;
sendTextToServer(TextObject.TEXT_PUBLISHED, tf);
// LogUtil.debug("Text published to: " + tf.text);
// currentlySelectedTextObject = null;
tf.border = false;
public function modifySelectedTextObject(textColor:uint, bgColorVisible:Boolean, backgroundColor:uint, textSize:Number):void {
// The presenter has changed the color or size of the text. Notify others of these change.
currentlySelectedTextObject.textColor = textColor;
currentlySelectedTextObject.textSize = textSize;
currentlySelectedTextObject.applyFormatting();
sendTextToServer(TextObject.TEXT_UPDATED, currentlySelectedTextObject);
}
/***************************************************************************************************************************************/
private function sendTextToServer(status:String, tobj:TextObject):void {
switch (status) {
case TextObject.TEXT_CREATED:
tobj.status = TextObject.TEXT_CREATED;
break;
case TextObject.TEXT_UPDATED:
tobj.status = TextObject.TEXT_UPDATED;
break;
case TextObject.TEXT_PUBLISHED:
tobj.status = TextObject.TEXT_PUBLISHED;
break;
}
var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_DESELECTED);
e.data = tf;
wbCanvas.dispatchEvent(e);
/* hide text toolbar because we don't want to show it if there is no text selected */
}
/* invoked by the WhiteboardManager that is invoked by the TextToolbar, that
specifies the currently selected TextObject to change its attributes. For example,
when a 'text color' ColorPicker is changed in the TextToolbar, the invocation
eventually reaches this method that causes the currently selected TextObject
to be re-sent to the red5 server with the modified attributes.
*/
public function modifySelectedTextObject(textColor:uint, bgColorVisible:Boolean, backgroundColor:uint, textSize:Number):void {
LogUtil.debug("modifySelectedTextObject = " + textSize);
currentlySelectedTextObject.textColor = textColor;
currentlySelectedTextObject.background = bgColorVisible;
currentlySelectedTextObject.backgroundColor = backgroundColor;
currentlySelectedTextObject.textSize = textSize;
LogUtil.debug("modifySelectedTextObject = " + currentlySelectedTextObject.textSize);
currentlySelectedTextObject.applyFormatting();
sendTextToServer(TextObject.TEXT_PUBLISHED, currentlySelectedTextObject);
}
private function sendTextToServer(status:String, tobj:TextObject):void {
switch (status) {
case TextObject.TEXT_CREATED:
tobj.status = TextObject.TEXT_CREATED;
break;
case TextObject.TEXT_UPDATED:
tobj.status = TextObject.TEXT_UPDATED;
break;
case TextObject.TEXT_PUBLISHED:
tobj.status = TextObject.TEXT_PUBLISHED;
break;
}
LogUtil.debug("SENDING TEXT: [" + tobj.textSize + "]");
var annotation:Object = new Object();
annotation["type"] = "text";
annotation["id"] = tobj.getGraphicID();
annotation["status"] = tobj.status;
annotation["text"] = tobj.text;
annotation["fontColor"] = tobj.textColor;
annotation["backgroundColor"] = tobj.backgroundColor;
annotation["background"] = tobj.background;
annotation["x"] = tobj.getOrigX();
annotation["y"] = tobj.getOrigY();
annotation["fontSize"] = tobj.textSize;
annotation["textBoxWidth"] = tobj.textBoxWidth;
annotation["textBoxHeight"] = tobj.textBoxHeight;
var msg:Annotation = new Annotation(tobj.getGraphicID(), "text", annotation);
wbCanvas.sendGraphicToServer(msg, WhiteboardDrawEvent.SEND_TEXT);
}
if (status == TextObject.TEXT_PUBLISHED) {
var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_DESELECTED);
e.data = tobj;
wbCanvas.dispatchEvent(e);
}
// LogUtil.debug("SENDING TEXT: [" + tobj.textSize + "]");
var annotation:Object = new Object();
annotation["type"] = "text";
annotation["id"] = tobj.id;
annotation["status"] = tobj.status;
annotation["text"] = tobj.text;
annotation["fontColor"] = tobj.textColor;
annotation["backgroundColor"] = tobj.backgroundColor;
annotation["background"] = tobj.background;
annotation["x"] = tobj.getOrigX();
annotation["y"] = tobj.getOrigY();
annotation["fontSize"] = tobj.textSize;
annotation["textBoxWidth"] = tobj.textBoxWidth;
annotation["textBoxHeight"] = tobj.textBoxHeight;
var msg:Annotation = new Annotation(tobj.id, "text", annotation);
wbCanvas.sendGraphicToServer(msg, WhiteboardDrawEvent.SEND_TEXT);
}
public function isPageEmpty():Boolean {
return graphicList.length == 0;
return _annotationsList.length == 0;
}
/** Helper method to test whether this user is the presenter */

View File

@ -26,8 +26,6 @@ package org.bigbluebutton.modules.whiteboard
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextBox;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.GraphicObjectFocusEvent;
@ -36,6 +34,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;
@ -50,7 +49,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 */
@ -64,8 +63,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 {
@ -81,7 +80,19 @@ package org.bigbluebutton.modules.whiteboard
public function changeFontSize(size:Number):void {
wbTool._fontSize = size;
}
public function onKeyDown(event:KeyboardEvent):void {
for (var ob:int = 0; ob < drawListeners.length; ob++) {
(drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey);
}
}
public function onKeyUp(event:KeyboardEvent):void {
for (var ob:int = 0; ob < drawListeners.length; ob++) {
(drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey);
}
}
public function doMouseUp(mouseX:Number, mouseY:Number):void {
// LogUtil.debug("CanvasModel doMouseUp ***");
for (var ob:int = 0; ob < drawListeners.length; ob++) {

View File

@ -1,309 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.modules.whiteboard.business
{
import com.asfusion.mate.events.Dispatcher;
import flash.events.NetStatusEvent;
import flash.events.SyncEvent;
import flash.events.TimerEvent;
import flash.net.NetConnection;
import flash.net.Responder;
import flash.net.SharedObject;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.main.model.users.IMessageListener;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObjectFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
import org.bigbluebutton.modules.whiteboard.events.StartWhiteboardModuleEvent;
import org.bigbluebutton.modules.whiteboard.events.ToggleGridEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardPresenterEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
/**
* The DrawProxy class is a Delegate class for the Red5 Server. It communicates directly with the Red5
* server and abstracts that communication so that other classes don't have to worry about it
* @author dzgonjan
*
*/
public class DrawProxy implements IMessageListener
{
private var url:String;
private var host:String;
private var conference:String;
private var room:String;
private var userid:Number;
private var connection:NetConnection;
private var manualDisconnect:Boolean = false;
private var dispatcher:Dispatcher;
private var drawFactory:DrawObjectFactory;
private var textFactory:TextFactory;
private var initialLoading:Boolean = true;
private var initialPageEvent:PageEvent;
public var whiteboardModel:WhiteboardModel;
public function DrawProxy() {
drawFactory = new DrawObjectFactory();
textFactory = new TextFactory();
dispatcher = new Dispatcher();
BBB.initConnectionManager().addMessageListener(this);
LogUtil.debug("DRAW PROXY INIT !!!!");
}
public function connect(e:StartWhiteboardModuleEvent):void{
extractAttributes(e.attributes);
}
private function extractAttributes(a:Object):void{
host = a.host as String;
conference = a.conference as String;
room = a.room as String;
userid = a.userid as Number;
connection = a.connection;
url = connection.uri;
}
public function onMessage(messageName:String, message:Object):void {
LogUtil.debug("WB: received message " + messageName);
switch (messageName) {
case "WhiteboardRequestAnnotationHistoryReply":
handleRequestAnnotationHistoryReply(message);
break;
case "WhiteboardIsWhiteboardEnabledReply":
handleIsWhiteboardEnabledReply(message);
break;
case "WhiteboardEnableWhiteboardCommand":
handleEnableWhiteboardCommand(message);
break;
case "WhiteboardNewAnnotationCommand":
handleNewAnnotationCommand(message);
break;
case "WhiteboardClearCommand":
handleClearCommand(message);
break;
case "WhiteboardUndoCommand":
handleUndoCommand(message);
break;
case "WhiteboardChangePageCommand":
handleChangePageCommand(message);
break;
default:
LogUtil.warn("Cannot handle message [" + messageName + "]");
}
}
private function handleChangePageCommand(message:Object):void {
LogUtil.debug("Handle Whiteboard Change Page Command [ " + message.pageNum + ", " + message.numAnnotations + "]");
}
private function handleClearCommand(message:Object):void {
LogUtil.debug("Handle Whiteboard Clear Command ");
dispatcher.dispatchEvent(new WhiteboardUpdate(WhiteboardUpdate.BOARD_CLEARED));
}
private function handleUndoCommand(message:Object):void {
LogUtil.debug("Handle Whiteboard Undo Command ");
// dispatcher.dispatchEvent(new WhiteboardUpdate(WhiteboardUpdate.SHAPE_UNDONE));
}
private function handleEnableWhiteboardCommand(message:Object):void {
//if (result as Boolean) modifyEnabledCallback(true);
LogUtil.debug("Handle Whiteboard Enabled Command " + message.enabled);
}
private function handleNewAnnotationCommand(message:Object):void {
LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]");
switch (message.type) {
case "text":
// annotation["type"] = "text";
// annotation["id"] = tobj.getGraphicID();
// annotation["status"] = tobj.status;
// annotation["text"] = tobj.text;
// annotation["fontColor"] = tobj.textColor;
// annotation["backgroundColor"] = tobj.backgroundColor;
// annotation["background"] = tobj.background;
// annotation["x"] = tobj.x;
// annotation["y"] = tobj.y;
// annotation["fontSize"] = tobj.textSize;
// addText(message.type, message.text, message.fontColor, message.backgroundColor,
break;
}
}
private function addText(graphicType:String, text:String, textColor:uint, bgColor:uint, bgColorVisible:Boolean,
x:Number, y:Number, textSize:Number, id:String, status:String, recvdShapes:Boolean = false):void {
LogUtil.debug("Rx add text **** with ID of " + id + " " + x + "," + y);
var t:TextObject = new TextObject(text, textColor, bgColor, bgColorVisible, x, y, textSize);
t.setGraphicID(id);
t.status = status;
// var e:WhiteboardUpdate = new WhiteboardUpdate(WhiteboardUpdate.BOARD_UPDATED);
// e.data = t;
// e.recvdShapes = recvdShapes;
// dispatcher.dispatchEvent(e);
}
private function handleIsWhiteboardEnabledReply(message:Object):void {
//if (result as Boolean) modifyEnabledCallback(true);
LogUtil.debug("Whiteboard Enabled? " + message.enabled);
}
private function handleRequestAnnotationHistoryReply(message:Object):void {
if (message.count == 0) {
LogUtil.debug("No annotations.");
} else {
LogUtil.debug("Number of annotations in history = " + message.count);
}
}
public function getPageHistory(e:PageEvent):void {
// var nc:NetConnection = connection;
//
// nc.call("whiteboard.setActivePage",
// new Responder(
// function(result:Object):void { // On successful result
// if ((result as int) != e.shapes.length) {
// LogUtil.debug("Whiteboard: Need to retrieve shapes. Have " + e.shapes.length + " on client, " + (result as int) + " on server");
// LogUtil.debug("Whiteboard: Retrieving shapes on page" + e.pageNum);
// getHistory();
// } else{
// LogUtil.debug("Whiteboard: Shapes up to date, no need to update");
// }
// },
//
// function(status:Object):void { // status - On error occurred
// LogUtil.error("Error occurred: Whiteboard::DrawProxy::getPageHistory()");
// for (var x:Object in status) {
// LogUtil.error(x + " : " + status[x]);
// }
// }
// ),//new Responder
// e.pageNum
// ); //_netConnection.call
}
/**
* Adds a shape to the ValueObject, then triggers an update event
* @param array The array representation of a shape
*
*/
/* public function addSegment(graphicType:String, array:Array, type:String, color:uint, thickness:uint,
fill:Boolean, fillColor:uint, transparent:Boolean, id:String, status:String, recvdShapes:Boolean = false):void{
//LogUtil.debug("Rx add segment **** with ID of " + id + " " + type
//+ " and " + color + " " + thickness + " " + fill + " " + transparent);
var d:DrawObject = drawFactory.makeDrawObject(type, array, color, thickness, fill, fillColor, transparent);
d.setGraphicID(id);
d.status = status;
var e:WhiteboardUpdate = new WhiteboardUpdate(WhiteboardUpdate.BOARD_UPDATED);
e.data = d;
e.recvdShapes = recvdShapes;
dispatcher.dispatchEvent(e);
}
*/
/**
* Triggers the undo shape event on all clients
*
*/
public function undo():void{
dispatcher.dispatchEvent(new WhiteboardUpdate(WhiteboardUpdate.GRAPHIC_UNDONE));
}
/**
* Triggers the toggle grid event
*
*/
public function toggleGridCallback():void{
LogUtil.debug("TOGGLE CALLBACK RECEIVED");
dispatcher.dispatchEvent(new ToggleGridEvent(ToggleGridEvent.GRID_TOGGLED));
}
public function modifyEnabledCallback(enabled:Boolean):void{
var e:WhiteboardUpdate = new WhiteboardUpdate(WhiteboardUpdate.BOARD_ENABLED);
e.boardEnabled = enabled;
dispatcher.dispatchEvent(e);
}
private function receivedGraphicsHistory(result:Object):void{
if (result == null) return;
var graphicObjs:Array = result as Array;
LogUtil.debug("Whiteboard::recievedShapesHistory() : recieved " + graphicObjs.length);
var receivedShapes:Array = new Array();
for (var i:int=0; i < graphicObjs.length-1; i++) {
var graphic:Array = graphicObjs[i] as Array;
var graphicType:String = graphic[0] as String;
if(graphicType == WhiteboardConstants.TYPE_SHAPE) {
var shapeArray:Array = graphic[1] as Array;
var type:String = graphic[2] as String;
var color:uint = graphic[3] as uint;
var thickness:uint = graphic[4] as uint;
var fill:Boolean = graphic[5] as Boolean;
var fillColor:uint = graphic[6] as uint;
var transparent:Boolean = graphic[7] as Boolean;
var id:String = graphic[8] as String;
var status:String = graphic[9] as String;
var dobj:DrawObject = new DrawObject(type, shapeArray, color, thickness, fill, fillColor, transparent);
dobj.setGraphicID(id);
receivedShapes.push(dobj);
addSegment(graphicType, shapeArray, type, color, thickness, fill, fillColor, transparent, id, status, true);
} else if(graphicType == WhiteboardConstants.TYPE_TEXT) {
var text:String = (graphic[1] as String);
var textColor:uint = (graphic[2] as uint);
var bgColor:uint = (graphic[3] as uint);
var bgColorVisible:Boolean = (graphic[4] as Boolean);
var x:Number = (graphic[5] as Number);
var y:Number = (graphic[6] as Number);
var textSize:Number = (graphic[7] as Number);
var id_other:String = (graphic[8] as String);
var status_other:String = (graphic[9] as String);
var tobj:TextObject = new TextObject(text, textColor, bgColor, bgColorVisible,
x, y, textSize);
tobj.status = status_other
tobj.setGraphicID(id_other);
receivedShapes.push(tobj);
addText(graphicType, text, textColor, bgColor, bgColorVisible, x, y, textSize, id_other, status_other, true);
}
}
var isGrid:Boolean = graphicObjs[graphicObjs.length-1][0] as Boolean;
if(isGrid) {
LogUtil.debug("Contacted server and server says grid mode is on for the current page. :D");
toggleGridCallback();
}
}
}
}

View File

@ -0,0 +1,20 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class DrawAnnotation implements IDrawAnnotation
{
protected var _id:String;
protected var _status:String;
public function set id(id:String):void {
_id = id;
}
public function set status(s:String):void {
_status = s;
}
public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {return null}
}
}

View File

@ -19,8 +19,10 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.Shape;
import flash.display.Sprite;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
/**
* The DrawObject class provides an interface for other geometric representations.
@ -41,25 +43,18 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
public static const TEXT:String = "text";
public static const TRIANGLE:String = "triangle";
public static const LINE:String = "line";
protected var type:String;
protected var shape:Array;
protected var color:uint;
protected var fillColor:uint;
protected var thickness:uint;
protected var fill:Boolean;
protected var transparent:Boolean;
/**
* Status = [START, UPDATE, END]
*/
public static const DRAW_UPDATE:String = "DRAW_UPDATE";
public static const DRAW_END:String = "DRAW_END";
public static const DRAW_START:String = "DRAW_START";
public var status:String = DRAW_START;
protected var _shape:Sprite = new Sprite();
protected var _segment:Array;
private var _id:String;
private var _type:String;
private var _status:String;
/**
* ID we can use to match the shape in the client's view
@ -71,32 +66,27 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
* The default constructor for the DrawObject
*
*/
public function DrawObject(type:String, segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean) {
this.type = type;
this.shape = segment;
this.color = color;
this.thickness = thickness;
this.fill = fill;
this.fillColor = fillColor;
this.transparent = trans;
this.optimize();
public function DrawObject(id:String, type:String, status:String) {
_id = id;
_type = type;
_status = status;
}
// public function getShape():Sprite {
// }
public function get id():String {
return _id;
}
public function getGraphicType():String {
return WhiteboardConstants.TYPE_SHAPE;
}
public function getGraphicID():String {
return ID;
}
public function setGraphicID(id:String):void {
this.ID = id;
}
public function get type():String {
return _type;
}
public function get status():String {
return _status;
}
public function set status(s:String):void {
_status = s;
}
public function denormalize(val:Number, side:Number):Number {
return (val*side)/100.0;
@ -105,98 +95,15 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
public function normalize(val:Number, side:Number):Number {
return (val*100.0)/side;
}
/**
* Returns the type of DrawObject this class is
* @return a string representing the type
*
*/
public function getType():String{
return this.type;
}
/**
* Returns the array of integers holding the different points needed to build this particular DrawObject
* @return
*
*/
public function getShapeArray():Array{
return this.shape;
}
/**
* Returns the Color of the DrawObject
* @return The color, represented as a uint
*
*/
public function getColor():uint{
return this.color;
}
/**
* Returns the fillColor of the DrawObject
* @return The fillColor, represented as a uint
*
*/
public function getFillColor():uint{
return this.fillColor;
}
/**
* Returns the thickness of the DrawObject
* @return The thickness, represented as a uint
*
*/
public function getThickness():uint{
return this.thickness;
}
/**
* Returns the fill of the DrawObject
* @return The thickness, represented as a Boolean
*
*/
public function getFill():Boolean{
return this.fill;
}
/**
* Returns the transparency of the DrawObject
* @return The transparency, represented as a Boolean
*
*/
public function getTransparency():Boolean{
return this.transparent;
}
/**
* Returns the alpha transparnecy of the DrawObject
* @return The alpha transparency, represented as a Number
*
*/
public function getTransparencyLevel():Number{
return transparent ? 0.6 : 1.0;
}
protected function optimize():void{
// do nothing
}
protected function readyToSend():Boolean {
return false;
}
public function makeGraphic(pW:Number, pH:Number):void {
return;
}
public function getProperties():Array {
return null;
}
// public function toString():String {
// return "[DrawObject] You should override this."
// }
public function makeGraphic(parentWidth:Number, parentHeight:Number):void {}
public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
}
public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
}
}
}

View File

@ -1,187 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
/**
* The DrawObjectFactory class receives a series of parameters and constructs an appropriate
* concrete DrawObject given those parameters.
* <p>
* DrawObjectFactory is a simple implementation of the Factory design pattern
* @author dzgonjan
*
*/
public class DrawObjectFactory
{
/**
* Creates a DrawObject by calling the appropriate helper method
* @param type The type of DrawObject to be created
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param fill Whether or not the DrawObject should be filled or not. Doesn't apply for Pencil/Line tools.
* @param trans Whether or not the DrawObject should be transparent.
* @return the DrawObject created from the parameters
*
*/
public function makeDrawObject(type:String, shape:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean):DrawObject{
var d:DrawObject = null;
if (type == DrawObject.PENCIL){
d = makePencil(shape, color, thickness, trans);
} else if (type == DrawObject.RECTANGLE){
d = makeRectangle(shape, color, thickness, fill, fillColor, trans);
} else if (type == DrawObject.ELLIPSE){
d = makeEllipse(shape, color, thickness, fill, fillColor, trans);
} else if (type == DrawObject.TRIANGLE){
d = makeTriangle(shape, color, thickness, fill, fillColor, trans);
} else if (type == DrawObject.LINE){
d = makeLine(shape, color, thickness, trans);
} else if (type == DrawObject.HIGHLIGHTER){
d = makeHighlighter(shape, color, thickness, trans);
} else if (type == DrawObject.ERASER){
d = makeEraser(shape, color, thickness, trans);
} else if (type == DrawObject.TEXT){
// d = makeText(shape, color, thickness);
// d.getShapeArray().push(d.getShape().width);
// d.getShapeArray().push(d.getShape().height);
}
return d;
}
/**
* A helper method for the makeDrawObject method which creates a Pencil DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param trans Whether or not the DrawObject should be transparent.
* @return the Pencil DrawObject created from the parameters
*
*/
public function makePencil(shape:Array, color:uint, thickness:uint, trans:Boolean):DrawObject{
return new Pencil(shape, color, thickness, trans);
}
/**
* A helper method for the makeDrawObject method which creates a Rectangle DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param fill Whether or not the DrawObject should be filled or not.
* @param fillColor if fill is true, the color to fill the DrawObject
* @param trans Whether or not the DrawObject should be transparent.
* @return the Rectangle DrawObject created from the parameters
*
*/
public function makeRectangle(shape:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean):DrawObject{
return new Rectangle(shape, color, thickness, fill, fillColor, trans);
}
/**
* A helper method for the makeDrawObject method whitch creates an Ellipse DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param fill Whether or not the DrawObject should be filled or not.
* @param fillColor if fill is true, the color to fill the DrawObject
* @param trans Whether or not the DrawObject should be transparent.
* @return the Ellipse DrawObject created from the parameters
*
*/
public function makeEllipse(shape:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint,trans:Boolean):DrawObject{
return new Ellipse(shape, color, thickness, fill, fillColor, trans);
}
/**
* A helper method for the makeDrawObject method whitch creates a Line DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param trans Whether or not the DrawObject should be transparent.
* @return the Line DrawObject created from the parameters
*
*/
public function makeLine(shape:Array, color:uint, thickness:uint, trans:Boolean):DrawObject{
return new Line(shape, color, thickness, trans);
}
/**
* A helper method for the makeDrawObject method whitch creates a Highlighter DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param trans Whether or not the DrawObject should be transparent.
* @return the Highlighter DrawObject created from the parameters
*
*/
public function makeHighlighter(shape:Array, color:uint, thickness:uint, trans:Boolean):DrawObject{
return new Highlighter(shape, color, thickness, trans);
}
/**
* A helper method for the makeDrawObject method whitch creates an Eraser DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param trans Whether or not the DrawObject should be transparent.
* @return the Eraser DrawObject created from the parameters
*
*/
public function makeEraser(shape:Array, color:uint, thickness:uint, trans:Boolean):DrawObject{
return new Eraser(shape, color, thickness, trans);
}
/**
* A helper method for the makeDrawObject method whitch creates a Triangle DrawObject
* <p>
* Even though it is a helper method it is made public for testing purposes
* @param shape The array holding the different points needed to create the DrawObject
* @param color The color of the DrawObject to be created
* @param thickness The thickness of the DrawObject to be created
* @param fill Whether or not the DrawObject should be filled or not.
* @param fillColor if fill is true, the color to fill the DrawObject
* @param trans Whether or not the DrawObject should be transparent.
* @return the Triangle DrawObject created from the parameters
*
*/
public function makeTriangle(shape:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean):DrawObject{
return new Triangle(shape, color, thickness, fill, fillColor, trans);
}
// public function makeText(shape:Array, color:uint, thickness:uint):DrawObject{
// return new Text(shape, color, thickness);
// }
}
}

View File

@ -19,6 +19,9 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Sprite;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
/**
* The Ellipse class. Extends the DrawObject
@ -27,67 +30,37 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*/
public class Ellipse extends DrawObject
{
/**
* The default constructor. Creates an Ellipse object
* <p>
* The constructor automaticaly optimizes this shape by calling the optimize method to get rid of the
* unnecessary data
* @param segment the array representing the points needed to create this Ellipse
* @param color the Color of this Ellipse
* @param fill the fill of this Ellipse
* @param trans the transparency of this Ellipse
* @param thickness the thickness of this Ellipse
*
*/
public function Ellipse(segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean)
{
super(DrawObject.ELLIPSE, segment, color, thickness, fill, fillColor, trans);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
var x1:Number = this.shape[0];
var y1:Number = this.shape[1];
var x2:Number = this.shape[this.shape.length - 2];
var y2:Number = this.shape[this.shape.length - 1];
this.shape = new Array();
this.shape.push(x1);
this.shape.push(y1);
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
if(!fill)
this.graphics.lineStyle(getThickness(), getColor(), getTransparencyLevel());
else this.graphics.lineStyle(getThickness(), getColor());
var arrayEnd:Number = getShapeArray().length;
var startX:Number = denormalize(getShapeArray()[0], parentWidth);
var startY:Number = denormalize(getShapeArray()[1], parentHeight);
var width:Number = denormalize(getShapeArray()[arrayEnd-2], parentWidth) - startX;
var height:Number = denormalize(getShapeArray()[arrayEnd-1], parentHeight) - startY;
if(fill) this.graphics.beginFill(getFillColor(), getTransparencyLevel());
this.graphics.drawEllipse(startX, startY, width, height);
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(this.color);
props.push(this.thickness);
props.push(this.fill);
props.push(this.fillColor);
props.push(this.transparent);
props.push(this.width);
props.push(this.height);
return props;
}
public function Ellipse(id:String, type:String, status:String)
{
super(id, type, status);
}
override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
LogUtil.debug("Drawing ELLIPSE");
var ao:Object = a.annotation;
if(!ao.fill)
this.graphics.lineStyle(ao.thickness, ao.color, ao.transparency ? 0.6 : 1.0);
else this.graphics.lineStyle(ao.thickness, ao.color);
var arrayEnd:Number = (ao.points as Array).length;
var startX:Number = denormalize((ao.points as Array)[0], parentWidth);
var startY:Number = denormalize((ao.points as Array)[1], parentHeight);
var width:Number = denormalize((ao.points as Array)[arrayEnd-2], parentWidth) - startX;
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);
if (ao.circle) {
this.graphics.drawEllipse(startX, startY, width, width);
} else {
this.graphics.drawEllipse(startX, startY, width, height);
}
}
override public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
draw(a, parentWidth, parentHeight);
}
}
}

View File

@ -0,0 +1,57 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class EllipseAnnotation extends DrawAnnotation
{
private var _type:String = DrawObject.ELLIPSE;
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 EllipseAnnotation(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["circle"] = true;
} else {
ao["circle"] = false;
}
return new Annotation(_id, _type, ao);
}
}
}

View File

@ -1,87 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Shape;
public class Eraser extends DrawObject
{
/**
* The dafault constructor. Creates a Eraser DrawObject
* @param segment the array representing the points needed to create this Eraser
* @param color the Color of this Eraser
* @param thickness the thickness of this Eraser
* @param trans the transparency of this Eraser
*/
public function Eraser(segment:Array, color:uint, thickness:uint, trans:Boolean)
{
super(DrawObject.ERASER, segment, 0xFFFFFF, thickness, false, 0x000000, false);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
var x1:Number = this.shape[0];
var y1:Number = this.shape[1];
var x2:Number = this.shape[this.shape.length - 2];
var y2:Number = this.shape[this.shape.length - 1];
this.shape = new Array();
this.shape.push(x1);
this.shape.push(y1);
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
this.graphics.lineStyle(getThickness(), 0xFFFFFF);
var graphicsCommands:Vector.<int> = new Vector.<int>();
graphicsCommands.push(1);
var coordinates:Vector.<Number> = new Vector.<Number>();
coordinates.push(denormalize(getShapeArray()[0], parentWidth), denormalize(getShapeArray()[1], parentHeight));
for (var i:int = 2; i < getShapeArray().length; i += 2){
graphicsCommands.push(2);
coordinates.push(denormalize(getShapeArray()[i], parentWidth), denormalize(getShapeArray()[i+1], parentHeight));
}
this.graphics.drawPath(graphicsCommands, coordinates);
this.alpha = 1;
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(0xFFFFFF);
props.push(this.thickness);
props.push(false);
props.push(false);
props.push(this.width);
props.push(this.height);
return props;
}
}
}

View File

@ -24,19 +24,15 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
import org.bigbluebutton.common.LogUtil;
public interface GraphicObject {
function getGraphicType():String;
function getGraphicID():String;
function setGraphicID(id:String):void;
function get type():String;
function get id():String;
function denormalize(val:Number, side:Number):Number;
function normalize(val:Number, side:Number):Number;
function makeGraphic(parentWidth:Number, parentHeight:Number):void;
function getProperties():Array;
}
}

View File

@ -1,83 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Shape;
public class Highlighter extends DrawObject
{
/**
* The dafault constructor. Creates a Highlighter DrawObject
* @param segment the array representing the points needed to create this Highlighter
* @param color the Color of this Highlighter
* @param thickness the thickness of this Highlighter
* @param trans the transparency of this Highlighter
*/
public function Highlighter(segment:Array, color:uint, thickness:uint, trans:Boolean)
{
super(DrawObject.HIGHLIGHTER, segment, color, thickness, false, 0x000000, true);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
var x1:Number = this.shape[0];
var y1:Number = this.shape[1];
var x2:Number = this.shape[this.shape.length - 2];
var y2:Number = this.shape[this.shape.length - 1];
this.shape = new Array();
this.shape.push(x1);
this.shape.push(y1);
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
if(thickness < 10) thickness = 10;
this.graphics.lineStyle(getThickness(), getColor(), getTransparencyLevel());
var arrayEnd:Number = getShapeArray().length;
var startX:Number = denormalize(getShapeArray()[0], parentWidth);
var startY:Number = denormalize(getShapeArray()[1], parentHeight);
var endX:Number = denormalize(getShapeArray()[arrayEnd-2], parentWidth);
var endY:Number = denormalize(getShapeArray()[arrayEnd-1], parentHeight);
this.x = startX;
this.y = startY;
this.graphics.lineTo(endX-startX, endY-startY);
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(this.color);
props.push(this.thickness);
props.push(false);
props.push(true);
props.push(this.width);
props.push(this.height);
return props;
}
}
}

View File

@ -0,0 +1,9 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public interface IDrawAnnotation
{
function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation;
}
}

View File

@ -21,63 +21,35 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Shape;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class Line extends DrawObject
{
/**
* The dafault constructor. Creates a Line DrawObject
* @param segment the array representing the points needed to create this Line
* @param color the Color of this Line
* @param thickness the thickness of this Line
* @param trans the transparency of this Line
*/
public function Line(segment:Array, color:uint, thickness:uint, trans:Boolean)
public function Line(id:String, type:String, status:String)
{
super(DrawObject.LINE, segment, color, thickness, false, 0x000000, false);
super(id, type, status);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
var x1:Number = this.shape[0];
var y1:Number = this.shape[1];
var x2:Number = this.shape[this.shape.length - 2];
var y2:Number = this.shape[this.shape.length - 1];
override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
LogUtil.debug("Drawing LINE");
var ao:Object = a.annotation;
this.shape = new Array();
this.shape.push(x1);
this.shape.push(y1);
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
this.graphics.lineStyle(getThickness(), getColor());
var arrayEnd:Number = getShapeArray().length;
var startX:Number = denormalize(getShapeArray()[0], parentWidth);
var startY:Number = denormalize(getShapeArray()[1], parentHeight);
var endX:Number = denormalize(getShapeArray()[arrayEnd-2], parentWidth);
var endY:Number = denormalize(getShapeArray()[arrayEnd-1], parentHeight);
this.graphics.lineStyle(ao.thickness, ao.color);
var arrayEnd:Number = (ao.points as Array).length;
var startX:Number = denormalize((ao.points as Array)[0], parentWidth);
var startY:Number = denormalize((ao.points as Array)[1], parentHeight);
var endX:Number = denormalize((ao.points as Array)[arrayEnd-2], parentWidth);
var endY:Number = denormalize((ao.points as Array)[arrayEnd-1], parentHeight);
this.alpha = 1;
this.x = startX;
this.y = startY;
this.graphics.lineTo(endX-startX, endY-startY);
this.graphics.lineTo(endX-startX, endY-startY);
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(this.color);
props.push(this.thickness);
props.push(false);
props.push(false);
props.push(this.width);
props.push(this.height);
return props;
override public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
draw(a, parentWidth, parentHeight);
}
}
}

View File

@ -0,0 +1,52 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class LineAnnotation extends DrawAnnotation
{
private var _type:String = DrawObject.LINE;
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 LineAnnotation(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;
return new Annotation(_id, _type, ao);
}
}
}

View File

@ -19,6 +19,8 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Sprite;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
/**
* The Pencil class. Extends a DrawObject
@ -27,54 +29,33 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*/
public class Pencil extends DrawObject
{
/**
* the default constructor. Creates a Pencil DrawObject.
* @param segment the array representing the points needed to create this Pencil
* @param color the Color of this Pencil
* @param thickness the thickness of this Pencil
* @param trans the transparency of this Pencil
*/
public function Pencil(segment:Array, color:uint, thickness:uint, trans:Boolean)
public function Pencil(id:String, type:String, status:String)
{
super(DrawObject.PENCIL, segment, color, thickness, false, 0x000000, false);
super(id, type, status);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
this.graphics.lineStyle(getThickness(), getColor());
var graphicsCommands:Vector.<int> = new Vector.<int>();
graphicsCommands.push(1);
var coordinates:Vector.<Number> = new Vector.<Number>();
coordinates.push(denormalize(getShapeArray()[0], parentWidth), denormalize(getShapeArray()[1], parentHeight));
for (var i:int = 2; i < getShapeArray().length; i += 2){
graphicsCommands.push(2);
coordinates.push(denormalize(getShapeArray()[i], parentWidth), denormalize(getShapeArray()[i+1], parentHeight));
}
this.graphics.drawPath(graphicsCommands, coordinates);
this.alpha = 1;
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(this.color);
props.push(this.thickness);
props.push(false);
props.push(false);
props.push(this.width);
props.push(this.height);
return props;
}
override public function toString():String {
var points:String = "";
for (var p:int = 0; p < _segment.length; p++) {
points += _segment[p] + ",";
override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
var ao:Object = a.annotation;
this.graphics.lineStyle(ao.thickness, ao.color);
var graphicsCommands:Vector.<int> = new Vector.<int>();
graphicsCommands.push(1);
var coordinates:Vector.<Number> = new Vector.<Number>();
coordinates.push(denormalize((ao.points as Array)[0], parentWidth), denormalize((ao.points as Array)[1], parentHeight));
for (var i:int = 2; i < (ao.points as Array).length; i += 2){
graphicsCommands.push(2);
coordinates.push(denormalize((ao.points as Array)[i], parentWidth), denormalize((ao.points as Array)[i+1], parentHeight));
}
return "{type=" + type + ",points=" + points + "]}";
this.graphics.drawPath(graphicsCommands, coordinates);
this.alpha = 1;
}
override public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
draw(a, parentWidth, parentHeight);
}
}
}

View File

@ -0,0 +1,37 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class PencilDrawAnnotation extends DrawAnnotation
{
private var _type:String = DrawObject.PENCIL;
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 PencilDrawAnnotation(segment:Array, color:uint, thickness:uint, trans:Boolean)
{
_shape = segment;
_color = color;
_thickness = thickness;
_transparent = trans;
}
override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {
var ao:Object = new Object();
ao["type"] = _type;
ao["points"] = _shape;
ao["color"] = _color;
ao["thickness"] = _thickness;
ao["id"] = _id;
ao["status"] = _status;
ao["transparency"] = _transparent;
return new Annotation(_id, _type, ao);
}
}
}

View File

@ -19,6 +19,9 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Sprite;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
/**
* The Rectangle class. Extends a DrawObject
@ -26,64 +29,58 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*
*/
public class Rectangle extends DrawObject
{
/**
* The dafault constructor. Creates a Rectangle DrawObject
* @param segment the array representing the points needed to create this Rectangle
* @param color the Color of this Rectangle
* @param thickness the thickness of this Rectangle
* @param fill the fill of this Rectangle
* @param trans the transparency of this Rectangle
*/
public function Rectangle(segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean)
{
public function Rectangle(id:String, type:String, status:String)
{
super(DrawObject.RECTANGLE, segment, color, thickness, fill, fillColor, trans);
super(id, type, status);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
var x1:Number = this.shape[0];
var y1:Number = this.shape[1];
var x2:Number = this.shape[this.shape.length - 2];
var y2:Number = this.shape[this.shape.length - 1];
this.shape = new Array();
this.shape.push(x1);
this.shape.push(y1);
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
if(!fill)
this.graphics.lineStyle(getThickness(), getColor(), getTransparencyLevel());
else this.graphics.lineStyle(getThickness(), getColor());
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
protected 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;
}
var arrayEnd:Number = getShapeArray().length;
var startX:Number = denormalize(getShapeArray()[0], parentWidth);
var startY:Number = denormalize(getShapeArray()[1], parentHeight);
var width:Number = denormalize(getShapeArray()[arrayEnd-2], parentWidth) - startX;
var height:Number = denormalize(getShapeArray()[arrayEnd-1], parentHeight) - startY;
if(fill) this.graphics.beginFill(getFillColor(), getTransparencyLevel());
this.graphics.drawRect(startX,startY,width,height);
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(this.color);
props.push(this.thickness);
props.push(this.fill);
props.push(this.fillColor);
props.push(this.transparent);
props.push(this.width);
props.push(this.height);
return props;
}
override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
LogUtil.debug("Drawing RECTANGLE");
var ao:Object = a.annotation;
if (!ao.fill)
this.graphics.lineStyle(ao.thickness, ao.color, ao.transparency ? 0.6 : 1.0);
else this.graphics.lineStyle(ao.thickness, ao.color);
var arrayEnd:Number = (ao.points as Array).length;
var startX:Number = denormalize((ao.points as Array)[0], parentWidth);
var startY:Number = denormalize((ao.points as Array)[1], parentHeight);
var width:Number = denormalize((ao.points as Array)[arrayEnd-2], parentWidth) - startX;
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);
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 {
draw(a, parentWidth, parentHeight);
}
}
}

View File

@ -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);
}
}
}

View File

@ -1,32 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
public class SelectObject {
public static const SELECT_TOOL:String = "selector";
public static const DELETE_TOOL:String = "deletor";
public var selection_type:String;
public function SelectObject(type:String) {
this.selection_type = type;
}
}
}

View File

@ -18,10 +18,10 @@
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Shape;
import flash.display.Shape;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
/**
* The ShapeFactory receives DrawObjects and converts them to Flash Shapes which can then be displayed
@ -33,13 +33,11 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
*/
public class ShapeFactory extends GraphicFactory
{
private var drawFactory:DrawObjectFactory;
private var _parentWidth:Number = 0;
private var _parentHeight:Number = 0;
public function ShapeFactory() {
super(GraphicFactory.SHAPE_FACTORY);
drawFactory = new DrawObjectFactory();
}
public function setParentDim(width:Number, height:Number):void {
@ -47,60 +45,60 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
_parentHeight = height;
}
/**
* Creates a Flash Shape, given a DrawObject representation of it
* @param shape
* @return
*
*/
public function makeShape(graphic:DrawObject):DrawObject{
if (graphic.getType() == DrawObject.PENCIL){
return makePencil(graphic as Pencil);
} else if (graphic.getType() == DrawObject.RECTANGLE){
return makeRectangle(graphic as Rectangle);
} else if (graphic.getType() == DrawObject.ELLIPSE){
return makeEllipse(graphic as Ellipse);
} else if (graphic.getType() == DrawObject.TRIANGLE){
return makeTriangle(graphic as Triangle);
} else if (graphic.getType() == DrawObject.LINE){
return makeLine(graphic as Line);
} else if (graphic.getType() == DrawObject.HIGHLIGHTER){
return makeHighlighter(graphic as Highlighter);
} else if (graphic.getType() == DrawObject.ERASER){
return makeEraser(graphic as Eraser);
public function get parentWidth():Number {
return _parentWidth;
}
public function get parentHeight():Number {
return _parentHeight;
}
public function makeDrawObject(a:Annotation, whiteboardModel:WhiteboardModel):DrawObject{
if (a.type == DrawObject.PENCIL) {
return new Pencil(a.id, a.type, a.status);
} else if (a.type == DrawObject.RECTANGLE) {
return new Rectangle(a.id, a.type, a.status);
} else if (a.type == DrawObject.ELLIPSE) {
return new Ellipse(a.id, a.type, a.status);
} else if (a.type == DrawObject.LINE) {
return new Line(a.id, a.type, a.status);
} else if (a.type == DrawObject.TRIANGLE) {
return new Triangle(a.id, a.type, a.status);
} else if (a.type == DrawObject.TEXT) {
return new TextDrawObject(a.id, a.type, a.status);
}
return null;
}
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);
} else if (type == DrawObject.ELLIPSE){
return new EllipseAnnotation(shape, color, thickness, trans);
} else if (type == DrawObject.LINE){
return new LineAnnotation(shape, color, thickness, trans);
} else if (type == DrawObject.TRIANGLE){
return new TriangleAnnotation(shape, color, thickness, trans);
}
return null;
}
public function createDrawObject(type:String, segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, transparency:Boolean):DrawObject {
return null;
}
public function createDrawObject(type:String, segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, transparency:Boolean):DrawAnnotation {
var normSegment:Array = new Array();
for (var i:int = 0; i < segment.length; i += 2) {
normSegment[i] = normalize(segment[i] , _parentWidth);
normSegment[i+1] = normalize(segment[i+1], _parentHeight);
}
return makeShape(drawFactory.makeDrawObject(type, normSegment, color, thickness, fill, fillColor, transparency));
return createAnnotation(type, normSegment, color, thickness, fill, fillColor, transparency);
}
/**
* Creates a shape from the specified parameters
* @param segment
* @param type
* @param color
* @param thickness
* @param fill
* @param fillColor
* @param trans
* @return A Flash Shape object
*
*/
public function makeFeedback(type:String, segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean):DrawObject{
return makeShape(drawFactory.makeDrawObject(type, segment, color, thickness, fill, fillColor, trans));
}
public function createTextObject(txt:String, txtColor:uint, bgColor:uint, bgColorVisible:Boolean, x:Number, y:Number, tbWidth:Number, tbHeight:Number, textSize:Number):TextObject {
var tobj:TextObject = new TextObject(txt, txtColor, bgColor, bgColorVisible, normalize(x , _parentWidth), normalize(y, _parentHeight),
normalize(tbWidth , _parentWidth), normalize(tbHeight , _parentWidth), textSize);
public function createTextObject(txt:String, txtColor:uint, x:Number, y:Number, tbWidth:Number, tbHeight:Number, textSize:Number):TextDrawAnnotation {
var tobj:TextDrawAnnotation = new TextDrawAnnotation(txt, txtColor, normalize(x , _parentWidth), normalize(y, _parentHeight),
normalize(tbWidth , _parentWidth), normalize(tbHeight , _parentWidth), textSize);
return tobj;
}
@ -108,104 +106,20 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
/* convenience method for above method, takes a TextObject and returns one with "normalized" coordinates */
public function makeTextObject(t:Annotation):TextObject {
// LogUtil.debug("***Making textObject [" + t.type + ", [" + t.annotation.x + "," + t.annotation.y + "]");
var tobj:TextObject = new TextObject(t.annotation.text, t.annotation.fontColor, t.annotation.backgroundColor, t.annotation.background,
t.annotation.x, t.annotation.y, t.annotation.textBoxWidth, t.annotation.textBoxHeight, t.annotation.fontSize);
var tobj:TextObject = new TextObject(t.annotation.text, t.annotation.fontColor,
t.annotation.x, t.annotation.y, t.annotation.textBoxWidth, t.annotation.textBoxHeight, t.annotation.fontSize);
tobj.makeGraphic(_parentWidth,_parentHeight);
// LogUtil.debug("***Made textObject [" + tobj.text + ", [" + tobj.x + "," + tobj.y + "," + tobj.textSize + "]");
return tobj;
return tobj;
}
public function redrawTextObject(a:Annotation, t:TextObject):TextObject {
// LogUtil.debug("***Redraw textObject [" + a.type + ", [" + a.annotation.x + "," + a.annotation.y + "]");
var tobj:TextObject = new TextObject(a.annotation.text, a.annotation.fontColor, a.annotation.backgroundColor, a.annotation.background,
// LogUtil.debug("***Redraw textObject [" + a.type + ", [" + a.annotation.x + "," + a.annotation.y + "]");
var tobj:TextObject = new TextObject(a.annotation.text, a.annotation.fontColor,
a.annotation.x, a.annotation.y, a.annotation.textBoxWidth, a.annotation.textBoxHeight, a.annotation.fontSize);
tobj.redrawText(t.oldParentWidth, t.oldParentHeight, _parentWidth,_parentHeight);
// LogUtil.debug("***Redraw textObject [" + tobj.text + ", [" + tobj.x + "," + tobj.y + "," + tobj.textSize + "]");
// LogUtil.debug("***Redraw textObject [" + tobj.text + ", [" + tobj.x + "," + tobj.y + "," + tobj.textSize + "]");
return tobj;
}
/**
* Creates a Flash Shape from a Pencil DrawObject
* @param p a Pencil DrawObject
* @return a Shape
*
*/
private function makePencil(p:Pencil):DrawObject{
p.makeGraphic(_parentWidth, _parentHeight);
return p;
}
/**
* Creates a Flash Shape from a Rectangle DrawObject
* @param r a Rectangle DrawObject
* @return a Shape
*
*/
private function makeRectangle(r:Rectangle):DrawObject{
r.makeGraphic(_parentWidth, _parentHeight);
return r;
}
/**
* Creates a Flash Shape from an Ellipse DrawObject
* @param e an Ellipse DrawObject
* @return a Shape
*
*/
private function makeEllipse(e:Ellipse):DrawObject{
e.makeGraphic(_parentWidth, _parentHeight);
return e;
}
/**
* Creates a Flash Shape from an Line DrawObject
* @param e an Line DrawObject
* @return a Shape
*
*/
private function makeLine(e:Line):DrawObject{
e.makeGraphic(_parentWidth, _parentHeight);
return e;
}
/**
* Creates a Flash Shape from an Highlighter DrawObject
* @param e an Highlighter DrawObject
* @return a Shape
*
*/
private function makeHighlighter(e:Highlighter):DrawObject{
e.makeGraphic(_parentWidth, _parentHeight);
return e;
}
/**
* Creates a Flash Shape from an Eraser DrawObject
* @param e an Eraser DrawObject
* @return a Shape
*
*/
private function makeEraser(e:Eraser):DrawObject{
e.makeGraphic(_parentWidth, _parentHeight);
return e;
}
/**
* Creates a Flash Shape from an Triangle DrawObject
* @param e an Triangle DrawObject
* @return a Shape
*
*/
private function makeTriangle(e:Triangle):DrawObject{
e.makeGraphic(_parentWidth, _parentHeight);
return e;
}
private function makeText(e:Text):DrawObject{
e.makeShape(_parentWidth, _parentHeight);
return e;
}
}
}
}

View File

@ -1,137 +0,0 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.PixelSnapping;
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.text.TextField;
import mx.controls.Image;
import mx.controls.Text;
public class Text extends DrawObject
{
public var text:String = "Hello World!";
public var fontStyle:String = "_sans";
public var fontSize:Number = 18;
public var textcolor:Object = 0xFF0000;
public function Text(segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean)
{
super(DrawObject.TEXT, segment, color, thickness, fill, fillColor, trans);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
}
private var resizeCount:int = 1;
private var txtSize:uint = 10;
private var oldParentWidth:Number = 0;
private var oldParentHeight:Number = 0;
private var tb:TextBox = null;
private var bitmapdata:BitmapData;
private var scale:uint = 1;
// private var fontSize:uint = 18;
// override
public function makeShape(parentWidth:Number, parentHeight:Number):void {
var newShape:Sprite = new Sprite();
newShape.x = denormalize(getShapeArray()[0], parentWidth);
newShape.y = denormalize(getShapeArray()[1], parentHeight);
var newFontSize:Number = fontSize;
if (oldParentHeight == 0 && oldParentWidth == 0) {
newFontSize = fontSize;
oldParentHeight = parentHeight;
oldParentWidth = parentWidth;
} else {
newFontSize = (parentHeight/oldParentHeight) * fontSize;
// scale *= 1;
}
;
resizeCount++;
// newShape.width = 200;
// newShape.height = 50;
// txtSize = (parentWidth/parentHeight) * 18;
// if (tb == null) {
tb = new TextBox(text, fontStyle, newFontSize, textcolor);
// tb.width = 400 + resizeCount;
// tb.height = 20 + resizeCount;
// tb.htmlText = "Hello World! " + resizeCount;
// var txt:mx.controls.Text = new mx.controls.Text();
// txt.text = "Foo Bar!";
// txt.width = 200;
// bitmapdata = new BitmapData(tb.width, tb.height, false, 0x000000FF);
// bitmapdata.draw(tb);
// }
// tb.height = resizeCount * 2;
// tb.width = resizeCount * 2;
newShape.addChild(tb);
/*
// var textfield:TextField = new TextField();
// textfield.text = "text";
/// textfield.width *= 1.1;
// textfield.height *= 1.1;
*/
/*
var image:Image = new Image();
image.load(new Bitmap(bitmapdata, PixelSnapping.NEVER, true));
var scaledWidth:uint = bitmapdata.width; //+ resizeCount; // * scale;
// var scaledHeight:uint = bitmapdata.height; //+ resizeCount; // * scale;
// image.width = scaledWidth;
// image.height = scaledHeight;
var scaledBitmapData:BitmapData = new BitmapData(scaledWidth, scaledHeight, true, 0x00FF0000);
scaledBitmapData.draw(image.content);
newShape.graphics.beginBitmapFill(scaledBitmapData, null, false, true);
newShape.graphics.drawRect(0, 0, scaledBitmapData.width, scaledBitmapData.width);
newShape.graphics.endFill();
image = null;
*/
/*
var mat:Matrix = new Matrix();
mat.scale(200, 20);
var bmpd_draw:BitmapData = new BitmapData(200, 20, false);
bmpd_draw.draw(bitmapdata, mat, null, null, null, true);
// var scaledBitmapData:BitmapData = bitmapScaled(tb, 200, 20);
newShape.graphics.beginBitmapFill(bmpd_draw, null, false, true);
newShape.graphics.drawRect(0, 0, bmpd_draw.width, bmpd_draw.width);
newShape.graphics.endFill();
*/
// image = null;
_shape = newShape;
}
private function bitmapScaled(do_source:DisplayObject, thumbWidth:Number, thumbHeight:Number):BitmapData {
var mat:Matrix = new Matrix();
mat.scale(thumbWidth/do_source.width, thumbHeight/do_source.height);
var bmpd_draw:BitmapData = new BitmapData(thumbWidth, thumbHeight, false);
bmpd_draw.draw(do_source, mat, null, null, null, true);
return bmpd_draw;
}
}
}

View File

@ -1,21 +0,0 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.text.TextFormat;
public class TextBox extends TextField
{
function TextBox(text:String, font:String, size:uint, color:Object)
{
super();
multiline = false;
autoSize = TextFieldAutoSize.LEFT;
type = TextFieldType.INPUT;
htmlText = text;
selectable = true;
setTextFormat(new TextFormat(font, size, color));
}
}
}

View File

@ -0,0 +1,46 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class TextDrawAnnotation extends DrawAnnotation
{
private var _type:String = DrawObject.TEXT;
private var _text:String;
private var _textBoxWidth:Number = 0;
private var _textBoxHeight:Number = 0;
private var _x:Number;
private var _y:Number;
private var _fontColor:uint;
private var _fontStyle:String = "arial";
private var _fontSize:Number;
public function TextDrawAnnotation(text:String, color:uint, x:Number, y:Number, width:Number, height:Number, fontSize:Number)
{
_text = text;
_fontColor = color;
_x = x;
_y = y;
_textBoxWidth = width;
_textBoxHeight = height;
_fontSize = fontSize;
}
override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {
var ao:Object = new Object();
ao["type"] = DrawObject.TEXT;
ao["id"] = _id;
ao["status"] = _status;
ao["text"] = _text;
ao["fontColor"] = _fontColor;
ao["x"] = _x;
ao["y"] = _y;
ao["fontSize"] = _fontSize;
ao["textBoxWidth"] = _textBoxWidth;
ao["textBoxHeight"] = _textBoxHeight;
return new Annotation(_id, DrawObject.TEXT, ao);
}
}
}

View File

@ -0,0 +1,185 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import com.asfusion.mate.core.GlobalDispatcher;
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.Stage;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TextEvent;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flashx.textLayout.edit.SelectionManager;
import flexlib.scheduling.scheduleClasses.utils.Selection;
import mx.controls.Text;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.WhiteboardCanvasModel;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class TextDrawObject extends DrawObject implements GraphicObject {
public static const TYPE_NOT_EDITABLE:String = "dynamic";
public static const TYPE_EDITABLE:String = "editable";
public static const TEXT_CREATED:String = "textCreated";
public static const TEXT_UPDATED:String = "textEdited";
public static const TEXT_PUBLISHED:String = "textPublished";
public static const TEXT_TOOL:String = "textTool";
private var _editable:Boolean;
private var _type:String = DrawObject.TEXT;
private var _origParentWidth:Number = 0;
private var _origParentHeight:Number = 0;
private var _textField:TextField = new TextField();
public function TextDrawObject(id:String, type:String, status:String) {
super(id, type, status);
addChild(_textField);
}
public function get origParentWidth():Number {
return _origParentWidth;
}
public function get origParentHeight():Number {
return _origParentHeight;
}
public function get textField():TextField {
return _textField;
}
override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
LogUtil.debug("Drawing TEXT");
this.x = denormalize(a.annotation.x, parentWidth);
this.y = denormalize(a.annotation.y, parentHeight);
var newFontSize:Number = a.annotation.fontSize;
if (_origParentHeight == 0 && _origParentWidth == 0) {
// LogUtil.debug("Old parent dim [" + _origParentWidth + "," + _origParentHeight + "]");
newFontSize = a.annotation.fontSize;
_origParentHeight = parentHeight;
_origParentWidth = parentWidth;
} else {
newFontSize = (parentHeight/_origParentHeight) * a.annotation.fontSize;
// LogUtil.debug("2 Old parent dim [" + _origParentWidth + "," + _origParentHeight + "] newFontSize=" + newFontSize);
}
_textField.text = a.annotation.text;
_textField.antiAliasType = AntiAliasType.ADVANCED;
var format:TextFormat = new TextFormat();
format.size = newFontSize;
format.font = "arial";
_textField.defaultTextFormat = format;
_textField.setTextFormat(format);
this.width = denormalize(a.annotation.textBoxWidth, parentWidth);
this.height = denormalize(a.annotation.textBoxHeight, parentHeight);
LogUtil.debug("2 Old parent dim [" + _origParentWidth + "," + _origParentHeight + "][" + width + "," + height + "] newFontSize=" + newFontSize);
}
public function redrawText(a:Annotation, origParentWidth:Number, origParentHeight:Number, parentWidth:Number, parentHeight:Number):void {
this.x = denormalize(a.annotation.x, parentWidth);
this.y = denormalize(a.annotation.y, parentHeight);
var newFontSize:Number = a.annotation.fontSize;
newFontSize = (parentHeight/origParentHeight) * a.annotation.fontSize;
/** Pass around the original parent width and height when this text was drawn.
* We need this to redraw the the text to the proper size properly.
* **/
_origParentHeight = origParentHeight;
_origParentWidth = origParentWidth;
_textField.text = a.annotation.text;
_textField.antiAliasType = AntiAliasType.ADVANCED;
var format:TextFormat = new TextFormat();
format.size = newFontSize;
format.font = "arial";
_textField.defaultTextFormat = format;
_textField.setTextFormat(format);
this.width = denormalize(a.annotation.textBoxWidth, parentWidth);
this.height = denormalize(a.annotation.textBoxHeight, parentHeight);
LogUtil.debug("Redraw dim [" + _origParentWidth + "," + _origParentHeight + "][" + width + "," + height + "] newFontSize=" + newFontSize);
// LogUtil.debug("Redraw 2 Old parent dim [" + this.width + "," + this.height + "] newFontSize=" + newFontSize);
}
public function displayForPresenter():void {
_textField.multiline = true;
_textField.wordWrap = true;
_textField.type = TextFieldType.INPUT;
_textField.border = true;
_textField.background = true;
_textField.backgroundColor = 0xFFFFFF;
}
public function displayNormally():void {
_textField.multiline = true;
_textField.wordWrap = true;
}
public function makeEditable(editable:Boolean):void {
if(editable) {
_textField.type = TextFieldType.INPUT;
} else {
_textField.type = TextFieldType.DYNAMIC;
}
this._editable = editable;
}
public function registerListeners(textObjGainedFocus:Function, textObjLostFocus:Function, textObjTextListener:Function, textObjDeleteListener:Function):void {
_textField.addEventListener(FocusEvent.FOCUS_IN, textObjGainedFocus);
_textField.addEventListener(FocusEvent.FOCUS_OUT, textObjLostFocus);
_textField.addEventListener(TextEvent.TEXT_INPUT, textObjTextListener);
_textField.addEventListener(KeyboardEvent.KEY_DOWN, textObjDeleteListener);
}
public function deregisterListeners(textObjGainedFocus:Function, textObjLostFocus:Function, textObjTextListener:Function, textObjDeleteListener:Function):void {
_textField.removeEventListener(FocusEvent.FOCUS_IN, textObjGainedFocus);
_textField.removeEventListener(FocusEvent.FOCUS_OUT, textObjLostFocus);
_textField.removeEventListener(TextEvent.TEXT_INPUT, textObjTextListener);
_textField.removeEventListener(KeyboardEvent.KEY_DOWN, textObjDeleteListener);
}
}
}

View File

@ -1,61 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
*/
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.common.LogUtil;
public class TextFactory extends GraphicFactory
{
private var _parentWidth:Number = 0;
private var _parentHeight:Number = 0;
public function TextFactory() {
super(GraphicFactory.TEXT_FACTORY);
}
public function setParentDim(width:Number, height:Number):void {
_parentWidth = width;
_parentHeight = height;
}
public function createTextObject(txt:String, txtColor:uint, bgColor:uint, bgColorVisible:Boolean, x:Number, y:Number, textSize:Number):TextObject {
var tobj:TextObject = new TextObject(txt, txtColor, bgColor, bgColorVisible, normalize(x , _parentWidth), normalize(y, _parentHeight), textSize);
return tobj;
}
/* convenience method for above method, takes a TextObject and returns one with "normalized" coordinates */
public function makeTextObject(t:TextObject):TextObject {
LogUtil.debug("***Making textObject [" + t.text + ", [" + t.x + "," + t.y + "]");
var tobj:TextObject = new TextObject(t.text, t.textColor, t.backgroundColor, t.background, t.x, t.y, t.textSize);
tobj.makeGraphic(_parentWidth,_parentHeight);
LogUtil.debug("***Made textObject [" + tobj.text + ", [" + tobj.x + "," + tobj.y + "]");
return tobj;
}
public function getParentWidth():Number {
return _parentWidth;
}
public function getParentHeight():Number {
return _parentHeight;
}
}
}

View File

@ -75,11 +75,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
private var _origParentHeight:Number = 0;
public var fontStyle:String = "arial";
public function TextObject(text:String, textColor:uint, bgColor:uint, bgColorVisible:Boolean, x:Number, y:Number, boxWidth:Number, boxHeight:Number, textSize:Number) {
public function TextObject(text:String, textColor:uint, x:Number, y:Number, boxWidth:Number, boxHeight:Number, textSize:Number) {
this.text = text;
this.textColor = textColor;
// this.backgroundColor = bgColor;
// this.background = bgColorVisible;
origX = x;
origY = y;
this.x = x;
@ -89,6 +87,14 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
this.textSize = textSize;
}
public function get id():String {
return ID;
}
override public function get type():String {
return WhiteboardConstants.TYPE_TEXT;
}
public function getOrigX():Number {
return origX;
}
@ -97,14 +103,6 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
return origY;
}
public function getGraphicType():String {
return WhiteboardConstants.TYPE_TEXT;
}
public function getGraphicID():String {
return ID;
}
public function setGraphicID(id:String):void {
this.ID = id;
}
@ -118,7 +116,6 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
}
private function applyTextFormat(size:Number):void {
// LogUtil.debug(" *** Font text size [" + textSize + "," + size + "]");
var tf:TextFormat = new TextFormat();
tf.size = size;
tf.font = "arial";
@ -133,22 +130,17 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
var newFontSize:Number = textSize;
if (_origParentHeight == 0 && _origParentWidth == 0) {
// LogUtil.debug("Old parent dim [" + _origParentWidth + "," + _origParentHeight + "]");
newFontSize = textSize;
_origParentHeight = parentHeight;
_origParentWidth = parentWidth;
} else {
newFontSize = (parentHeight/_origParentHeight) * textSize;
// LogUtil.debug("2 Old parent dim [" + _origParentWidth + "," + _origParentHeight + "] newFontSize=" + newFontSize);
}
this.antiAliasType = AntiAliasType.ADVANCED;
applyTextFormat(newFontSize);
// setTextFormat(new TextFormat(fontStyle, newFontSize, textColor));
this.width = denormalize(_textBoxWidth, parentWidth);
// this.height = denormalize(_textBoxHeight, parentHeight);
LogUtil.debug("2 Old parent dim [" + _origParentWidth + "," + _origParentHeight + "][" + width + "," + height + "] newFontSize=" + newFontSize);
this.height = denormalize(_textBoxHeight, parentHeight);
}
public function get textBoxWidth():Number {
@ -180,18 +172,11 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
_origParentHeight = origParentHeight;
_origParentWidth = origParentWidth;
// LogUtil.debug("Redraw 2 Old parent dim [" + origParentWidth + "," + origParentHeight + "] newFontSize=" + newFontSize);
this.antiAliasType = AntiAliasType.ADVANCED;
applyTextFormat(newFontSize);
// setTextFormat(new TextFormat(fontStyle, newFontSize, textColor));
this.width = denormalize(_textBoxWidth, parentWidth);
this.height = denormalize(_textBoxHeight, parentHeight);
LogUtil.debug("Redraw dim [" + _origParentWidth + "," + _origParentHeight + "][" + width + "," + height + "] newFontSize=" + newFontSize);
// LogUtil.debug("Redraw 2 Old parent dim [" + this.width + "," + this.height + "] newFontSize=" + newFontSize);
}
public function getProperties():Array {
@ -222,14 +207,13 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
this.setTextFormat(tf);
this.multiline = true;
this.wordWrap = true;
// this.autoSize = TextFieldAutoSize.LEFT;
this.antiAliasType = AntiAliasType.ADVANCED;
}
public function registerListeners(textObjGainedFocus:Function, textObjLostFocus:Function, textObjTextListener:Function, textObjDeleteListener:Function):void {
this.addEventListener(FocusEvent.FOCUS_IN, textObjGainedFocus);
this.addEventListener(FocusEvent.FOCUS_OUT, textObjLostFocus);
this.addEventListener(TextEvent.TEXT_INPUT, textObjTextListener);
this.addEventListener(Event.CHANGE, textObjTextListener);
this.addEventListener(KeyboardEvent.KEY_DOWN, textObjDeleteListener);
}

View File

@ -22,69 +22,42 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
import flash.display.Shape;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class Triangle extends DrawObject
{
/**
* The dafault constructor. Creates a Triangle DrawObject
* @param segment the array representing the points needed to create this Triangle
* @param color the Color of this Triangle
* @param thickness the thickness of this Triangle
* @param trans the transparency of this Triangle
*/
public function Triangle(segment:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean)
public function Triangle(id:String, type:String, status:String)
{
super(DrawObject.TRIANGLE, segment, color, thickness, fill, fillColor, trans);
super(id, type, status);
}
/**
* Gets rid of the unnecessary data in the segment array, so that the object can be more easily passed to
* the server
*
*/
override protected function optimize():void{
var x1:Number = this.shape[0];
var y1:Number = this.shape[1];
var x2:Number = this.shape[this.shape.length - 2];
var y2:Number = this.shape[this.shape.length - 1];
override public function draw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
LogUtil.debug("Drawing TRIANGLE");
var ao:Object = a.annotation;
if (!ao.fill)
this.graphics.lineStyle(ao.thickness, ao.color, ao.transparency ? 0.6 : 1.0);
else this.graphics.lineStyle(ao.thickness, ao.color);
var arrayEnd:Number = (ao.points as Array).length;
var startX:Number = denormalize((ao.points as Array)[0], parentWidth);
var startY:Number = denormalize((ao.points as Array)[1], parentHeight);
var triangleWidth:Number = denormalize((ao.points as Array)[arrayEnd-2], parentWidth) - startX;
var triangleHeight:Number = denormalize((ao.points as Array)[arrayEnd-1], parentHeight) - startY;
// LogUtil.debug(startX + " " + startY + " " + triangleWidth + " " + triangleHeight);
if (ao.fill) this.graphics.beginFill(ao.fillColor, ao.transparency ? 0.6 : 1.0);
this.shape = new Array();
this.shape.push(x1);
this.shape.push(y1);
this.shape.push(x2);
this.shape.push(y2);
}
override public function makeGraphic(parentWidth:Number, parentHeight:Number):void {
if(!fill)
this.graphics.lineStyle(getThickness(), getColor(), getTransparencyLevel());
else this.graphics.lineStyle(getThickness(), getColor());
var arrayEnd:Number = getShapeArray().length;
var startX:Number = denormalize(getShapeArray()[0], parentWidth);
var startY:Number = denormalize(getShapeArray()[1], parentHeight);
var triangleWidth:Number = denormalize(getShapeArray()[arrayEnd-2], parentWidth) - startX;
var triangleHeight:Number = denormalize(getShapeArray()[arrayEnd-1], parentHeight) - startY;
LogUtil.debug(startX + " " + startY + " " + triangleWidth + " " + triangleHeight);
if(fill) this.graphics.beginFill(getFillColor(), getTransparencyLevel());
this.graphics.moveTo(startX+triangleWidth/2, startY);
this.graphics.lineTo(startX+triangleWidth, startY+triangleHeight);
this.graphics.lineTo(startX, triangleHeight+startY);
this.graphics.lineTo(startX+triangleWidth/2, startY);
this.graphics.lineTo(startX+triangleWidth/2, startY);
}
override public function getProperties():Array {
var props:Array = new Array();
props.push(this.type);
props.push(this.shape);
props.push(this.color);
props.push(this.thickness);
props.push(this.fill);
props.push(this.fillColor);
props.push(this.transparent);
props.push(this.width);
props.push(this.height);
return props;
}
override public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
draw(a, parentWidth, parentHeight);
}
}
}

View File

@ -0,0 +1,51 @@
package org.bigbluebutton.modules.whiteboard.business.shapes
{
import org.bigbluebutton.modules.whiteboard.models.Annotation;
public class TriangleAnnotation extends DrawAnnotation
{
private var _type:String = DrawObject.TRIANGLE;
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 TriangleAnnotation(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;
return new Annotation(_id, _type, ao);
}
}
}

View File

@ -21,7 +21,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
{
public class WhiteboardConstants {
public static const TYPE_SHAPE:String = "SHAPE";
public static const TYPE_TEXT:String = "TEXT";
public static const TYPE_TEXT:String = "text";
public static const TYPE_SELECTION:String = "SELECTION";
public static const TYPE_CLEAR:String = "WhiteboardClearButton";
public static const TYPE_ZOOM:String = "WhiteboardPanZoomButton";

View File

@ -20,15 +20,14 @@
package org.bigbluebutton.modules.whiteboard.events
{
import flash.events.Event;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
public class GraphicObjectFocusEvent extends Event
{
public static const OBJECT_SELECTED:String = "objSelect";
public static const OBJECT_DESELECTED:String = "objDeselect";
public var data:GraphicObject;
public var data:TextObject;
public function GraphicObjectFocusEvent(type:String) {
super(type, true, false);

View File

@ -37,7 +37,6 @@ package org.bigbluebutton.modules.whiteboard.events
public static const CHANGE_PAGE:String = "WhiteboardChangePageEvent";
public var annotation:Annotation;
public var recvdShapes:Boolean;
public var boardEnabled:Boolean;
public var annotationID:String;

View File

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="1024" minHeight="768">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.Label;
import mx.core.UIComponent;
public var tb:TextField = new TextField();
public function clickHandler(clickEvent:Event):void
{
// Alert.show("Event Type:" + clickEvent.type + " came from:" + clickEvent.currentTarget.id);
Me.visible = false;
var tbw:UIComponent = new UIComponent();
// drawing a white rectangle
// tbw.graphics.beginFill(0xFFFFFF); // white
// tbw.graphics.drawRect(0,0,300,20); // x, y, width, height
// tbw.graphics.endFill();
// drawing a black border
// tbw.graphics.lineStyle(2, 0x000000, 100); // line thickness, line color (black), line alpha or opacity
// tbw.graphics.drawRect(0,0,300,20); // x, y, width, height
// var textfield:TextField = new TextField()
// textfield.text = "Hi there!"
tbw.width = 600;
tbw.height = 300;
tbw.x = 50;
tbw.y = 50;
tbw.addChild(tb);
// tb.autoSize = TextFieldAutoSize.LEFT;
tb.wordWrap = true;
tb.width = 600;
tb.height = 300;
tb.x = 0;
tb.y = 0;
tb.border = true;
// tb.background = true;
// tb.backgroundColor = 0xFF0000;
tb.text = "Hello asbcdefsdfsd sdfsdfsdf ";
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0xFF0000;
format.size = 24;
// format.underline = true;
tb.defaultTextFormat = format;
tb.setTextFormat(format);
dc.addChild(tbw);
// var lb:Label = new Label();
// lb.text = "BigBlueButton";
// vb.addChildAt(lb, 1);
//
// var mbox:MessageBox = new MessageBox();
// dc.addChild(mbox);
}
]]>
</fx:Script>
<mx:VBox id="vb" width="100%" height="100%">
<s:Button id="Me" label="Handle Click" click="clickHandler(event)"/>
<mx:Canvas id="dc" width="100%" height="100%" backgroundColor="blue">
<mx:Text text="Foo bar" x="400" y="300"/>
<!--mx:TextArea text="This is a text area" borderColor="black" x="100" y="100" height="500" width="400"/-->
</mx:Canvas>
</mx:VBox>
</s:Application>

View File

@ -1,97 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
*/
package org.bigbluebutton.modules.whiteboard.managers
{
import mx.collections.ArrayCollection;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
public class Page extends ArrayCollection
{
private var isGrid:Boolean = false;;
public function Page(source:Array=null)
{
super(source);
}
public function toggleGrid():void {
isGrid = !isGrid;
}
public function isGridToggled():Boolean {
return isGrid;
}
public function addToPage(gobj:GraphicObject):void {
/*if(gobj.getGraphicType() == WhiteboardConstants.TYPE_SHAPE) {
if ((gobj as DrawObject).status != DrawObject.DRAW_END) return
} else if(gobj.getGraphicType() == WhiteboardConstants.TYPE_TEXT) {
if ((gobj as TextObject).status != TextObject.TEXT_PUBLISHED) return
}*/
if(!containsUniqueInPage(gobj.getGraphicID()))
this.addItem(gobj);
//else //LogUtil.error("Adding previously existing item to page: " + gobj.getGraphicID());
}
public function removeFromPage(gobj:GraphicObject):void {
this.removeItemAt(getIndexOf(gobj));
}
private function getIndexOf(gobj:GraphicObject):int {
var thisID:String = gobj.getGraphicID();
for(var i:int = 0; i < this.length; i++) {
var currObj:GraphicObject = this[i];
if(thisID == currObj.getGraphicID()) return i;
}
return -1;
}
private function getIndexOfID(id:String):int {
for(var i:int = 0; i < this.length; i++) {
var currObj:GraphicObject = this[i];
if(id == currObj.getGraphicID()) return i;
}
return -1;
}
public function modifyInPage(modifyingGobj:GraphicObject):void {
var indexToModify:int = getIndexOf(modifyingGobj);
this[indexToModify] = modifyingGobj;
}
public function containsUniqueInPage(id:String):Boolean {
for(var i:int = 0; i < this.length; i++) {
var currObj:GraphicObject = this[i];
if(id == currObj.getGraphicID()) return true;
}
return false;
}
public function containsInPage(modifyingGobj:GraphicObject):Boolean {
return this.contains(modifyingGobj);
}
}
}

View File

@ -1,123 +0,0 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2010 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.modules.whiteboard.managers
{
import com.asfusion.mate.events.Dispatcher;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.collections.ArrayCollection;
import org.bigbluebutton.modules.present.events.NavigationEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
public class PageManager
{
private var pageNum:int;
private var pages:ArrayCollection;
private var dispatcher:Dispatcher;
public function PageManager() {
pageNum = 0;
pages = new ArrayCollection();
dispatcher = new Dispatcher();
}
public function addShapeToPage(e:WhiteboardUpdate):void {
(pages.getItemAt(pageNum) as ArrayCollection).addItem(e.annotation);
}
public function addGraphicToPage(e:WhiteboardUpdate):void {
/* var gobjToAdd:GraphicObject = e.annotation as GraphicObject;
var currPage:Page = pages.getItemAt(pageNum) as Page;
if(gobjToAdd.getGraphicType() == WhiteboardConstants.TYPE_TEXT) {
if(checkIfModifiedText(currPage, gobjToAdd)) {
currPage.modifyInPage(gobjToAdd);
} else {
currPage.addToPage(gobjToAdd);
}
return;
}
currPage.addToPage(gobjToAdd);
*/ }
public function checkIfModifiedText(pageToCheck:Page, gobj:GraphicObject):Boolean {
if(pageToCheck.containsUniqueInPage(gobj.getGraphicID())) return true;
return false;
}
public function undoGraphicFromPage():void {
var page:Page = pages.getItemAt(pageNum) as Page;
if (page.length > 0) page.removeItemAt(page.length - 1);
}
public function clearPage():void {
var page:ArrayCollection = pages.getItemAt(pageNum) as ArrayCollection;
page.removeAll();
}
public function toggleGrid():void {
var page:Page = pages.getItemAt(pageNum) as Page;
page.toggleGrid();
}
public function isGridToggled():Boolean {
var page:Page = pages.getItemAt(pageNum) as Page;
return page.isGridToggled();
}
public function loadPage(e:PageEvent):void {
if (pages.length == 0) return;
if ((pages.getItemAt(e.pageNum) as Page).length == 0) return;
var timer:Timer = new Timer(300, 1);
timer.addEventListener(TimerEvent.TIMER, defferedLoad);
timer.start();
}
private function defferedLoad(e:TimerEvent):void {
gotoPage(this.pageNum);
}
public function changePage(e:NavigationEvent):void {
gotoPage(e.pageNumber);
}
private function gotoPage(pageNumber:int):void {
if (pages == null || pages.length < pageNumber) return;
var event:PageEvent = new PageEvent(PageEvent.CHANGE_PAGE);
event.pageNum = pageNumber;
this.pageNum = pageNumber;
event.graphicObjs = this.pages.getItemAt(pageNumber) as Page;
event.isGrid = isGridToggled();
dispatcher.dispatchEvent(event);
}
public function createPages(e:PresentationEvent):void {
pages.removeAll();
for (var i:int = 0; i<e.numberOfPages; i++){
pages.addItem(new Page());
}
}
}
}

View File

@ -29,7 +29,6 @@
import org.bigbluebutton.modules.present.events.NavigationEvent;
import org.bigbluebutton.modules.present.events.PresentationEvent;
import org.bigbluebutton.modules.present.events.WindowResizedEvent;
import org.bigbluebutton.modules.whiteboard.business.DrawProxy;
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
import org.bigbluebutton.modules.whiteboard.events.StartWhiteboardModuleEvent;
import org.bigbluebutton.modules.whiteboard.events.ToggleGridEvent;
@ -37,7 +36,6 @@
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardPresenterEvent;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
import org.bigbluebutton.modules.whiteboard.managers.PageManager;
import org.bigbluebutton.modules.whiteboard.managers.WhiteboardManager;
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
import org.bigbluebutton.modules.whiteboard.services.MessageReceiver;
@ -45,11 +43,6 @@
import org.bigbluebutton.modules.whiteboard.services.WhiteboardService;
import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas;
private function dummyMethod():void{
}
// constructorArguments="{WhiteboardModel}" constructorArguments="{lastReturn}" constructorArguments="{scope.dispatcher}"
]]>
</mx:Script>
@ -57,13 +50,8 @@
<EventHandlers type="{WhiteboardPresenterEvent.MODIFY_ENABLED}" >
<MethodInvoker generator="{WhiteboardService}" method="modifyEnabled" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{NavigationEvent.GOTO_PAGE}" >
<MethodInvoker generator="{PageManager}" method="changePage" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{PresentationEvent.PRESENTATION_LOADED}" >
<MethodInvoker generator="{PageManager}" method="createPages" arguments="{event}" />
<MethodInvoker generator="{WhiteboardService}" method="setActivePresentation" arguments="{event}" />
</EventHandlers>
@ -94,55 +82,15 @@
<EventHandlers type="{ToggleGridEvent.TOGGLE_GRID}" >
<MethodInvoker generator="{WhiteboardService}" method="toggleGrid" />
</EventHandlers>
<EventHandlers type="{WhiteboardUpdate.BOARD_UPDATED}">
<MethodInvoker generator="{PageManager}" method="addGraphicToPage" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{WhiteboardUpdate.GRAPHIC_UNDONE}" >
<MethodInvoker generator="{PageManager}" method="undoGraphicFromPage" />
</EventHandlers>
<EventHandlers type="{WhiteboardUpdate.BOARD_CLEARED}" >
<MethodInvoker generator="{PageManager}" method="clearPage" />
</EventHandlers>
<EventHandlers type="{ToggleGridEvent.GRID_TOGGLED}" >
<MethodInvoker generator="{PageManager}" method="toggleGrid" />
<EventHandlers type="{NavigationEvent.GOTO_PAGE}" >
<MethodInvoker generator="{WhiteboardService}" method="changePage" arguments="{event.pageNumber}" />
</EventHandlers>
<EventHandlers type="{PageEvent.CHANGE_PAGE}" >
<MethodInvoker generator="{WhiteboardService}" method="changePage" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{PageEvent.LOAD_PAGE}" >
<MethodInvoker generator="{PageManager}" method="loadPage" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{WhiteboardButtonEvent.WHITEBOARD_ADDED_TO_PRESENTATION}" >
<MethodInvoker generator="{WhiteboardManager}" method="positionToolbar" arguments="{event}" />
</EventHandlers>
<EventHandlers type="{AddOverlayCanvasEvent.ADD_OVERLAY_CANVAS}" >
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{WindowResizedEvent.PRESENTATION_WINDOW_RESIZED_EVENT}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{AddButtonToPresentationEvent.ADD_BUTTON}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{NavigationEvent.GOTO_PAGE}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{PresentationEvent.PRESENTATION_LOADED}">
<InlineInvoker method="dummyMethod" />
</EventHandlers>
<EventHandlers type="{WhiteboardUpdate.RECEIVED_ANNOTATION_HISTORY}" >
<MethodInvoker generator="{WhiteboardManager}" method="receivedAnnotationsHistory"/>
</EventHandlers>

View File

@ -30,7 +30,6 @@ package org.bigbluebutton.modules.whiteboard.models
var event:WhiteboardUpdate = new WhiteboardUpdate(WhiteboardUpdate.BOARD_UPDATED);
event.annotation = annotation;
event.recvdShapes = false;
_dispatcher.dispatchEvent(event);
LogUtil.debug("*** Dispatched WhiteboardUpdate.BOARD_UPDATED Event ****");
}

View File

@ -4,7 +4,6 @@ package org.bigbluebutton.modules.whiteboard.services
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.main.model.users.IMessageListener;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObjectFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
@ -14,10 +13,7 @@ package org.bigbluebutton.modules.whiteboard.services
/* Injected by Mate */
public var whiteboardModel:WhiteboardModel;
private var drawFactory:DrawObjectFactory;
public function MessageReceiver() {
drawFactory = new DrawObjectFactory();
BBB.initConnectionManager().addMessageListener(this);
}

View File

@ -1,7 +1,8 @@
package org.bigbluebutton.modules.whiteboard.services
{
import flash.net.NetConnection;
import flash.net.Responder;
import flash.net.Responder;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.managers.ConnectionManager;
@ -14,10 +15,10 @@ package org.bigbluebutton.modules.whiteboard.services
public class MessageSender
{
public function changePage(e:PageEvent):void{
public function changePage(pageNum:Number):void{
// LogUtil.debug("Sending [whiteboard.setActivePage] to server.");
var message:Object = new Object();
message["pageNum"] = e.pageNum;
message["pageNum"] = pageNum;
var _nc:ConnectionManager = BBB.initConnectionManager();
_nc.sendMessage("whiteboard.setActivePage",

View File

@ -19,8 +19,8 @@ package org.bigbluebutton.modules.whiteboard.services
sender.modifyEnabled(e);
}
public function changePage(e:PageEvent):void{
sender.changePage(e);
public function changePage(pageNum:Number):void{
sender.changePage(pageNum);
}
public function toggleGrid():void{

View File

@ -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;
}

View File

@ -7,5 +7,6 @@ package org.bigbluebutton.modules.whiteboard.views
function onMouseDown(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void;
function onMouseMove(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void;
function onMouseUp(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void;
function ctrlKeyDown(down:Boolean):void;
}
}

View File

@ -1,6 +1,7 @@
package org.bigbluebutton.modules.whiteboard.views
{
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawAnnotation;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.Pencil;
import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory;
@ -17,9 +18,13 @@ package org.bigbluebutton.modules.whiteboard.views
private var _wbCanvas:WhiteboardCanvas;
private var _sendFrequency:int;
private var _shapeFactory:ShapeFactory;
public function PencilDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
private var _ctrlKeyDown:Boolean = false;
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;
@ -36,6 +41,11 @@ package org.bigbluebutton.modules.whiteboard.views
}
}
public function ctrlKeyDown(down:Boolean):void {
_ctrlKeyDown = down;
}
public function onMouseMove(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void
{
if (tool.graphicType == WhiteboardConstants.TYPE_SHAPE) {
@ -81,18 +91,22 @@ package org.bigbluebutton.modules.whiteboard.views
private function sendShapeToServer(status:String, tool:WhiteboardTool):void {
if (_segment.length == 0) return;
var dobj:DrawObject = _shapeFactory.createDrawObject(tool.toolType, _segment, tool.drawColor, tool.thickness, tool.fillOn, tool.fillColor, tool.transparencyOn);
var dobj:DrawAnnotation = _shapeFactory.createDrawObject(tool.toolType, _segment, tool.drawColor, tool.thickness, tool.fillOn, tool.fillColor, tool.transparencyOn);
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;
}
@ -106,19 +120,11 @@ package org.bigbluebutton.modules.whiteboard.views
_segment.push(xy[0], xy[1]);
}
var annotation:Object = new Object();
annotation["type"] = dobj.getType();
annotation["points"] = dobj.getShapeArray();
annotation["color"] = dobj.getColor();
annotation["thickness"] = dobj.getThickness();
annotation["id"] = dobj.getGraphicID();
annotation["status"] = dobj.status;
annotation["fill"] = dobj.getFill();
annotation["fillColor"] = dobj.getFillColor();
annotation["transparency"] = dobj.getTransparency();
var msg:Annotation = new Annotation(dobj.getGraphicID(), dobj.getType(), annotation);
_wbCanvas.sendGraphicToServer(msg, WhiteboardDrawEvent.SEND_SHAPE);
var an:Annotation = dobj.createAnnotation(_ctrlKeyDown);
if (an != null) {
_wbCanvas.sendGraphicToServer(an, WhiteboardDrawEvent.SEND_SHAPE);
}
}
}
}

View File

@ -0,0 +1,24 @@
package org.bigbluebutton.modules.whiteboard.views
{
import flash.display.Sprite;
public class RectangleFeedbackTextBox extends Sprite
{
public function RectangleFeedbackTextBox()
{
super();
}
public function draw(startX:Number, startY:Number, width:Number, height:Number):void {
graphics.clear();
graphics.lineStyle(1, 0x0)
graphics.drawRect(0, 0, width, height);
x = startX;
y = startY;
}
public function clear():void {
graphics.clear();
}
}
}

View File

@ -2,6 +2,7 @@ package org.bigbluebutton.modules.whiteboard.views
{
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextDrawAnnotation;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
@ -16,19 +17,26 @@ 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;
public function TextDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
private var _curID:String;
private var feedback:RectangleFeedbackTextBox = new RectangleFeedbackTextBox();
public function TextDrawListener(idGenerator:AnnotationIDGenerator, wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
{
_idGenerator = idGenerator;
_wbCanvas = wbCanvas;
_sendFrequency = sendShapeFrequency;
_shapeFactory = shapeFactory;
}
public function ctrlKeyDown(down:Boolean):void {
// Ignore
}
public function onMouseDown(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void
{
if(tool.graphicType == WhiteboardConstants.TYPE_TEXT) {
if (tool.graphicType == WhiteboardConstants.TYPE_TEXT) {
_mouseXDown = mouseX;
_mouseYDown = mouseY;
@ -41,13 +49,25 @@ package org.bigbluebutton.modules.whiteboard.views
public function onMouseMove(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void
{
// do nothing
if (tool.graphicType == WhiteboardConstants.TYPE_TEXT && _mousedDown) {
if (_wbCanvas.contains(feedback)) {
_wbCanvas.removeRawChild(feedback);
}
feedback.draw(_mouseXDown, _mouseYDown, mouseX - _mouseXDown, mouseY - _mouseYDown);
_wbCanvas.addRawChild(feedback);
}
}
public function onMouseUp(mouseX:Number, mouseY:Number, tool:WhiteboardTool):void
{
if(tool.graphicType == WhiteboardConstants.TYPE_TEXT && _mousedDown) {
if (tool.graphicType == WhiteboardConstants.TYPE_TEXT && _mousedDown) {
feedback.clear();
if (_wbCanvas.contains(feedback)) {
_wbCanvas.removeRawChild(feedback);
}
_mousedDown = false;
var tbWidth:Number = mouseX - _mouseXDown;
@ -55,45 +75,32 @@ package org.bigbluebutton.modules.whiteboard.views
if (tbHeight < 15 || tbWidth < 50) return;
var tobj:TextObject = _shapeFactory.createTextObject("", 0x000000, 0x000000, false, _mouseXDown, _mouseYDown, tbWidth, tbHeight, 18);
LogUtil.error("Creating text at [" + mouseX + "," + mouseY + "] norm=[" + tobj.getOrigX() + "," + tobj.getOrigY() + "][" + tobj.textBoxWidth + "," + tobj.textBoxHeight + "]");
var tobj:TextDrawAnnotation = _shapeFactory.createTextObject("", 0x000000, _mouseXDown, _mouseYDown, tbWidth, tbHeight, 18);
sendTextToServer(TextObject.TEXT_CREATED, tobj);
}
}
private function sendTextToServer(status:String, tobj:TextObject):void {
private function sendTextToServer(status:String, tobj:TextDrawAnnotation):void {
switch (status) {
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;
}
// LogUtil.debug("SENDING TEXT: [" + tobj.text + "]");
var annotation:Object = new Object();
annotation["type"] = "text";
annotation["id"] = tobj.getGraphicID();
annotation["status"] = tobj.status;
annotation["text"] = tobj.text;
annotation["fontColor"] = tobj.textColor;
annotation["backgroundColor"] = tobj.backgroundColor;
annotation["background"] = tobj.background;
annotation["x"] = tobj.getOrigX();
annotation["y"] = tobj.getOrigY();
annotation["fontSize"] = tobj.textSize;
annotation["textBoxWidth"] = tobj.textBoxWidth;
annotation["textBoxHeight"] = tobj.textBoxHeight;
var msg:Annotation = new Annotation(tobj.getGraphicID(), "text", annotation);
_wbCanvas.sendGraphicToServer(msg, WhiteboardDrawEvent.SEND_TEXT);
_wbCanvas.sendGraphicToServer(tobj.createAnnotation(), WhiteboardDrawEvent.SEND_TEXT);
}
}
}

View File

@ -36,7 +36,6 @@
import org.bigbluebutton.modules.whiteboard.WhiteboardCanvasModel;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.SelectObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.events.PageEvent;
@ -81,19 +80,32 @@
addEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
addEventListener(MouseEvent.MOUSE_UP, doMouseUp);
addEventListener(MouseEvent.MOUSE_MOVE, doMouseMove);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
public function unregisterForMouseEvents():void {
removeEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, doMouseUp);
removeEventListener(MouseEvent.MOUSE_MOVE, doMouseMove);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
private function onKeyDown(event:KeyboardEvent):void {
model.onKeyDown(event);
}
private function onKeyUp(event:KeyboardEvent):void {
model.onKeyUp(event);
}
private function doMouseUp(event:Event):void {
model.doMouseUp(this.mouseX, this.mouseY);
}
private function doMouseDown(event:Event):void {
private function doMouseDown(event:Event):void {
displayModel.doMouseDown(this.mouseX, this.mouseY);
model.doMouseDown(this.mouseX, this.mouseY);
}
@ -175,8 +187,13 @@
}
private function setWhiteboardVisibility():void {
if (this.whiteboardEnabled && this.showWhiteboard) this.visible = true;
else this.visible = false;
if (this.whiteboardEnabled && this.showWhiteboard) {
this.visible = true;
registerForMouseEvents();
} else {
this.visible = false;
unregisterForMouseEvents();
}
}
/* added this functionality in WhiteboardToolbar.mxml instead to allow a variety of cursors */
@ -201,8 +218,8 @@
CursorManager.setCursor(eraser_icon);
} else if(toolType == TextObject.TEXT_TOOL) {
CursorManager.setCursor(text_icon);
} else if(toolType == SelectObject.SELECT_TOOL) {
CursorManager.setCursor(select_icon);
// } else if(toolType == SelectObject.SELECT_TOOL) {
// CursorManager.setCursor(select_icon);
}
}

View File

@ -225,7 +225,7 @@ Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
private function handleObjSelected(event:GraphicObjectFocusEvent):void {
LogUtil.debug("###### handleObjSelected");
if(event.data.getGraphicType() != WhiteboardConstants.TYPE_TEXT) return;
// if(event.data.id != WhiteboardConstants.TYPE_TEXT) return;
var tobj:TextObject = event.data as TextObject;
repositionToolbar(tobj);
syncPropsWith(tobj);
@ -234,7 +234,7 @@ Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
private function handleObjDeselected(event:GraphicObjectFocusEvent):void {
LogUtil.debug("##### handleObjDeselected");
if(event.data.getGraphicType() != WhiteboardConstants.TYPE_TEXT) return;
// if(event.data.id != WhiteboardConstants.TYPE_TEXT) return;
var tobj:TextObject = event.data as TextObject;
/* checks if the new focus of the stage is not the TextToolbar, and if not,
@ -266,16 +266,7 @@ Author: Ajay Gopinath <ajgopi124(at)gmail(dot)com>
<mx:ColorPicker width="20" height="20" change="setTextColor(event)" id="ctextpik" selectedColor="0x000000"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.textColorPicker')}"/>
<!--
<mx:Spacer width="3" />
<mx:Button width="20" height="20" id="btnToggleBackground" click="setBackgroundVisible(event)" icon="{toggle_text_background_icon}"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.backColorVisible')}" toggle="true"/>
<mx:ColorPicker width="20" height="20" change="changeTextBackgroundColor(event)" id="cbackpik" selectedColor="0x000000"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.backColorPicker')}"/>
-->
<views:PopUpCombo id="textSizeMenu" creationComplete="initTextSizeMenu()"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.textSizeMenu')}"
openAlways="true" specificOpenDirection="{PopUpCombo.OPEN_UP}" />

View File

@ -57,11 +57,10 @@
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.ui.Keyboard;
import mx.events.MoveEvent;
import mx.events.ResizeEvent;
import mx.managers.CursorManager;
import mx.managers.CursorManager;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.events.MadePresenterEvent;
@ -70,7 +69,6 @@
import org.bigbluebutton.modules.present.ui.views.PresentationWindow;
import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.SelectObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.GraphicObjectFocusEvent;
@ -111,6 +109,13 @@
private function onCreationComplete():void {
setToolType(WhiteboardConstants.TYPE_ZOOM, null);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
private function onKeyUp(event:KeyboardEvent):void {
if (event.ctrlKey && event.keyCode == Keyboard.Z) {
sendUndoCommand();
}
}
private function handleWhiteboardButtonPressed(e:WhiteboardButtonEvent):void {
@ -221,12 +226,12 @@
private function graphicObjSelected(event:GraphicObjectFocusEvent):void {
var gobj:GraphicObject = event.data;
LogUtil.debug("!!!!SELECTED:" + " " + gobj.getProperties());
LogUtil.debug("!!!!SELECTED:" );
}
private function graphicObjDeselected(event:GraphicObjectFocusEvent):void {
var gobj:GraphicObject = event.data;
LogUtil.debug("!!!!DESELECTED:" + " " + gobj.getProperties());
LogUtil.debug("!!!!DESELECTED:" + " " );
}
]]>

48
bigbluebutton-config/bin/bbb-record Executable file → Normal file
View File

@ -24,6 +24,7 @@
# 2011-11-20 FFD Added more checks for processing of recording
# 2012-01-04 GUG Add option to check for errors
# 2012-02-27 GUG Add option to delete one meeting and recording
# 2012-08-13 GUG Republish recording
set -e
#set -x
@ -77,6 +78,24 @@ mark_for_rebuild() {
done
}
mark_for_republish() {
MEETING_ID=$1
#set -x
for type in $TYPES; do
if [ -d $BASE/publish/$type/$MEETING_ID ]; then
rm -rf $BASE/publish/$type/$MEETING_ID
fi
if [ -d /var/bigbluebutton/published/$type/$MEETING_ID ]; then
rm -rf /var/bigbluebutton/published/$type/$MEETING_ID
fi
if [ -d /var/bigbluebutton/unpublished/$type/$MEETING_ID ]; then
rm -rf /var/bigbluebutton/unpublished/$type/$MEETING_ID
fi
done
}
BIGBLUEBUTTON_RELEASE=0.8-beta-4
need_root() {
@ -105,6 +124,7 @@ usage() {
echo "Monitoring:"
echo " --watch Watch processing of recordings"
echo " --rebuild [meetingID] rebuild the output for meetingID"
echo " --republish [meetingID] republish the recording for meetingID"
echo " --delete [meetingID] delete one meeting and recording"
echo " --deletall delete all meetings and recordings"
echo " --debug check for recording errors"
@ -145,8 +165,19 @@ while [ $# -gt 0 ]; do
shift
continue
fi
if [ "$1" = "-republish" -o "$1" = "--republish" ]; then
need_root
if [ ! -z "${2}" ]; then
MEETING_ID="${2}"
shift
fi
REPUBLISH=1
shift
continue
fi
if [ "$1" = "-delete" -o "$1" = "--delete" ]; then
if [ "$1" = "-delete" -o "$1" = "--delete" ]; then
need_root
if [ ! -z "${2}" ]; then
MEETING_ID="${2}"
@ -196,6 +227,21 @@ if [ $REBUILD ]; then
fi
fi
if [ $REPUBLISH ]; then
if [ -z "$MEETING_ID" ]; then
#
# Republish all meetings
#
for recording in $(dir $BASE/raw); do
echo "Marking for republish: $recording"
mark_for_republish $recording
done
else
echo "Marking for republish: $MEETING_ID"
mark_for_republish $MEETING_ID
fi
fi
if [ $DELETE ]; then
if [ ! -z "$MEETING_ID" ]; then
for type in $TYPES; do

View File

@ -134,7 +134,7 @@ class BigBlueButton {
'&logoutURL='.urlencode($creationParams['logoutUrl']).
'&maxParticipants='.urlencode($creationParams['maxParticipants']).
'&record='.urlencode($creationParams['record']).
'&duration='.urlencode($creationParams['duration']).
'&duration='.urlencode($creationParams['duration']);
//'&meta_category='.urlencode($creationParams['meta_category']);
$welcomeMessage = $creationParams['welcomeMsg'];
if(trim($welcomeMessage))