1 /**********************************************************************
2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.core
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import java
.util
.ArrayList
;
18 import java
.util
.Arrays
;
19 import java
.util
.Comparator
;
20 import java
.util
.HashMap
;
21 import java
.util
.List
;
24 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.TmfUiTracer
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
30 * The base class used for all UML2 graph nodes displayed in the Sequence Diagram SDWidget.
35 public abstract class GraphNode
{
37 private static final String UI_DELIMITER
= "*****************************\n"; //$NON-NLS-1$
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 * The start event occurrence.
44 private int fStartEventOccurrence
= 0;
46 * The event event occurrence.
48 private int fEndEventOccurrence
= 0;
50 * Preference ColorId to use to draw font
52 private String fPrefId
= ISDPreferences
.PREF_SYNC_MESS
;
54 * The selection state of the graph node.
56 private boolean fSelected
= false;
58 * The focus state of the graph node.
60 private boolean fFocused
= false;
62 * Flag to indicate whether node has children or not.
64 private boolean fHasChilden
= false;
66 * The graph node name used to label the graph node in the View.
68 private String fName
= ""; //$NON-NLS-1$
70 * A map from node name to graph node.
72 private Map
<String
, List
<GraphNode
>> fNodes
;
74 * A map from node name to graph node for forward sorting
76 private Map
<String
, List
<GraphNode
>> fForwardNodes
;
78 * A map from node name to graph node for backwards sorting.
80 private Map
<String
, List
<GraphNode
>> fBackwardNodes
;
82 * A map from node name to index.
84 private Map
<String
, Integer
> fIndexes
;
86 * A map from node name to flag for forwards sorting.
88 private Map
<String
, Boolean
> fForwardSort
;
90 * A map from node name to flag for backwards sorting.
92 private Map
<String
, Boolean
> fBackwardSort
;
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
99 * Reset the internal index of the first visible GraphNode for each ordered GraphNode lists
101 public void resetIndex() {
106 for (Map
.Entry
<String
, Integer
> entry
: fIndexes
.entrySet()) {
107 entry
.setValue(Integer
.valueOf(0));
112 * Add a GraphNode into the receiver
114 * @param nodeToAdd the node to add
116 public void addNode(GraphNode nodeToAdd
) {
118 fNodes
= new HashMap
<>(2);
119 fForwardNodes
= new HashMap
<>(2);
120 fBackwardNodes
= new HashMap
<>(2);
121 fIndexes
= new HashMap
<>(2);
122 fBackwardSort
= new HashMap
<>(2);
123 fForwardSort
= new HashMap
<>(2);
128 if (nodeToAdd
== null) {
132 if (fNodes
.get(nodeToAdd
.getArrayId()) == null) {
133 fNodes
.put(nodeToAdd
.getArrayId(), new ArrayList
<GraphNode
>(1));
134 fIndexes
.put(nodeToAdd
.getArrayId(), Integer
.valueOf(0));
135 fForwardNodes
.put(nodeToAdd
.getArrayId(), new ArrayList
<GraphNode
>(1));
136 fForwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.FALSE
);
137 if (nodeToAdd
.getBackComparator() != null) {
138 fBackwardNodes
.put(nodeToAdd
.getArrayId(), new ArrayList
<GraphNode
>(1));
139 fBackwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.FALSE
);
143 List
<GraphNode
> fNodeList
= fForwardNodes
.get(nodeToAdd
.getArrayId());
144 List
<GraphNode
> bNodeList
= null;
145 if (fBackwardNodes
!= null) {
146 bNodeList
= fBackwardNodes
.get(nodeToAdd
.getArrayId());
148 if (fNodeList
!= null && fNodeList
.size() > 0) {
149 // check if the nodes are added y ordered
150 // if not, tag the list to sort it later (during draw)
151 GraphNode node
= fNodeList
.get(fNodeList
.size() - 1);
152 Comparator
<GraphNode
> fcomp
= nodeToAdd
.getComparator();
153 Comparator
<GraphNode
> bcomp
= nodeToAdd
.getBackComparator();
154 if ((fcomp
!= null) && (fcomp
.compare(node
, nodeToAdd
) > 0)) {
155 fForwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.TRUE
);
157 if ((bcomp
!= null) && (bcomp
.compare(node
, nodeToAdd
) > 0)) {
158 fBackwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.TRUE
);
162 if (fNodeList
== null) {
163 fNodeList
= new ArrayList
<>();
166 fNodeList
.add(nodeToAdd
);
167 fNodes
.put(nodeToAdd
.getArrayId(), fNodeList
);
168 fForwardNodes
.put(nodeToAdd
.getArrayId(), fNodeList
);
169 if ((bNodeList
!= null) && (nodeToAdd
.getBackComparator() != null)) {
170 bNodeList
.add(nodeToAdd
);
171 fBackwardNodes
.put(nodeToAdd
.getArrayId(), bNodeList
);
176 * Set the graph node name.<br>
177 * It is the name display in the view to label the graph node.
179 * @param nodeName the name to set
181 public void setName(String nodeName
) {
186 * Returns the graph node name.<br>
187 * It is the name display in the view to label the graph node.
189 * @return the graph node name
191 public String
getName() {
196 * Tags the the graph node has selected.<br>
197 * WARNING: This method is only used to draw the graph node using the system selection colors. <br>
198 * To use the complete SDViewer selection mechanism (selection management, notification, etc..) see SDWidget class
200 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#addSelection(GraphNode)
201 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#removeSelection(GraphNode)
202 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#clearSelection()
203 * @param selection - true to set selected, false to set unselected
205 public void setSelected(boolean selection
) {
206 fSelected
= selection
;
210 * Tags the the graph node as focused.<br>
211 * WARNING: This method is only used to draw the graph node using the system focus style. <br>
212 * To use the complete SDViewer focus mechanism see SDWidget class
214 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#addSelection(GraphNode)
215 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#removeSelection(GraphNode)
216 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#clearSelection()
217 * @param focus - true to set focued, false otherwise
219 public void setFocused(boolean focus
) {
224 * Returns true if the graph node is selected, false otherwise.<br>
225 * The returned value is used to highlight the graph node in the View.
227 * @return true if selected, false otherwise
229 public boolean isSelected() {
234 * Returns true if the graph node is focused, false otherwise.<br>
235 * The returned value is used to highlight the graph node in the View.
237 * @return true if focused, false otherwise
239 public boolean hasFocus() {
244 * Returns true if the graph node contains the point given in parameter,
245 * return false otherwise.
248 * the x coordinate of the point to test containment
250 * the y coordinate of the point to test containment
251 * @return true if contained, false otherwise
253 public abstract boolean contains(int x
, int y
);
256 * Returns the x coordinate of the graph node
258 * @return the x coordinate
260 public abstract int getX();
263 * Returns the y coordinate of the graph node
265 * @return the y coordinate
267 public abstract int getY();
270 * Returns the graph node height
272 * @return the graph node height
274 public abstract int getHeight();
277 * Returns the graph node width
279 * @return the graph node width
281 public abstract int getWidth();
284 * Draws the graph node in the given context
286 * @param context the graphical context to draw in
288 protected abstract void draw(IGC context
);
291 * Returns the GraphNode visibility for the given visible area. Wrong
292 * visibility calculation, may strongly impact drawing performance
299 * The width of the area
301 * The height of the area
302 * @return true if visible, false otherwise
304 public boolean isVisible(int x
, int y
, int width
, int height
) {
309 * Return a comparator to sort the GraphNode of the same type This
310 * comparator is used to order the GraphNode array of the given node type.
313 * @return the comparator
315 public Comparator
<GraphNode
> getComparator() {
320 * If needed, return a different comparator to backward scan the GraphNode
323 * @return the backward comparator or null if not needed
325 public Comparator
<GraphNode
> getBackComparator() {
330 * Compare two graphNodes
333 * the node to compare to
334 * @return true if equal false otherwise
336 public boolean isSameAs(GraphNode node
) {
341 * Return the node type for all class instances. This id is used to store the same nodes kind in the same ordered
344 * @return the node type identifier
346 public abstract String
getArrayId();
349 * Return true if the distance from the GraphNode to the given point is positive
351 * @param x the point x coordinate
352 * @param y the point y coordinate
353 * @return true if positive false otherwise
355 public boolean positiveDistanceToPoint(int x
, int y
) {
360 * Returns the graph node which contains the point given in parameter WARNING: Only graph nodes in the current
361 * visible area can be returned
363 * @param x the x coordinate of the point to test
364 * @param y the y coordinate of the point to test
365 * @return the graph node containing the point given in parameter, null otherwise
367 public GraphNode
getNodeAt(int x
, int y
) {
368 GraphNode toReturn
= null;
374 GraphNode node
= null;
375 for (Map
.Entry
<String
, List
<GraphNode
>> entry
: fNodes
.entrySet()) {
376 List
<GraphNode
> list
= entry
.getValue();
377 int index
= checkNotNull(fIndexes
.get(entry
.getKey())).intValue();
378 node
= getNodeFromListAt(x
, y
, list
, index
);
379 if (toReturn
== null) {
383 GraphNode internalNode
= node
.getNodeAt(x
, y
);
384 if (internalNode
!= null) {
386 } else if (Math
.abs(node
.getWidth()) < Math
.abs(toReturn
.getWidth()) || Math
.abs(node
.getHeight()) < Math
.abs(toReturn
.getHeight())) {
395 * Gets node list from node A to node B
397 * @param from A from node
398 * @param to A to node
399 * @return the list of nodes
401 public List
<GraphNode
> getNodeList(GraphNode from
, GraphNode to
) {
402 List
<GraphNode
> result
= new ArrayList
<>();
406 } else if (to
!= null) {
410 if ((from
== null) || (to
== null)) {
418 int startX
= Math
.min(from
.getX(), Math
.min(to
.getX(), Math
.min(from
.getX() + from
.getWidth(), to
.getX() + to
.getWidth())));
419 int endX
= Math
.max(from
.getX(), Math
.max(to
.getX(), Math
.max(from
.getX() + from
.getWidth(), to
.getX() + to
.getWidth())));
420 int startY
= Math
.min(from
.getY(), Math
.min(to
.getY(), Math
.min(from
.getY() + from
.getHeight(), to
.getY() + to
.getHeight())));
421 int endY
= Math
.max(from
.getY(), Math
.max(to
.getY(), Math
.max(from
.getY() + from
.getHeight(), to
.getY() + to
.getHeight())));
427 for (Map
.Entry
<String
, List
<GraphNode
>> entry
: fNodes
.entrySet()) {
428 List
<GraphNode
> nodesList
= entry
.getValue();
429 if (nodesList
== null || nodesList
.isEmpty()) {
432 for (int i
= 0; i
< nodesList
.size(); i
++) {
433 GraphNode node
= nodesList
.get(i
);
434 int nw
= node
.getWidth();
435 int nh
= node
.getHeight();
436 int nx
= node
.getX();
437 int ny
= node
.getY();
438 if (contains(startX
, startY
, endX
- startX
, endY
- startY
, nx
+ 1, ny
+ 1) && contains(startX
, startY
, endX
- startX
, endY
- startY
, nx
+ nw
- 2, ny
+ nh
- 2)) {
441 result
.addAll(node
.getNodeList(from
, to
));
445 if (!result
.contains(to
)) {
452 * Returns the graph node which contains the point given in parameter for the given graph node list and starting the
453 * iteration at the given index<br>
454 * WARNING: Only graph nodes with smaller coordinates than the current visible area can be returned.<br>
456 * @param x the x coordinate of the point to test
457 * @param y the y coordinate of the point to test
458 * @param list the list to search in
459 * @param fromIndex list browsing starting point
460 * @return the graph node containing the point given in parameter, null otherwise
462 protected GraphNode
getNodeFromListAt(int x
, int y
, List
<GraphNode
> list
, int fromIndex
) {
466 for (int i
= fromIndex
; i
< list
.size(); i
++) {
467 GraphNode node
= list
.get(i
);
468 if (node
.contains(x
, y
)) {
476 * Returns the start event occurrence attached to this graphNode.
478 * @return the start event occurrence attached to the graphNode
480 public int getStartOccurrence() {
481 return fStartEventOccurrence
;
485 * Returns the end event occurrence attached to this graphNode
487 * @return the start event occurrence attached to the graphNode
489 public int getEndOccurrence() {
490 return fEndEventOccurrence
;
494 * Computes the index of the first visible GraphNode for each ordered graph node lists depending on the visible area
497 * @param x visible area top left corner x coordinate
498 * @param y visible area top left corner y coordinate
499 * @param width visible area width
500 * @param height visible area height
502 public void updateIndex(int x
, int y
, int width
, int height
) {
506 if(TmfUiTracer
.isIndexTraced()) {
507 TmfUiTracer
.traceIndex(UI_DELIMITER
);
508 TmfUiTracer
.traceIndex("Visible area position in virtual screen (x,y)= " + x
+ " " + y
+ "\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
511 for (Map
.Entry
<String
, List
<GraphNode
>> entry
: fNodes
.entrySet()) {
512 String nodeType
= entry
.getKey();
514 int drawIndex
= checkNotNull(fIndexes
.get(nodeType
)).intValue();
515 if ((entry
.getValue() != null) && (entry
.getValue().size() > 1)) {
516 if (entry
.getValue().get(drawIndex
).positiveDistanceToPoint(x
, y
)) {
520 if (drawIndex
== 0) {
524 List
<GraphNode
> nodes
= fBackwardNodes
.get(nodeType
);
525 if ((direction
== -1) && (nodes
!= null)) {
526 GraphNode currentNode
= entry
.getValue().get(drawIndex
);
527 drawIndex
= Arrays
.binarySearch(nodes
.toArray(new GraphNode
[nodes
.size()]),
528 entry
.getValue().get(drawIndex
), currentNode
.getBackComparator());
529 entry
.setValue(nodes
);
534 entry
.setValue(fBackwardNodes
.get(nodeType
));
537 GraphNode prev
= null;
539 for (int i
= drawIndex
; i
< entry
.getValue().size() && i
>= 0; i
= i
+ direction
) {
541 fIndexes
.put(nodeType
, Integer
.valueOf(i
));
543 GraphNode currentNode
= entry
.getValue().get(i
);
549 Comparator
<GraphNode
> comp
= currentNode
.getComparator();
550 Map
<String
, Boolean
> sort
= fForwardSort
;
552 if ((direction
== -1) && (currentNode
.getBackComparator() != null)) {
553 comp
= currentNode
.getBackComparator();
554 sort
= fBackwardSort
;
557 if (i
< entry
.getValue().size() - 1) {
558 GraphNode next
= entry
.getValue().get(i
+ 1);
560 if ((comp
!= null) && (comp
.compare(currentNode
, next
) > 0)) {
561 sort
.put(nodeType
, Boolean
.TRUE
);
564 if (direction
== 1) {
565 if (entry
.getValue().get(i
).positiveDistanceToPoint(x
, y
)) {
569 if (currentNode
.getBackComparator() == null) {
570 if (!currentNode
.positiveDistanceToPoint(x
, y
)) {
574 if (currentNode
.isVisible(x
, y
, width
, height
) && !currentNode
.positiveDistanceToPoint(x
, y
)) {
575 if ((comp
!= null) && (comp
.compare(currentNode
, prev
) <= 0)) {
578 } else if ((comp
!= null) && (comp
.compare(currentNode
, prev
) <= 0)) {
585 entry
.setValue(fForwardNodes
.get(nodeType
));
586 if ((fBackwardNodes
.get(nodeType
) != null) && (direction
== -1)) {
587 int index
= checkNotNull(fIndexes
.get(nodeType
)).intValue();
588 List
<GraphNode
> list
= entry
.getValue();
589 List
<GraphNode
> backList
= checkNotNull(fBackwardNodes
.get(nodeType
));
590 GraphNode currentNode
= (backList
.get(index
));
592 index
= Arrays
.binarySearch(list
.toArray(new GraphNode
[list
.size()]), backList
.get(index
), currentNode
.getComparator());
596 fIndexes
.put(nodeType
, Integer
.valueOf(index
));
600 for (int i
= drawIndex
; i
< entry
.getValue().size() && i
>= 0; i
++) {
601 GraphNode toDraw
= entry
.getValue().get(i
);
602 toDraw
.updateIndex(x
, y
, width
, height
);
603 if (!toDraw
.isVisible(x
, y
, width
, height
)) {
608 if (TmfUiTracer
.isIndexTraced()) {
609 TmfUiTracer
.traceIndex("First drawn " + nodeType
+ " index = " + drawIndex
+ "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
610 TmfUiTracer
.traceIndex(nodeType
+ " found in " + 0 + " iterations\n"); //$NON-NLS-1$ //$NON-NLS-2$
614 if (TmfUiTracer
.isIndexTraced()) {
615 TmfUiTracer
.traceIndex(UI_DELIMITER
);
620 * Draws the children nodes on the given context.<br>
621 * This method start width GraphNodes ordering if needed.<br>
622 * After, depending on the visible area, only visible GraphNodes are drawn.<br>
624 * @param context the context to draw to
625 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode#draw(IGC)
627 protected void drawChildenNodes(IGC context
) {
632 // If the nodes have not been added ordered, the array is ordered
633 for (Map
.Entry
<String
, Boolean
> entry
: fForwardSort
.entrySet()) {
634 boolean sort
= entry
.getValue().booleanValue();
636 sortNodes(fForwardNodes
, entry
, true);
640 for (Map
.Entry
<String
, Boolean
> entry
: fBackwardSort
.entrySet()) {
641 boolean sort
= entry
.getValue().booleanValue();
643 sortNodes(fBackwardNodes
, entry
, false);
647 if (TmfUiTracer
.isDisplayTraced()) {
648 TmfUiTracer
.traceDisplay(UI_DELIMITER
);
652 if ((Metrics
.getMessageFontHeigth() + Metrics
.MESSAGES_NAME_SPACING
* 2) * context
.getZoom() < Metrics
.MESSAGE_SIGNIFICANT_VSPACING
) {
653 arrayStep
= Math
.round(Metrics
.MESSAGE_SIGNIFICANT_VSPACING
/ ((Metrics
.getMessageFontHeigth() + Metrics
.MESSAGES_NAME_SPACING
* 2) * context
.getZoom()));
657 for (Map
.Entry
<String
, Boolean
> entry
: fForwardSort
.entrySet()) {
659 String nodeType
= entry
.getKey();
660 GraphNode node
= checkNotNull(fNodes
.get(nodeType
)).get(0);
661 context
.setFont(SDViewPref
.getInstance().getFont(node
.fPrefId
));
662 int index
= checkNotNull(fIndexes
.get(nodeType
)).intValue();
663 count
= drawNodes(context
, fNodes
.get(nodeType
), index
, arrayStep
);
664 if (TmfUiTracer
.isDisplayTraced()) {
665 TmfUiTracer
.traceDisplay(count
+ " " + nodeType
+ " drawn, starting from index " + index
+ "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
668 if (TmfUiTracer
.isDisplayTraced()) {
669 TmfUiTracer
.traceDisplay(UI_DELIMITER
);
674 private void sortNodes(Map
<String
, List
<GraphNode
>> nodesToSort
, Map
.Entry
<String
, Boolean
> sortMapEntry
, boolean forward
) {
675 String nodeType
= sortMapEntry
.getKey();
676 GraphNode
[] temp
= checkNotNull(nodesToSort
.get(nodeType
)).stream().toArray(GraphNode
[]::new);
677 GraphNode node
= checkNotNull(fNodes
.get(nodeType
)).get(0);
679 Arrays
.sort(temp
, node
.getComparator());
680 fNodes
.put(nodeType
, Arrays
.asList(temp
));
682 Arrays
.sort(temp
, node
.getBackComparator());
684 nodesToSort
.put(nodeType
, Arrays
.asList(temp
));
685 sortMapEntry
.setValue(Boolean
.FALSE
);
686 if (TmfUiTracer
.isSortingTraced()) {
687 TmfUiTracer
.traceSorting(nodeType
+ " array sorted\n"); //$NON-NLS-1$
692 * Draw the GraphNode stored in the given list, starting at index startIndex with the given step
694 * @param context the context to draw to
695 * @param list the GraphNodes list
696 * @param startIndex the start index
697 * @param step the step to browse the list
698 * @return the number of GraphNodes drawn
700 protected int drawNodes(IGC context
, List
<GraphNode
> list
, int startIndex
, int step
) {
705 GraphNode last
= null;
707 if (list
.isEmpty()) {
711 GraphNode node
= list
.get(0);
712 context
.setFont(SDViewPref
.getInstance().getFont(node
.fPrefId
));
713 Comparator
<GraphNode
> comparator
= node
.getComparator();
714 for (int i
= startIndex
; i
< list
.size(); i
= i
+ step
) {
715 GraphNode toDraw
= list
.get(i
);
716 if (i
< list
.size() - 1) {
717 GraphNode next
= list
.get(i
+ 1);
718 if ((comparator
!= null) && (comparator
.compare(toDraw
, next
) > 0)) {
719 fForwardSort
.put(next
.getArrayId(), Boolean
.TRUE
);
722 int cx
= context
.getContentsX();
723 int cy
= context
.getContentsY();
724 int cw
= context
.getVisibleWidth();
725 int ch
= context
.getVisibleHeight();
726 // The arrays should be ordered, no needs to continue for this one
727 if (!toDraw
.isVisible(cx
, cy
, cw
, ch
) && toDraw
.positiveDistanceToPoint(cx
+ cw
, cy
+ ch
)) {
730 // ***Common*** nodes visibility
731 if ((!toDraw
.isSameAs(last
) || toDraw
.isSelected()) && (toDraw
.isVisible(context
.getContentsX(), context
.getContentsY(), context
.getVisibleWidth(), context
.getVisibleHeight()))) {
734 toDraw
.draw(context
);
736 toDraw
.drawFocus(context
);
745 * Draws the focus within the graphical context.
750 public void drawFocus(IGC context
) {
751 context
.drawFocus(getX(), getY(), getWidth(), getHeight());
755 * Determine if the given point (px,py) is contained in the rectangle (x,y,width,height)
757 * @param x the rectangle x coordinate
758 * @param y the rectangle y coordinate
759 * @param width the rectangle width
760 * @param height the rectangle height
761 * @param px the x coordinate of the point to test
762 * @param py the y coordinate of the point to test
763 * @return true if contained false otherwise
765 public static boolean contains(int x
, int y
, int width
, int height
, int px
, int py
) {
768 int locWidth
= width
;
769 int locHeight
= height
;
773 locWidth
= -locWidth
;
777 locY
= locY
+ height
;
778 locHeight
= -locHeight
;
780 return (px
>= locX
) && (py
>= locY
) && ((px
- locX
) <= locWidth
) && ((py
- locY
) <= locHeight
);
784 * Sets the start event occurrence attached to this graphNode.
787 * the start event occurrence attached to the graphNode
789 protected void setStartOccurrence(int occurence
) {
790 fStartEventOccurrence
= occurence
;
794 * Sets the end event occurrence attached to this graphNode
797 * the start event occurrence attached to the graphNode
799 protected void setEndOccurrence(int occurence
) {
800 fEndEventOccurrence
= occurence
;
804 * Sets the color preference id
806 * The color preference id
808 protected void setColorPrefId(String id
) {
813 * Gets the color preference id
814 * @return the color preference id
816 protected String
getColorPrefId() {
821 * @return if node has children or not
823 protected boolean hasChildren() {
828 * Sets the flag indicating where the node has children or not.
830 * if node has children or not
832 protected void hasChildren(boolean hasChildren
) {
833 fHasChilden
= hasChildren
;
836 * Returns a map from node name to graph node.
838 * @return map with children graph bodes
840 protected Map
<String
, List
<GraphNode
>> getNodeMap() {
844 * Returns a map from node name to graph node for forward sorting
846 * @return forward sorting map
848 protected Map
<String
, List
<GraphNode
>> getForwardNodes() {
849 return fForwardNodes
;
852 * Returns a map from node name to graph node for backwards sorting.
854 * @return backwards sorting map
856 protected Map
<String
, List
<GraphNode
>> getBackwardNodes() {
857 return fBackwardNodes
;
860 * Returns a map from node name to index.
862 * @return map with node name to index
864 protected Map
<String
, Integer
> getIndexes() {
869 * Returns a map from node name to sort flag for forwards sorting.
870 * @return a map from node name to sort flag
872 protected Map
<String
, Boolean
> getForwardSortMap() {
876 * Returns a map from node name to flag for backwards sorting.
877 * @return map from node name to flag for backwards sorting.
879 protected Map
<String
, Boolean
> getBackwardSortMap() {
880 return fBackwardSort
;