11package ee .ut .similaritydetector .ui .controllers ;
22
33import 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 ;
48import javafx .application .Platform ;
59import javafx .beans .binding .Bindings ;
610import javafx .fxml .FXML ;
711import javafx .fxml .FXMLLoader ;
812import javafx .scene .control .*;
13+ import javafx .scene .image .Image ;
14+ import javafx .scene .image .ImageView ;
915import javafx .scene .layout .AnchorPane ;
1016import javafx .scene .layout .Priority ;
1117import javafx .scene .layout .VBox ;
1218import ee .ut .similaritydetector .backend .SimilarSolutionCluster ;
1319import ee .ut .similaritydetector .backend .SimilarSolutionPair ;
1420import ee .ut .similaritydetector .backend .Solution ;
1521import ee .ut .similaritydetector .ui .components .AccordionTableView ;
22+ import javafx .util .Duration ;
1623
1724import java .io .IOException ;
1825import 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 /**
0 commit comments