All files Drawable.js

100% Statements 17/17
100% Branches 20/20
100% Functions 1/1
100% Lines 17/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 1081x     1x     1x                               2x               1x               2x               1x               1x               2x               1x               2x                       91x   13x 13x 13x 13x               1x        
import {
    Publisher
} from './Publisher.js';
import {
    MapInformation
} from './MapInformation.js';
import {
    Rectangle
} from './Rectangle.js';
 
/**
 * @author Michael Duve <mduve@designmail.net>
 * @file represents an item, that is displayed and needs information for its position
 * @copyright Michael Duve 2016
 */
export class Drawable extends Rectangle {
 
    /**
     * stores mapdimension information
     * @return {Rectangle} map
     */
    get view() {
        return this.info.get().view;
    }
 
    /**
     * stores level information
     * @return {Number} level
     */
    get level() {
        return this.info.get().level;
    }
 
    /**
     * stores viewport information
     * @return {Rectangle} viewport
     */
    get viewport() {
        return this.info.get().viewport;
    }
 
    /**
     * stores distortion information
     * @return {Number} distortionFactor
     */
    get distortionFactor() {
        return this.info.get().distortionFactor;
    }
 
    /**
     * stores x offset to center
     * @return {Number} offsetToCenter
     */
    get offsetToCenter() {
        return this.info.get().offsetToCenter;
    }
 
    /**
     * stores latlng position of map center
     * @return {LatLng} center
     */
    get centerPosition() {
        return this.info.get().center;
    }
 
    /**
     * stores current zoom factor
     * @return {Number} zoomFactor
     */
    get zoomFactor() {
        return this.info.get().zoomFactor;
    }
 
    /**
     * stores boundary information
     * @return {Bounds} bounds
     */
    get bounds() {
        return this.info.get().bounds;
    }
 
    /**
     * @constructor
     * @param  {Number} id = 0 - id of parent instance
     * @param  {Number} x  = 0 - position x of element
     * @param  {Number} y  = 0 - position y of element
     * @param  {Number} w  = 0 - width of element
     * @param  {Number} h  = 0 - height of element
     * @return {Drawable} instance of Drawable for chaining
     */
    constructor(id = 0, x = 0, y = 0, w = 0, h = 0) {
        super(x, y, w, h);
        this.id = id;
        this.info = new MapInformation(this.id);
        this.eventManager = new Publisher(this.id);
        return this;
    }
 
    /**
     * execute on displaying instance
     * @return {Drawable} instance of Drawable for chaining
     */
    draw() {
        return this;
    }
 
}