• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package ohos.devtools.views.trace;
17 
18 import com.intellij.ui.components.JBPanel;
19 
20 import java.awt.Graphics2D;
21 import java.awt.Point;
22 import java.awt.Rectangle;
23 import java.awt.event.MouseEvent;
24 import java.util.List;
25 
26 /**
27  * AbstractNode
28  *
29  * @since 2021/5/14 14:54
30  */
31 public abstract class AbstractNode {
32     /**
33      * current Rectangle
34      */
35     protected Rectangle rect = new Rectangle();
36 
37     /**
38      * boolean is Mouse In this node
39      */
40     protected boolean isMouseIn;
41 
42     /**
43      * edge inspect
44      *
45      * @return return the current Rectangle
46      */
getRect()47     public Rectangle getRect() {
48         return rect;
49     }
50 
51     /**
52      * set the Rectangle
53      *
54      * @param rect rect
55      */
setRect(Rectangle rect)56     public void setRect(Rectangle rect) {
57         this.rect = rect;
58     }
59 
60     /**
61      * node draw function
62      *
63      * @param paint Graphics2D
64      */
draw(Graphics2D paint)65     public abstract void draw(Graphics2D paint);
66 
67     /**
68      * get the string list
69      *
70      * @param time String
71      * @return string list
72      */
getStringList(String time)73     public abstract List<String> getStringList(String time);
74 
75     /**
76      * when the mouse move into this node
77      *
78      * @param point point
79      * @param content content
80      */
moveIn(Point point, JBPanel content)81     public void moveIn(Point point, JBPanel content) {
82         isMouseIn = true;
83         content.repaint(getRect());
84     }
85 
86     /**
87      * when the mouse move out from this node
88      *
89      * @param point point
90      * @param content content
91      */
moveOut(Point point, JBPanel content)92     public void moveOut(Point point, JBPanel content) {
93         isMouseIn = false;
94         content.repaint(getRect());
95     }
96 
97     /**
98      * when the node click
99      *
100      * @param event event
101      */
onClick(MouseEvent event)102     public void onClick(MouseEvent event) {
103         event.getX();
104     }
105 }
106