Skip to content

Commit bdd3ce2

Browse files
committed
Code view's cluster pane has a hide/show button now.
1 parent ab6ec0b commit bdd3ce2

File tree

4 files changed

+91
-15
lines changed

4 files changed

+91
-15
lines changed

src/main/java/ee/ut/similaritydetector/ui/components/AccordionTableView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public AccordionTableView(SimilarSolutionCluster cluster) {
7272

7373
// TitledPane restrictions
7474
this.setExpanded(false);
75-
this.setMinWidth(200);
75+
this.setMinWidth(0);
7676
this.setMaxWidth(400);
7777
this.setWrapText(true);
7878
}

src/main/java/ee/ut/similaritydetector/ui/controllers/CodeViewController.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package ee.ut.similaritydetector.ui.controllers;
22

33
import ee.ut.similaritydetector.backend.Analyser;
4+
import javafx.animation.Interpolator;
5+
import javafx.animation.KeyFrame;
6+
import javafx.animation.KeyValue;
7+
import javafx.animation.Timeline;
48
import javafx.application.Platform;
59
import javafx.beans.binding.Bindings;
610
import javafx.fxml.FXML;
711
import javafx.fxml.FXMLLoader;
812
import javafx.scene.control.*;
13+
import javafx.scene.image.Image;
14+
import javafx.scene.image.ImageView;
915
import javafx.scene.layout.AnchorPane;
1016
import javafx.scene.layout.Priority;
1117
import javafx.scene.layout.VBox;
1218
import ee.ut.similaritydetector.backend.SimilarSolutionCluster;
1319
import ee.ut.similaritydetector.backend.SimilarSolutionPair;
1420
import ee.ut.similaritydetector.backend.Solution;
1521
import ee.ut.similaritydetector.ui.components.AccordionTableView;
22+
import javafx.util.Duration;
1623

1724
import java.io.IOException;
1825
import java.util.ArrayList;
@@ -34,6 +41,8 @@ public class CodeViewController {
3441
private VBox solutionClusterView;
3542
@FXML
3643
private SplitPane codeSplitPane;
44+
@FXML
45+
private Button hideSideBarButton;
3746

3847
@FXML
3948
private MenuItem closeAllTabsMenuItem;
@@ -83,6 +92,50 @@ private void initialize() {
8392
);
8493
closeAllTabsMenuItem.setVisible(true);
8594
closeAllTabsMenuItem.setOnAction(e -> closeAllCodeTabs());
95+
hideSideBarButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
96+
hideSideBarButton.setOnAction(event -> Platform.runLater(this::hideClusterPane));
97+
ImageView arrowImg = new ImageView(new Image(
98+
getClass().getResourceAsStream("/ee/ut/similaritydetector/img/hidearrow.png")));
99+
arrowImg.setFitHeight(13);
100+
arrowImg.setFitWidth(9);
101+
hideSideBarButton.setGraphic(arrowImg);
102+
}
103+
104+
/**
105+
* Animates the closing of cluster pane.
106+
*/
107+
private void hideClusterPane(){
108+
Duration duration = Duration.millis(300);
109+
solutionClusterView.setPrefWidth(solutionClusterView.getWidth());
110+
solutionClusterView.setMinWidth(solutionClusterView.getWidth());
111+
Timeline timeline = new Timeline(
112+
new KeyFrame(duration,
113+
new KeyValue(solutionClusterView.maxWidthProperty(), 0, Interpolator.EASE_OUT),
114+
new KeyValue(solutionClusterView.minWidthProperty(), 0, Interpolator.EASE_OUT)));
115+
timeline.setOnFinished(event -> {
116+
solutionClusterView.setVisible(false);
117+
hideSideBarButton.setOnAction(e -> Platform.runLater(this::openClusterPane));
118+
});
119+
hideSideBarButton.setOnAction(e -> {});
120+
timeline.play();
121+
hideSideBarButton.setRotate(180);
122+
123+
}
124+
125+
/**
126+
* Animates the opening of cluster pane.
127+
*/
128+
public void openClusterPane(){
129+
Duration duration = Duration.millis(300);
130+
Timeline timeline = new Timeline(
131+
new KeyFrame(duration,
132+
new KeyValue(solutionClusterView.maxWidthProperty(), solutionClusterView.getPrefWidth(), Interpolator.EASE_OUT),
133+
new KeyValue(solutionClusterView.minWidthProperty(), solutionClusterView.getPrefWidth(), Interpolator.EASE_OUT)));
134+
solutionClusterView.setVisible(true);
135+
timeline.setOnFinished(event -> hideSideBarButton.setOnAction(e -> Platform.runLater(this::hideClusterPane)));
136+
hideSideBarButton.setOnAction(e -> {});
137+
timeline.play();
138+
hideSideBarButton.setRotate(0);
86139
}
87140

88141
/**
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<?import javafx.geometry.Insets?>
4+
<?import javafx.scene.control.Button?>
35
<?import javafx.scene.control.ContextMenu?>
46
<?import javafx.scene.control.MenuItem?>
57
<?import javafx.scene.control.SplitPane?>
68
<?import javafx.scene.layout.AnchorPane?>
79
<?import javafx.scene.layout.BorderPane?>
810
<?import javafx.scene.layout.VBox?>
911

10-
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="600.0" prefHeight="700.0" prefWidth="1000.0" stylesheets="/ee/ut/similaritydetector/style/style.scss, /ee/ut/similaritydetector/style/code_view_style.scss" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ee.ut.similaritydetector.ui.controllers.CodeViewController">
12+
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="600.0" prefHeight="700.0" prefWidth="1000.0" stylesheets="/ee/ut/similaritydetector/style/style.scss, /ee/ut/similaritydetector/style/code_view_style.scss" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ee.ut.similaritydetector.ui.controllers.CodeViewController">
1113
<children>
12-
<BorderPane prefHeight="700.0" prefWidth="1000.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
14+
<BorderPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
1315
<center>
14-
<SplitPane fx:id="codeSplitPane" BorderPane.alignment="CENTER">
15-
<contextMenu>
16-
<ContextMenu>
17-
<items>
18-
<MenuItem fx:id="closeAllTabsMenuItem" mnemonicParsing="false" onAction="#closeAllCodeTabs" text="Close all tabs"/>
19-
</items>
20-
</ContextMenu>
21-
</contextMenu></SplitPane>
16+
<BorderPane prefHeight="700.0" prefWidth="1000.0">
17+
<center>
18+
<SplitPane fx:id="codeSplitPane" BorderPane.alignment="CENTER">
19+
<contextMenu>
20+
<ContextMenu>
21+
<items>
22+
<MenuItem fx:id="closeAllTabsMenuItem" mnemonicParsing="false" onAction="#closeAllCodeTabs" text="Close all tabs" />
23+
</items>
24+
</ContextMenu>
25+
</contextMenu>
26+
</SplitPane>
27+
</center>
28+
<left>
29+
<VBox fx:id="solutionClusterView" />
30+
</left>
31+
<top>
32+
<fx:include fx:id="menuBar" source="menu_bar.fxml" />
33+
</top>
34+
</BorderPane>
2235
</center>
2336
<left>
24-
<VBox fx:id="solutionClusterView" BorderPane.alignment="CENTER" />
37+
<Button fx:id="hideSideBarButton" focusTraversable="false" mnemonicParsing="false" prefHeight="20.0" prefWidth="20.0" text="Button" BorderPane.alignment="CENTER">
38+
<BorderPane.margin>
39+
<Insets right="-25.0" />
40+
</BorderPane.margin>
41+
</Button>
2542
</left>
26-
<top>
27-
<fx:include fx:id="menuBar" source="menu_bar.fxml" />
28-
</top>
2943
</BorderPane>
3044
</children>
3145
</AnchorPane>

src/main/resources/ee/ut/similaritydetector/style/code_view_style.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@
3737
.titledPane-multiline > .title > .arrow-button {
3838
-fx-translate-x: -20; /* move back arrow, which is also subject to the padding */
3939
}
40+
41+
#hideSideBarButton {
42+
-fx-background-radius: 1000;
43+
-fx-opacity: 0.85;
44+
}
45+
46+
#hideSideBarButton:focused {
47+
-fx-background-insets: 0;
48+
}

0 commit comments

Comments
 (0)