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 java
.util
.ArrayList
;
16 import java
.util
.Arrays
;
17 import java
.util
.Comparator
;
18 import java
.util
.HashMap
;
19 import java
.util
.Iterator
;
20 import java
.util
.List
;
23 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.TmfUiTracer
;
24 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.drawings
.IGC
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.ISDPreferences
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.uml2sd
.preferences
.SDViewPref
;
29 * The base class used for all UML2 graph nodes displayed in the Sequence Diagram SDWidget.
34 public abstract class GraphNode
{
36 private static final String UI_DELIMITER
= "*****************************\n"; //$NON-NLS-1$
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 * The start event occurrence.
43 private int fStartEventOccurrence
= 0;
45 * The event event occurrence.
47 private int fEndEventOccurrence
= 0;
49 * Preference ColorId to use to draw font
51 private String fPrefId
= ISDPreferences
.PREF_SYNC_MESS
;
53 * The selection state of the graph node.
55 private boolean fSelected
= false;
57 * The focus state of the graph node.
59 private boolean fFocused
= false;
61 * Flag to indicate whether node has children or not.
63 private boolean fHasChilden
= false;
65 * The graph node name used to label the graph node in the View.
67 private String fName
= ""; //$NON-NLS-1$
69 * A map from node name to graph node.
71 private Map
<String
, List
<GraphNode
>> fNodes
;
73 * A map from node name to graph node for forward sorting
75 private Map
<String
, List
<GraphNode
>> fForwardNodes
;
77 * A map from node name to graph node for backwards sorting.
79 private Map
<String
, List
<GraphNode
>> fBackwardNodes
;
81 * A map from node name to index.
83 private Map
<String
, Integer
> fIndexes
;
85 * A map from node name to flag for forwards sorting.
87 private Map
<String
, Boolean
> fForwardSort
;
89 * A map from node name to flag for backwards sorting.
91 private Map
<String
, Boolean
> fBackwardSort
;
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
98 * Reset the internal index of the first visible GraphNode for each ordered GraphNode lists
100 public void resetIndex() {
105 Iterator
<String
> it
= fIndexes
.keySet().iterator();
106 while (it
.hasNext()) {
107 String nodeType
= it
.next();
108 fIndexes
.put(nodeType
, Integer
.valueOf(0));
113 * Add a GraphNode into the receiver
115 * @param nodeToAdd the node to add
117 public void addNode(GraphNode nodeToAdd
) {
119 fNodes
= new HashMap
<>(2);
120 fForwardNodes
= new HashMap
<>(2);
121 fBackwardNodes
= new HashMap
<>(2);
122 fIndexes
= new HashMap
<>(2);
123 fBackwardSort
= new HashMap
<>(2);
124 fForwardSort
= new HashMap
<>(2);
129 if (nodeToAdd
== null) {
133 if (fNodes
.get(nodeToAdd
.getArrayId()) == null) {
134 fNodes
.put(nodeToAdd
.getArrayId(), new ArrayList
<GraphNode
>(1));
135 fIndexes
.put(nodeToAdd
.getArrayId(), Integer
.valueOf(0));
136 fForwardNodes
.put(nodeToAdd
.getArrayId(), new ArrayList
<GraphNode
>(1));
137 fForwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.FALSE
);
138 if (nodeToAdd
.getBackComparator() != null) {
139 fBackwardNodes
.put(nodeToAdd
.getArrayId(), new ArrayList
<GraphNode
>(1));
140 fBackwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.FALSE
);
144 List
<GraphNode
> fNodeList
= fForwardNodes
.get(nodeToAdd
.getArrayId());
145 List
<GraphNode
> bNodeList
= null;
146 if (fBackwardNodes
!= null) {
147 bNodeList
= fBackwardNodes
.get(nodeToAdd
.getArrayId());
149 if (fNodeList
!= null && fNodeList
.size() > 0) {
150 // check if the nodes are added y ordered
151 // if not, tag the list to sort it later (during draw)
152 GraphNode node
= fNodeList
.get(fNodeList
.size() - 1);
153 Comparator
<GraphNode
> fcomp
= nodeToAdd
.getComparator();
154 Comparator
<GraphNode
> bcomp
= nodeToAdd
.getBackComparator();
155 if ((fcomp
!= null) && (fcomp
.compare(node
, nodeToAdd
) > 0)) {
156 fForwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.TRUE
);
158 if ((bcomp
!= null) && (bcomp
.compare(node
, nodeToAdd
) > 0)) {
159 fBackwardSort
.put(nodeToAdd
.getArrayId(), Boolean
.TRUE
);
163 if (fNodeList
== null) {
164 fNodeList
= new ArrayList
<>();
167 fNodeList
.add(nodeToAdd
);
168 fNodes
.put(nodeToAdd
.getArrayId(), fNodeList
);
169 fForwardNodes
.put(nodeToAdd
.getArrayId(), fNodeList
);
170 if ((bNodeList
!= null) && (nodeToAdd
.getBackComparator() != null)) {
171 bNodeList
.add(nodeToAdd
);
172 fBackwardNodes
.put(nodeToAdd
.getArrayId(), bNodeList
);
177 * Set the graph node name.<br>
178 * It is the name display in the view to label the graph node.
180 * @param nodeName the name to set
182 public void setName(String nodeName
) {
187 * Returns the graph node name.<br>
188 * It is the name display in the view to label the graph node.
190 * @return the graph node name
192 public String
getName() {
197 * Tags the the graph node has selected.<br>
198 * WARNING: This method is only used to draw the graph node using the system selection colors. <br>
199 * To use the complete SDViewer selection mechanism (selection management, notification, etc..) see SDWidget class
201 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#addSelection(GraphNode)
202 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#removeSelection(GraphNode)
203 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#clearSelection()
204 * @param selection - true to set selected, false to set unselected
206 public void setSelected(boolean selection
) {
207 fSelected
= selection
;
211 * Tags the the graph node as focused.<br>
212 * WARNING: This method is only used to draw the graph node using the system focus style. <br>
213 * To use the complete SDViewer focus mechanism see SDWidget class
215 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#addSelection(GraphNode)
216 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#removeSelection(GraphNode)
217 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget#clearSelection()
218 * @param focus - true to set focued, false otherwise
220 public void setFocused(boolean focus
) {
225 * Returns true if the graph node is selected, false otherwise.<br>
226 * The returned value is used to highlight the graph node in the View.
228 * @return true if selected, false otherwise
230 public boolean isSelected() {
235 * Returns true if the graph node is focused, false otherwise.<br>
236 * The returned value is used to highlight the graph node in the View.
238 * @return true if focused, false otherwise
240 public boolean hasFocus() {
245 * Returns true if the graph node contains the point given in parameter,
246 * return false otherwise.
249 * the x coordinate of the point to test containment
251 * the y coordinate of the point to test containment
252 * @return true if contained, false otherwise
254 public abstract boolean contains(int x
, int y
);
257 * Returns the x coordinate of the graph node
259 * @return the x coordinate
261 public abstract int getX();
264 * Returns the y coordinate of the graph node
266 * @return the y coordinate
268 public abstract int getY();
271 * Returns the graph node height
273 * @return the graph node height
275 public abstract int getHeight();
278 * Returns the graph node width
280 * @return the graph node width
282 public abstract int getWidth();
285 * Draws the graph node in the given context
287 * @param context the graphical context to draw in
289 protected abstract void draw(IGC context
);
292 * Returns the GraphNode visibility for the given visible area. Wrong
293 * visibility calculation, may strongly impact drawing performance
300 * The width of the area
302 * The height of the area
303 * @return true if visible, false otherwise
305 public boolean isVisible(int x
, int y
, int width
, int height
) {
310 * Return a comparator to sort the GraphNode of the same type This
311 * comparator is used to order the GraphNode array of the given node type.
314 * @return the comparator
316 public Comparator
<GraphNode
> getComparator() {
321 * If needed, return a different comparator to backward scan the GraphNode
324 * @return the backward comparator or null if not needed
326 public Comparator
<GraphNode
> getBackComparator() {
331 * Compare two graphNodes
334 * the node to compare to
335 * @return true if equal false otherwise
337 public boolean isSameAs(GraphNode node
) {
342 * Return the node type for all class instances. This id is used to store the same nodes kind in the same ordered
345 * @return the node type identifier
347 public abstract String
getArrayId();
350 * Return true if the distance from the GraphNode to the given point is positive
352 * @param x the point x coordinate
353 * @param y the point y coordinate
354 * @return true if positive false otherwise
356 public boolean positiveDistanceToPoint(int x
, int y
) {
361 * Returns the graph node which contains the point given in parameter WARNING: Only graph nodes in the current
362 * visible area can be returned
364 * @param x the x coordinate of the point to test
365 * @param y the y coordinate of the point to test
366 * @return the graph node containing the point given in parameter, null otherwise
368 public GraphNode
getNodeAt(int x
, int y
) {
369 GraphNode toReturn
= null;
375 GraphNode node
= null;
376 for (Map
.Entry
<String
, List
<GraphNode
>> entry
: fNodes
.entrySet()) {
377 List
<GraphNode
> list
= entry
.getValue();
378 int index
= fIndexes
.get(entry
.getKey()).intValue();
379 node
= getNodeFromListAt(x
, y
, list
, index
);
380 if (toReturn
== null) {
384 GraphNode internalNode
= node
.getNodeAt(x
, y
);
385 if (internalNode
!= null) {
387 } else if (Math
.abs(node
.getWidth()) < Math
.abs(toReturn
.getWidth()) || Math
.abs(node
.getHeight()) < Math
.abs(toReturn
.getHeight())) {
396 * Gets node list from node A to node B
398 * @param from A from node
399 * @param to A to node
400 * @return the list of nodes
402 public List
<GraphNode
> getNodeList(GraphNode from
, GraphNode to
) {
403 List
<GraphNode
> result
= new ArrayList
<>();
407 } else if (to
!= null) {
411 if ((from
== null) || (to
== null)) {
419 int startX
= Math
.min(from
.getX(), Math
.min(to
.getX(), Math
.min(from
.getX() + from
.getWidth(), to
.getX() + to
.getWidth())));
420 int endX
= Math
.max(from
.getX(), Math
.max(to
.getX(), Math
.max(from
.getX() + from
.getWidth(), to
.getX() + to
.getWidth())));
421 int startY
= Math
.min(from
.getY(), Math
.min(to
.getY(), Math
.min(from
.getY() + from
.getHeight(), to
.getY() + to
.getHeight())));
422 int endY
= Math
.max(from
.getY(), Math
.max(to
.getY(), Math
.max(from
.getY() + from
.getHeight(), to
.getY() + to
.getHeight())));
428 for (Map
.Entry
<String
, List
<GraphNode
>> entry
: fNodes
.entrySet()) {
429 List
<GraphNode
> nodesList
= entry
.getValue();
430 if (nodesList
== null || nodesList
.isEmpty()) {
433 for (int i
= 0; i
< nodesList
.size(); i
++) {
434 GraphNode node
= nodesList
.get(i
);
435 int nw
= node
.getWidth();
436 int nh
= node
.getHeight();
437 int nx
= node
.getX();
438 int ny
= node
.getY();
439 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)) {
442 result
.addAll(node
.getNodeList(from
, to
));
446 if (!result
.contains(to
)) {
453 * Returns the graph node which contains the point given in parameter for the given graph node list and starting the
454 * iteration at the given index<br>
455 * WARNING: Only graph nodes with smaller coordinates than the current visible area can be returned.<br>
457 * @param x the x coordinate of the point to test
458 * @param y the y coordinate of the point to test
459 * @param list the list to search in
460 * @param fromIndex list browsing starting point
461 * @return the graph node containing the point given in parameter, null otherwise
463 protected GraphNode
getNodeFromListAt(int x
, int y
, List
<GraphNode
> list
, int fromIndex
) {
467 for (int i
= fromIndex
; i
< list
.size(); i
++) {
468 GraphNode node
= list
.get(i
);
469 if (node
.contains(x
, y
)) {
477 * Returns the start event occurrence attached to this graphNode.
479 * @return the start event occurrence attached to the graphNode
481 public int getStartOccurrence() {
482 return fStartEventOccurrence
;
486 * Returns the end event occurrence attached to this graphNode
488 * @return the start event occurrence attached to the graphNode
490 public int getEndOccurrence() {
491 return fEndEventOccurrence
;
495 * Computes the index of the first visible GraphNode for each ordered graph node lists depending on the visible area
498 * @param x visible area top left corner x coordinate
499 * @param y visible area top left corner y coordinate
500 * @param width visible area width
501 * @param height visible area height
503 public void updateIndex(int x
, int y
, int width
, int height
) {
507 if(TmfUiTracer
.isIndexTraced()) {
508 TmfUiTracer
.traceIndex(UI_DELIMITER
);
509 TmfUiTracer
.traceIndex("Visible area position in virtual screen (x,y)= " + x
+ " " + y
+ "\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
512 for (Map
.Entry
<String
, List
<GraphNode
>> entry
: fNodes
.entrySet()) {
513 String nodeType
= entry
.getKey();
515 int drawIndex
= fIndexes
.get(nodeType
).intValue();
517 if ((entry
.getValue() != null) && (entry
.getValue().size() > 1)) {
518 if (entry
.getValue().get(drawIndex
).positiveDistanceToPoint(x
, y
)) {
522 if (drawIndex
== 0) {
526 if ((direction
== -1) && (fBackwardNodes
.get(nodeType
) != null)) {
527 GraphNode currentNode
= entry
.getValue().get(drawIndex
);
528 drawIndex
= Arrays
.binarySearch(fBackwardNodes
.get(nodeType
).toArray(new GraphNode
[fBackwardNodes
.get(nodeType
).size()]),
529 entry
.getValue().get(drawIndex
), currentNode
.getBackComparator());
530 entry
.setValue(fBackwardNodes
.get(nodeType
));
535 entry
.setValue(fBackwardNodes
.get(nodeType
));
538 GraphNode prev
= null;
540 for (int i
= drawIndex
; i
< entry
.getValue().size() && i
>= 0; i
= i
+ direction
) {
542 fIndexes
.put(nodeType
, Integer
.valueOf(i
));
544 GraphNode currentNode
= entry
.getValue().get(i
);
550 Comparator
<GraphNode
> comp
= currentNode
.getComparator();
551 Map
<String
, Boolean
> sort
= fForwardSort
;
553 if ((direction
== -1) && (currentNode
.getBackComparator() != null)) {
554 comp
= currentNode
.getBackComparator();
555 sort
= fBackwardSort
;
558 if (i
< entry
.getValue().size() - 1) {
559 GraphNode next
= entry
.getValue().get(i
+ 1);
561 if ((comp
!= null) && (comp
.compare(currentNode
, next
) > 0)) {
562 sort
.put(nodeType
, Boolean
.TRUE
);
565 if (direction
== 1) {
566 if (entry
.getValue().get(i
).positiveDistanceToPoint(x
, y
)) {
570 if (currentNode
.getBackComparator() == null) {
571 if (!currentNode
.positiveDistanceToPoint(x
, y
)) {
575 if (currentNode
.isVisible(x
, y
, width
, height
) && !currentNode
.positiveDistanceToPoint(x
, y
)) {
576 if ((comp
!= null) && (comp
.compare(currentNode
, prev
) <= 0)) {
579 } else if ((comp
!= null) && (comp
.compare(currentNode
, prev
) <= 0)) {
586 entry
.setValue(fForwardNodes
.get(nodeType
));
587 if ((fBackwardNodes
.get(nodeType
) != null) && (direction
== -1)) {
588 int index
= fIndexes
.get(nodeType
).intValue();
589 List
<GraphNode
> list
= entry
.getValue();
590 List
<GraphNode
> backList
= fBackwardNodes
.get(nodeType
);
591 GraphNode currentNode
= (backList
.get(index
));
593 index
= Arrays
.binarySearch(list
.toArray(new GraphNode
[list
.size()]), backList
.get(index
), currentNode
.getComparator());
597 fIndexes
.put(nodeType
, Integer
.valueOf(index
));
601 for (int i
= drawIndex
; i
< entry
.getValue().size() && i
>= 0; i
++) {
602 GraphNode toDraw
= entry
.getValue().get(i
);
603 toDraw
.updateIndex(x
, y
, width
, height
);
604 if (!toDraw
.isVisible(x
, y
, width
, height
)) {
609 if (TmfUiTracer
.isIndexTraced()) {
610 TmfUiTracer
.traceIndex("First drawn " + nodeType
+ " index = " + drawIndex
+ "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
611 TmfUiTracer
.traceIndex(nodeType
+ " found in " + 0 + " iterations\n"); //$NON-NLS-1$ //$NON-NLS-2$
615 if (TmfUiTracer
.isIndexTraced()) {
616 TmfUiTracer
.traceIndex(UI_DELIMITER
);
621 * Draws the children nodes on the given context.<br>
622 * This method start width GraphNodes ordering if needed.<br>
623 * After, depending on the visible area, only visible GraphNodes are drawn.<br>
625 * @param context the context to draw to
626 * @see org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode#draw(IGC)
628 protected void drawChildenNodes(IGC context
) {
633 // If the nodes have not been added ordered, the array is ordered
634 for (Map
.Entry
<String
, Boolean
> entry
: fForwardSort
.entrySet()) {
635 String nodeType
= entry
.getKey();
636 boolean sort
= entry
.getValue().booleanValue();
638 GraphNode
[] temp
= fForwardNodes
.get(nodeType
).toArray(new GraphNode
[fForwardNodes
.get(nodeType
).size()]);
639 GraphNode node
= fNodes
.get(nodeType
).get(0);
640 Arrays
.sort(temp
, node
.getComparator());
641 entry
.setValue(Boolean
.FALSE
);
642 fNodes
.put(nodeType
, Arrays
.asList(temp
));
643 fForwardNodes
.put(nodeType
, Arrays
.asList(temp
));
644 if (TmfUiTracer
.isSortingTraced()) {
645 TmfUiTracer
.traceSorting(nodeType
+ " array sorted\n"); //$NON-NLS-1$
650 for (Map
.Entry
<String
, Boolean
> entry
: fBackwardSort
.entrySet()) {
651 String nodeType
= entry
.getKey();
652 boolean sort
= entry
.getValue().booleanValue();
654 GraphNode
[] temp
= fBackwardNodes
.get(nodeType
).toArray(new GraphNode
[fBackwardNodes
.get(nodeType
).size()]);
655 GraphNode node
= fNodes
.get(nodeType
).get(0);
656 Arrays
.sort(temp
, node
.getBackComparator());
657 entry
.setValue(Boolean
.FALSE
);
658 fBackwardNodes
.put(nodeType
, Arrays
.asList(temp
));
659 if (TmfUiTracer
.isSortingTraced()) {
660 TmfUiTracer
.traceSorting(nodeType
+ " back array sorted\n"); //$NON-NLS-1$
665 if (TmfUiTracer
.isDisplayTraced()) {
666 TmfUiTracer
.traceDisplay(UI_DELIMITER
);
670 if ((Metrics
.getMessageFontHeigth() + Metrics
.MESSAGES_NAME_SPACING
* 2) * context
.getZoom() < Metrics
.MESSAGE_SIGNIFICANT_VSPACING
) {
671 arrayStep
= Math
.round(Metrics
.MESSAGE_SIGNIFICANT_VSPACING
/ ((Metrics
.getMessageFontHeigth() + Metrics
.MESSAGES_NAME_SPACING
* 2) * context
.getZoom()));
675 Iterator
<String
> it3
= fForwardSort
.keySet().iterator();
676 while (it3
.hasNext()) {
678 Object nodeType
= it3
.next();
679 GraphNode node
= fNodes
.get(nodeType
).get(0);
680 context
.setFont(SDViewPref
.getInstance().getFont(node
.fPrefId
));
681 int index
= fIndexes
.get(nodeType
).intValue();
682 count
= drawNodes(context
, fNodes
.get(nodeType
), index
, arrayStep
);
683 if (TmfUiTracer
.isDisplayTraced()) {
684 TmfUiTracer
.traceDisplay(count
+ " " + nodeType
+ " drawn, starting from index " + index
+ "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
687 if (TmfUiTracer
.isDisplayTraced()) {
688 TmfUiTracer
.traceDisplay(UI_DELIMITER
);
694 * Draw the GraphNode stored in the given list, starting at index startIndex with the given step
696 * @param context the context to draw to
697 * @param list the GraphNodes list
698 * @param startIndex the start index
699 * @param step the step to browse the list
700 * @return the number of GraphNodes drawn
702 protected int drawNodes(IGC context
, List
<GraphNode
> list
, int startIndex
, int step
) {
707 GraphNode last
= null;
709 if (list
.isEmpty()) {
713 GraphNode node
= list
.get(0);
714 context
.setFont(SDViewPref
.getInstance().getFont(node
.fPrefId
));
715 Comparator
<GraphNode
> comparator
= node
.getComparator();
716 for (int i
= startIndex
; i
< list
.size(); i
= i
+ step
) {
717 GraphNode toDraw
= list
.get(i
);
718 if (i
< list
.size() - 1) {
719 GraphNode next
= list
.get(i
+ 1);
720 if ((comparator
!= null) && (comparator
.compare(toDraw
, next
) > 0)) {
721 fForwardSort
.put(next
.getArrayId(), Boolean
.TRUE
);
724 int cx
= context
.getContentsX();
725 int cy
= context
.getContentsY();
726 int cw
= context
.getVisibleWidth();
727 int ch
= context
.getVisibleHeight();
728 // The arrays should be ordered, no needs to continue for this one
729 if (!toDraw
.isVisible(cx
, cy
, cw
, ch
) && toDraw
.positiveDistanceToPoint(cx
+ cw
, cy
+ ch
)) {
732 // ***Common*** nodes visibility
733 if ((!toDraw
.isSameAs(last
) || toDraw
.isSelected()) && (toDraw
.isVisible(context
.getContentsX(), context
.getContentsY(), context
.getVisibleWidth(), context
.getVisibleHeight()))) {
736 toDraw
.draw(context
);
738 toDraw
.drawFocus(context
);
747 * Draws the focus within the graphical context.
752 public void drawFocus(IGC context
) {
753 context
.drawFocus(getX(), getY(), getWidth(), getHeight());
757 * Determine if the given point (px,py) is contained in the rectangle (x,y,width,height)
759 * @param x the rectangle x coordinate
760 * @param y the rectangle y coordinate
761 * @param width the rectangle width
762 * @param height the rectangle height
763 * @param px the x coordinate of the point to test
764 * @param py the y coordinate of the point to test
765 * @return true if contained false otherwise
767 public static boolean contains(int x
, int y
, int width
, int height
, int px
, int py
) {
770 int locWidth
= width
;
771 int locHeight
= height
;
775 locWidth
= -locWidth
;
779 locY
= locY
+ height
;
780 locHeight
= -locHeight
;
782 return (px
>= locX
) && (py
>= locY
) && ((px
- locX
) <= locWidth
) && ((py
- locY
) <= locHeight
);
786 * Sets the start event occurrence attached to this graphNode.
789 * the start event occurrence attached to the graphNode
791 protected void setStartOccurrence(int occurence
) {
792 fStartEventOccurrence
= occurence
;
796 * Sets the end event occurrence attached to this graphNode
799 * the start event occurrence attached to the graphNode
801 protected void setEndOccurrence(int occurence
) {
802 fEndEventOccurrence
= occurence
;
806 * Sets the color preference id
808 * The color preference id
810 protected void setColorPrefId(String id
) {
815 * Gets the color preference id
816 * @return the color preference id
818 protected String
getColorPrefId() {
823 * @return if node has children or not
825 protected boolean hasChildren() {
830 * Sets the flag indicating where the node has children or not.
832 * if node has children or not
834 protected void hasChildren(boolean hasChildren
) {
835 fHasChilden
= hasChildren
;
838 * Returns a map from node name to graph node.
840 * @return map with children graph bodes
842 protected Map
<String
, List
<GraphNode
>> getNodeMap() {
846 * Returns a map from node name to graph node for forward sorting
848 * @return forward sorting map
850 protected Map
<String
, List
<GraphNode
>> getForwardNodes() {
851 return fForwardNodes
;
854 * Returns a map from node name to graph node for backwards sorting.
856 * @return backwards sorting map
858 protected Map
<String
, List
<GraphNode
>> getBackwardNodes() {
859 return fBackwardNodes
;
862 * Returns a map from node name to index.
864 * @return map with node name to index
866 protected Map
<String
, Integer
> getIndexes() {
871 * Returns a map from node name to sort flag for forwards sorting.
872 * @return a map from node name to sort flag
874 protected Map
<String
, Boolean
> getForwardSortMap() {
878 * Returns a map from node name to flag for backwards sorting.
879 * @return map from node name to flag for backwards sorting.
881 protected Map
<String
, Boolean
> getBackwardSortMap() {
882 return fBackwardSort
;