33import com .application .fxgraph .graph .Cell ;
44import com .application .fxgraph .graph .CustomColors ;
55import javafx .geometry .Pos ;
6+ import javafx .scene .Node ;
67import javafx .scene .control .Label ;
78import javafx .scene .effect .DropShadow ;
89import javafx .scene .layout .StackPane ;
@@ -21,131 +22,127 @@ public class CircleCell extends Cell {
2122 private Shape nodeShape ;
2223
2324 private StackPane minMaxStackPane ;
25+ Glyph minMaxGlyph ;
26+
2427 private StackPane infoStackPane ;
2528
29+
2630 private StackPane rootStackPane ;
2731
2832 private double bookmarkStrokeWidth = 3 ;
29- private double firstPortion = 0.7 ;
30- private double secondPortion = 1 - firstPortion ;
33+ // private double firstPortion = 0.7;
34+ // private double secondPortion = 1 - firstPortion;
3135
32- private double rectWidth = 70 ;
33- private double rectHeight = 70 ;
36+ private double rectWidth = 100 ;
37+ private double rectHeight = 35 ;
3438
3539 private Rectangle bookmarkBar ;
3640
41+ private boolean collapsed = false ;
42+
3743 public CircleCell (String id ) {
3844 super (id );
3945
40- // Uncomment to see a colored background on the whole circle cell stack pane.
41- // setStyle("-fx-background-smallButtonsColor: mediumslateblue");
42-
43- nodeShape = createRectangle ();
44-
45- label = new Label ("This is a long string" );
46-
47-
48- setUpIdLabel (id );
49- setUpMethodName ();
50- setUpButtons ();
51- setUpDropShadow ();
52- setFill ();
53- setUpBookmark ();
54-
55- // rootStackPane = new StackPane(nodeShape, methodNameLabel, idBubble, minMaxStackPane, infoStackPane);
56- // getChildren().addAll(rootStackPane);
5746
58- getChildren ().addAll (nodeShape , methodNameLabel , idBubble , minMaxStackPane , infoStackPane , bookmarkBar );
59- idBubble .toFront ();
60-
61- // setView(group);
62- this .toFront ();
6347 }
6448
6549 private void setUpBookmark () {
66- bookmarkBar = new Rectangle (rectWidth , 4 );
67- bookmarkBar .relocate (0 , 0 );
50+ bookmarkBar = new Rectangle (rectWidth - 2 , 30 );
51+ bookmarkBar .relocate (1 , - 3 );
6852 bookmarkBar .setFill (Color .TRANSPARENT );
53+ bookmarkBar .setStroke (Color .TRANSPARENT );
54+ bookmarkBar .setStrokeWidth (0.1 );
6955 bookmarkBar .setArcWidth (20 );
7056 bookmarkBar .setArcHeight (20 );
7157 }
7258
73-
74-
7559 private void setUpButtons () {
7660 setUpMinMaxButton ();
7761 setUpInfoButton ();
7862 }
7963
80-
8164 private void setUpMinMaxButton () {
82- // Min-Max button
83- Arc minMaxArc = new Arc ();
84- minMaxArc .setCenterX (20.5 );
85- minMaxArc .setCenterY (20.5 );
86- minMaxArc .setRadiusX (20 );
87- minMaxArc .setRadiusY (20 );
88- minMaxArc .setStartAngle (270 );
89- minMaxArc .setLength (180 );
90- minMaxArc .setType (ArcType .ROUND );
91- minMaxArc .setFill (Color .TRANSPARENT );
92-
93- Rectangle minMaxButton = new Rectangle ();
94- minMaxButton .setWidth (((Rectangle ) nodeShape ).getWidth () * 0.5 );
95- minMaxButton .setHeight (((Rectangle ) nodeShape ).getHeight () * secondPortion );
96- minMaxButton .setArcHeight (10 );
97- minMaxButton .setArcWidth (10 );
98- minMaxButton .setFill (CustomColors .TRANSPARENT .getPaint ());
99-
100- // minMaxButton.setStroke(CustomColors.DARK_GREY.getPaint());
101-
102- Glyph minMaxGlyph = new Glyph ("FontAwesome" , FontAwesome .Glyph .EXPAND );
103- minMaxGlyph .setColor (smallButtonsColor );
104-
105- minMaxStackPane = new StackPane (minMaxButton , minMaxGlyph );
106- minMaxStackPane .relocate (((Rectangle ) nodeShape ).getWidth () * 0.5 - 3 , ((Rectangle ) nodeShape ).getHeight () * firstPortion );
65+ setMinMaxIcon ();
10766
67+ minMaxStackPane = new StackPane (minMaxGlyph );
68+ minMaxStackPane .relocate (rectWidth - 8 , -8 );
69+ minMaxStackPane .setVisible (false );
10870 }
10971
11072 private void setUpInfoButton () {
111- Arc infoArc = new Arc ();
112- infoArc .setCenterX (20.5 );
113- infoArc .setCenterY (20.5 );
114- infoArc .setRadiusX (20 );
115- infoArc .setRadiusY (20 );
116- infoArc .setStartAngle (90 );
117- infoArc .setLength (180 );
118- infoArc .setType (ArcType .ROUND );
119- infoArc .setFill (Color .TRANSPARENT );
120-
121- // info button
122- Rectangle infoButton = new Rectangle ();
123- infoButton .setWidth (((Rectangle ) nodeShape ).getWidth () * 0.5 );
124- infoButton .setHeight (((Rectangle ) nodeShape ).getHeight () * secondPortion );
125- infoButton .setArcHeight (10 );
126- infoButton .setArcWidth (10 );
127- infoButton .setFill (CustomColors .TRANSPARENT .getPaint ());
128- // infoButton.setStroke(CustomColors.DARK_GREY.getPaint());
129-
13073 Glyph infoGlyph = new Glyph ("FontAwesome" , FontAwesome .Glyph .INFO_CIRCLE );
131- infoGlyph .setColor (smallButtonsColor );
74+ infoGlyph .setColor (infoButtonColor );
13275
133- infoStackPane = new StackPane (infoButton , infoGlyph );
134- infoStackPane .relocate (((Rectangle ) nodeShape ).getWidth () * 0 + 3 , ((Rectangle ) nodeShape ).getHeight () * firstPortion );
76+ infoStackPane = new StackPane (infoGlyph );
77+ infoStackPane .relocate (rectWidth - 8 , (rectHeight - 8 ));
78+ infoStackPane .setVisible (false );
13579 }
13680
13781
138- public CircleCell (String id , float xCoordinate , float yCoordinate ) {
82+ public CircleCell (String id , float xCoordinate , float yCoordinate , int collapsed ) {
13983 this (id );
140- this .relocate (xCoordinate , yCoordinate );
84+
85+ // Uncomment to see a colored background on the whole circle cell stack pane.
86+ // setStyle("-fx-background-smallButtonsColor: mediumslateblue");
87+
88+ nodeShape = createRectangle ();
89+
90+ this .collapsed = collapsed != 0 ;
91+ label = new Label ("" );
92+
93+ setUpDropShadow ();
94+ setUpIdLabel (id );
95+ setUpMethodName ();
96+ setUpButtons ();
97+ setFill ();
98+ setUpBookmark ();
99+
100+ getChildren ().addAll (nodeShape , methodNameLabel , idBubble , minMaxStackPane , infoStackPane , bookmarkBar );
101+
102+ idBubble .toFront ();
103+ bookmarkBar .toBack ();
141104 this .toFront ();
105+ // guess is, drop shadows block the mouse events. set pick on bounds to false to make mouse events work.
106+ this .setPickOnBounds (false );
107+
108+ this .setOnMouseEntered (event -> {
109+ infoStackPane .setVisible (true );
110+ minMaxStackPane .setVisible (true );
111+ });
112+
113+ this .setOnMouseExited (event -> {
114+ infoStackPane .setVisible (false );
115+ minMaxStackPane .setVisible (false );
116+ });
117+
118+ this .relocate (xCoordinate , yCoordinate );
142119 }
143120
144- public CircleCell (String id , float xCoordinate , float yCoordinate , String methodName ) {
145- this (id , xCoordinate , yCoordinate );
121+ public CircleCell (String id , float xCoordinate , float yCoordinate , String methodName , int collapsed ) {
122+ this (id , xCoordinate , yCoordinate , collapsed );
146123 this .methodNameLabel .setText (methodName );
147124 }
148125
126+ public void setCollapsed (int collapsed ) {
127+ System .out .println ("CircleCell.setCollapsed: collapsed: " + collapsed );
128+ this .collapsed = collapsed != 0 ;
129+ setMinMaxIcon ();
130+ }
131+
132+ private void setMinMaxIcon () {
133+ if (minMaxGlyph == null ) {
134+ minMaxGlyph = new Glyph ("FontAwesome" , FontAwesome .Glyph .MINUS_SQUARE );
135+ }
136+
137+ if (collapsed ) {
138+ minMaxGlyph .setIcon (FontAwesome .Glyph .PLUS_SQUARE );
139+ } else {
140+ minMaxGlyph .setIcon (FontAwesome .Glyph .MINUS_SQUARE );
141+ }
142+
143+ minMaxGlyph .setColor (minMaxButtonColor );
144+ }
145+
149146 public void setLabel (String text ) {
150147 this .label .setText (text );
151148 }
@@ -161,8 +158,10 @@ private void setUpMethodName() {
161158 methodNameLabel .setFont (Font .font (12 ));
162159 methodNameLabel .setMaxWidth (((Rectangle ) nodeShape ).getWidth () - 5 );
163160 methodNameLabel .setMinWidth (((Rectangle ) nodeShape ).getWidth () - 5 );
164- methodNameLabel .setMaxHeight (((Rectangle ) nodeShape ).getHeight () * firstPortion );
165- methodNameLabel .setMinHeight (((Rectangle ) nodeShape ).getHeight () * firstPortion );
161+ // methodNameLabel.setMaxHeight(((Rectangle) nodeShape).getHeight() * firstPortion);
162+ // methodNameLabel.setMinHeight(((Rectangle) nodeShape).getHeight() * firstPortion);
163+ methodNameLabel .setMaxHeight (((Rectangle ) nodeShape ).getHeight ());
164+ methodNameLabel .setMinHeight (((Rectangle ) nodeShape ).getHeight ());
166165
167166 // align the method name to top of the square.
168167 methodNameLabel .relocate (2.5 , 0 );//-this.methodNameLabel.getMinHeight()/2);
@@ -175,11 +174,6 @@ private void setUpMethodName() {
175174 public void setMethodNameLabel (String methodName ) {
176175 this .methodNameLabel .setText (methodName );
177176 }
178- /*
179- // Used?
180- public void setColor(Color smallButtonsColor) {
181- circle.setFill(smallButtonsColor);
182- }*/
183177
184178 public StackPane getMinMaxStackPane () {
185179 return minMaxStackPane ;
@@ -190,17 +184,14 @@ public StackPane getInfoStackPane() {
190184 }
191185
192186 public void bookmarkCell (String color ) {
193- // nodeShape.setStroke(Paint.valueOf(color));
194- // nodeShape.setStrokeWidth(bookmarkStrokeWidth);
195-
196187 bookmarkBar .setFill (Paint .valueOf (color ));
188+ bookmarkBar .setStroke (Color .BLACK );
189+ bookmarkBar .setStrokeWidth (0.1 );
197190 }
198191
199192 public void removeBookmark () {
200- // nodeShape.setStroke(CustomColors.LIGHT_TURQUOISE.getPaint());
201- // nodeShape.setStrokeWidth(1);
202-
203193 bookmarkBar .setFill (Color .TRANSPARENT );
194+ bookmarkBar .setStroke (Color .TRANSPARENT );
204195 }
205196
206197 @ Override
@@ -220,8 +211,6 @@ private Shape createCircle() {
220211
221212 private Shape createRectangle () {
222213 Shape rect = new Rectangle (rectWidth , rectHeight );
223- // rect.setStroke(CustomColors.LIGHT_TURQUOISE.getPaint());
224- // rect.setFill(CustomColors.DARK_GREY.getPaint());
225214 ((Rectangle ) rect ).setArcWidth (20 );
226215 ((Rectangle ) rect ).setArcHeight (20 );
227216 rect .relocate (0 ,0 );
@@ -230,9 +219,7 @@ private Shape createRectangle() {
230219 }
231220
232221 private void setFill () {
233- // Stop[] stops = new Stop[] { new Stop(0, Color.valueOf("#04b3e3")), new Stop(1, Color.valueOf("#04cabe"))};
234222 Stop [] stops = new Stop [] { new Stop (0 , cell1Color ), new Stop (1 , cell2Color )};
235- // Stop[] stops = new Stop[] { new Stop(0, Color.valueOf("#b2f0d9")), new Stop(1, Color.valueOf("#b2e9f0"))};
236223 LinearGradient linearGradient = new LinearGradient (0 , 0 , 1 , 0 , true , CycleMethod .NO_CYCLE , stops );
237224 nodeShape .setFill (linearGradient );
238225 }
@@ -278,10 +265,12 @@ private void setUpDropShadow() {
278265 dropShadow .setOffsetY (12 );
279266 dropShadow .setRadius (40 );
280267 dropShadow .setColor (cellShadowColor );
281- nodeShape .setEffect (dropShadow );
268+ this .setEffect (dropShadow );
282269 }
270+
283271 // Color smallButtonsColor = Color.valueOf("#e5a2d0");
284- Color smallButtonsColor = Color .WHITE ;
272+ Color minMaxButtonColor = Color .valueOf ("#FF4136" );
273+ Color infoButtonColor = Color .valueOf ("#001f3f" );
285274 Color idBubbleBackgroundColor = Color .valueOf ("#f6dfef" );
286275 Color cell1Color = Color .valueOf ("#b2baf0" );
287276 Color cell2Color = Color .valueOf ("#bab2f0" );
0 commit comments