List of usage examples for javafx.beans.property SimpleObjectProperty SimpleObjectProperty
public SimpleObjectProperty()
From source file:cz.lbenda.dataman.db.RowDesc.java
@SuppressWarnings("unchecked") private <T> ObservableValue<T> createObjectProperty(@Nonnull ColumnDesc columnDesc) { switch (columnDesc.getDataType()) { case BOOLEAN: return (ObservableValue<T>) new SimpleBooleanProperty(null, null); case BYTE://from ww w . j a va 2 s . c o m case SHORT: case LONG: case INTEGER: case FLOAT: case DOUBLE: case DECIMAL: return new SimpleObjectProperty<>(); case DATE: return (ObservableValue<T>) new SimpleLocalDateProperty(); case TIMESTAMP: return (ObservableValue<T>) new SimpleLocalDateTimeProperty(); case TIME: return (ObservableValue<T>) new SimpleLocalTimeProperty(); case STRING: return (ObservableValue<T>) new SimpleStringProperty(); case BYTE_ARRAY: case CLOB: case BLOB: return (ObservableValue<T>) new SimpleObjectProperty<>(); default: return (ObservableValue<T>) new SimpleObjectProperty<>(); } }
From source file:com.github.vatbub.tictactoe.view.Main.java
@FXML // This method is called by the FXMLLoader when initialization is complete void initialize() { // modify the default exception handler to show a good error message on every uncaught exception final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread .getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> { if (currentUncaughtExceptionHandler != null) { // execute current handler as we only want to append it currentUncaughtExceptionHandler.uncaughtException(thread, exception); }//from w w w .j a va2 s .co m Platform.runLater(() -> new ExceptionAlert(exception).showAndWait()); }); opponentsTurnHBox.heightProperty() .addListener((observable, oldValue, newValue) -> updateOpponentsTurnHBox(false)); aiLevelLabelClipRectangle = new Rectangle(0, 0, 0, 0); aiLevelLabelClipRectangle.setEffect(new MotionBlur(0, 10)); aiLevelLabelPane.setClip(aiLevelLabelClipRectangle); aiLevelLabelClipRectangle.heightProperty().bind(aiLevelLabelPane.heightProperty()); aiLevelLabelPane.widthProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel(true)); Rectangle menuSubBoxClipRectangle = new Rectangle(0, 0, 0, 0); menuSubBox.setClip(menuSubBoxClipRectangle); menuSubBoxClipRectangle.heightProperty().bind(menuSubBox.heightProperty()); menuSubBoxClipRectangle.widthProperty().bind(menuSubBox.widthProperty()); Rectangle playOnlineClipRectangle = new Rectangle(0, 0, 0, 0); playOnlineClipAnchorPane.setClip(playOnlineClipRectangle); playOnlineClipRectangle.heightProperty().bind(playOnlineClipAnchorPane.heightProperty()); playOnlineClipRectangle.widthProperty().bind(playOnlineClipAnchorPane.widthProperty()); player1SetSampleName(); player2SetSampleName(); gameTable.heightProperty() .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(gameTable.getWidth(), oldValue.doubleValue(), gameTable.getWidth(), newValue.doubleValue())); gameTable.widthProperty() .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(oldValue.doubleValue(), gameTable.getHeight(), newValue.doubleValue(), gameTable.getHeight())); player1AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> { showHideAILevelSlider(newValue, player2AIToggle.isSelected()); player1SetSampleName(); }); player2AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> { showHideAILevelSlider(player1AIToggle.isSelected(), newValue); player2SetSampleName(); }); gameTable.setSelectionModel(null); gameTable.heightProperty().addListener((observable, oldValue, newValue) -> { Pane header = (Pane) gameTable.lookup("TableHeaderRow"); if (header.isVisible()) { header.setMaxHeight(0); header.setMinHeight(0); header.setPrefHeight(0); header.setVisible(false); } renderRows(); }); gameTable.setRowFactory(param -> { TableRow<Row> row = new TableRow<>(); row.styleProperty().bind(style); if (rowFont == null) { rowFont = new SimpleObjectProperty<>(); rowFont.bind(row.fontProperty()); } return row; }); looseImage.fitHeightProperty().bind(looserPane.heightProperty()); looseImage.fitWidthProperty().bind(looserPane.widthProperty()); looseImage.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage, getClass().getResource("loose.png").toString(), looseImage.getFitWidth(), newValue.doubleValue())); looseImage.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage, getClass().getResource("loose.png").toString(), newValue.doubleValue(), looseImage.getFitWidth())); confetti.fitHeightProperty().bind(winPane.heightProperty()); confetti.fitWidthProperty().bind(winPane.widthProperty()); confetti.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti, getClass().getResource("confetti.png").toString(), confetti.getFitWidth(), newValue.doubleValue())); confetti.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti, getClass().getResource("confetti.png").toString(), newValue.doubleValue(), confetti.getFitWidth())); aiLevelSlider.valueProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel()); playOnlineHyperlink.widthProperty().addListener((observable, oldValue, newValue) -> { if (playOnlineAnchorPane.isVisible()) { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true); } }); playOnlineHyperlink.heightProperty().addListener((observable, oldValue, newValue) -> { if (playOnlineAnchorPane.isVisible()) { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true); } }); playOnlineHyperlink.textProperty().addListener((observable, oldValue, newValue) -> { if (!newValue.equals(oldValue)) { if (newValue.contains("ff")) { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, 1); } else { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, -1); } } }); // Kunami code root.setOnKeyPressed(event -> { if (KunamiCode.isCompleted(event.getCode())) { if (root.getEffect() != null && root.getEffect() instanceof Blend) { BlendMode currentMode = ((Blend) root.getEffect()).getMode(); BlendMode nextMode; if (currentMode == BlendMode.values()[BlendMode.values().length - 1]) { nextMode = BlendMode.values()[0]; } else { nextMode = BlendMode.values()[Arrays.asList(BlendMode.values()).indexOf(currentMode) + 1]; } ((Blend) root.getEffect()).setMode(nextMode); } else { root.setEffect(new Blend(BlendMode.EXCLUSION)); } } }); // prompt text of the my username field in the online multiplayer menu onlineMyUsername.promptTextProperty().bind(player1Name.promptTextProperty()); onlineMyUsername.textProperty().bindBidirectional(player1Name.textProperty()); setAccessibleTextsForNodesThatDoNotChange(); updateAccessibleTexts(); initBoard(); initNewGame(); }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void editVoxelSpace(final File voxelFile) { if (editingFrameOpened) { return;//from w w w . j a va2s . com } 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)); } }
From source file:org.kles.m3.service.CheckM3ConnectionService.java
public CheckM3ConnectionService() { m3connector = new SimpleObjectProperty<>(); }