|
@@ -1,232 +0,0 @@
|
|
|
-/*
|
|
|
- * *********************************************************************************************************************
|
|
|
- *
|
|
|
- * !!
|
|
|
- * .F88X
|
|
|
- * X8888Y
|
|
|
- * .}888888N;
|
|
|
- * i888888N; .:! .I$WI:
|
|
|
- * R888888I .'N88~ i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
|
|
|
- * .R888888I .;N8888~ .X8' "8I.!,/8" !%NY8`"8I8~~8>,88I
|
|
|
- * +888888N; .8888888Y "&&8Y.}8,
|
|
|
- * ./888888N; .R888888Y .'}~ .>}'.`+> i}! "i' +/' .'i~ !11,.:">, .~]! .i}i
|
|
|
- * ~888888%: .I888888l .]88~`1/iY88Ii+1'.R$8$8]"888888888> Y8$ W8E X8E W8888'188Il}Y88$*
|
|
|
- * 18888888 E8888881 .]W%8$`R8X'&8%++N8i,8N%N8+l8%` .}8N:.R$RE%N88N%N$K$R 188,FE$8%~Y88I
|
|
|
- * .E888888I .i8888888' .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
|
|
|
- * 8888888I .,N888888~ ~88i"8W,!N8*.I88.}888%F,i$88"F88" 888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
|
|
|
- * i888888N' I888Y ]88;/EX*IFKFK88X K8R .l8W 88Y ~88}'88E&%8W.X8N``]88!.$8K .:W8I
|
|
|
- * .i888888N; I8Y .&8$ .X88! i881.:%888>I88 ;88] +88+.';;;;:.Y88X 18N.,88l .+88/
|
|
|
- * .:R888888I
|
|
|
- * .&888888I Copyright (c) 2016-2020. 博锐尚格科技股份有限公司
|
|
|
- * ~8888'
|
|
|
- * .!88~ All rights reserved.
|
|
|
- *
|
|
|
- * *********************************************************************************************************************
|
|
|
- */
|
|
|
-
|
|
|
-import {
|
|
|
- SColor,
|
|
|
- SLineCapStyle,
|
|
|
- SPainter,
|
|
|
- SRect,
|
|
|
- SSize
|
|
|
-} from "@persagy-web/draw/lib";
|
|
|
-import { SGraphItem } from "../SGraphItem";
|
|
|
-
|
|
|
-/**
|
|
|
- * 线Item类
|
|
|
- *
|
|
|
- * @author 庞利祥(sybotan@126.com)
|
|
|
- */
|
|
|
-export class SGraphClockItem extends SGraphItem {
|
|
|
- /** 大小 */
|
|
|
- size: SSize;
|
|
|
-
|
|
|
- /** 宽度 */
|
|
|
- get width() {
|
|
|
- return this.size.width;
|
|
|
- } // Get width
|
|
|
- set width(v: number) {
|
|
|
- this.size.width = v;
|
|
|
- } // Set width
|
|
|
-
|
|
|
- /** 高度 */
|
|
|
- get height() {
|
|
|
- return this.size.height;
|
|
|
- } // Get width
|
|
|
- set height(v: number) {
|
|
|
- this.size.height = v;
|
|
|
- } // Set width
|
|
|
-
|
|
|
- /** 半径 */
|
|
|
- get radius() {
|
|
|
- return Math.min(this.width, this.height) / 2.0;
|
|
|
- } // Get radius
|
|
|
-
|
|
|
- /**
|
|
|
- * 构造函数
|
|
|
- *
|
|
|
- * @param parent 指向父Item
|
|
|
- * @param size 大小
|
|
|
- */
|
|
|
- constructor(parent: SGraphItem | null, size: SSize);
|
|
|
-
|
|
|
- /**
|
|
|
- * 构造函数
|
|
|
- *
|
|
|
- * @param parent 指向父Item
|
|
|
- * @param width 宽度
|
|
|
- * @param height 高度
|
|
|
- */
|
|
|
- constructor(parent: SGraphItem | null, width: number, height: number);
|
|
|
-
|
|
|
- /**
|
|
|
- * 构造函数
|
|
|
- *
|
|
|
- * @param parent 指向父Item
|
|
|
- * @param width 宽度
|
|
|
- * @param height 高度
|
|
|
- */
|
|
|
- constructor(
|
|
|
- parent: SGraphItem | null,
|
|
|
- width: number | SSize,
|
|
|
- height?: number
|
|
|
- ) {
|
|
|
- super(parent);
|
|
|
- if (width instanceof SSize) {
|
|
|
- this.size = new SSize(width.width, width.height);
|
|
|
- } else {
|
|
|
- this.size = new SSize(width as number, height as number);
|
|
|
- }
|
|
|
- } // Constructor()
|
|
|
-
|
|
|
- /**
|
|
|
- * 对象边界区域
|
|
|
- *
|
|
|
- * @return 边界区域
|
|
|
- */
|
|
|
- boundingRect(): SRect {
|
|
|
- return new SRect(0, 0, this.width, this.height);
|
|
|
- } // Function SRect()
|
|
|
-
|
|
|
- /**
|
|
|
- * Item绘制操作
|
|
|
- *
|
|
|
- * @param painter painter对象
|
|
|
- */
|
|
|
- onDraw(painter: SPainter): void {
|
|
|
- painter.translate(this.width / 2, this.height / 2);
|
|
|
- let t = new Date();
|
|
|
-
|
|
|
- this.drawScale(painter);
|
|
|
- this.drawHour(painter, t.getHours(), t.getMinutes(), t.getSeconds());
|
|
|
- this.drawMinute(painter, t.getMinutes(), t.getSeconds());
|
|
|
- this.drawSecond(painter, t.getSeconds() + t.getMilliseconds() / 1000.0);
|
|
|
- } // Function onDraw()
|
|
|
-
|
|
|
- /**
|
|
|
- * 绘制表刻度
|
|
|
- *
|
|
|
- * @param painter painter对象
|
|
|
- */
|
|
|
- private drawScale(painter: SPainter): void {
|
|
|
- let scaleLength = Math.max(this.radius / 10.0, 2.0);
|
|
|
- let scaleLength1 = scaleLength * 1.2;
|
|
|
- let strokeWidth = Math.max(this.radius / 100.0, 2.0);
|
|
|
- let strokeWidth1 = strokeWidth * 2.0;
|
|
|
-
|
|
|
- painter.save();
|
|
|
- painter.pen.color = SColor.Blue;
|
|
|
-
|
|
|
- for (let i = 1; i <= 12; i++) {
|
|
|
- // 12小时刻度
|
|
|
- painter.pen.lineWidth = strokeWidth1;
|
|
|
- painter.drawLine(0, -this.radius, 0, -this.radius + scaleLength1);
|
|
|
-
|
|
|
- if (this.radius >= 40) {
|
|
|
- // 如果半度大于40显示分钟刻度
|
|
|
- painter.rotate(6);
|
|
|
- for (let j = 1; j <= 4; j++) {
|
|
|
- // 分钟刻度
|
|
|
- painter.pen.lineWidth = strokeWidth;
|
|
|
- painter.drawLine(
|
|
|
- 0,
|
|
|
- -this.radius,
|
|
|
- 0,
|
|
|
- -this.radius + scaleLength
|
|
|
- );
|
|
|
- painter.rotate(6);
|
|
|
- }
|
|
|
- } else {
|
|
|
- painter.rotate(30);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- painter.restore();
|
|
|
- } // Function drawScale()
|
|
|
-
|
|
|
- /**
|
|
|
- * 绘制时针
|
|
|
- *
|
|
|
- * @param painter painter对象
|
|
|
- * @param hour 时
|
|
|
- * @param minute 分
|
|
|
- * @param second 秒
|
|
|
- */
|
|
|
- private drawHour(
|
|
|
- painter: SPainter,
|
|
|
- hour: number,
|
|
|
- minute: number,
|
|
|
- second: number
|
|
|
- ): void {
|
|
|
- painter.save();
|
|
|
- painter.pen.lineCapStyle = SLineCapStyle.Round;
|
|
|
- painter.pen.lineWidth = Math.max(this.radius / 30.0, 4.0);
|
|
|
- painter.rotate(
|
|
|
- hour * 30.0 + (minute * 30.0) / 60 + (second * 30.0) / 3600
|
|
|
- );
|
|
|
- painter.drawLine(0, this.radius / 10.0, 0, -this.radius / 2.0);
|
|
|
- painter.restore();
|
|
|
- } // Function drawHour()
|
|
|
-
|
|
|
- /**
|
|
|
- * 绘制秒针
|
|
|
- *
|
|
|
- * @param painter painter对象
|
|
|
- * @param minute 分
|
|
|
- * @param second 秒
|
|
|
- */
|
|
|
- private drawMinute(
|
|
|
- painter: SPainter,
|
|
|
- minute: number,
|
|
|
- second: number
|
|
|
- ): void {
|
|
|
- painter.save();
|
|
|
- painter.pen.lineCapStyle = SLineCapStyle.Round;
|
|
|
- painter.pen.lineWidth = Math.max(this.radius / 40.0, 4.0);
|
|
|
- painter.rotate(minute * 6 + (second * 6) / 60.0);
|
|
|
- painter.drawLine(0, this.radius / 10.0, 0, (-this.radius * 2.0) / 3.0);
|
|
|
- painter.restore();
|
|
|
- } // Function drawMinute()
|
|
|
-
|
|
|
- /**
|
|
|
- * 绘制秒针
|
|
|
- *
|
|
|
- * @param painter painter对象
|
|
|
- * @param second 秒
|
|
|
- */
|
|
|
- private drawSecond(painter: SPainter, second: number): void {
|
|
|
- painter.save();
|
|
|
- painter.pen.lineCapStyle = SLineCapStyle.Round;
|
|
|
- painter.pen.lineWidth = Math.max(this.radius / 100.0, 3.0);
|
|
|
- painter.pen.color = SColor.Red;
|
|
|
- painter.rotate(second * 6);
|
|
|
- painter.drawLine(
|
|
|
- 0,
|
|
|
- this.radius / 5.0,
|
|
|
- 0,
|
|
|
- -this.radius + this.radius / 10.0
|
|
|
- );
|
|
|
- painter.restore();
|
|
|
- } // Function drawSecond()
|
|
|
-} // Class SGraphClockItem
|