diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 09:48:38 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 09:48:38 +0200 |
| commit | 09596c3c5a6a2a44675f170106bb38746229e02a (patch) | |
| tree | 763d1b710dc5f2fcab920ac6ab2c555cee4d6342 /src/scripts/views/layers/dcprogressbar.ts | |
| parent | 057952b0bacc6e963c74bb1bbebbcccd6174a75c (diff) | |
Remove old frontend
Diffstat (limited to 'src/scripts/views/layers/dcprogressbar.ts')
| -rw-r--r-- | src/scripts/views/layers/dcprogressbar.ts | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/src/scripts/views/layers/dcprogressbar.ts b/src/scripts/views/layers/dcprogressbar.ts deleted file mode 100644 index e518ead4..00000000 --- a/src/scripts/views/layers/dcprogressbar.ts +++ /dev/null @@ -1,99 +0,0 @@ -import {DCObjectLayer} from "./dcobject"; -import {CELL_SIZE} from "../../controllers/mapcontroller"; - - -export class DCProgressBar { - public static PROGRESS_BAR_WIDTH = CELL_SIZE / 7.0; - - public container: createjs.Container; - public fillRatio: number; - - private backgroundRect: createjs.Shape; - private backgroundColor: string; - private fillRect: createjs.Shape; - private fillColor: string; - private bitmap: createjs.Bitmap; - private position: IGridPosition; - private distanceFromBottom: number; - - - /** - * Draws a progress rectangle with rounded ends. - * - * @param position The coordinates of the grid cell in which it should be located - * @param color The background color of the item - * @param container The container to which it should be drawn - * @param distanceFromBottom The index of its vertical position, counted from the bottom (0 is the lowest position) - * @param fractionFilled The fraction of the available horizontal space that the progress bar should take up - * @returns {createjs.Shape} The drawn shape - */ - public static drawItemProgressRectangle(position: IGridPosition, color: string, - container: createjs.Container, distanceFromBottom: number, - fractionFilled: number): createjs.Shape { - const shape = new createjs.Shape(); - shape.graphics.beginFill(color); - let x = position.x * CELL_SIZE + DCObjectLayer.ITEM_MARGIN + DCObjectLayer.ITEM_PADDING; - let y = (position.y + 1) * CELL_SIZE - DCObjectLayer.ITEM_MARGIN - DCObjectLayer.ITEM_PADDING - - DCProgressBar.PROGRESS_BAR_WIDTH - distanceFromBottom * - (DCProgressBar.PROGRESS_BAR_WIDTH + DCObjectLayer.PROGRESS_BAR_DISTANCE); - let width = (CELL_SIZE - (DCObjectLayer.ITEM_MARGIN + DCObjectLayer.ITEM_PADDING) * 2) * fractionFilled; - let height; - let radius; - - if (width < DCProgressBar.PROGRESS_BAR_WIDTH) { - height = width; - radius = width / 2; - y += (DCProgressBar.PROGRESS_BAR_WIDTH - height) / 2; - } else { - height = DCProgressBar.PROGRESS_BAR_WIDTH; - radius = DCProgressBar.PROGRESS_BAR_WIDTH / 2; - } - - shape.graphics.drawRoundRect( - x, y, width, height, radius - ); - container.addChild(shape); - return shape; - } - - /** - * Draws an bitmap in progressbar format. - * - * @param position The coordinates of the grid cell in which it should be located - * @param container The container to which it should be drawn - * @param originBitmap The bitmap that should be drawn - * @param distanceFromBottom The index of its vertical position, counted from the bottom (0 is the lowest position) - * @returns {createjs.Bitmap} The drawn bitmap - */ - public static drawProgressbarIcon(position: IGridPosition, container: createjs.Container, originBitmap: createjs.Bitmap, - distanceFromBottom: number): createjs.Bitmap { - const bitmap = originBitmap.clone(); - container.addChild(bitmap); - bitmap.x = (position.x + 0.5) * CELL_SIZE - DCProgressBar.PROGRESS_BAR_WIDTH * 0.5; - bitmap.y = (position.y + 1) * CELL_SIZE - DCObjectLayer.ITEM_MARGIN - DCObjectLayer.ITEM_PADDING - - DCProgressBar.PROGRESS_BAR_WIDTH - distanceFromBottom * - (DCProgressBar.PROGRESS_BAR_WIDTH + DCObjectLayer.PROGRESS_BAR_DISTANCE); - return bitmap; - } - - constructor(container: createjs.Container, backgroundColor: string, - fillColor: string, bitmap: createjs.Bitmap, position: IGridPosition, - indexFromBottom: number, fillRatio: number) { - this.container = container; - this.backgroundColor = backgroundColor; - this.fillColor = fillColor; - this.bitmap = bitmap; - this.position = position; - this.distanceFromBottom = indexFromBottom; - this.fillRatio = fillRatio; - } - - public draw() { - this.backgroundRect = DCProgressBar.drawItemProgressRectangle(this.position, this.backgroundColor, - this.container, this.distanceFromBottom, 1); - this.fillRect = DCProgressBar.drawItemProgressRectangle(this.position, this.fillColor, this.container, - this.distanceFromBottom, this.fillRatio); - - DCProgressBar.drawProgressbarIcon(this.position, this.container, this.bitmap, this.distanceFromBottom); - } -} |
