Package NTNU.IDATT1002.controllers
Class Search
java.lang.Object
NTNU.IDATT1002.controllers.NavBarController
NTNU.IDATT1002.controllers.Search
- All Implemented Interfaces:
javafx.fxml.Initializable
public class Search extends NavBarController implements javafx.fxml.Initializable
Controls the buttons and changeable elements on search.fxml,
a page where you can search for images
- Version:
- 1.0 22.03.2020
-
Field Summary
Fields Modifier and Type Field Description javafx.scene.text.Text
albumsPlaceholder
javafx.scene.control.Tab
albumsTab
javafx.scene.text.Text
amountAlbums
javafx.scene.text.Text
amountImages
javafx.scene.text.Text
amountTotal
javafx.scene.text.Text
imagesPlaceholder
javafx.scene.control.Tab
imagesTab
javafx.scene.control.Button
nextBtn
javafx.scene.layout.VBox
pageRootContainer
javafx.scene.control.Button
previousBtn
javafx.scene.control.ProgressBar
progressBar
javafx.scene.layout.HBox
progressBarContainer
javafx.scene.layout.VBox
rootAlbumsContainer
javafx.scene.layout.VBox
rootImagesContainer
javafx.scene.text.Text
searchWord
javafx.scene.control.TabPane
tabContainer
Fields inherited from class NTNU.IDATT1002.controllers.NavBarController
navBarAlbums, navBarExplore, navBarLogo, navBarLogOut, navBarMap, navBarSearch, navBarSearchBtn, navBarUpload, returnButton
-
Constructor Summary
Constructors Constructor Description Search()
TellDataExchange
that search page was visited. -
Method Summary
Modifier and Type Method Description void
addTabListeners()
Method that updates next and previous buttons disable-properties based on the active tab.javafx.scene.layout.VBox
computeRootAlbumsContainerChildren(javafx.collections.ObservableList<Album> listOfAlbums, int start, int end)
Create aVBox
of albumHBox
children to add to a root container.javafx.scene.layout.VBox
computeRootImagesContainerChildren(javafx.collections.ObservableList<Image> listOfImages, int start, int end)
Create aVBox
of imageHBox
children to add to a root container.long
findId(javafx.scene.input.MouseEvent mouseEvent)
It takes a clicked element within an container and finds the fx:id of the main parentvoid
initialize(java.net.URL location, java.util.ResourceBundle resources)
Generates content based on the search word.void
switchToNext(javafx.event.ActionEvent actionEvent)
It finds out witch is current selected tab and if it is possible to load next content on that page.void
switchToPrevious(javafx.event.ActionEvent actionEvent)
It finds out witch is current selected tab and if it is possible to load previous content on that page.void
switchToViewAlbum(javafx.scene.input.MouseEvent mouseEvent)
Changes to view album page.void
switchToViewImage(javafx.scene.input.MouseEvent mouseEvent)
Changes to view image page.Methods inherited from class NTNU.IDATT1002.controllers.NavBarController
doBeforePageExit, enterSearch, goToPrevious, logOut, search, switchToAlbums, switchToExplore, switchToMain, switchToMap, switchToSearch, switchToUpload
-
Field Details
-
searchWord
public javafx.scene.text.Text searchWord -
amountTotal
public javafx.scene.text.Text amountTotal -
amountAlbums
public javafx.scene.text.Text amountAlbums -
amountImages
public javafx.scene.text.Text amountImages -
rootAlbumsContainer
public javafx.scene.layout.VBox rootAlbumsContainer -
rootImagesContainer
public javafx.scene.layout.VBox rootImagesContainer -
albumsPlaceholder
public javafx.scene.text.Text albumsPlaceholder -
imagesPlaceholder
public javafx.scene.text.Text imagesPlaceholder -
progressBar
public javafx.scene.control.ProgressBar progressBar -
progressBarContainer
public javafx.scene.layout.HBox progressBarContainer -
pageRootContainer
public javafx.scene.layout.VBox pageRootContainer -
tabContainer
public javafx.scene.control.TabPane tabContainer -
albumsTab
public javafx.scene.control.Tab albumsTab -
imagesTab
public javafx.scene.control.Tab imagesTab -
previousBtn
public javafx.scene.control.Button previousBtn -
nextBtn
public javafx.scene.control.Button nextBtn
-
-
Constructor Details
-
Search
public Search()TellDataExchange
that search page was visited. Display search word.
-
-
Method Details
-
initialize
public void initialize(java.net.URL location, java.util.ResourceBundle resources)Generates content based on the search word. Searches both images and albums. When the tasks is done the content is displayed as well as the number of each result type.- Specified by:
initialize
in interfacejavafx.fxml.Initializable
- Parameters:
location
-resources
-
-
addTabListeners
public void addTabListeners()Method that updates next and previous buttons disable-properties based on the active tab. If albums tab is active and it is not possible to go to next page due to too few search results, the button is disabled. -
computeRootImagesContainerChildren
public javafx.scene.layout.VBox computeRootImagesContainerChildren(javafx.collections.ObservableList<Image> listOfImages, int start, int end)Create aVBox
of imageHBox
children to add to a root container.- Parameters:
listOfImages
- the images to addstart
- min index of image list to be addedend
- max index of images list to be added- Returns:
- the VBox containing image containers
-
computeRootAlbumsContainerChildren
public javafx.scene.layout.VBox computeRootAlbumsContainerChildren(javafx.collections.ObservableList<Album> listOfAlbums, int start, int end)Create aVBox
of albumHBox
children to add to a root container. Load each corresponding preview images in a separate background task and add them when ready.- Parameters:
listOfAlbums
- the albums to addstart
- min index of albums list to be addedend
- max index of albums list to be added- Returns:
- the VBox containing album containers
-
switchToPrevious
public void switchToPrevious(javafx.event.ActionEvent actionEvent) throws java.io.IOExceptionIt finds out witch is current selected tab and if it is possible to load previous content on that page. If yes it updates content to previous elements of the list.- Parameters:
actionEvent
-- Throws:
java.io.IOException
-
switchToNext
public void switchToNext(javafx.event.ActionEvent actionEvent) throws java.io.IOExceptionIt finds out witch is current selected tab and if it is possible to load next content on that page. If yes it updates content to next elements of the list.- Parameters:
actionEvent
-- Throws:
java.io.IOException
-
switchToViewImage
public void switchToViewImage(javafx.scene.input.MouseEvent mouseEvent) throws java.io.IOExceptionChanges to view image page. It takes a clicked element within an image container and finds the fx:id of the main parent, and passes the value toDataExchange
.- Parameters:
mouseEvent
-- Throws:
java.io.IOException
-
switchToViewAlbum
public void switchToViewAlbum(javafx.scene.input.MouseEvent mouseEvent) throws java.io.IOExceptionChanges to view album page. It takes a clicked element within an album container and finds the fx:id of the main parent, and passes the value toDataExchange
.- Parameters:
mouseEvent
-- Throws:
java.io.IOException
-
findId
public long findId(javafx.scene.input.MouseEvent mouseEvent)It takes a clicked element within an container and finds the fx:id of the main parent- Parameters:
mouseEvent
-- Returns:
- main containers id of clicked element
-