/*
 * ********************************************************************************************************************
 *
 *                      :*$@@%$*:                         ;:                ;;    ;;
 *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
 *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
 *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
 *                   =@*                                  %!              @ $= % %@=   =%@!      %=
 *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
 *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
 *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
 *          $@*   ;@@@%=!:                *@*
 *          =@$    ;;;!=%@@@@=!           =@!
 *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
 *            ;%@@$=$@@%*       *@@@$=%@@%;
 *               ::;::             ::;::                                              All rights reserved.
 *
 * ********************************************************************************************************************
 */
// @ts-nocheck
import { SGraphItem } from "@saga-web/graph/lib";
import { SColor, SLine, SPainter, SPoint, SRect } from "@saga-web/draw/lib";
import { ItemOrder, ItemColor } from '@saga-web/big/lib';

/**
 * 吸附时高亮对象
 *
 * @author  郝建龙
 */
export class HighlightItem extends SGraphItem {
    /** 对象与鼠标位置距离   */
    distance: number = 0;
    /** 对象类型   */
    private type: number = 1;

    /** 点对象数据-当吸附的为线时,此点为垂线与线段的交点   */
    _point: SPoint = new SPoint();
    get point(): SPoint {
        return this._point;
    } // Get point
    set point(v: SPoint) {
        this._point = v;
        this.type = 1;
        this.update();
    } // Set point

    /** 点对象数据   */
    _line: SLine = new SLine();
    get line(): SLine {
        return this._line;
    } // Get line
    set line(v: SLine) {
        this._line = v;
        this.type = 2;
        this.update();
    } // Set line

    /**
     * 构造函数
     *
     * @param   parent  指向父对象
     */
    constructor(parent: SGraphItem | null) {
        super(parent);
        this.visible = false;
        this.zOrder = ItemOrder.highLightOrder;
    } // Constructor

    /**
     * Item对象边界区域
     *
     * @return	SRect
     */
    boundingRect(): SRect {
        return new SRect(this.point.x, this.point.y, 10, 10);
    } // Function boundingRect()

    /**
     * Item绘制操作
     *
     * @param   painter painter对象
     */
    onDraw(painter: SPainter): void {
        if (this.type == 2) {
            painter.pen.color = ItemColor.highLightLineColor;
            painter.pen.lineWidth = painter.toPx(6);
            painter.drawLine(this.line);
        }
        painter.pen.color = SColor.Transparent;
        painter.brush.color = ItemColor.highLightPointColor;
        painter.drawCircle(this.point.x, this.point.y, painter.toPx(5));
    } // Function onDraw()
} // Class HighlightItem
