- cleanup

This commit is contained in:
Richard Alam 2012-08-13 18:10:33 +00:00
parent 58a301cac7
commit f11231fd3e
7 changed files with 41 additions and 233 deletions

View File

@ -24,14 +24,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.TextDrawAnnotation;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextDrawObject;
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;
@ -52,7 +50,6 @@ package org.bigbluebutton.modules.whiteboard
public var wbCanvas:WhiteboardCanvas;
private var _annotationsList:Array = new Array();
private var shapeFactory:ShapeFactory = new ShapeFactory();
private var drawFactory:DrawObjectFactory = new DrawObjectFactory();
private var currentlySelectedTextObject:TextObject;
private var bbbCanvas:IBbbCanvas;
@ -66,7 +63,7 @@ package org.bigbluebutton.modules.whiteboard
var dobj:DrawObject;
switch (o.status) {
case DrawObject.DRAW_START:
dobj = drawFactory.makeDrawObject(o, whiteboardModel);
dobj = shapeFactory.makeDrawObject(o, whiteboardModel);
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
@ -77,7 +74,7 @@ package org.bigbluebutton.modules.whiteboard
case DrawObject.DRAW_END:
var gobj:DrawObject = _annotationsList.pop();
wbCanvas.removeGraphic(gobj as DisplayObject);
dobj = drawFactory.makeDrawObject(o, whiteboardModel);
dobj = shapeFactory.makeDrawObject(o, whiteboardModel);
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
@ -95,7 +92,7 @@ package org.bigbluebutton.modules.whiteboard
var dobj:TextDrawObject;
switch (o.status) {
case TextObject.TEXT_CREATED:
dobj = drawFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
dobj = shapeFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
if (isPresenter) {
@ -112,7 +109,7 @@ package org.bigbluebutton.modules.whiteboard
case TextObject.TEXT_UPDATED:
var gobj1:DrawObject = _annotationsList.pop();
wbCanvas.removeGraphic(gobj1 as DisplayObject);
dobj = drawFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
dobj = shapeFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
if (isPresenter) {
@ -128,7 +125,7 @@ package org.bigbluebutton.modules.whiteboard
case TextObject.TEXT_PUBLISHED:
var gobj:DrawObject = _annotationsList.pop();
wbCanvas.removeGraphic(gobj as DisplayObject);
dobj = drawFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
dobj = shapeFactory.makeDrawObject(o, whiteboardModel) as TextDrawObject;
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
dobj.displayNormally();
@ -307,7 +304,7 @@ 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 = drawFactory.makeDrawObject(an, whiteboardModel);
var dobj:DrawObject = shapeFactory.makeDrawObject(an, whiteboardModel);
if (dobj != null) {
dobj.draw(an, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
@ -332,7 +329,7 @@ package org.bigbluebutton.modules.whiteboard
var an:Annotation = annotations[i] as Annotation;
// LogUtil.debug("**** Drawing graphic from changePage [" + an.type + "] *****");
if(an.type != DrawObject.TEXT) {
var dobj:DrawObject = drawFactory.makeDrawObject(an, whiteboardModel);
var dobj:DrawObject = shapeFactory.makeDrawObject(an, whiteboardModel);
if (dobj != null) {
dobj.draw(an, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
@ -383,7 +380,7 @@ package org.bigbluebutton.modules.whiteboard
o = whiteboardModel.getAnnotation(gobj.id);
if (o != null) {
var dobj:DrawObject = drawFactory.makeDrawObject(o, whiteboardModel);
var dobj:DrawObject = shapeFactory.makeDrawObject(o, whiteboardModel);
if (dobj != null) {
dobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
wbCanvas.addGraphic(dobj);
@ -404,14 +401,7 @@ package org.bigbluebutton.modules.whiteboard
tobj.wordWrap = true;
tobj.background = false;
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);
// }
tobj.background = false;
wbCanvas.addGraphic(tobj);
_annotationsList[objIndex] = tobj;
}
@ -478,12 +468,12 @@ package org.bigbluebutton.modules.whiteboard
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);
// LogUtil.debug("modifySelectedTextObject = " + textSize);
currentlySelectedTextObject.textColor = textColor;
currentlySelectedTextObject.background = bgColorVisible;
currentlySelectedTextObject.backgroundColor = backgroundColor;
currentlySelectedTextObject.textSize = textSize;
LogUtil.debug("modifySelectedTextObject = " + currentlySelectedTextObject.textSize);
// LogUtil.debug("modifySelectedTextObject = " + currentlySelectedTextObject.textSize);
currentlySelectedTextObject.applyFormatting();
sendTextToServer(TextObject.TEXT_PUBLISHED, currentlySelectedTextObject);
}
@ -501,7 +491,7 @@ package org.bigbluebutton.modules.whiteboard
break;
}
LogUtil.debug("SENDING TEXT: [" + tobj.textSize + "]");
// LogUtil.debug("SENDING TEXT: [" + tobj.textSize + "]");
var annotation:Object = new Object();
annotation["type"] = "text";

View File

@ -12,13 +12,11 @@ package org.bigbluebutton.modules.whiteboard
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import flash.ui.Keyboard;
import mx.controls.TextInput;
import mx.core.Application;
import mx.core.UIComponent;
import mx.managers.CursorManager;
import mx.managers.CursorManager;
import org.bigbluebutton.common.IBbbCanvas;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.core.managers.UserManager;
@ -28,7 +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.TextFactory;
import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject;
import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants;
import org.bigbluebutton.modules.whiteboard.events.GraphicObjectFocusEvent;

View File

@ -1,57 +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
{
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.whiteboard.models.Annotation;
import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel;
/**
* 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
{
public function makeDrawObject(a:Annotation, whiteboardModel:WhiteboardModel):DrawObject{
if (a.type == DrawObject.PENCIL) {
LogUtil.debug("Creating SCRIBBLE Annotation");
return new Pencil(a.id, a.type, a.status);
} else if (a.type == DrawObject.RECTANGLE) {
LogUtil.debug("Creating RECTANGLE Annotation");
return new Rectangle(a.id, a.type, a.status);
} else if (a.type == DrawObject.ELLIPSE) {
LogUtil.debug("Creating ELLIPSE Annotation");
return new Ellipse(a.id, a.type, a.status);
} else if (a.type == DrawObject.LINE) {
LogUtil.debug("Creating LINE Annotation");
return new Line(a.id, a.type, a.status);
} else if (a.type == DrawObject.TRIANGLE) {
LogUtil.debug("Creating TRIANGLE Annotation");
return new Triangle(a.id, a.type, a.status);
}
return null;
}
}
}

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 {
@ -55,6 +53,27 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
return _parentHeight;
}
public function makeDrawObject(a:Annotation, whiteboardModel:WhiteboardModel):DrawObject{
if (a.type == DrawObject.PENCIL) {
LogUtil.debug("Creating SCRIBBLE Annotation");
return new Pencil(a.id, a.type, a.status);
} else if (a.type == DrawObject.RECTANGLE) {
LogUtil.debug("Creating RECTANGLE Annotation");
return new Rectangle(a.id, a.type, a.status);
} else if (a.type == DrawObject.ELLIPSE) {
LogUtil.debug("Creating ELLIPSE Annotation");
return new Ellipse(a.id, a.type, a.status);
} else if (a.type == DrawObject.LINE) {
LogUtil.debug("Creating LINE Annotation");
return new Line(a.id, a.type, a.status);
} else if (a.type == DrawObject.TRIANGLE) {
LogUtil.debug("Creating TRIANGLE Annotation");
return new Triangle(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);
@ -89,20 +108,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 + "]");
// 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.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 + "]");
// LogUtil.debug("***Made textObject [" + tobj.text + ", [" + tobj.x + "," + tobj.y + "," + tobj.textSize + "]");
return tobj;
}
public function redrawTextObject(a:Annotation, t:TextObject):TextObject {
LogUtil.debug("***Redraw textObject [" + a.type + ", [" + a.annotation.x + "," + a.annotation.y + "]");
// 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;
}
}

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

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

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