/* * Copyright 2015 Sudipto Chandra. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.sandsoft.cymric.view.components; import java.net.URL; import java.util.ResourceBundle; import org.sandsoft.cymric.util.Commons; import org.sandsoft.cymric.util.Logs; import javafx.beans.property.DoubleProperty; import javafx.beans.property.StringProperty; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; /** * FXML Controller class * * @author Sudipto Chandra */ public class StatusBar extends HBox implements Initializable { // // Controls // @FXML private Label statusLabel; @FXML private ProgressBar progressBar; //constructor public StatusBar() { } /** * Initializer for other values after FXML is loaded */ @Override public void initialize(URL location, ResourceBundle resources) { } // // Methods // /** * Gets status property on display. * * @return Status property on display. */ public StringProperty statusProperty() { return statusLabel.textProperty(); } /** * Gets the current status on display. * * @return Current status on display. */ public String getStatus() { return statusLabel.getText(); } /** * Sets an status to display. * * @param text Status to display. */ public void setStatus(String text) { this.setStatus(text, null); } /** * Sets an status to display with an icon. * * @param text Status to display. * @param icon Icon image to display. */ public void setStatus(String text, Image icon) { statusLabel.setGraphic(new ImageView(icon)); statusLabel.setText(text); } /** * Gets progress property on display. * * @return Progress property on display. */ public DoubleProperty progressProperty() { return progressBar.progressProperty(); } /** * Gets current progress on display. * * @return Current progress on display. */ public double getProgress() { return progressBar.getProgress(); } /** * Sets current progress to display. * * @param value Current progress between 0 and 1. */ public void setProgress(double value) { progressBar.setProgress(value); } /** * Sets current progress to display. * * @param value Current progress. * @param maximum Maximum progress. */ public void setProgress(double value, double maximum) { if (maximum == 0) { progressBar.setProgress(1); } else { progressBar.setProgress(value / maximum); } } }