Skip to content

Commit 5617eb8

Browse files
committed
added lite mode
1 parent 8120e43 commit 5617eb8

File tree

4 files changed

+112
-69
lines changed

4 files changed

+112
-69
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import com.application.service.modules.ModuleLocator;
1515
import com.application.service.tasks.ConstructTreeTask;
1616
import com.application.service.tasks.ParseFileTask;
17+
import javafx.beans.binding.Bindings;
18+
import javafx.beans.property.BooleanProperty;
19+
import javafx.beans.property.SimpleBooleanProperty;
1720
import javafx.concurrent.Task;
1821
import javafx.embed.swing.SwingFXUtils;
1922
import javafx.fxml.FXML;
@@ -39,6 +42,7 @@
3942
import org.controlsfx.glyphfont.Glyph;
4043

4144
import javax.imageio.ImageIO;
45+
import javax.naming.Binding;
4246
import java.io.File;
4347
import java.io.IOException;
4448
import java.sql.SQLException;
@@ -89,6 +93,10 @@ public class MenuController {
8993
@FXML
9094
private MenuItem addHighlightMenuItem;
9195

96+
// Settings Menu
97+
@FXML
98+
private CheckMenuItem liteModeCheckMenuItem;
99+
public Boolean isLiteModeEnabled = false;
92100

93101
// Debug menu button
94102
@FXML
@@ -122,6 +130,7 @@ private void initialize() {
122130
setUpBookmarksMenu();
123131
setUpHighlightsMenu();
124132
setUpViewMenu();
133+
setUpSettingMenu();
125134
setUpDebugMenu();
126135

127136
initMenuGraphics();
@@ -250,6 +259,12 @@ private void setUpViewMenu() {
250259
refreshMenuItem.setOnAction(event -> ControllerLoader.canvasController.clearAndUpdate());
251260
}
252261

262+
private void setUpSettingMenu() {
263+
liteModeCheckMenuItem.selectedProperty().addListener((observable, oldValue, newValue) -> {
264+
isLiteModeEnabled = newValue;
265+
});
266+
}
267+
253268
private void setUpDebugMenu() {
254269
printViewPortDimsMenuItem.setOnAction(event -> {
255270
System.out.println("ScrollPane viewport dimensions");

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

Lines changed: 76 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.application.controller.ControllerLoader;
44
import com.application.fxgraph.graph.Cell;
5+
import com.application.fxgraph.graph.ColorProp;
56
import com.application.fxgraph.graph.CustomColors;
67
import javafx.geometry.Pos;
78
import javafx.scene.Node;
@@ -43,45 +44,11 @@ public class CircleCell extends Cell {
4344

4445
public CircleCell(String id) {
4546
super(id);
46-
47-
48-
}
49-
50-
private void setUpBookmark() {
51-
bookmarkBar = new Rectangle(rectWidth - 2, 30);
52-
bookmarkBar.relocate(1, -3);
53-
bookmarkBar.setFill(Color.TRANSPARENT);
54-
bookmarkBar.setStroke(Color.TRANSPARENT);
55-
bookmarkBar.setStrokeWidth(0.1);
56-
bookmarkBar.setArcWidth(20);
57-
bookmarkBar.setArcHeight(20);
58-
}
59-
60-
private void setUpButtons() {
61-
setUpMinMaxButton();
62-
setUpInfoButton();
63-
}
64-
65-
private void setUpMinMaxButton() {
66-
setMinMaxIcon();
67-
68-
minMaxStackPane = new StackPane(minMaxGlyph);
69-
minMaxStackPane.relocate(rectWidth - 6, -8);
70-
minMaxStackPane.setVisible(false);
7147
}
7248

73-
private void setUpInfoButton() {
74-
Glyph infoGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.INFO_CIRCLE);
75-
infoGlyph.setColor(infoButtonColor);
76-
77-
infoStackPane = new StackPane(infoGlyph);
78-
infoStackPane.relocate(rectWidth - 6, (rectHeight - 8));
79-
infoStackPane.setVisible(false);
80-
}
81-
82-
8349
public CircleCell (String id, float xCoordinate, float yCoordinate, int collapsed) {
8450
this(id);
51+
boolean isLite = ControllerLoader.menuController.isLiteModeEnabled;
8552

8653
// Uncomment to see a colored background on the whole circle cell stack pane.
8754
// setStyle("-fx-background-smallButtonsColor: mediumslateblue");
@@ -91,11 +58,11 @@ public CircleCell (String id, float xCoordinate, float yCoordinate, int collapse
9158
this.collapsed = collapsed != 0;
9259
label = new Label("");
9360

94-
setUpDropShadow();
95-
setUpIdLabel(id);
61+
setUpDropShadow(isLite);
62+
setUpIdLabel(id, isLite);
9663
setUpMethodName();
9764
setUpButtons();
98-
setFill();
65+
setFill(isLite);
9966
setUpBookmark();
10067

10168
getChildren().addAll(nodeShape, methodNameLabel, idBubble, minMaxStackPane, infoStackPane, bookmarkBar);
@@ -123,6 +90,39 @@ public CircleCell (String id, float xCoordinate, float yCoordinate, int collapse
12390
this.relocate(xCoordinate , yCoordinate);
12491
}
12592

93+
private void setUpBookmark() {
94+
bookmarkBar = new Rectangle(rectWidth - 2, 30);
95+
bookmarkBar.relocate(1, -3);
96+
bookmarkBar.setFill(Color.TRANSPARENT);
97+
bookmarkBar.setStroke(Color.TRANSPARENT);
98+
bookmarkBar.setStrokeWidth(0.1);
99+
bookmarkBar.setArcWidth(20);
100+
bookmarkBar.setArcHeight(20);
101+
}
102+
103+
private void setUpButtons() {
104+
setUpMinMaxButton();
105+
setUpInfoButton();
106+
}
107+
108+
private void setUpMinMaxButton() {
109+
setMinMaxIcon();
110+
111+
minMaxStackPane = new StackPane(minMaxGlyph);
112+
minMaxStackPane.relocate(rectWidth - 6, -8);
113+
minMaxStackPane.setVisible(false);
114+
}
115+
116+
private void setUpInfoButton() {
117+
Glyph infoGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.INFO_CIRCLE);
118+
infoGlyph.setColor(infoButtonColor);
119+
120+
infoStackPane = new StackPane(infoGlyph);
121+
infoStackPane.relocate(rectWidth - 6, (rectHeight - 8));
122+
infoStackPane.setVisible(false);
123+
}
124+
125+
126126
public CircleCell(String id, float xCoordinate, float yCoordinate, String methodName, int collapsed) {
127127
this(id, xCoordinate, yCoordinate, collapsed);
128128
this.methodNameLabel.setText(methodName);
@@ -222,13 +222,20 @@ private Shape createRectangle() {
222222
return rect;
223223
}
224224

225-
private void setFill() {
226-
Stop[] stops = new Stop[] { new Stop(0, cell1Color), new Stop(1, cell2Color)};
227-
LinearGradient linearGradient = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
228-
nodeShape.setFill(linearGradient);
225+
private void setFill(boolean isLite) {
226+
if (isLite) {
227+
nodeShape.setFill(Color.WHITE);
228+
nodeShape.setStroke(Color.GREY);
229+
nodeShape.setStrokeWidth(0.5);
230+
} else {
231+
Stop[] stops = new Stop[] { new Stop(0, cell1Color), new Stop(1, cell2Color)};
232+
LinearGradient linearGradient = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
233+
nodeShape.setFill(linearGradient);
234+
}
235+
229236
}
230237

231-
private void setUpIdLabel(String id) {
238+
private void setUpIdLabel(String id, boolean isLite) {
232239
double x = 0, y = 0;
233240
Label idLabel = new Label(id);
234241
idLabel.setFont(Font.font(10));
@@ -242,17 +249,22 @@ private void setUpIdLabel(String id) {
242249
((Rectangle) background).setHeight(height);
243250
((Rectangle) background).setArcHeight(10);
244251
((Rectangle) background).setArcWidth(10);
245-
background.setFill(idBubbleBackgroundColor);
246-
247-
DropShadow dropShadow = new DropShadow();
248-
dropShadow.setWidth(width);
249-
dropShadow.setHeight(width);
250-
dropShadow.setOffsetX(2);
251-
dropShadow.setOffsetY(2);
252-
dropShadow.setRadius(5);
253-
dropShadow.setColor(idBubbleShadowColor);
254-
background.setEffect(dropShadow);
252+
background.setFill(idBubbleBackgroundColor);
255253

254+
if (isLite) {
255+
// background.setFill(Color.WHITE);
256+
// background.setStroke(ColorProp.GREY);
257+
// background.setStrokeWidth(.5);
258+
} else {
259+
DropShadow dropShadow = new DropShadow();
260+
dropShadow.setWidth(width);
261+
dropShadow.setHeight(width);
262+
dropShadow.setOffsetX(2);
263+
dropShadow.setOffsetY(2);
264+
dropShadow.setRadius(5);
265+
dropShadow.setColor(idBubbleShadowColor);
266+
background.setEffect(dropShadow);
267+
}
256268

257269
// background.setStroke(CustomColors.DARK_GREY.getPaint());
258270

@@ -261,15 +273,17 @@ private void setUpIdLabel(String id) {
261273
idBubble.relocate(-((Rectangle) background).getWidth() * 0.5, -((Rectangle) background).getHeight() * 0.5);
262274
}
263275

264-
private void setUpDropShadow() {
265-
DropShadow dropShadow = new DropShadow();
266-
dropShadow.setWidth(rectWidth);
267-
dropShadow.setHeight(rectHeight);
268-
dropShadow.setOffsetX(12);
269-
dropShadow.setOffsetY(12);
270-
dropShadow.setRadius(40);
271-
dropShadow.setColor(cellShadowColor);
272-
this.setEffect(dropShadow);
276+
private void setUpDropShadow(boolean isLite) {
277+
if (!isLite) {
278+
DropShadow dropShadow = new DropShadow();
279+
dropShadow.setWidth(rectWidth);
280+
dropShadow.setHeight(rectHeight);
281+
dropShadow.setOffsetX(12);
282+
dropShadow.setOffsetY(12);
283+
dropShadow.setRadius(40);
284+
dropShadow.setColor(cellShadowColor);
285+
this.setEffect(dropShadow);
286+
}
273287
}
274288

275289
// Color smallButtonsColor = Color.valueOf("#e5a2d0");

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.application.fxgraph.graph;
22

3+
import com.application.controller.ControllerLoader;
34
import javafx.scene.Group;
45
import javafx.scene.control.Label;
56
import javafx.scene.effect.Glow;
@@ -55,6 +56,8 @@ public Edge(Cell source, Cell target) {
5556

5657
public Edge(String edgeId, double startX, double endX, double startY, double endY) {
5758
this.edgeId = edgeId;
59+
boolean isLite = ControllerLoader.menuController.isLiteModeEnabled;
60+
5861
// this.source = source;
5962
// this.target = target;
6063
//
@@ -69,12 +72,19 @@ public Edge(String edgeId, double startX, double endX, double startY, double end
6972
line.setEndX(endX + Cell.prefWidth * .5 );
7073
line.setEndY(endY + Cell.prefHeight * .5 );
7174

72-
Glow glow = new Glow();
73-
glow.setLevel(0.4);
74-
// line.setEffect(glow);
7575

76-
line.setFill(Color.valueOf("#bab2f0"));
77-
line.setStroke(Color.valueOf("#dab2f0"));
76+
if (isLite) {
77+
line.setStroke(Color.valueOf("#bab2f0"));
78+
line.setStrokeWidth(0.8);
79+
// line.setFill(Color.valueOf("#bab2f0"));
80+
} else {
81+
// line.setFill(Color.valueOf("#bab2f0"));
82+
line.setStroke(Color.valueOf("#dab2f0"));
83+
84+
Glow glow = new Glow();
85+
glow.setLevel(0.5);
86+
line.setEffect(glow);
87+
}
7888

7989
// line.startXProperty().bind( source.layoutXProperty().add(source.getLayoutX()));
8090
// line.startYProperty().bind( source.layoutYProperty().add(source.getLayoutY()));

src/main/resources/fxml/menu.fxml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<?import javafx.scene.control.MenuItem?>
55

66
<?import javafx.scene.control.SeparatorMenuItem?>
7+
<?import javafx.scene.control.CheckMenuItem?>
78
<MenuBar fx:id="menuBar"
8-
fx:controller="com.application.controller.MenuController"
9+
fx:controller="com.application.controller.MenuController"
910
xmlns:fx="http://javafx.com/fxml/1">
1011

1112
<Menu fx:id="fileMenu" text="_File">
@@ -31,9 +32,12 @@
3132

3233
<Menu fx:id="bookmarksMenu" text="_Bookmarks"> </Menu>
3334

34-
3535
<Menu fx:id="debugMenu" text="_Debug">
3636
<MenuItem fx:id="printViewPortDimsMenuItem" text="Print _viewport dimensions"/>
3737
</Menu>
3838

39+
<Menu fx:id="settingMenu" text="_Settings">
40+
<CheckMenuItem fx:id="liteModeCheckMenuItem" text="Enable lite mode"/>
41+
</Menu>
42+
3943
</MenuBar>

0 commit comments

Comments
 (0)