package application; import jalviewfx.controllers.engine.ControlledScreen; import jalviewfx.controllers.engine.ScreensController; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.TextField; import javafx.scene.text.TextAlignment; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; public class Controller implements Initializable, ControlledScreen { @FXML private WebView browser; @FXML private TextField tf; @FXML private Canvas canvas; ScreensController myController; @FXML void initialize() { String pre_msg = "fx:id=\""; String post_msg = "\" was not ingected: check the FXML file 'TestUI.fxml' "; assert browser != null : pre_msg + "map_listview" + post_msg; assert canvas != null : pre_msg + "canvas" + post_msg; System.out.println("Textfield : "+tf); System.out.println("Canvas : "+canvas); } public void doSmt() throws MalformedURLException, IOException { System.out.println("do smt .."); System.out.println(tf.getText()); System.out.println(browser.getId()); WebEngine webEngine = browser.getEngine(); webEngine.load(getClass().getResource("/html/alignment.html").toString()); } public void gotoStageTwo() throws IOException{ System.out.println("Going to next stage"); Scene sceneTwo = new Scene((Parent) FXMLLoader.load(getClass().getResource("/fxml/TestUI.fxml"))); Main.getPrimaryStage().setScene(sceneTwo); } public void useCanvas() { System.out.println("Canvas object ------> "+canvas); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setTextAlign(TextAlignment.JUSTIFY); // gc.setTextBaseline(VPos.TOP); String longestSeq = "MASVSATMISTSFMPRKPAVTSLKPIP-NVG-EALFGLKS---ANGGKVTCMASYKVKLITPDGPIEFDCPDNVYILDQAEEAGHDLPYSCRAGSCSSCAGKIAGGAVDQT"; int charSpace = 0; double fontSize = 8;//gc.getFont().getSize(); for(int x = 1; x < longestSeq.length(); x++){ if(x % 10 == 0){ gc.fillText(String.valueOf(x), charSpace, 15); }else{ gc.fillText(" ", charSpace, 15); } if(x % 5 == 0){ gc.fillText("|", charSpace, 30); } charSpace += fontSize; } gc.fillText(longestSeq, 0, 45); gc.fillText("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 60); } @Override public void setScreenParent(ScreensController screenParent) { myController = screenParent; } @Override public void initialize(URL paramURL, ResourceBundle paramResourceBundle) { // TODO Auto-generated method stub } }