List of usage examples for javafx.scene.shape Line setLayoutX
public final void setLayoutX(double value)
From source file:editeurpanovisu.EditeurPanovisu.java
private void afficheNord(double longitude) { double largeur = imagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX(); Node ancPoV = (Node) pano.lookup("#Nord"); if (ancPoV != null) { pano.getChildren().remove(ancPoV); }//from www .ja v a 2s.com Line ligne = new Line(0, 0, 0, imagePanoramique.getFitHeight()); ligne.setCursor(Cursor.DEFAULT); ligne.setLayoutX(X); ligne.setStroke(Color.RED); ligne.setStrokeWidth(4); ligne.setId("Nord"); ligne.setOnDragDetected((MouseEvent me1) -> { ligne.setStroke(Color.BLUEVIOLET); dragDrop = true; me1.consume(); }); ligne.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getSceneX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } ligne.setLayoutX(XX + imagePanoramique.getLayoutX()); me1.consume(); }); ligne.setOnMouseReleased((MouseEvent me1) -> { double X1 = me1.getSceneX(); double mouseX1 = X1 - imagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > imagePanoramique.getFitWidth()) { mouseX1 = imagePanoramique.getFitWidth(); } double regardX = 360.0f * mouseX1 / largeur - 180; panoramiquesProjet[panoActuel].setZeroNord(regardX); ligne.setStroke(Color.RED); me1.consume(); }); pano.getChildren().add(ligne); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param longitude//from w w w.j a v a2s . c om */ private static void afficheNord(double longitude) { double largeur = ivImagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + ivImagePanoramique.getLayoutX(); Node nodeAncienNord = (Node) panePanoramique.lookup("#Nord"); if (nodeAncienNord != null) { panePanoramique.getChildren().remove(nodeAncienNord); } Line lineNord = new Line(0, 0, 0, ivImagePanoramique.getFitHeight()); lineNord.setCursor(Cursor.DEFAULT); lineNord.setLayoutX(X); lineNord.setStroke(Color.RED); lineNord.setStrokeWidth(4); lineNord.setId("Nord"); lineNord.setOnDragDetected((mouseEvent1) -> { lineNord.setStroke(Color.BLUEVIOLET); bDragDrop = true; mouseEvent1.consume(); }); lineNord.setOnMouseDragged((me1) -> { double XX = me1.getSceneX() - ivImagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > ivImagePanoramique.getFitWidth()) { XX = ivImagePanoramique.getFitWidth(); } lineNord.setLayoutX(XX + ivImagePanoramique.getLayoutX()); me1.consume(); double YY = me1.getY(); afficheLoupe(XX, YY); }); lineNord.setOnMouseReleased((me1) -> { double X1 = me1.getSceneX(); double mouseX1 = X1 - ivImagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > ivImagePanoramique.getFitWidth()) { mouseX1 = ivImagePanoramique.getFitWidth(); } double regardX = 360.0f * mouseX1 / largeur - 180; navigateurPanoramique.setPositNord(regardX - 180); navigateurPanoramique.affiche(); getPanoramiquesProjet()[getiPanoActuel()].setZeroNord(regardX); lineNord.setStroke(Color.RED); me1.consume(); }); panePanoramique.getChildren().add(lineNord); }
From source file:view.FXApplicationController.java
@Override public void initialize(URL arg0, ResourceBundle arg1) { System.out.println("initialize called"); overlay3.addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() { @Override/*ww w . j a v a 2 s.c o m*/ public void handle(MouseEvent mouse) { mouseX.set(mouse.getX()); mouseY.set(mouse.getY()); if (kComplexFlag) { if (mouse.getEventType() == MouseEvent.MOUSE_PRESSED) { Line line = new Line(); line.setStyle("-fx-stroke: red;"); overlay3.getChildren().add(line); line.setStartX(0); line.setStartY(0); line.setLayoutX(mouseX.get()); line.setLayoutY(mouseY.get()); lines.add(line); } if (mouse.isPrimaryButtonDown() && (!lines.isEmpty())) { Line line = lines.getLast(); double endXPos = mouseX.get() - line.getLayoutX(); double endYPos = mouseY.get() - line.getLayoutY(); line.setEndX(endXPos); line.setEndY(endYPos); calculatePercentageKComplex(); } } if (help1Flag) { double offsetSize = 1. / (activeChannels.size() + 1.); double posOnOverlay = mouse.getY(); double zoom = 1.0; for (int i = 0; i < activeChannels.size(); i++) { double realOffset = (1 - (i + 1.) * offsetSize); double upperBound = yAxis.getDisplayPosition( (realOffset - offsetSize / 2.) * yAxis.getUpperBound()) + yAxis.getLayoutY(); double lowerBound = yAxis.getDisplayPosition( (realOffset + offsetSize / 2.) * yAxis.getUpperBound()) + yAxis.getLayoutY(); if ((posOnOverlay <= upperBound) && (posOnOverlay > lowerBound)) { zoom = getZoomFromChannel(activeChannels.get(i)); } } space.set(75.0 * zoom / yAxis.getUpperBound() * yAxis.getHeight()); line1.setVisible(true); line2.setVisible(true); } else { line1.setVisible(false); line2.setVisible(false); } } }); //Key Listener lineChart.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { keyAction(ke); } }); toolBarGoto.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ENTER) { int valueTextField = -1; try { valueTextField = Integer.parseInt(toolBarGoto.getText()); } catch (NumberFormatException e) { toolBarGoto.setText((currentEpoch + 1) + ""); valueTextField = currentEpoch + 1; Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Error during handling enter key.", e); } if (valueTextField > dataModel.getNumberOf30sEpochs()) { valueTextField = dataModel.getNumberOf30sEpochs(); } else if (valueTextField < 1) { valueTextField = 1; } currentEpoch = valueTextField - 1; goToEpoch(currentEpoch); if (kComplexFlag) { calculatePercentageKComplex(); } } } }); choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); if (newValue != null) { featureModel.setFeatureChannel(Arrays.asList(channelNames).indexOf(newValue)); System.out.println("########" + Arrays.asList(channelNames).indexOf(newValue)); System.out.println(featureModel.getFeatureChannel()); featureModel.setTsneComputed(false); featureModel.setFeaturesComputed(false); featureModel.setClassificationDone(false); featureModel.setReadinDone(false); classifyButton.setDisable(false); recompute = true; if (viewModel.isKcMarkersActive()) { computeKCfeatures(); } else { overlay4.getChildren().clear(); } } } }); choiceBoxModel.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { classifier = classifierList.get(newValue.intValue()); System.out.println(classifier); featureModel.setClassificationDone(false); featureModel.setReadinDone(false); classifyButton.setDisable(false); recompute = true; } }); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { System.out.println("RandomAccessFile closed"); dataModel.getReader().close(); Platform.exit(); } }); kComplexOnAction(); help1OnAction(); }