SE401:Group19:Feature:Colouring connections

From Marks Wiki
Jump to navigation Jump to search

◄ Back

Description

When the user confronts with complex function block network, it is hard to determine if the element is exactly what the user wants when trying to select. This implementation gives visual feedback to the users by changing the colour of the connection line when the mouse pointer is above the line.

Development

Implementation

Created a boolean called mouseEntered in the class GraphElement which sets true/false when the mouse pointer enters/exits the element using MouseListener methods mouseEntered(MouseEvent evt)/mouseExited(MouseEvent evt) respectively. When the mouse pointer enters the element, the element is moved to front of the panel with method ((JLayeredPane) p).moveToFront(this); to avoid other element blocking the full visibility, and moved to back of the panel to allow other elements to display properly when the mouse pointer exits the element. Once the boolean is set, when the elements are drawn in the class GraphEdge or GraphNode, it checks the boolean status and chooses colour.