Skip to content

Commit a6e576b

Browse files
KhureshiKhureshi
authored andcommitted
made minmax and info button more awesome
1 parent f948660 commit a6e576b

File tree

6 files changed

+111
-118
lines changed

6 files changed

+111
-118
lines changed

src/main/java/com/application/controller/ControllerUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static List<CircleCell> convertElementDTOTOCell(List<ElementDTO> elementD
5959
// System.out.println();
6060
// System.out.println("ControllerUtil.convertElementDTOTOCell ");
6161
elementDTOList.forEach(elementDTO -> {
62-
CircleCell circleCell = new CircleCell(elementDTO.getId(), elementDTO.getBoundBoxXCoordinate(), elementDTO.getBoundBoxYCoordinate(), elementDTO.getMethodName());
62+
CircleCell circleCell = new CircleCell(elementDTO.getId(), elementDTO.getBoundBoxXCoordinate(), elementDTO.getBoundBoxYCoordinate(), elementDTO.getMethodName(), elementDTO.getCollapsed());
6363
circleCellList.add(circleCell);
6464
// System.out.print(circleCell.getCellId() + ", ");
6565
});

src/main/java/com/application/controller/EventHandlers.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ public void handle(MouseEvent event) {
448448
private EventHandler<MouseEvent> minMaxButtonOnClickEventHandler = new EventHandler<MouseEvent>() {
449449
@Override
450450
public void handle(MouseEvent event) {
451+
System.out.println("EventHandlers.handle. minMaxButtonOnClickEventHandler ");
451452
CircleCell cell = ((CircleCell) ((Node) event.getSource()).getParent());
452453
minMaxButtonOnClick(cell, ControllerLoader.centerLayoutController.getCurrentThreadId());
453454
}
@@ -492,7 +493,7 @@ private void minMaxButtonOnClick(CircleCell clickedCell, String threadId) {
492493
// .setFill(Color.BLUE);
493494
// cell.getChildren().get(0).setStyle("-fx-background-color: blue");
494495
// cell.setStyle("-fx-background-color: blue");
495-
496+
//
496497
int nextCellId = ElementDAOImpl.getNextLowerSiblingOrAncestorNode(clickedElementDTO, threadId);
497498
int lastCellId = ElementDAOImpl.getLowestCellInThread(threadId);
498499
// delta is only meaningful for a node when minimizing the tree at that node.
@@ -515,6 +516,7 @@ private void minMaxButtonOnClick(CircleCell clickedCell, String threadId) {
515516

516517
updateDBInBackgroundThread(clickedElementDTO, true, nextCellId, Integer.valueOf(threadId), lastCellId);
517518

519+
clickedCell.setCollapsed(2);
518520
} else if (collapsed == 2) {
519521
System.out.println();
520522
System.out.println("EventHandlers.minMaxButtonOnClick: clicked on : " + clickedCellID);
@@ -525,6 +527,7 @@ private void minMaxButtonOnClick(CircleCell clickedCell, String threadId) {
525527
// all other cells: <0 -> ++1
526528

527529
expandTreeAt(clickedElementDTO, threadId);
530+
clickedCell.setCollapsed(0);
528531
}
529532
}
530533
}

src/main/java/com/application/db/DatabaseUtil.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,17 @@ public static ResultSet select(String query ) {
341341
}
342342

343343
public static void close() {
344-
try {
345-
if (conn != null) {
346-
conn.close();
347-
}
348-
349-
if (ps != null) {
350-
ps.close();
351-
}
352-
} catch (SQLException e) {
353-
e.printStackTrace();
354-
}
344+
// try {
345+
// if (conn != null) {
346+
// conn.close();
347+
// }
348+
//
349+
// if (ps != null) {
350+
// ps.close();
351+
// }
352+
// } catch (SQLException e) {
353+
// e.printStackTrace();
354+
// }
355355
}
356356

357357
public static int executeSelectForInt(String query) {

src/main/java/com/application/fxgraph/cells/CircleCell.java

Lines changed: 90 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.application.fxgraph.graph.Cell;
44
import com.application.fxgraph.graph.CustomColors;
55
import javafx.geometry.Pos;
6+
import javafx.scene.Node;
67
import javafx.scene.control.Label;
78
import javafx.scene.effect.DropShadow;
89
import 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");

src/main/java/com/application/fxgraph/graph/BoundBox.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class BoundBox {
1313
public float xBottomLeft;
1414
public float yBottomLeft;
1515

16-
public static final int unitWidthFactor = 100; // The width of the rectangular space that contains a single element on UI
17-
public static final int unitHeightFactor = 100; // The height of the rectangular space that contains a single element on UI
16+
public static final int unitWidthFactor = 120; // The width of the rectangular space that contains a single element on UI
17+
public static final int unitHeightFactor = 70; // The height of the rectangular space that contains a single element on UI
1818

1919
public float xCoordinate;
2020
public float yCoordinate;

src/main/java/com/application/service/modules/ElementTreeModule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ private void addCircleCells() {
457457
// Add circle cell to model and UI only if they are not already present on UI and if collapsed value is 0 or 2
458458
if (!mapCircleCellsOnUI.containsKey(id) && (collapsed == 0 || collapsed == 2)) {
459459
// System.out.println("ElementTreeModule::addCircleCells: adding new cells to UI: cell id: " + id);
460-
curCircleCell = new CircleCell(id, xCoordinate, yCoordinate);
460+
curCircleCell = new CircleCell(id, xCoordinate, yCoordinate, collapsed);
461461
curCircleCell.setMethodNameLabel(methodName);
462462
model.addCell(curCircleCell);
463463
// SimplifiedElement ele = new SimplifiedElement(id, methodName);
@@ -485,7 +485,8 @@ private void addCircleCells() {
485485
if (rsTemp.next() && rsTemp.getInt("LEVEL_COUNT") > 1) {
486486
float xCoordinateTemp = rsTemp.getFloat("bound_box_x_coordinate");
487487
float yCoordinateTemp = rsTemp.getFloat("bound_box_y_coordinate");
488-
parentCircleCell = new CircleCell(parentId, xCoordinateTemp, yCoordinateTemp);
488+
int parentCollapsed = rsTemp.getInt("collapsed");
489+
parentCircleCell = new CircleCell(parentId, xCoordinateTemp, yCoordinateTemp, parentCollapsed);
489490
// System.out.println("ElementTreeModule::addCircleCells: adding new parent cells to UI: cell id: " + parentId);
490491
model.addCell(parentCircleCell);
491492
}

0 commit comments

Comments
 (0)