KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > graph > ParticipantView


1 /* ParticipantView.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.graph;
12
13
14
15 import org.jgraph.JGraph;
16 import org.jgraph.graph.*;
17
18 import java.awt.*;
19 import java.awt.geom.Rectangle2D JavaDoc;
20 import java.util.*;
21
22 /**
23 * Represents a view for a model's Participant object.
24 */

25 public class ParticipantView extends VertexView {
26
27    /** Renderer for the class. */
28    public static ParticipantRenderer renderer = new ParticipantRenderer();
29
30    /**
31    * Constructs a participant view for the specified model object.
32    *
33    * @param cell reference to the model object
34    */

35    public ParticipantView(Object JavaDoc cell, JGraph graph, CellMapper cm) {
36       super(cell, graph, cm);
37    }
38
39    /**
40    * Returns a renderer for the class.
41    */

42    public CellViewRenderer getRenderer() {
43       return renderer;
44    }
45
46    /**
47    * Returns true if name portion of ParticipantView intersects the given rectangle.
48    */

49    public boolean intersects(Graphics g, Rectangle2D JavaDoc rect) {//HM, JGraph3.4.1
50
Rectangle2D JavaDoc bounds = getBounds();//HM, JGraph3.4.1
51
if (bounds != null) {
52          Rectangle nameBounds=new Rectangle((int)bounds.getX(),(int)bounds.getY(),
53                renderer.participantNameWidth,(int)bounds.getHeight());
54          return nameBounds.intersects(rect);
55       }
56       return false;
57    }
58
59    /**
60    * Clears childView's and then refreshes it.
61    */

62    public void refreshChildViews () {
63       childViews.clear();
64       refresh(false);
65    }
66
67    /**
68    * Returns the bounding rectangle for this view.
69    */

70    public Rectangle2D JavaDoc getBounds() {//HM, JGraph3.4.1
71
return bounds;
72    }
73
74    /**
75    * Adds participants child view to it.
76    */

77    public void addChildView (CellView childView) {
78       if (childView != null) {
79          childViews.add(childView);
80       }
81    }
82
83 }
84
85 /* End of ParticipantView.java */
86
Popular Tags