[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/assign/feedback/editpdf/yui/src/editor/js/ -> annotationrectangle.js (source)

   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   * Provides an in browser PDF editor.
  18   *
  19   * @module moodle-assignfeedback_editpdf-editor
  20   */
  21  
  22  /**
  23   * Class representing a rectangle.
  24   *
  25   * @namespace M.assignfeedback_editpdf
  26   * @class annotationrectangle
  27   * @extends M.assignfeedback_editpdf.annotation
  28   */
  29  ANNOTATIONRECTANGLE = function(config) {
  30      ANNOTATIONRECTANGLE.superclass.constructor.apply(this, [config]);
  31  };
  32  
  33  ANNOTATIONRECTANGLE.NAME = "annotationrectangle";
  34  ANNOTATIONRECTANGLE.ATTRS = {};
  35  
  36  Y.extend(ANNOTATIONRECTANGLE, M.assignfeedback_editpdf.annotation, {
  37      /**
  38       * Draw a rectangle annotation
  39       * @protected
  40       * @method draw
  41       * @return M.assignfeedback_editpdf.drawable
  42       */
  43      draw : function() {
  44          var drawable,
  45              shape;
  46  
  47          drawable = new M.assignfeedback_editpdf.drawable(this.editor);
  48  
  49          bounds = new M.assignfeedback_editpdf.rect();
  50          bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y),
  51                        new M.assignfeedback_editpdf.point(this.endx, this.endy)]);
  52  
  53          shape = this.editor.graphic.addShape({
  54              type: Y.Rect,
  55              width: bounds.width,
  56              height: bounds.height,
  57              stroke: {
  58                 weight: STROKEWEIGHT,
  59                 color: ANNOTATIONCOLOUR[this.colour]
  60              },
  61              x: bounds.x,
  62              y: bounds.y
  63          });
  64          drawable.shapes.push(shape);
  65          this.drawable = drawable;
  66  
  67          return ANNOTATIONRECTANGLE.superclass.draw.apply(this);
  68      },
  69  
  70      /**
  71       * Draw the in progress edit.
  72       *
  73       * @public
  74       * @method draw_current_edit
  75       * @param M.assignfeedback_editpdf.edit edit
  76       */
  77      draw_current_edit : function(edit) {
  78          var drawable = new M.assignfeedback_editpdf.drawable(this.editor),
  79              shape,
  80              bounds;
  81  
  82          bounds = new M.assignfeedback_editpdf.rect();
  83          bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y),
  84                        new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]);
  85  
  86          // Set min. width and height of rectangle.
  87          if (!bounds.has_min_width()) {
  88              bounds.set_min_width();
  89          }
  90          if (!bounds.has_min_height()) {
  91              bounds.set_min_height();
  92          }
  93  
  94          shape = this.editor.graphic.addShape({
  95              type: Y.Rect,
  96              width: bounds.width,
  97              height: bounds.height,
  98              stroke: {
  99                 weight: STROKEWEIGHT,
 100                 color: ANNOTATIONCOLOUR[edit.annotationcolour]
 101              },
 102              x: bounds.x,
 103              y: bounds.y
 104          });
 105  
 106          drawable.shapes.push(shape);
 107  
 108          return drawable;
 109      }
 110  });
 111  
 112  M.assignfeedback_editpdf = M.assignfeedback_editpdf || {};
 113  M.assignfeedback_editpdf.annotationrectangle = ANNOTATIONRECTANGLE;


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1