- draw square when control key is pressed
This commit is contained in:
parent
f0aba5e593
commit
fbfc49fd5d
@ -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())) {
|
||||
|
@ -430,7 +430,7 @@ package org.bigbluebutton.modules.whiteboard
|
||||
var e:GraphicObjectFocusEvent = new GraphicObjectFocusEvent(GraphicObjectFocusEvent.OBJECT_SELECTED);
|
||||
e.data = tobj;
|
||||
wbCanvas.dispatchEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
wbCanvas.addGraphic(tobj);
|
||||
graphicList[objIndex] = tobj;
|
||||
|
@ -12,11 +12,13 @@ package org.bigbluebutton.modules.whiteboard
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import flash.text.TextFieldType;
|
||||
import flash.text.TextFormat;
|
||||
import flash.ui.Keyboard;
|
||||
import flash.ui.Keyboard;
|
||||
|
||||
import mx.controls.TextInput;
|
||||
import mx.core.Application;
|
||||
import mx.core.UIComponent;
|
||||
import mx.managers.CursorManager;
|
||||
import mx.managers.CursorManager;
|
||||
|
||||
import org.bigbluebutton.common.IBbbCanvas;
|
||||
import org.bigbluebutton.common.LogUtil;
|
||||
import org.bigbluebutton.core.managers.UserManager;
|
||||
@ -35,6 +37,7 @@ package org.bigbluebutton.modules.whiteboard
|
||||
import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent;
|
||||
import org.bigbluebutton.modules.whiteboard.events.WhiteboardSettingResetEvent;
|
||||
import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate;
|
||||
import org.bigbluebutton.modules.whiteboard.views.AnnotationIDGenerator;
|
||||
import org.bigbluebutton.modules.whiteboard.views.IDrawListener;
|
||||
import org.bigbluebutton.modules.whiteboard.views.PencilDrawListener;
|
||||
import org.bigbluebutton.modules.whiteboard.views.TextDrawListener;
|
||||
@ -49,7 +52,7 @@ package org.bigbluebutton.modules.whiteboard
|
||||
private var drawListeners:Array = new Array();
|
||||
private var wbTool:WhiteboardTool = new WhiteboardTool();
|
||||
private var shapeFactory:ShapeFactory = new ShapeFactory();
|
||||
|
||||
private var idGenerator:AnnotationIDGenerator = new AnnotationIDGenerator();
|
||||
|
||||
/* represents the max number of 'points' enumerated in 'segment' before
|
||||
sending an update to server. Used to prevent spamming red5 with unnecessary packets */
|
||||
@ -63,8 +66,8 @@ package org.bigbluebutton.modules.whiteboard
|
||||
|
||||
public function set wbCanvas(canvas:WhiteboardCanvas):void {
|
||||
_wbCanvas = canvas;
|
||||
drawListeners.push(new PencilDrawListener(_wbCanvas, sendShapeFrequency, shapeFactory));
|
||||
drawListeners.push(new TextDrawListener(_wbCanvas, sendShapeFrequency, shapeFactory));
|
||||
drawListeners.push(new PencilDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory));
|
||||
drawListeners.push(new TextDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory));
|
||||
}
|
||||
|
||||
public function zoomCanvas(width:Number, height:Number):void {
|
||||
|
@ -15,6 +15,6 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
_status = s;
|
||||
}
|
||||
|
||||
public function createAnnotation():Annotation {return null}
|
||||
public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {return null}
|
||||
}
|
||||
}
|
@ -4,6 +4,6 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
|
||||
public interface IDrawAnnotation
|
||||
{
|
||||
function createAnnotation():Annotation;
|
||||
function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation;
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
_transparent = trans;
|
||||
}
|
||||
|
||||
override public function createAnnotation():Annotation {
|
||||
override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {
|
||||
var ao:Object = new Object();
|
||||
ao["type"] = _type;
|
||||
ao["points"] = _shape;
|
||||
|
@ -70,7 +70,13 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
var height:Number = denormalize((ao.points as Array)[arrayEnd-1], parentHeight) - startY;
|
||||
|
||||
if (ao.fill) this.graphics.beginFill(ao.fillColor, ao.transparency ? 0.6 : 1.0);
|
||||
this.graphics.drawRect(startX,startY,width,width);
|
||||
|
||||
if (ao.square) {
|
||||
this.graphics.drawRect(startX, startY, width, width);
|
||||
} else {
|
||||
this.graphics.drawRect(startX, startY, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override public function redraw(a:Annotation, parentWidth:Number, parentHeight:Number):void {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -80,7 +80,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
private function createAnnotation(type:String, shape:Array, color:uint, thickness:uint, fill:Boolean, fillColor:uint, trans:Boolean):DrawAnnotation{
|
||||
if (type == DrawObject.PENCIL){
|
||||
return new PencilDrawAnnotation(shape, color, thickness, trans);
|
||||
}
|
||||
} else if (type == DrawObject.RECTANGLE){
|
||||
return new RectangleAnnotation(shape, color, thickness, trans);
|
||||
}
|
||||
|
||||
return null;
|
||||
// else if (type == DrawObject.RECTANGLE){
|
||||
|
@ -27,7 +27,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
_fontSize = fontSize;
|
||||
}
|
||||
|
||||
override public function createAnnotation():Annotation {
|
||||
override public function createAnnotation(ctrlKeyPressed:Boolean=false):Annotation {
|
||||
var ao:Object = new Object();
|
||||
ao["type"] = DrawObject.TEXT;
|
||||
ao["id"] = _id;
|
||||
|
@ -82,7 +82,7 @@ package org.bigbluebutton.modules.whiteboard.services
|
||||
}
|
||||
|
||||
private function handleNewAnnotationCommand(message:Object):void {
|
||||
// LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]");
|
||||
LogUtil.debug("Handle new annotation[" + message.type + ", " + message.id + ", " + message.status + "]");
|
||||
if (message.type == undefined || message.type == null || message.type == "") return;
|
||||
if (message.id == undefined || message.id == null || message.id == "") return;
|
||||
if (message.status == undefined || message.status == null || message.status == "") return;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -19,9 +19,12 @@ package org.bigbluebutton.modules.whiteboard.views
|
||||
private var _sendFrequency:int;
|
||||
private var _shapeFactory:ShapeFactory;
|
||||
private var _ctrlKeyDown:Boolean = false;
|
||||
|
||||
public function PencilDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
|
||||
private var _idGenerator:AnnotationIDGenerator;
|
||||
private var _curID:String;
|
||||
|
||||
public function PencilDrawListener(idGenerator:AnnotationIDGenerator, wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
|
||||
{
|
||||
_idGenerator = idGenerator;
|
||||
_wbCanvas = wbCanvas;
|
||||
_sendFrequency = sendShapeFrequency;
|
||||
_shapeFactory = shapeFactory;
|
||||
@ -93,13 +96,17 @@ package org.bigbluebutton.modules.whiteboard.views
|
||||
switch (status) {
|
||||
case DrawObject.DRAW_START:
|
||||
dobj.status = DrawObject.DRAW_START;
|
||||
_curID = _idGenerator.generateID();
|
||||
dobj.id = _curID;
|
||||
_drawStatus = DrawObject.DRAW_UPDATE;
|
||||
break;
|
||||
case DrawObject.DRAW_UPDATE:
|
||||
dobj.status = DrawObject.DRAW_UPDATE;
|
||||
dobj.status = DrawObject.DRAW_UPDATE;
|
||||
dobj.id = _curID;
|
||||
break;
|
||||
case DrawObject.DRAW_END:
|
||||
dobj.status = DrawObject.DRAW_END;
|
||||
dobj.id = _curID;
|
||||
_drawStatus = DrawObject.DRAW_START;
|
||||
break;
|
||||
}
|
||||
@ -113,7 +120,7 @@ package org.bigbluebutton.modules.whiteboard.views
|
||||
_segment.push(xy[0], xy[1]);
|
||||
}
|
||||
|
||||
_wbCanvas.sendGraphicToServer(dobj.createAnnotation(), WhiteboardDrawEvent.SEND_SHAPE);
|
||||
_wbCanvas.sendGraphicToServer(dobj.createAnnotation(_ctrlKeyDown), WhiteboardDrawEvent.SEND_SHAPE);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,13 @@ package org.bigbluebutton.modules.whiteboard.views
|
||||
private var _textStatus:String = TextObject.TEXT_CREATED;
|
||||
private var _mouseXDown:Number = 0;
|
||||
private var _mouseYDown:Number = 0;
|
||||
|
||||
private var _idGenerator:AnnotationIDGenerator;
|
||||
private var _mousedDown:Boolean = false;
|
||||
private var _curID:String;
|
||||
|
||||
public function TextDrawListener(wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
|
||||
public function TextDrawListener(idGenerator:AnnotationIDGenerator, wbCanvas:WhiteboardCanvas, sendShapeFrequency:int, shapeFactory:ShapeFactory)
|
||||
{
|
||||
_idGenerator = idGenerator;
|
||||
_wbCanvas = wbCanvas;
|
||||
_sendFrequency = sendShapeFrequency;
|
||||
_shapeFactory = shapeFactory;
|
||||
@ -71,13 +73,17 @@ package org.bigbluebutton.modules.whiteboard.views
|
||||
case TextObject.TEXT_CREATED:
|
||||
tobj.status = TextObject.TEXT_CREATED;
|
||||
_textStatus = TextObject.TEXT_UPDATED;
|
||||
_curID = _idGenerator.generateID();
|
||||
tobj.id = _curID;
|
||||
break;
|
||||
case TextObject.TEXT_UPDATED:
|
||||
tobj.status = TextObject.TEXT_UPDATED;
|
||||
tobj.id = _curID;
|
||||
break;
|
||||
case TextObject.TEXT_PUBLISHED:
|
||||
tobj.status = TextObject.TEXT_PUBLISHED;
|
||||
_textStatus = TextObject.TEXT_CREATED;
|
||||
tobj.id = _curID;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user