Search in sources :

Example 16 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class MediaPlayerWidget method ConfigurePlayback.

private void ConfigurePlayback(DataManager dataMgr) {
    dataMgr.AddListener(_PlaybackControlID, _PlaybackControl_Namespace, new ChangeListener() {

        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            String strPlaybackCmd = newVal.toString();
            if (strPlaybackCmd.equalsIgnoreCase("Play")) {
                OnPlay();
            } else if (strPlaybackCmd.equalsIgnoreCase("Pause")) {
                OnPause();
            } else if (strPlaybackCmd.equalsIgnoreCase("Stop")) {
                OnStop();
            } else if (// could be Volume or JumpTo
            strPlaybackCmd.contains(":")) {
                String[] parts = strPlaybackCmd.split(":");
                double dVal;
                if (parts.length > 1) {
                    String strTask = parts[0];
                    try {
                        dVal = Double.parseDouble(parts[1]);
                    } catch (NumberFormatException ex) {
                        LOGGER.severe(_WidgetType + " received invalid command --> " + strPlaybackCmd);
                        return;
                    }
                    if (strTask.equalsIgnoreCase("Volume")) {
                        OnSetVolume(dVal);
                    } else if (strTask.equalsIgnoreCase("JumpTo")) {
                        OnJumpTo(dVal);
                    } else {
                        LOGGER.severe(_WidgetType + " received invalid command --> " + strPlaybackCmd);
                    }
                } else {
                    LOGGER.severe(_WidgetType + " received invalid command --> " + strPlaybackCmd);
                }
            }
        }
    });
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener)

Example 17 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class MediaPlayerWidget method Create.

protected boolean Create(DataManager dataMgr) {
    if (!VerifyInputFiles()) {
        return false;
    }
    if (!VerifySupportsMedia()) {
        return false;
    }
    if (_ListOfIDs.size() == 1) {
        _CurrentMediaID = _ListOfIDs.get(0);
    }
    if (null != _PlaybackControlID && null != _PlaybackControl_Namespace) {
        ConfigurePlayback(dataMgr);
    }
    dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            String strVal = newVal.toString().replaceAll("(\\r|\\n)", "");
            String key;
            if (// go to next media in the list
            strVal.equalsIgnoreCase("Next")) {
                key = _ListOfIDs.GetNext();
            } else if (// go to previous media in the list
            strVal.equalsIgnoreCase("Previous")) {
                key = _ListOfIDs.GetPrevious();
            } else {
                // expecting an ID
                key = strVal;
                // just to keep next/prev alignment
                _ListOfIDs.get(key);
            }
            key = key.toLowerCase();
            PlayMedia(key);
        }
    });
    if (null != _CurrentMediaID) {
        _ListOfIDs.get(_CurrentMediaID);
        if (!PlayMedia(_CurrentMediaID)) {
            return false;
        }
    }
    return true;
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener)

Example 18 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class PDF_ReaderWidget method Create.

@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
    SetParent(pane);
    if (setupPDF()) {
        _objGroup = new Group();
        _objGroup.getChildren().add(_pdf);
        ConfigureAlignment();
        SetupPeekaboo(dataMgr);
        SetupTaskAction();
        ConfigureDimentions();
        pane.add(_objGroup, getColumn(), getRow(), getColumnSpan(), getRowSpan());
        gotoPage(_CurrPage);
        if (_AutoAdvance) {
            if (null == getMinionID() || null == getNamespace()) {
                String ID = this.toString() + "." + Integer.toBinaryString(PDF_ReaderWidget._AutoAdvancePageNumber);
                PDF_ReaderWidget._AutoAdvancePageNumber++;
                if (null == getMinionID()) {
                    setMinionID(ID);
                }
                if (null == getNamespace()) {
                    setNamespace(ID);
                }
            }
            MarvinTask mt = new MarvinTask();
            mt.AddDataset(getMinionID(), getNamespace(), "Next");
            TASKMAN.AddPostponedTask(mt, _AutoAdvanceInterval);
        }
        dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

            @Override
            public void changed(ObservableValue o, Object oldVal, Object newVal) {
                MyHandler(newVal);
            }
        });
        return ApplyCSS();
    }
    return false;
}
Also used : Group(javafx.scene.Group) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) MarvinTask(kutch.biff.marvin.task.MarvinTask)

Example 19 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class BarChartWidget method setupListenersForSingleSource.

@SuppressWarnings("unchecked")
private void setupListenersForSingleSource(DataManager dataMgr) {
    XYChart.Series<String, Number> objSeries = new XYChart.Series<>();
    for (int iLoop = 0; iLoop < getxAxisMaxCount(); iLoop++) {
        XYChart.Data objData = new XYChart.Data<>(Integer.toString(iLoop), 0);
        objSeries.getData().add(objData);
    }
    ((BarChart) getChart()).getData().add(objSeries);
    dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (IsPaused()) {
                return;
            }
            String[] strList = newVal.toString().split(",");
            if (strList.length != getxAxisMaxCount()) {
                LOGGER.severe("Received " + Integer.toString(strList.length) + " items for a Bar Chart , however Widget only defined for " + Integer.toString(getxAxisMaxCount()));
                return;
            }
            int index = 0;
            for (String strValue : strList) {
                double newValue;
                try {
                    newValue = Double.parseDouble(strValue);
                } catch (NumberFormatException ex) {
                    LOGGER.severe("Invalid data for Bar Chart received: " + strValue);
                    return;
                }
                XYChart.Data objData = objSeries.getData().get(index++);
                objData.setYValue(newValue);
            }
        }
    });
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) XYChart(javafx.scene.chart.XYChart) ChangeListener(javafx.beans.value.ChangeListener)

Example 20 with ObservableValue

use of javafx.beans.value.ObservableValue in project tokentool by RPTools.

the class TokenTool_Controller method initialize.

@FXML
void initialize() {
    // Note: A Pane is added to the compositeTokenPane so the ScrollPane doesn't consume the mouse events
    assert fileManageOverlaysMenu != null : "fx:id=\"fileManageOverlaysMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileSaveAsMenu != null : "fx:id=\"fileSaveAsMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileExitMenu != null : "fx:id=\"fileExitMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editCaptureScreenMenu != null : "fx:id=\"editCaptureScreenMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editCopyImageMenu != null : "fx:id=\"editCopyImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert editPasteImageMenu != null : "fx:id=\"editPasteImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert helpAboutMenu != null : "fx:id=\"helpAboutMenu\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert saveOptionsPane != null : "fx:id=\"saveOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayOptionsPane != null : "fx:id=\"overlayOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert backgroundOptionsPane != null : "fx:id=\"backgroundOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert zoomOptionsPane != null : "fx:id=\"zoomOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert compositeTokenPane != null : "fx:id=\"compositeTokenPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert tokenPreviewPane != null : "fx:id=\"tokenPreviewPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitScrollPane != null : "fx:id=\"portraitScrollPane\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert compositeGroup != null : "fx:id=\"compositeGroup\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayTreeView != null : "fx:id=\"overlayTreeview\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitImageView != null : "fx:id=\"portraitImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert maskImageView != null : "fx:id=\"maskImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayImageView != null : "fx:id=\"overlayImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert tokenImageView != null : "fx:id=\"tokenImageView\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert useFileNumberingCheckbox != null : "fx:id=\"useFileNumberingCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayUseAsBaseCheckbox != null : "fx:id=\"overlayUseAsBaseCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert clipPortraitCheckbox != null : "fx:id=\"clipPortraitCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameTextField != null : "fx:id=\"fileNameTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameSuffixLabel != null : "fx:id=\"fileNameSuffixLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert fileNameSuffixTextField != null : "fx:id=\"fileNameSuffixTextField\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayNameLabel != null : "fx:id=\"overlayNameLabel\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert backgroundColorPicker != null : "fx:id=\"backgroundColorPicker\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayAspectToggleButton != null : "fx:id=\"overlayAspectToggleButton\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitTransparencySlider != null : "fx:id=\"portraitTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitBlurSlider != null : "fx:id=\"portraitBlurSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert portraitGlowSlider != null : "fx:id=\"portraitGlowSlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayTransparencySlider != null : "fx:id=\"overlayTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayWidthSpinner != null : "fx:id=\"overlayWidthSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayHeightSpinner != null : "fx:id=\"overlayHeightSpinner\" was not injected: check your FXML file 'TokenTool.fxml'.";
    assert overlayTreeProgressBar != null : "fx:id=\"overlayTreeProgressIndicator\" was not injected: check your FXML file 'ManageOverlays.fxml'.";
    executorService = Executors.newCachedThreadPool(runable -> {
        loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable);
        loadOverlaysThread.setDaemon(true);
        return loadOverlaysThread;
    });
    overlayTreeView.setShowRoot(false);
    overlayTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> updateCompositImageView((TreeItem<Path>) newValue));
    addPseudoClassToLeafs(overlayTreeView);
    // Bind color picker to compositeTokenPane background fill
    backgroundColorPicker.setValue(Color.TRANSPARENT);
    ObjectProperty<Background> background = compositeTokenPane.backgroundProperty();
    background.bind(Bindings.createObjectBinding(() -> {
        BackgroundFill fill = new BackgroundFill(backgroundColorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY);
        return new Background(fill);
    }, backgroundColorPicker.valueProperty()));
    // Bind transparency slider to portraitImageView opacity
    portraitTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            portraitImageView.setOpacity(new_val.doubleValue());
            updateTokenPreviewImageView();
        }
    });
    // // Restrict text field to valid filename characters
    // Pattern validDoubleText = Pattern.compile("[^a-zA-Z0-9\\\\._ \\\\/`~!@#$%\\\\^&\\\\(\\\\)\\\\-\\\\=\\\\+\\\\[\\\\]\\\\{\\\\}',\\\\\\\\:]");
    // Pattern validText = Pattern.compile("[^a-zA-Z0-9 ]");
    // TextFormatter<> textFormatter = new TextFormatter<>(
    // change -> {
    // String newText = change.getControlNewText();
    // if (validText.matcher(newText).matches()) {
    // return change;
    // } else
    // return null;
    // });
    // UnaryOperator<TextFormatter.Change> filter = new UnaryOperator<TextFormatter.Change>() {
    // @Override
    // public TextFormatter.Change apply(TextFormatter.Change t) {
    // String validText = "[^a-zA-Z0-9]";
    // 
    // if (t.isReplaced())
    // if (t.getText().matches(validText))
    // t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd()));
    // 
    // if (t.isAdded()) {
    // if (t.getText().matches(validText)) {
    // return null;
    // }
    // }
    // 
    // return t;
    // }
    // };
    UnaryOperator<Change> filter = change -> {
        String text = change.getText();
        if (text.matches(AppConstants.VALID_FILE_NAME_PATTERN)) {
            return change;
        } else {
            change.setText(FileSaveUtil.cleanFileName(text));
            ;
            return change;
        }
    // 
    // return null;
    };
    TextFormatter<String> textFormatter = new TextFormatter<>(filter);
    fileNameTextField.setTextFormatter(textFormatter);
    // Effects
    GaussianBlur gaussianBlur = new GaussianBlur(0);
    Glow glow = new Glow(0);
    gaussianBlur.setInput(glow);
    // Bind blur slider to portraitImageView opacity
    portraitBlurSlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            gaussianBlur.setRadius(new_val.doubleValue());
            portraitImageView.setEffect(gaussianBlur);
            updateTokenPreviewImageView();
        }
    });
    // Bind glow slider to portraitImageView opacity
    portraitGlowSlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            glow.setLevel(new_val.doubleValue());
            portraitImageView.setEffect(gaussianBlur);
            updateTokenPreviewImageView();
        }
    });
    // Bind transparency slider to overlayImageView opacity
    overlayTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            overlayImageView.setOpacity(new_val.doubleValue());
            updateTokenPreviewImageView();
        }
    });
    // Bind width/height spinners to overlay width/height
    overlayWidthSpinner.getValueFactory().valueProperty().bindBidirectional(overlayHeightSpinner.getValueFactory().valueProperty());
    overlayWidthSpinner.valueProperty().addListener((observable, oldValue, newValue) -> overlayWidthSpinner_onTextChanged(oldValue, newValue));
    overlayHeightSpinner.valueProperty().addListener((observable, oldValue, newValue) -> overlayHeightSpinner_onTextChanged(oldValue, newValue));
}
Also used : Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) PseudoClass(javafx.css.PseudoClass) Credits(net.rptools.tokentool.client.Credits) ManageOverlays(net.rptools.tokentool.client.ManageOverlays) Glow(javafx.scene.effect.Glow) Point(java.awt.Point) UnaryOperator(java.util.function.UnaryOperator) StackPane(javafx.scene.layout.StackPane) TextFormatter(javafx.scene.control.TextFormatter) DragEvent(javafx.scene.input.DragEvent) RegionSelector(net.rptools.tokentool.client.RegionSelector) Task(javafx.concurrent.Task) ScrollPane(javafx.scene.control.ScrollPane) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) ImageIO(javax.imageio.ImageIO) RotateEvent(javafx.scene.input.RotateEvent) GaussianBlur(javafx.scene.effect.GaussianBlur) Path(java.nio.file.Path) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) NavigableSet(java.util.NavigableSet) Spinner(javafx.scene.control.Spinner) Group(javafx.scene.Group) Executors(java.util.concurrent.Executors) TreeView(javafx.scene.control.TreeView) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Duration(javafx.util.Duration) Logger(org.apache.logging.log4j.Logger) ImageUtil(net.rptools.tokentool.util.ImageUtil) ToggleButton(javafx.scene.control.ToggleButton) Clipboard(javafx.scene.input.Clipboard) Entry(java.util.Map.Entry) ClipboardContent(javafx.scene.input.ClipboardContent) BorderPane(javafx.scene.layout.BorderPane) FilenameUtils(org.apache.commons.io.FilenameUtils) CornerRadii(javafx.scene.layout.CornerRadii) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) FileSaveUtil(net.rptools.tokentool.util.FileSaveUtil) Bindings(javafx.beans.binding.Bindings) TreeSet(java.util.TreeSet) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) AppConstants(net.rptools.tokentool.AppConstants) LinkedHashMap(java.util.LinkedHashMap) Dragboard(javafx.scene.input.Dragboard) FadeTransition(javafx.animation.FadeTransition) Insets(javafx.geometry.Insets) ProgressBar(javafx.scene.control.ProgressBar) Slider(javafx.scene.control.Slider) BackgroundFill(javafx.scene.layout.BackgroundFill) I18N(net.rptools.tokentool.util.I18N) ZoomEvent(javafx.scene.input.ZoomEvent) ExecutorService(java.util.concurrent.ExecutorService) ColorPicker(javafx.scene.control.ColorPicker) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) Change(javafx.scene.control.TextFormatter.Change) TitledPane(javafx.scene.control.TitledPane) MouseDragEvent(javafx.scene.input.MouseDragEvent) Files(java.nio.file.Files) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) ScrollEvent(javafx.scene.input.ScrollEvent) Background(javafx.scene.layout.Background) File(java.io.File) Cursor(javafx.scene.Cursor) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) ImageView(javafx.scene.image.ImageView) AppPreferences(net.rptools.tokentool.AppPreferences) SwingFXUtils(javafx.embed.swing.SwingFXUtils) TreeCell(javafx.scene.control.TreeCell) ObservableValue(javafx.beans.value.ObservableValue) Comparator(java.util.Comparator) ChangeListener(javafx.beans.value.ChangeListener) LogManager(org.apache.logging.log4j.LogManager) Image(javafx.scene.image.Image) TextFormatter(javafx.scene.control.TextFormatter) Background(javafx.scene.layout.Background) TreeItem(javafx.scene.control.TreeItem) GaussianBlur(javafx.scene.effect.GaussianBlur) BackgroundFill(javafx.scene.layout.BackgroundFill) Change(javafx.scene.control.TextFormatter.Change) Glow(javafx.scene.effect.Glow) FXML(javafx.fxml.FXML)

Aggregations

ObservableValue (javafx.beans.value.ObservableValue)85 ChangeListener (javafx.beans.value.ChangeListener)53 FXML (javafx.fxml.FXML)13 Scene (javafx.scene.Scene)13 ImageView (javafx.scene.image.ImageView)13 KeyEvent (javafx.scene.input.KeyEvent)11 ArrayList (java.util.ArrayList)10 Label (javafx.scene.control.Label)10 TableColumn (javafx.scene.control.TableColumn)10 TableView (javafx.scene.control.TableView)10 ActionEvent (javafx.event.ActionEvent)9 MouseEvent (javafx.scene.input.MouseEvent)9 TextField (javafx.scene.control.TextField)8 Color (javafx.scene.paint.Color)8 ObservableList (javafx.collections.ObservableList)7 MenuItem (javafx.scene.control.MenuItem)7 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)7 List (java.util.List)6 Set (java.util.Set)6 Platform (javafx.application.Platform)6