List of usage examples for javafx.beans.property SimpleIntegerProperty SimpleIntegerProperty
public SimpleIntegerProperty(int initialValue)
From source file:Main.java
public static void main(String[] args) { IntegerProperty x = new SimpleIntegerProperty(100); IntegerProperty y = new SimpleIntegerProperty(200); // Create a binding: sum = x + y NumberBinding sum = x.add(y);/*www . j av a2 s.c om*/ System.out.println("After creating sum"); System.out.println("sum.isValid(): " + sum.isValid()); // Let us get the value of sum, so it computes its value and // becomes valid int value = sum.intValue(); System.out.println(); System.out.println("After requesting value"); System.out.println("sum.isValid(): " + sum.isValid()); System.out.println("sum = " + value); // Change the value of x x.set(250); System.out.println(); System.out.println("After changing x"); System.out.println("sum.isValid(): " + sum.isValid()); // Get the value of sum again value = sum.intValue(); System.out.println(); System.out.println("After requesting value"); System.out.println("sum.isValid(): " + sum.isValid()); System.out.println("sum = " + value); }
From source file:Main.java
public static void main(String[] args) { IntegerProperty intProperty = new SimpleIntegerProperty(1024); final ChangeListener changeListener = new ChangeListener() { @Override//from w ww.j a v a 2s.c o m public void changed(ObservableValue observableValue, Object oldValue, Object newValue) { System.out.println("oldValue:" + oldValue + ", newValue = " + newValue); } }; intProperty.addListener(changeListener); intProperty.set(5120); intProperty.removeListener(changeListener); intProperty.set(6144); }
From source file:Main.java
public static void main(String[] args) { IntegerProperty x1 = new SimpleIntegerProperty(0); IntegerProperty y1 = new SimpleIntegerProperty(0); final NumberBinding x1y2 = Bindings.multiply(x1, y1); final NumberBinding sum1 = Bindings.add(x1y2, 2); final NumberBinding diff1 = Bindings.subtract(sum1, 1); final NumberBinding determinant = Bindings.subtract(diff1, 2); final NumberBinding area = Bindings.divide(determinant, 2.0D); x1.set(0);/*w w w . ja v a2 s. c o m*/ y1.set(0); printResult(x1, y1, area); x1.set(1); y1.set(0); printResult(x1, y1, area); }
From source file:Main.java
public static void main(String[] args) { IntegerProperty x1 = new SimpleIntegerProperty(0); IntegerProperty y1 = new SimpleIntegerProperty(0); final NumberBinding area = x1.multiply(y1).divide(2.0D); StringExpression output = Bindings.format("For A(%d,%d), the area is %3.1f", x1, y1, area); x1.set(0);/* w w w.ja v a 2 s.c o m*/ y1.set(0); System.out.println(output.get()); x1.set(10); y1.set(110); System.out.println(output.get()); }
From source file:Main.java
public static void main(String[] args) { SimpleIntegerProperty xProperty = new SimpleIntegerProperty(0); // Adding a invalidation listener (anonymous inner class) xProperty.addListener(new InvalidationListener() { @Override/*from w w w . j a v a 2 s .com*/ public void invalidated(Observable o) { System.out.println(o.toString()); } }); // Adding a invalidation listener (lambda expression) xProperty.addListener((Observable o) -> { System.out.println(o.toString()); }); }
From source file:mesclasses.model.Cours.java
public Cours() { this.id = RandomStringUtils.randomAlphanumeric(5); day = new SimpleStringProperty(); classe = new SimpleObjectProperty<>(); room = new SimpleStringProperty(""); week = new SimpleStringProperty(); startHour = new SimpleIntegerProperty(8); startMin = new SimpleIntegerProperty(0); endHour = new SimpleIntegerProperty(9); endMin = new SimpleIntegerProperty(0); ponctuel = new SimpleBooleanProperty(false); }
From source file:com.adobe.ags.curly.model.ActionResult.java
public ActionResult(ActionRunner runner) { this.runner = runner; reportRow().add(new SimpleStringProperty(runner.getAction().getName())); reportRow().add(new SimpleStringProperty("")); reportRow().add(new SimpleIntegerProperty(0)); reportRow().add(new SimpleStringProperty("")); reportRow().add(getDuration());//from ww w . j a v a 2 s.c o m setStatus(NOT_STARTED, 0, ""); }
From source file:com.adobe.ags.curly.model.ActionResult.java
public ActionResult(String name, Exception ex) { reportRow().add(new SimpleStringProperty(name)); reportRow().add(new SimpleStringProperty("Failure")); reportRow().add(new SimpleIntegerProperty(0)); reportRow().add(new SimpleStringProperty("")); reportRow().add(getDuration());/* www .j a va2 s .c o m*/ setException(ex); }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void editVoxelSpace(final File voxelFile) { if (editingFrameOpened) { return;// w w w .j av a 2s.co m } editingFrameOpened = true; voxelsToRemove.clear(); final String attributeToView = "PadBVTotal"; //window size ObservableList<Screen> screens = Screen.getScreens(); if (screens != null && screens.size() > 0) { SCREEN_WIDTH = screens.get(0).getBounds().getWidth(); SCREEN_HEIGHT = screens.get(0).getBounds().getHeight(); } try { Service s = new Service() { @Override protected Task createTask() { return new Task() { @Override protected Object call() throws Exception { SimpleViewer viewer3D = new SimpleViewer((int) (SCREEN_WIDTH / 4.0d), (int) (SCREEN_HEIGHT / 4.0d), (int) (SCREEN_WIDTH / 1.5d), (int) (SCREEN_HEIGHT / 2.0d), voxelFile.toString()); fr.amap.viewer3d.object.scene.Scene scene = viewer3D.getScene(); /** * *VOXEL SPACE** */ updateMessage("Loading voxel space: " + voxelFile.getAbsolutePath()); final VoxelSpaceSceneObject voxelSpace = new VoxelSpaceSceneObject(voxelFile); voxelSpace.setMousePickable(true); voxelSpace.addVoxelSpaceListener(new VoxelSpaceAdapter() { @Override public void voxelSpaceCreationProgress(int progress) { updateProgress(progress, 100); } }); voxelSpace.loadVoxels(); float voxelResolution = voxelSpace.data.getVoxelSpaceInfos().getResolution(); VoxelFileReader reader = new VoxelFileReader(voxelFile); VoxelSpaceInfos infos = reader.getVoxelSpaceInfos(); final SceneObject boundingBox = new SimpleSceneObject(); boundingBox.setMesh(GLMeshFactory.createBoundingBox((float) infos.getMinCorner().x, (float) infos.getMinCorner().y, (float) infos.getMinCorner().z, (float) infos.getMaxCorner().x, (float) infos.getMaxCorner().y, (float) infos.getMaxCorner().z)); SimpleShader s = new SimpleShader(); s.setColor(new Vec3F(1, 0, 0)); boundingBox.setShader(s); boundingBox.setDrawType(GLMesh.DrawType.LINES); scene.addSceneObject(boundingBox); /* * Voxel information */ StringToImage stringToImage = new StringToImage(1024, 1024); stringToImage.setAdaptableFontSize(true); stringToImage.setBackgroundColor(new Color(255, 255, 255, 127)); stringToImage.setTextColor(new Color(0, 0, 0, 255)); BufferedImage image = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_ARGB); Texture texture = new Texture(image); int pickingInfoObjectWidth = viewer3D.getWidth() / 5; int pickingInfoObjectHeight = viewer3D.getHeight() / 5; SceneObject pickingInfoObject = SceneObjectFactory.createTexturedPlane( new Vec3F(viewer3D.getWidth() - pickingInfoObjectWidth, viewer3D.getHeight() - pickingInfoObjectHeight, 0), pickingInfoObjectWidth, pickingInfoObjectHeight, texture); pickingInfoObject.setShader(new TextureShader()); pickingInfoObject.setDrawType(GLMesh.DrawType.TRIANGLES); SceneObject sceneObjectSelectedVox = new SimpleSceneObject( GLMeshFactory.createBoundingBox(-voxelResolution / 2.0f, -voxelResolution / 2.0f, -voxelResolution / 2.0f, voxelResolution / 2.0f, voxelResolution / 2.0f, voxelResolution / 2.0f), false); SimpleShader simpleShader = new SimpleShader(); simpleShader.setColor(new Vec3F(1, 0, 0)); sceneObjectSelectedVox.setVisible(false); sceneObjectSelectedVox.setShader(simpleShader); sceneObjectSelectedVox.setDrawType(GLMesh.DrawType.LINES); viewer3D.getScene().addSceneObject(sceneObjectSelectedVox); final SimpleObjectProperty<VoxelObject> selectedVoxel = new SimpleObjectProperty<>(); SceneObjectListener listener = new SceneObjectListener() { @Override public void clicked(SceneObject sceneObject, MousePicker mousePicker, Point3D intersection) { Vec3F camLocation = viewer3D.getScene().getCamera().getLocation(); selectedVoxel.set(voxelSpace.doPicking(mousePicker)); if (selectedVoxel.get() != null) { String[][] lines = new String[voxelSpace.getColumnsNames().length][2]; for (int i = 0; i < voxelSpace.getColumnsNames().length; i++) { lines[i][0] = voxelSpace.getColumnsNames()[i]; float attribut = selectedVoxel.get().getAttributs()[i]; if (Float.isNaN(attribut)) { lines[i][1] = "NaN"; } else { lines[i][1] = String .valueOf(Math.round(attribut * 1000.0f) / 1000.0f); } } arrangeText(lines); String text = ""; for (int i = 0; i < voxelSpace.getColumnsNames().length; i++) { String attribut = lines[i][0] + " " + lines[i][1]; text += attribut + "\n"; } stringToImage.setText(text, 0, 0); texture.setBufferedImage(stringToImage.buildImage()); Point3f voxelPosition = voxelSpace.getVoxelPosition(selectedVoxel.get().$i, selectedVoxel.get().$j, selectedVoxel.get().$k); sceneObjectSelectedVox.setPosition( new Point3F(voxelPosition.x, voxelPosition.y, voxelPosition.z)); sceneObjectSelectedVox.setVisible(true); pickingInfoObject.setVisible(true); } else { sceneObjectSelectedVox.setVisible(false); pickingInfoObject.setVisible(false); } } }; final SimpleIntegerProperty currentZCropIndex = new SimpleIntegerProperty(0); viewer3D.addEventListener(new EventManager(null, new InputKeyListener()) { @Override public void updateEvents() { if (this.keyboard.isKeyClicked(KeyEvent.VK_DELETE)) { if (selectedVoxel.get() != null) { selectedVoxel.get().setAlpha(0); selectedVoxel.get().isHidden = true; voxelSpace.updateVao(); sceneObjectSelectedVox.setVisible(false); pickingInfoObject.setVisible(false); voxelsToRemove.add(new Point3i(selectedVoxel.get().$i, selectedVoxel.get().$j, selectedVoxel.get().$k)); } } } }); voxelSpace.addSceneObjectListener(listener); voxelSpace.changeCurrentAttribut(attributeToView); voxelSpace.setShader(new InstanceLightedShader()); voxelSpace.setDrawType(GLMesh.DrawType.TRIANGLES); scene.addSceneObject(voxelSpace); scene.addSceneObjectAsHud(pickingInfoObject); /** * *scale** */ updateMessage("Generating scale"); final Texture scaleTexture = new Texture(ScaleGradient.createColorScaleBufferedImage( voxelSpace.getGradient(), voxelSpace.getAttributValueMin(), voxelSpace.getAttributValueMax(), viewer3D.getWidth() - 80, (int) (viewer3D.getHeight() / 20), ScaleGradient.Orientation.HORIZONTAL, 5, 8)); SceneObject scalePlane = SceneObjectFactory.createTexturedPlane(new Vec3F(40, 20, 0), (int) (viewer3D.getWidth() - 80), (int) (viewer3D.getHeight() / 20), scaleTexture); scalePlane.setShader(new TextureShader()); scalePlane.setDrawType(GLMesh.DrawType.TRIANGLES); scene.addSceneObjectAsHud(scalePlane); voxelSpace.addPropertyChangeListener("gradientUpdated", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { BufferedImage image = ScaleGradient.createColorScaleBufferedImage( voxelSpace.getGradient(), voxelSpace.getAttributValueMin(), voxelSpace.getAttributValueMax(), viewer3D.getWidth() - 80, (int) (viewer3D.getHeight() / 20), ScaleGradient.Orientation.HORIZONTAL, 5, 8); scaleTexture.setBufferedImage(image); } }); /** * *light** */ scene.setLightPosition( new Point3F(voxelSpace.getGravityCenter().x, voxelSpace.getGravityCenter().y, voxelSpace.getGravityCenter().z + voxelSpace.widthZ + 100)); /** * *camera** */ TrackballCamera trackballCamera = new TrackballCamera(); trackballCamera.setPivot(voxelSpace); trackballCamera .setLocation(new Vec3F(voxelSpace.getGravityCenter().x + voxelSpace.widthX, voxelSpace.getGravityCenter().y + voxelSpace.widthY, voxelSpace.getGravityCenter().z + voxelSpace.widthZ)); viewer3D.getScene().setCamera(trackballCamera); Platform.runLater(new Runnable() { @Override public void run() { final Stage toolBarFrameStage = new Stage(); final FXMLLoader loader = new FXMLLoader( getClass().getResource("/fxml/ToolBoxFrame.fxml")); try { stage.setAlwaysOnTop(false); Parent root = loader.load(); toolBarFrameStage.setScene(new Scene(root)); toolBarFrameStage.initStyle(StageStyle.UNDECORATED); toolBarFrameStage.setAlwaysOnTop(true); ToolBoxFrameController toolBarFrameController = loader.getController(); toolBarFrameController.setStage(toolBarFrameStage); toolBarFrameStage.setX(viewer3D.getPosition().getX()); toolBarFrameStage.setY(viewer3D.getPosition().getY()); toolBarFrameController.setJoglListener(viewer3D.getJoglContext()); toolBarFrameController.setAttributes(attributeToView, voxelSpace.data.getVoxelSpaceInfos().getColumnNames()); toolBarFrameStage.focusedProperty() .addListener(new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { toolBarFrameStage.setAlwaysOnTop(true); toolBarFrameStage.setX(viewer3D.getPosition().getX()); toolBarFrameStage.setY(viewer3D.getPosition().getY()); } else if (!viewer3D.isFocused()) { toolBarFrameStage.setAlwaysOnTop(false); } } }); toolBarFrameController.initContent(voxelSpace); toolBarFrameStage.setAlwaysOnTop(true); toolBarFrameStage.show(); double maxToolBoxHeight = toolBarFrameStage.getHeight(); viewer3D.getJoglContext().setStartX((int) toolBarFrameStage.getWidth()); viewer3D.getRenderFrame().addWindowListener(new WindowAdapter() { @Override public void windowResized(com.jogamp.newt.event.WindowEvent we) { Window window = (Window) we.getSource(); final double height = window.getHeight(); Platform.runLater(new Runnable() { @Override public void run() { if (height < maxToolBoxHeight) { toolBarFrameStage.setHeight(height); } else { toolBarFrameStage.setHeight(maxToolBoxHeight); } toolBarFrameStage.setX(viewer3D.getPosition().getX()); toolBarFrameStage.setY(viewer3D.getPosition().getY()); } }); } @Override public void windowMoved(com.jogamp.newt.event.WindowEvent we) { Platform.runLater(new Runnable() { @Override public void run() { toolBarFrameStage.setX(viewer3D.getPosition().getX()); toolBarFrameStage.setY(viewer3D.getPosition().getY()); } }); } @Override public void windowDestroyed(com.jogamp.newt.event.WindowEvent we) { Platform.runLater(new Runnable() { @Override public void run() { toolBarFrameStage.close(); if (fcSaveVoxelFileForAreaExtracting == null) { fcSaveVoxelFileForAreaExtracting = new FileChooserContext(); if (fcOpenVoxelFileForAreaExtracting != null) { fcSaveVoxelFileForAreaExtracting.fc .setInitialDirectory( fcOpenVoxelFileForAreaExtracting.lastSelectedFile .getParentFile()); } } File selectedFile = fcSaveVoxelFileForAreaExtracting .showSaveDialog(stage); if (selectedFile != null) { VoxelFileReader reader; BufferedWriter writer = null; try { reader = new VoxelFileReader(voxelFile, true); VoxelSpaceInfos infos = reader.getVoxelSpaceInfos(); writer = new BufferedWriter( new FileWriter(selectedFile)); writer.write(infos.toString() + "\n"); Iterator<Voxel> iterator = reader.iterator(); while (iterator.hasNext()) { Voxel voxel = iterator.next(); if (voxelsToRemove.contains(new Point3i( voxel.$i, voxel.$j, voxel.$k))) { voxel.PadBVTotal = 0; voxel.nbEchos = 0; voxel.transmittance = 1; voxel.bvIntercepted = 0; } writer.write(voxel + "\n"); } writer.close(); addFileToProductsList(selectedFile); } catch (Exception ex) { showErrorDialog(ex); } finally { try { if (writer != null) { writer.close(); } } catch (IOException ex) { showErrorDialog(ex); } } } editingFrameOpened = false; } }); } @Override public void windowGainedFocus(com.jogamp.newt.event.WindowEvent we) { viewer3D.setIsFocused(true); Platform.runLater(new Runnable() { @Override public void run() { if (!toolBarFrameStage.isShowing()) { toolBarFrameStage.toFront(); } toolBarFrameStage.setIconified(false); toolBarFrameStage.setAlwaysOnTop(true); toolBarFrameStage.setX(viewer3D.getPosition().getX()); toolBarFrameStage.setY(viewer3D.getPosition().getY()); } }); } @Override public void windowLostFocus(com.jogamp.newt.event.WindowEvent e) { viewer3D.setIsFocused(false); Platform.runLater(new Runnable() { @Override public void run() { if (!toolBarFrameStage.focusedProperty().get()) { toolBarFrameStage.setIconified(true); toolBarFrameStage.setAlwaysOnTop(false); } } }); } }); viewer3D.show(); toolBarFrameStage.setAlwaysOnTop(true); } catch (IOException e) { showErrorDialog(new Exception("Loading ToolBarFrame.fxml failed", e)); } catch (Exception e) { showErrorDialog(new Exception("Error occured during toolbar init", e)); } } }); return null; } }; } }; ProgressDialog d = new ProgressDialog(s); d.show(); s.start(); } catch (Exception ex) { showErrorDialog(new Exception("Cannot launch 3d view", ex)); } }