~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to mod/assign/feedback/editpdf/yui/src/editor/js/annotationoval.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of Moodle - http://moodle.org/
 
2
//
 
3
// Moodle is free software: you can redistribute it and/or modify
 
4
// it under the terms of the GNU General Public License as published by
 
5
// the Free Software Foundation, either version 3 of the License, or
 
6
// (at your option) any later version.
 
7
//
 
8
// Moodle is distributed in the hope that it will be useful,
 
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
// GNU General Public License for more details.
 
12
//
 
13
// You should have received a copy of the GNU General Public License
 
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
/**
 
17
 * Class representing a oval.
 
18
 *
 
19
 * @namespace M.assignfeedback_editpdf
 
20
 * @class annotationoval
 
21
 * @extends annotation
 
22
 * @module moodle-assignfeedback_editpdf-editor
 
23
 */
 
24
ANNOTATIONOVAL = function(config) {
 
25
    ANNOTATIONOVAL.superclass.constructor.apply(this, [config]);
 
26
};
 
27
 
 
28
ANNOTATIONOVAL.NAME = "annotationoval";
 
29
ANNOTATIONOVAL.ATTRS = {};
 
30
 
 
31
Y.extend(ANNOTATIONOVAL, M.assignfeedback_editpdf.annotation, {
 
32
    /**
 
33
     * Draw a oval annotation
 
34
     * @protected
 
35
     * @method draw
 
36
     * @return M.assignfeedback_editpdf.drawable
 
37
     */
 
38
    draw : function() {
 
39
        var drawable,
 
40
            shape;
 
41
 
 
42
        drawable = new M.assignfeedback_editpdf.drawable(this.editor);
 
43
 
 
44
        bounds = new M.assignfeedback_editpdf.rect();
 
45
        bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y),
 
46
                      new M.assignfeedback_editpdf.point(this.endx, this.endy)]);
 
47
 
 
48
        shape = this.editor.graphic.addShape({
 
49
            type: Y.Ellipse,
 
50
            width: bounds.width,
 
51
            height: bounds.height,
 
52
            stroke: {
 
53
               weight: STROKEWEIGHT,
 
54
               color: ANNOTATIONCOLOUR[this.colour]
 
55
            },
 
56
            x: bounds.x,
 
57
            y: bounds.y
 
58
        });
 
59
        drawable.shapes.push(shape);
 
60
        this.drawable = drawable;
 
61
 
 
62
        return ANNOTATIONOVAL.superclass.draw.apply(this);
 
63
    },
 
64
 
 
65
    /**
 
66
     * Draw the in progress edit.
 
67
     *
 
68
     * @public
 
69
     * @method draw_current_edit
 
70
     * @param M.assignfeedback_editpdf.edit edit
 
71
     */
 
72
    draw_current_edit : function(edit) {
 
73
        var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
 
74
            shape,
 
75
            bounds;
 
76
 
 
77
        bounds = new M.assignfeedback_editpdf.rect();
 
78
        bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
 
79
                      new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
 
80
 
 
81
        // Set min. width and height of oval.
 
82
        if (!bounds.has_min_width()) {
 
83
            bounds.set_min_width();
 
84
        }
 
85
        if (!bounds.has_min_height()) {
 
86
            bounds.set_min_height();
 
87
        }
 
88
 
 
89
        shape = this.editor.graphic.addShape({
 
90
            type: Y.Ellipse,
 
91
            width: bounds.width,
 
92
            height: bounds.height,
 
93
            stroke: {
 
94
               weight: STROKEWEIGHT,
 
95
               color: ANNOTATIONCOLOUR[edit.annotationcolour]
 
96
            },
 
97
            x: bounds.x,
 
98
            y: bounds.y
 
99
        });
 
100
 
 
101
        drawable.shapes.push(shape);
 
102
 
 
103
        return drawable;
 
104
    }
 
105
});
 
106
 
 
107
M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
 
108
M.assignfeedback_editpdf.annotationoval = ANNOTATIONOVAL;