|
1 | 1 | package org.bigbluebutton.modules.whiteboard
|
2 | 2 | {
|
3 |
| - import flash.display.DisplayObject; |
4 |
| - import flash.display.Shape; |
5 |
| - import flash.display.Sprite; |
6 |
| - import flash.events.FocusEvent; |
7 |
| - import flash.events.KeyboardEvent; |
8 |
| - import flash.events.MouseEvent; |
9 |
| - import flash.events.TextEvent; |
10 |
| - import flash.geom.Point; |
11 |
| - import flash.text.TextField; |
12 |
| - import flash.text.TextFieldAutoSize; |
13 |
| - import flash.text.TextFieldType; |
14 |
| - import flash.text.TextFormat; |
15 |
| - import flash.ui.Keyboard; |
16 |
| - |
17 |
| - import mx.controls.TextInput; |
18 |
| - import mx.core.Application; |
19 |
| - import mx.core.UIComponent; |
20 |
| - import mx.managers.CursorManager; |
21 |
| - |
22 |
| - import org.bigbluebutton.common.IBbbCanvas; |
23 |
| - import org.bigbluebutton.common.LogUtil; |
24 |
| - import org.bigbluebutton.core.managers.UserManager; |
25 |
| - import org.bigbluebutton.main.events.MadePresenterEvent; |
26 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.DrawGrid; |
27 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject; |
28 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicFactory; |
29 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject; |
30 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory; |
31 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject; |
32 |
| - import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants; |
33 |
| - import org.bigbluebutton.modules.whiteboard.events.GraphicObjectFocusEvent; |
34 |
| - import org.bigbluebutton.modules.whiteboard.events.PageEvent; |
35 |
| - import org.bigbluebutton.modules.whiteboard.events.ToggleGridEvent; |
36 |
| - import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent; |
37 |
| - import org.bigbluebutton.modules.whiteboard.events.WhiteboardSettingResetEvent; |
38 |
| - import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate; |
39 |
| - import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel; |
40 |
| - import org.bigbluebutton.modules.whiteboard.views.AnnotationIDGenerator; |
41 |
| - import org.bigbluebutton.modules.whiteboard.views.IDrawListener; |
42 |
| - import org.bigbluebutton.modules.whiteboard.views.PencilDrawListener; |
43 |
| - import org.bigbluebutton.modules.whiteboard.views.TextDrawListener; |
44 |
| - import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas; |
45 |
| - import org.bigbluebutton.modules.whiteboard.views.models.WhiteboardTool; |
46 |
| - |
| 3 | + import flash.display.DisplayObject; |
| 4 | + import flash.display.Shape; |
| 5 | + import flash.display.Sprite; |
| 6 | + import flash.events.FocusEvent; |
| 7 | + import flash.events.KeyboardEvent; |
| 8 | + import flash.events.MouseEvent; |
| 9 | + import flash.events.TextEvent; |
| 10 | + import flash.geom.Point; |
| 11 | + import flash.text.TextField; |
| 12 | + import flash.text.TextFieldAutoSize; |
| 13 | + import flash.text.TextFieldType; |
| 14 | + import flash.text.TextFormat; |
| 15 | + import flash.ui.Keyboard; |
| 16 | + import mx.controls.TextInput; |
| 17 | + import mx.core.Application; |
| 18 | + import mx.core.UIComponent; |
| 19 | + import mx.managers.CursorManager; |
| 20 | + import org.bigbluebutton.common.IBbbCanvas; |
| 21 | + import org.bigbluebutton.common.LogUtil; |
| 22 | + import org.bigbluebutton.core.managers.UserManager; |
| 23 | + import org.bigbluebutton.main.events.MadePresenterEvent; |
| 24 | + import org.bigbluebutton.modules.whiteboard.business.shapes.DrawGrid; |
| 25 | + import org.bigbluebutton.modules.whiteboard.business.shapes.DrawObject; |
| 26 | + import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicFactory; |
| 27 | + import org.bigbluebutton.modules.whiteboard.business.shapes.GraphicObject; |
| 28 | + import org.bigbluebutton.modules.whiteboard.business.shapes.ShapeFactory; |
| 29 | + import org.bigbluebutton.modules.whiteboard.business.shapes.TextObject; |
| 30 | + import org.bigbluebutton.modules.whiteboard.business.shapes.WhiteboardConstants; |
| 31 | + import org.bigbluebutton.modules.whiteboard.events.GraphicObjectFocusEvent; |
| 32 | + import org.bigbluebutton.modules.whiteboard.events.PageEvent; |
| 33 | + import org.bigbluebutton.modules.whiteboard.events.ToggleGridEvent; |
| 34 | + import org.bigbluebutton.modules.whiteboard.events.WhiteboardDrawEvent; |
| 35 | + import org.bigbluebutton.modules.whiteboard.events.WhiteboardSettingResetEvent; |
| 36 | + import org.bigbluebutton.modules.whiteboard.events.WhiteboardUpdate; |
| 37 | + import org.bigbluebutton.modules.whiteboard.models.WhiteboardModel; |
| 38 | + import org.bigbluebutton.modules.whiteboard.views.AnnotationIDGenerator; |
| 39 | + import org.bigbluebutton.modules.whiteboard.views.IDrawListener; |
| 40 | + import org.bigbluebutton.modules.whiteboard.views.PencilDrawListener; |
| 41 | + import org.bigbluebutton.modules.whiteboard.views.TextDrawListener; |
| 42 | + import org.bigbluebutton.modules.whiteboard.views.WhiteboardCanvas; |
| 43 | + import org.bigbluebutton.modules.whiteboard.views.models.WhiteboardTool; |
| 44 | + |
47 | 45 | /**
|
48 | 46 | * Class responsible for handling actions from presenter and sending annotations to the server.
|
49 | 47 | */
|
50 |
| - public class WhiteboardCanvasModel { |
51 |
| - public var whiteboardModel:WhiteboardModel; |
52 |
| - private var _wbCanvas:WhiteboardCanvas; |
53 |
| - private var drawListeners:Array = new Array(); |
54 |
| - private var wbTool:WhiteboardTool = new WhiteboardTool(); |
55 |
| - private var shapeFactory:ShapeFactory = new ShapeFactory(); |
56 |
| - private var idGenerator:AnnotationIDGenerator = new AnnotationIDGenerator(); |
57 |
| - |
58 |
| - /* represents the max number of 'points' enumerated in 'segment' before |
59 |
| - sending an update to server. Used to prevent spamming red5 with unnecessary packets */ |
60 |
| - private var sendShapeFrequency:uint = 30; |
61 |
| - |
62 |
| - /* same as above, except a faster interval may be desirable when erasing, for aesthetics */ |
63 |
| - private var sendEraserFrequency:uint = 20; |
| 48 | + public class WhiteboardCanvasModel { |
| 49 | + public var whiteboardModel:WhiteboardModel; |
| 50 | + private var _wbCanvas:WhiteboardCanvas; |
| 51 | + private var drawListeners:Array = new Array(); |
| 52 | + private var wbTool:WhiteboardTool = new WhiteboardTool(); |
| 53 | + private var shapeFactory:ShapeFactory = new ShapeFactory(); |
| 54 | + private var idGenerator:AnnotationIDGenerator = new AnnotationIDGenerator(); |
| 55 | + |
| 56 | + /* represents the max number of 'points' enumerated in 'segment' before |
| 57 | + sending an update to server. Used to prevent spamming red5 with unnecessary packets */ |
| 58 | + private var sendShapeFrequency:uint = 30; |
64 | 59 |
|
65 |
| - private var width:Number; |
66 |
| - private var height:Number; |
| 60 | + /* same as above, except a faster interval may be desirable when erasing, for aesthetics */ |
| 61 | + private var sendEraserFrequency:uint = 20; |
| 62 | + |
| 63 | + private var width:Number; |
| 64 | + private var height:Number; |
67 | 65 |
|
68 |
| - public function set wbCanvas(canvas:WhiteboardCanvas):void { |
69 |
| - _wbCanvas = canvas; |
70 |
| - drawListeners.push(new PencilDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory, whiteboardModel)); |
71 |
| - drawListeners.push(new TextDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory, whiteboardModel)); |
72 |
| - } |
| 66 | + public function set wbCanvas(canvas:WhiteboardCanvas):void { |
| 67 | + _wbCanvas = canvas; |
| 68 | + drawListeners.push(new PencilDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory, whiteboardModel)); |
| 69 | + drawListeners.push(new TextDrawListener(idGenerator, _wbCanvas, sendShapeFrequency, shapeFactory, whiteboardModel)); |
| 70 | + } |
73 | 71 |
|
74 |
| - public function zoomCanvas(width:Number, height:Number):void { |
75 |
| - shapeFactory.setParentDim(width, height); |
76 |
| - this.width = width; |
77 |
| - this.height = height; |
78 |
| - } |
| 72 | + public function zoomCanvas(width:Number, height:Number):void { |
| 73 | + shapeFactory.setParentDim(width, height); |
| 74 | + this.width = width; |
| 75 | + this.height = height; |
| 76 | + } |
79 | 77 |
|
80 |
| - public function changeFontStyle(font:String):void { |
81 |
| - wbTool._fontStyle = font; |
82 |
| - } |
83 |
| - |
84 |
| - public function changeFontSize(size:Number):void { |
85 |
| - wbTool._fontSize = size; |
86 |
| - } |
| 78 | + public function changeFontStyle(font:String):void { |
| 79 | + wbTool._fontStyle = font; |
| 80 | + } |
| 81 | + |
| 82 | + public function changeFontSize(size:Number):void { |
| 83 | + wbTool._fontSize = size; |
| 84 | + } |
87 | 85 |
|
88 |
| - public function onKeyDown(event:KeyboardEvent):void { |
89 |
| - for (var ob:int = 0; ob < drawListeners.length; ob++) { |
90 |
| - (drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey); |
91 |
| - } |
92 |
| - } |
| 86 | + public function onKeyDown(event:KeyboardEvent):void { |
| 87 | + for (var ob:int = 0; ob < drawListeners.length; ob++) { |
| 88 | + (drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey); |
| 89 | + } |
| 90 | + } |
93 | 91 |
|
94 |
| - public function onKeyUp(event:KeyboardEvent):void { |
95 |
| - for (var ob:int = 0; ob < drawListeners.length; ob++) { |
96 |
| - (drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey); |
97 |
| - } |
98 |
| - } |
| 92 | + public function onKeyUp(event:KeyboardEvent):void { |
| 93 | + for (var ob:int = 0; ob < drawListeners.length; ob++) { |
| 94 | + (drawListeners[ob] as IDrawListener).ctrlKeyDown(event.ctrlKey); |
| 95 | + } |
| 96 | + } |
99 | 97 |
|
100 |
| - public function doMouseUp(mouseX:Number, mouseY:Number):void { |
101 |
| -// LogUtil.debug("CanvasModel doMouseUp ***"); |
102 |
| - for (var ob:int = 0; ob < drawListeners.length; ob++) { |
103 |
| - (drawListeners[ob] as IDrawListener).onMouseUp(mouseX, mouseY, wbTool); |
104 |
| - } |
105 |
| - } |
106 |
| - |
107 |
| - public function doMouseDown(mouseX:Number, mouseY:Number):void { |
108 |
| -// LogUtil.debug("*** CanvasModel doMouseDown"); |
109 |
| - for (var ob:int = 0; ob < drawListeners.length; ob++) { |
110 |
| - (drawListeners[ob] as IDrawListener).onMouseDown(mouseX, mouseY, wbTool); |
111 |
| - } |
112 |
| - } |
113 |
| - |
114 |
| - public function doMouseMove(mouseX:Number, mouseY:Number):void { |
115 |
| - for (var ob:int = 0; ob < drawListeners.length; ob++) { |
116 |
| - (drawListeners[ob] as IDrawListener).onMouseMove(mouseX, mouseY, wbTool); |
117 |
| - } |
118 |
| - } |
119 |
| - |
120 |
| - public function setGraphicType(type:String):void { |
121 |
| -// LogUtil.debug("!!! Set graphic type = " + type); |
122 |
| - wbTool.graphicType = type; |
123 |
| - } |
124 |
| - |
125 |
| - public function setTool(s:String):void { |
126 |
| -// LogUtil.debug("!!!! Set graphic tool = " + s); |
127 |
| - wbTool.toolType = s; |
128 |
| - } |
129 |
| - |
130 |
| - public function changeColor(color:uint):void { |
131 |
| - wbTool.drawColor = color; |
132 |
| - } |
133 |
| - |
134 |
| - public function changeThickness(thickness:uint):void { |
135 |
| - wbTool.thickness = thickness; |
136 |
| - } |
| 98 | + public function doMouseUp(mouseX:Number, mouseY:Number):void { |
| 99 | + // LogUtil.debug("CanvasModel doMouseUp ***"); |
| 100 | + for (var ob:int = 0; ob < drawListeners.length; ob++) { |
| 101 | + (drawListeners[ob] as IDrawListener).onMouseUp(mouseX, mouseY, wbTool); |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + public function doMouseDown(mouseX:Number, mouseY:Number):void { |
| 106 | + // LogUtil.debug("*** CanvasModel doMouseDown"); |
| 107 | + for (var ob:int = 0; ob < drawListeners.length; ob++) { |
| 108 | + (drawListeners[ob] as IDrawListener).onMouseDown(mouseX, mouseY, wbTool); |
| 109 | + } |
| 110 | + } |
| 111 | + |
| 112 | + public function doMouseMove(mouseX:Number, mouseY:Number):void { |
| 113 | + for (var ob:int = 0; ob < drawListeners.length; ob++) { |
| 114 | + (drawListeners[ob] as IDrawListener).onMouseMove(mouseX, mouseY, wbTool); |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + public function setGraphicType(type:String):void { |
| 119 | + //LogUtil.debug("!!! Set graphic type = " + type); |
| 120 | + wbTool.graphicType = type; |
| 121 | + } |
| 122 | + |
| 123 | + public function setTool(s:String):void { |
| 124 | + // LogUtil.debug("!!!! Set graphic tool = " + s); |
| 125 | + wbTool.toolType = s; |
| 126 | + } |
| 127 | + |
| 128 | + public function changeColor(color:uint):void { |
| 129 | + wbTool.drawColor = color; |
| 130 | + } |
| 131 | + |
| 132 | + public function changeThickness(thickness:uint):void { |
| 133 | + wbTool.thickness = thickness; |
| 134 | + } |
137 | 135 |
|
138 |
| - /** Helper method to test whether this user is the presenter */ |
139 |
| - private function get isPresenter():Boolean { |
140 |
| - return UserManager.getInstance().getConference().amIPresenter(); |
141 |
| - } |
142 |
| - } |
| 136 | + /** Helper method to test whether this user is the presenter */ |
| 137 | + private function get isPresenter():Boolean { |
| 138 | + return UserManager.getInstance().getConference().amIPresenter(); |
| 139 | + } |
| 140 | + } |
143 | 141 | }
|
0 commit comments