- start add text to whiteboard
This commit is contained in:
parent
71cc44eac2
commit
2ba634e797
@ -78,7 +78,7 @@ package org.bigbluebutton.modules.whiteboard
|
||||
break;
|
||||
}
|
||||
|
||||
LogUtil.error("SEGMENT LENGTH = [" + segment.length + "] STATUS = [" + dobj.status + "]");
|
||||
// LogUtil.error("SEGMENT LENGTH = [" + segment.length + "] STATUS = [" + dobj.status + "]");
|
||||
|
||||
if (this.shapeStyle == DrawObject.PENCIL) {
|
||||
dobj.status = DrawObject.DRAW_END;
|
||||
|
@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
{
|
||||
import flash.display.Shape;
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
/**
|
||||
* The DrawObject class provides an interface for other geometric representations.
|
||||
@ -34,7 +34,8 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
public static const PENCIL:String = "pencil";
|
||||
public static const RECTANGLE:String = "rectangle";
|
||||
public static const ELLIPSE:String = "ellipse";
|
||||
|
||||
public static const TEXT:String = "text";
|
||||
|
||||
protected var type:String;
|
||||
protected var shape:Array;
|
||||
protected var color:uint;
|
||||
@ -54,7 +55,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
public static const DRAW_START:String = "DRAW_START";
|
||||
public var status:String = DRAW_START;
|
||||
|
||||
protected var _shape:Shape = new Shape();
|
||||
protected var _shape:Sprite = new Sprite();
|
||||
protected var _segment:Array;
|
||||
|
||||
/**
|
||||
@ -69,7 +70,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
this.optimize();
|
||||
}
|
||||
|
||||
public function getShape():Shape {
|
||||
public function getShape():Sprite {
|
||||
return _shape;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,12 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
d = makeRectangle(shape, color, thickness);
|
||||
} else if (type == DrawObject.ELLIPSE){
|
||||
d = makeEllipse(shape, color, thickness);
|
||||
}
|
||||
} else if (type == DrawObject.TEXT){
|
||||
d = makeText(shape, color, thickness);
|
||||
d.getShapeArray().push(d.getShape().width);
|
||||
d.getShapeArray().push(d.getShape().height);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
@ -69,6 +74,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
*/
|
||||
public function makePencil(shape:Array, color:uint, thickness:uint):DrawObject{
|
||||
return new Pencil(shape, color, thickness);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +88,8 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
*
|
||||
*/
|
||||
public function makeRectangle(shape:Array, color:uint, thickness:uint):DrawObject{
|
||||
return new Rectangle(shape, color, thickness);
|
||||
//return new Rectangle(shape, color, thickness);
|
||||
return new Text(shape, color, thickness);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,5 +106,8 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
return new Ellipse(shape, color, thickness);
|
||||
}
|
||||
|
||||
public function makeText(shape:Array, color:uint, thickness:uint):DrawObject{
|
||||
return new Text(shape, color, thickness);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
{
|
||||
import flash.display.Shape;
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
/**
|
||||
* The Ellipse class. Extends the DrawObject
|
||||
@ -61,7 +61,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
}
|
||||
|
||||
override public function makeShape(parentWidth:Number, parentHeight:Number):void {
|
||||
var newShape:Shape = new Shape();
|
||||
var newShape:Sprite = new Sprite();
|
||||
newShape.graphics.lineStyle(getThickness(), getColor());
|
||||
var arrayEnd:Number = getShapeArray().length;
|
||||
var x:Number = denormalize(getShapeArray()[0], parentWidth);
|
||||
|
@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
{
|
||||
import flash.display.Shape;
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
/**
|
||||
* The Pencil class. Extends a DrawObject
|
||||
@ -40,7 +40,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
}
|
||||
|
||||
override public function makeShape(parentWidth:Number, parentHeight:Number):void {
|
||||
var newShape:Shape = new Shape();
|
||||
var newShape:Sprite = new Sprite();
|
||||
newShape.graphics.lineStyle(getThickness(), getColor());
|
||||
|
||||
var graphicsCommands:Vector.<int> = new Vector.<int>();
|
||||
|
@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
{
|
||||
import flash.display.Shape;
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
/**
|
||||
* The Rectangle class. Extends a DrawObject
|
||||
@ -58,7 +58,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
}
|
||||
|
||||
override public function makeShape(parentWidth:Number, parentHeight:Number):void {
|
||||
var newShape:Shape = new Shape();
|
||||
var newShape:Sprite = new Sprite();
|
||||
newShape.graphics.lineStyle(getThickness(), getColor());
|
||||
var arrayEnd:Number = getShapeArray().length;
|
||||
var x:Number = denormalize(getShapeArray()[0], parentWidth);
|
||||
|
@ -56,7 +56,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
return makeRectangle(shape as Rectangle);
|
||||
} else if (shape.getType() == DrawObject.ELLIPSE){
|
||||
return makeEllipse(shape as Ellipse);
|
||||
}
|
||||
} else if (shape.getType() == DrawObject.TEXT){
|
||||
return makeText(shape as Text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -73,7 +75,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
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));
|
||||
}
|
||||
|
||||
@ -125,5 +127,9 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
return e;
|
||||
}
|
||||
|
||||
private function makeText(e:Text):DrawObject{
|
||||
e.makeShape(_parentWidth, _parentHeight);
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
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 function Text(segment:Array, color:uint, thickness:uint)
|
||||
{
|
||||
super(DrawObject.TEXT, segment, color, thickness);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
if (oldParentHeight == 0 && oldParentWidth == 0) {
|
||||
fontSize = 18;
|
||||
oldParentHeight = parentHeight;
|
||||
oldParentWidth = parentWidth;
|
||||
|
||||
} else {
|
||||
fontSize = (parentHeight/oldParentHeight) * 18;
|
||||
// scale *= 1;
|
||||
}
|
||||
|
||||
;
|
||||
resizeCount++;
|
||||
// newShape.width = 200;
|
||||
// newShape.height = 50;
|
||||
// txtSize = (parentWidth/parentHeight) * 18;
|
||||
// if (tb == null) {
|
||||
tb = new TextBox(fontSize);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
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(size:uint)
|
||||
{
|
||||
super();
|
||||
// defaultTextFormat = new TextFormat("_sans", size, 0xFFFFFF);
|
||||
// background = true;
|
||||
// backgroundColor = 0xFF88FF;
|
||||
multiline = false;
|
||||
autoSize = TextFieldAutoSize.LEFT;
|
||||
type = TextFieldType.INPUT;
|
||||
htmlText = "Hello World! ";
|
||||
selectable = true;
|
||||
setTextFormat(new TextFormat("_sans", size, 0xFFFFFF));
|
||||
}
|
||||
}
|
||||
}
|
@ -96,17 +96,26 @@
|
||||
btnPenc.selected = true;
|
||||
btnEllipse.selected = false;
|
||||
btnRectangle.selected = false;
|
||||
btnText.selected = false;
|
||||
break;
|
||||
case DrawObject.ELLIPSE:
|
||||
btnPenc.selected = false;
|
||||
btnEllipse.selected = true;
|
||||
btnRectangle.selected = false;
|
||||
btnText.selected = false;
|
||||
break;
|
||||
case DrawObject.RECTANGLE:
|
||||
btnPenc.selected = false;
|
||||
btnEllipse.selected = false;
|
||||
btnRectangle.selected = true;
|
||||
btnText.selected = false;
|
||||
break;
|
||||
case DrawObject.TEXT:
|
||||
btnPenc.selected = false;
|
||||
btnEllipse.selected = false;
|
||||
btnRectangle.selected = false;
|
||||
btnText.selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +195,8 @@
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
<mx:Button width="20" height="20" id="btnText" click="setShape(DrawObject.TEXT)" icon="{rectangle_icon}"
|
||||
toolTip="{ResourceUtil.getInstance().getString('bbb.highlighter.toolbar.rectangle')}" toggle="true" />
|
||||
<mx:Button width="20" height="20" id="btnPenc" click="setShape(DrawObject.PENCIL)" icon="{pencil_icon}"
|
||||
toolTip="{ResourceUtil.getInstance().getString('bbb.highlighter.toolbar.pencil')}" toggle="true" selected="true" />
|
||||
<mx:Button width="20" height="20" id="btnRectangle" click="setShape(DrawObject.RECTANGLE)" icon="{rectangle_icon}"
|
||||
|
Loading…
Reference in New Issue
Block a user