javafx.scene.CacheHint Java Examples

The following examples show how to use javafx.scene.CacheHint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlipTileSkin.java    From OEE-Designer with MIT License 7 votes vote down vote up
private void flipForward() {
    timeline.stop();

    flap.setCache(true);
    flap.setCacheHint(CacheHint.ROTATE);
    //flap.setCacheHint(CacheHint.SPEED);

    currentSelectionIndex++;
    if (currentSelectionIndex >= characters.size()) {
        currentSelectionIndex = 0;
    }
    nextSelectionIndex = currentSelectionIndex + 1;
    if (nextSelectionIndex >= characters.size()) {
        nextSelectionIndex = 0;
    }
    KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
    //KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
    KeyFrame keyFrame     = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
    timeline.getKeyFrames().setAll(keyFrame);
    timeline.play();
}
 
Example #2
Source File: Gauge2TileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void drawNeedle() {
    double needleWidth  = size * 0.04536638;
    double needleHeight = size * 0.23706897;
    needle.setCache(false);
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.754441805225653, needleHeight *0.0743545454545455, needleWidth *0.788052256532067, needleHeight * 0, needleWidth * 0.499643705463183, needleHeight * 0));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.211235154394299, needleHeight *0, needleWidth *0.248907363420428, needleHeight * 0.0741090909090909, needleWidth * 0.186104513064133, needleHeight * 0.227272727272727));
    needle.getElements().add(new LineTo(needleWidth * 0.000831353919239905, needleHeight * 0.886363636363636));
    needle.getElements().add(new CubicCurveTo(needleWidth * -0.0155581947743468, needleHeight *0.978604545454545, needleWidth *0.211235154394299, needleHeight * 1, needleWidth * 0.499643705463183, needleHeight * 1));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.788052256532067, needleHeight *1, needleWidth *1.0253919239905, needleHeight * 0.976459090909091, needleWidth * 0.998456057007126, needleHeight * 0.886363636363636));
    needle.getElements().add(new LineTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727));
    needle.getElements().add(new ClosePath());
    needle.getElements().add(new MoveTo(needleWidth * 0.552826603325416, needleHeight *0.854286363636364));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.536223277909739, needleHeight *0.852981818181818, needleWidth *0.518313539192399, needleHeight * 0.852272727272727, needleWidth * 0.499643705463183, needleHeight * 0.852272727272727));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.480237529691211, needleHeight *0.852272727272727, needleWidth *0.46166270783848, needleHeight * 0.853040909090909, needleWidth * 0.444513064133017, needleHeight * 0.854445454545455));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.37313539192399, needleHeight *0.858890909090909, needleWidth *0.321496437054632, needleHeight * 0.871736363636364, needleWidth * 0.321496437054632, needleHeight * 0.886868181818182));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.321496437054632, needleHeight *0.905681818181818, needleWidth *0.401330166270784, needleHeight * 0.920959090909091, needleWidth * 0.499643705463183, needleHeight * 0.920959090909091));
    needle.getElements().add(new LineTo(needleWidth * 0.500285035629454, needleHeight *0.920959090909091));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.598598574821853, needleHeight *0.920959090909091, needleWidth *0.678432304038005, needleHeight * 0.905681818181818, needleWidth * 0.678432304038005, needleHeight * 0.886868181818182));
    needle.getElements().add(new CubicCurveTo(needleWidth * 0.678432304038005, needleHeight *0.871554545454545, needleWidth *0.625534441805226, needleHeight * 0.858581818181818, needleWidth * 0.552826603325416, needleHeight * 0.854286363636364));
    needle.getElements().add(new ClosePath());
    needle.setCache(true);
    needle.setCacheHint(CacheHint.ROTATE);
}
 
Example #3
Source File: SelectableLabel.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param text the label to use for the text. Styles will be copied from
 * this label.
 * @param wrapText specifies whether text wrapping is allowed in this label.
 * @param style the CSS style of the label. This can be null.
 * @param tipsPane the tooltip for the label. This can be null.
 * @param contextMenuItems a list of menu items to add to the context menu
 * of the label. This can be null.
 */
public SelectableLabel(final String text, boolean wrapText, String style, final TooltipPane tipsPane, final List<MenuItem> contextMenuItems) {
    getStyleClass().add("selectable-label");
    setText(text == null ? "" : text);
    setWrapText(wrapText);
    setEditable(false);
    setPadding(Insets.EMPTY);
    setCache(true);
    setCacheHint(CacheHint.SPEED);
    setMinHeight(USE_PREF_SIZE);

    if (style != null) {
        setStyle(style);
    }

    if (tipsPane != null) {
        TooltipUtilities.activateTextInputControl(this, tipsPane);
    }

    this.contextMenuItems = contextMenuItems;
}
 
Example #4
Source File: CustomPlainAmpSkin.java    From medusademo with Apache License 2.0 6 votes vote down vote up
@Override protected void redraw() {
    locale       = gauge.getLocale();
    formatString = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f").toString();

    ticksAndSectionsCanvas.setCache(false);
    ticksAndSections.clearRect(0, 0, width, height);

    if (gauge.getSectionsVisible()) drawSections(ticksAndSections);
    drawTickMarks(ticksAndSections);
    ticksAndSectionsCanvas.setCache(true);
    ticksAndSectionsCanvas.setCacheHint(CacheHint.QUALITY);

    //unitText.setFill(gauge.getUnitColor());
    unitText.setText(gauge.getUnit());

    if (gauge.isLedVisible()) drawLed(led);

    shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);

    // Markers
    drawMarkers();
    thresholdTooltip.setText("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
}
 
Example #5
Source File: TaChart.java    From TAcharting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Constructor.
 * @param box a ChartIndicatorBox
 */
public TaChart(IndicatorBox box){
    mapTradingRecordMarker = new HashMap<>();
    this.chartIndicatorBox = box;
    this.chartIndicatorBox.getIndicartors().addListener(this);
    XYDataset candlesBarData = createOHLCDataset(chartIndicatorBox.getBarSeries());
    this.mainPlot = createMainPlot(candlesBarData);
    this.combinedXYPlot = createCombinedDomainXYPlot(mainPlot);
    this.setCache(true);
    this.setCacheHint(CacheHint.SPEED);
    final JFreeChart chart = new JFreeChart(combinedXYPlot);
    TaChartViewer viewer = new TaChartViewer(chart);
    Color chartBackground = Color.WHITE;
    chart.setBackgroundPaint(chartBackground);
    getChildren().add(viewer);
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.TOP);
    legend.setItemFont(new Font("Arial", Font.BOLD, 12));
    Color legendBackground = new Color(0, 0, 0, 0);
    legend.setBackgroundPaint(legendBackground);

    chartIndicatorBox.getObservableBarSeries().addListener((ob, o, n) -> reloadBarSeries(n));
}
 
Example #6
Source File: UnitedStatesMapPane.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public UnitedStatesMapPane() {
    getStyleClass().add("map-pane");
    setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
    setPrefHeight(450);
    setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    liveMap.setId("liveMap");
    liveMap.setManaged(false);
        liveMap.setCache(true);
        liveMap.setCacheHint(CacheHint.SCALE);
    getChildren().add(liveMap);
    overlayGroup.setId("overlay");
    
    // setip map transforms
    liveMap.getTransforms().setAll(mapPreTranslate, mapScale, mapPostTranslate);
    // load map fxml
    try {
        statesGroup = FXMLLoader.load(UnitedStatesMapPane.class.getResource("us-states-map.fxml"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    // set live map children
    liveMap.getChildren().addAll(statesGroup, overlayGroup);
}
 
Example #7
Source File: UnitedStatesMapPane.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public UnitedStatesMapPane() {
    getStyleClass().add("map-pane");
    setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
    setPrefHeight(450);
    setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    liveMap.setId("liveMap");
    liveMap.setManaged(false);
        liveMap.setCache(true);
        liveMap.setCacheHint(CacheHint.SCALE);
    getChildren().add(liveMap);
    overlayGroup.setId("overlay");
    
    // setip map transforms
    liveMap.getTransforms().setAll(mapPreTranslate, mapScale, mapPostTranslate);
    // load map fxml
    try {
        statesGroup = FXMLLoader.load(UnitedStatesMapPane.class.getResource("us-states-map.fxml"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    // set live map children
    liveMap.getChildren().addAll(statesGroup, overlayGroup);
}
 
Example #8
Source File: ModernSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
@Override protected void redraw() {
    sectionsVisible = gauge.getSectionsVisible();
    locale          = gauge.getLocale();
    barColor        = gauge.getBarColor();
    thresholdColor  = gauge.getThresholdColor();
    needle.setFill(gauge.getNeedleColor());
    titleText.setFill(gauge.getTitleColor());
    subTitleText.setFill(gauge.getSubTitleColor());
    unitText.setFill(gauge.getUnitColor());
    valueText.setFill(gauge.getValueColor());
    buttonTooltip.setText(gauge.getButtonTooltipText());

    mainCanvas.setCache(false);
    mainCanvas.setWidth(size);
    mainCanvas.setHeight(size);
    drawMainCanvas();
    mainCanvas.setCache(true);
    mainCanvas.setCacheHint(CacheHint.QUALITY);
    resizeText();
}
 
Example #9
Source File: JFXRippler.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
OverLayRipple() {
    super();
    setOverLayBounds(this);
    this.getStyleClass().add("jfx-rippler-overlay");
    // update initial position
    if (JFXRippler.this.getChildrenUnmodifiable().contains(control)) {
        double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
        double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
        Bounds bounds = control.getBoundsInParent();
        this.setX(bounds.getMinX() + diffMinX - snappedLeftInset());
        this.setY(bounds.getMinY() + diffMinY - snappedTopInset());
    }
    // set initial attributes
    setOpacity(0);
    setCache(true);
    setCacheHint(CacheHint.SPEED);
    setCacheShape(true);
    setManaged(false);
}
 
Example #10
Source File: World.java    From worldfx with Apache License 2.0 6 votes vote down vote up
private void resize() {
    width  = getWidth() - getInsets().getLeft() - getInsets().getRight();
    height = getHeight() - getInsets().getTop() - getInsets().getBottom();

    if (ASPECT_RATIO * width > height) {
        width = 1 / (ASPECT_RATIO / height);
    } else if (1 / (ASPECT_RATIO / height) > width) {
        height = ASPECT_RATIO * width;
    }

    if (width > 0 && height > 0) {
        if (isZoomEnabled()) resetZoom();

        pane.setCache(true);
        pane.setCacheHint(CacheHint.SCALE);

        pane.setScaleX(width / PREFERRED_WIDTH);
        pane.setScaleY(height / PREFERRED_HEIGHT);

        group.resize(width, height);
        group.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);

        pane.setCache(false);
    }
}
 
Example #11
Source File: TinySkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
@Override protected void redraw() {
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * size))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    locale               = gauge.getLocale();
    formatString         = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f").toString();
    colorGradientEnabled = gauge.isGradientBarEnabled();
    noOfGradientStops    = gauge.getGradientBarStops().size();

    barBackground.setStroke(gauge.getBarBackgroundColor());

    // Areas, Sections and Tick Marks
    sectionCanvas.setCache(false);
    sectionCtx.clearRect(0, 0, size, size);
    if (gauge.isGradientBarEnabled() && gauge.getGradientLookup() != null) {
        drawGradientBar();
        if (gauge.getMajorTickMarksVisible()) drawTickMarks();
    } else if (gauge.getSectionsVisible()) {
        drawSections();
        if (gauge.getMajorTickMarksVisible()) drawTickMarks();
    }
    sectionCanvas.setCache(true);
    sectionCanvas.setCacheHint(CacheHint.QUALITY);

    needle.setFill(gauge.getNeedleColor());
}
 
Example #12
Source File: JFXFillTransition.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
protected void starting() {
    // init animation values
    if (start == null) {
        oldCache = region.get().isCache();
        oldCacheHint = region.get().getCacheHint();
        radii = region.get().getBackground() == null ? null : region.get()
            .getBackground()
            .getFills()
            .get(0)
            .getRadii();
        insets = region.get().getBackground() == null ? null : region.get()
            .getBackground()
            .getFills()
            .get(0)
            .getInsets();
        start = fromValue.get();
        end = toValue.get();
        region.get().setCache(true);
        region.get().setCacheHint(CacheHint.SPEED);
    }
}
 
Example #13
Source File: FlipTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void flipForward() {
    timeline.stop();

    flap.setCache(true);
    flap.setCacheHint(CacheHint.ROTATE);
    //flap.setCacheHint(CacheHint.SPEED);

    currentSelectionIndex++;
    if (currentSelectionIndex >= characters.size()) {
        currentSelectionIndex = 0;
    }
    nextSelectionIndex = currentSelectionIndex + 1;
    if (nextSelectionIndex >= characters.size()) {
        nextSelectionIndex = 0;
    }
    KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
    //KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
    KeyFrame keyFrame     = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
    timeline.getKeyFrames().setAll(keyFrame);
    timeline.play();
}
 
Example #14
Source File: HealingNumber.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public HealingNumber(String text, GameToken parent) {
	this.parent = parent;

	setText(text);
	setFill(Color.GREEN);
	setStyle("-fx-font-size: 28pt; -fx-font-family: \"System\";-fx-font-weight: bolder;-fx-stroke: black;-fx-stroke-width: 2;");

	setCache(true);
	setCacheHint(CacheHint.SPEED);

	parent.getAnchor().getChildren().add(this);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), this);
	animation.setToY(-30);
	animation.setOnFinished(this::onComplete);
	animation.play();
}
 
Example #15
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the new ticker billboard
 */
public void createBillboard() {

	matrix = DotMatrixBuilder.create().prefSize(925, 54).colsAndRows(196, 11).dotOnColor(Color.rgb(255, 55, 0))
			.dotOffColor(Color.rgb(64, 64, 64)).dotShape(DotShape.ROUND).matrixFont(MatrixFont8x8.INSTANCE).build();

	billboard = new StackPane(matrix);
	// billboard.setPadding(new Insets(1));
	billboard.setBackground(
			new Background(new BackgroundFill(Color.rgb(20, 20, 20), CornerRadii.EMPTY, Insets.EMPTY)));
	// billboard.setBorder(new Border(new BorderStroke(Color.DARKCYAN,
	// BorderStrokeStyle.DOTTED, CornerRadii.EMPTY, BorderWidths.FULL)));
	dragNode = new DraggableNode(billboard, stage, 925, 54);

	dragNode.setCache(true);
	dragNode.setCacheShape(true);
	dragNode.setCacheHint(CacheHint.SPEED);
}
 
Example #16
Source File: dashboardBase.java    From Client with MIT License 6 votes vote down vote up
private VBox getLoadingPane()
{
    //This returns the loading screen

    //Base pane
    VBox loadingPane = new VBox();
    loadingPane.setSpacing(5);
    loadingPane.setAlignment(Pos.CENTER);

    //Loading Indicator (will be customised to match with the design language later)
    loadingIndicator = new ProgressIndicator(0);
    //enable caching to improve performance
    loadingIndicator.setCache(true);
    loadingIndicator.setCacheHint(CacheHint.SPEED);

    //Loading info Label
    loadingInfoLabel = new Label();

    //Add them and return the node
    loadingPane.getChildren().addAll(loadingIndicator, loadingInfoLabel);
    return loadingPane;
}
 
Example #17
Source File: RadarChart.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public void redraw() {
    chartCanvas.setCache(false);
    drawChart();
    chartCanvas.setCache(true);
    chartCanvas.setCacheHint(CacheHint.QUALITY);

    overlayCanvas.setCache(false);
    drawOverlay();
    overlayCanvas.setCache(true);
    overlayCanvas.setCacheHint(CacheHint.QUALITY);

    drawText();
}
 
Example #18
Source File: RadarChart.java    From OEE-Designer with MIT License 5 votes vote down vote up
public void redraw() {
    chartCanvas.setCache(false);
    drawChart();
    chartCanvas.setCache(true);
    chartCanvas.setCacheHint(CacheHint.QUALITY);

    overlayCanvas.setCache(false);
    drawOverlay();
    overlayCanvas.setCache(true);
    overlayCanvas.setCacheHint(CacheHint.QUALITY);

    redrawText();
}
 
Example #19
Source File: CachePolicy.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void cache(Pane node) {
    if (!cache.containsKey(node)) {
        SnapshotParameters snapShotparams = new SnapshotParameters();
        snapShotparams.setFill(Color.TRANSPARENT);
        WritableImage temp = node.snapshot(snapShotparams,
            new WritableImage((int) node.getLayoutBounds().getWidth(),
                (int) node.getLayoutBounds().getHeight()));
        ImageView tempImage = new ImageView(temp);
        tempImage.setCache(true);
        tempImage.setCacheHint(CacheHint.SPEED);
        cache.put(node, new ArrayList<>(node.getChildren()));
        node.getChildren().setAll(tempImage);
    }
}
 
Example #20
Source File: FatClockSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
private void createHourPointer() {
    double width  = size * 0.09733333;
    double height = size * 0.42066667;
    hour.setCache(false);
    hour.getElements().clear();
    hour.getElements().add(new MoveTo(0.0, 0.0));
    hour.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.884310618066561 * height, 0.0, 0.884310618066561 * height));
    hour.getElements().add(new CubicCurveTo(0.0, 0.9477020602218701 * height, 0.22602739726027396 * width, height, 0.5 * width, height));
    hour.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9477020602218701 * height, width, 0.884310618066561 * height));
    hour.getElements().add(new CubicCurveTo(width, 0.884310618066561 * height, width, 0.0, width, 0.0));
    hour.getElements().add(new LineTo(0.0, 0.0));
    hour.getElements().add(new ClosePath());
    hour.setCache(true);
    hour.setCacheHint(CacheHint.ROTATE);
}
 
Example #21
Source File: BulletChartSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
private void drawSections(final GraphicsContext CTX) {
    sectionsCanvas.setCache(false);
    CTX.clearRect(0, 0, sectionsCanvas.getWidth(), sectionsCanvas.getHeight());
    CTX.setFill(gauge.getBackgroundPaint());
    if (Orientation.VERTICAL == orientation) {
        CTX.fillRect(0, 0, 0.5 * width, 0.9 * height);
    } else {
        CTX.fillRect(0, 0, 0.79699248 * width, 0.5 * height);
    }

    double tmpStepSize = stepSize * 1.11111111;
    double minValue = gauge.getMinValue();
    double maxValue = gauge.getMaxValue();

    int listSize = gauge.getSections().size();
    for (int i = 0 ; i < listSize ; i++) {
        final Section SECTION = gauge.getSections().get(i);
        final double SECTION_START;

        final double SECTION_SIZE = SECTION.getRange() * tmpStepSize;
        if (Double.compare(SECTION.getStart(), maxValue) <= 0 && Double.compare(SECTION.getStop(), minValue) >= 0) {
            if (Double.compare(SECTION.getStart(), minValue) < 0 && Double.compare(SECTION.getStop(), maxValue) < 0) {
                SECTION_START = minValue * tmpStepSize;
            } else {
                SECTION_START = height - (SECTION.getStart() * tmpStepSize) - SECTION_SIZE;
            }
            CTX.save();
            CTX.setFill(SECTION.getColor());
            if (Orientation.VERTICAL == orientation) {
                CTX.fillRect(0.0, SECTION_START, 0.5 * width, SECTION_SIZE);
            } else {
                CTX.fillRect(SECTION_START, 0.0, SECTION_SIZE, 0.5 * height);
            }
            CTX.restore();
        }
    }
    sectionsCanvas.setCache(true);
    sectionsCanvas.setCacheHint(CacheHint.QUALITY);
}
 
Example #22
Source File: World.java    From charts with Apache License 2.0 5 votes vote down vote up
private void resize() {
    width  = getWidth() - getInsets().getLeft() - getInsets().getRight();
    height = getHeight() - getInsets().getTop() - getInsets().getBottom();
    size   = width < height ? width : height;

    if (ASPECT_RATIO * width > height) {
        width = 1 / (ASPECT_RATIO / height);
    } else if (1 / (ASPECT_RATIO / height) > width) {
        height = ASPECT_RATIO * width;
    }

    if (width > 0 && height > 0) {
        if (isZoomEnabled()) resetZoom();

        pane.setCache(true);
        pane.setCacheHint(CacheHint.SCALE);

        pane.setScaleX(width / PREFERRED_WIDTH);
        pane.setScaleY(height / PREFERRED_HEIGHT);

        group.resize(width, height);
        group.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);

        //heatMap.setSize(width, height);
        //heatMap.relocate(((getWidth() - getInsets().getLeft() - getInsets().getRight()) - width) * 0.5, ((getHeight() - getInsets().getTop() - getInsets().getBottom()) - height) * 0.5);

        heatMap.setScaleX(pane.getScaleX());
        heatMap.setScaleY(pane.getScaleY());
        heatMap.setTranslateX(group.getBoundsInParent().getMinX() - group.getLayoutBounds().getMinX());
        heatMap.setTranslateY(group.getBoundsInParent().getMinY() - group.getLayoutBounds().getMinY());

        pane.setCache(false);
    }
}
 
Example #23
Source File: CacheMemento.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
/**
 * this method will cache the node only if it wasn't cached before
 */
public void cache() {
    if (!isCached.getAndSet(true)) {
        this.cache = node.isCache();
        this.cacheHint = node.getCacheHint();
        node.setCache(true);
        node.setCacheHint(CacheHint.SPEED);
        if (node instanceof Region) {
            this.cacheShape = ((Region) node).isCacheShape();
            this.snapToPixel = ((Region) node).isSnapToPixel();
            ((Region) node).setCacheShape(true);
            ((Region) node).setSnapToPixel(true);
        }
    }
}
 
Example #24
Source File: FatClockSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
private void createMinutePointer() {
    double width  = size * 0.09733333;
    double height = size * 0.548;
    minute.setCache(false);
    minute.getElements().clear();
    minute.getElements().add(new MoveTo(0.0, 0.0));
    minute.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.9111922141119222 * height, 0.0, 0.9111922141119222 * height));
    minute.getElements().add(new CubicCurveTo(0.0, 0.9598540145985401 * height, 0.22602739726027396 * width, height, 0.5 * width, height));
    minute.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9598540145985401 * height, width, 0.9111922141119222 * height));
    minute.getElements().add(new CubicCurveTo(width, 0.9111922141119222 * height, width, 0.0, width, 0.0));
    minute.getElements().add(new LineTo(0.0, 0.0));
    minute.getElements().add(new ClosePath());
    minute.setCache(true);
    minute.setCacheHint(CacheHint.ROTATE);
}
 
Example #25
Source File: KpiSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
private void drawNeedle() {
    double needleWidth  = size * 0.064;
    double needleHeight = size * 0.44;
    needle.setCache(false);
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.1875 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.1875 * needleWidth, 0.0,
                                            0.1875 * needleWidth, 0.8727272727272727 * needleHeight,
                                            0.1875 * needleWidth, 0.8727272727272727 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0625 * needleWidth, 0.8818181818181818 * needleHeight,
                                            0.0, 0.9 * needleHeight,
                                            0.0, 0.9272727272727272 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9636363636363636 * needleHeight,
                                            0.25 * needleWidth, needleHeight,
                                            0.5 * needleWidth, needleHeight));
    needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, needleHeight,
                                            needleWidth, 0.9636363636363636 * needleHeight,
                                            needleWidth, 0.9272727272727272 * needleHeight));
    needle.getElements().add(new CubicCurveTo(needleWidth, 0.9 * needleHeight,
                                            0.9375 * needleWidth, 0.8818181818181818 * needleHeight,
                                            0.8125 * needleWidth, 0.8727272727272727 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.8125 * needleWidth, 0.8727272727272727 * needleHeight,
                                            0.8125 * needleWidth, 0.0,
                                            0.8125 * needleWidth, 0.0));
    needle.getElements().add(new LineTo(0.1875 * needleWidth, 0.0));
    needle.getElements().add(new ClosePath());
    needle.setCache(true);
    needle.setCacheHint(CacheHint.ROTATE);
}
 
Example #26
Source File: Dialogs.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
public static Node createLoadingNode () {
    
    Circle c0 = new Circle(65);
    c0.setFill(Color.TRANSPARENT);
    c0.setStrokeWidth(0.0);

    Circle c1 = new Circle(50);
    c1.setFill(Color.TRANSPARENT);
    c1.setStrokeType(StrokeType.INSIDE);
    c1.setStrokeLineCap(StrokeLineCap.BUTT);
    c1.getStrokeDashArray().addAll(78.54); // 50 * 2 * 3.1416 / 4
    c1.setCache(true);
    c1.setCacheHint(CacheHint.ROTATE);   
    c1.getStyleClass().add("loading-circle");
    setRotate(c1, true, 440.0, 10);

    Circle c2 = new Circle(40);
    c2.setFill(Color.TRANSPARENT);
    c2.setStrokeType(StrokeType.INSIDE);
    c2.setStrokeLineCap(StrokeLineCap.BUTT);
    c2.getStrokeDashArray().addAll(41.89); // 40 * 2 * 3.1416 / 6
    c2.setCache(true);
    c2.setCacheHint(CacheHint.ROTATE);    
    c2.getStyleClass().add("loading-circle");
    setRotate(c2, true, 360.0, 14);

    Circle c3 = new Circle(30);
    c3.setFill(Color.TRANSPARENT);
    c3.setStrokeType(StrokeType.INSIDE);
    c3.setStrokeLineCap(StrokeLineCap.BUTT);        
    c3.getStyleClass().add("loading-circle");

    Group g = new Group(c0, c1, c2, c3);
    g.getStylesheets().add(Dialogs.class.getResource("/com/adr/helloiot/styles/loading.css").toExternalForm());
    
    return g;
}
 
Example #27
Source File: Dialogs.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
public static Node createSmallLoadingNode () {
    
    Circle c0 = new Circle(45);
    c0.setFill(Color.TRANSPARENT);
    c0.setStrokeWidth(0.0);

    Circle c2 = new Circle(40);
    c2.setFill(Color.TRANSPARENT);
    c2.setStrokeType(StrokeType.INSIDE);
    c2.setStrokeLineCap(StrokeLineCap.BUTT);
    c2.getStrokeDashArray().addAll(41.89); // 40 * 2 * 3.1416 / 6
    c2.setCache(true);
    c2.setCacheHint(CacheHint.ROTATE);    
    c2.getStyleClass().add("loading-circle");
    setRotate(c2, true, 360.0, 14);

    Circle c3 = new Circle(30);
    c3.setFill(Color.TRANSPARENT);
    c3.setStrokeType(StrokeType.INSIDE);
    c3.setStrokeLineCap(StrokeLineCap.BUTT);        
    c3.getStyleClass().add("loading-circle");

    Group g = new Group(c0, c2, c3);
    g.getStylesheets().add(Dialogs.class.getResource("/com/adr/helloiot/styles/loading.css").toExternalForm());
    
    return g;
}
 
Example #28
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void showDialog() {
    if (dialogContainer == null) {
        throw new RuntimeException("ERROR: JFXDialog container is not set!");
    }
    if (isCacheContainer()) {
        tempContent = new ArrayList<>(dialogContainer.getChildren());

        SnapshotParameters snapShotparams = new SnapshotParameters();
        snapShotparams.setFill(Color.TRANSPARENT);
        WritableImage temp = dialogContainer.snapshot(snapShotparams,
            new WritableImage((int) dialogContainer.getWidth(),
                (int) dialogContainer.getHeight()));
        ImageView tempImage = new ImageView(temp);
        tempImage.setCache(true);
        tempImage.setCacheHint(CacheHint.SPEED);
        dialogContainer.getChildren().setAll(tempImage, this);
    } else {
    	//prevent error if opening an already opened dialog
    	dialogContainer.getChildren().remove(this);
    	tempContent = null;
    	dialogContainer.getChildren().add(this);
    }

    if (animation != null) {
        animation.play();
    } else {
        setVisible(true);
        setOpacity(1);
        Event.fireEvent(JFXDialog.this, new JFXDialogEvent(JFXDialogEvent.OPENED));
    }
}
 
Example #29
Source File: ShakeTransition.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
* Called when the animation is starting
*/
protected final void starting() {
    if (useCache) {
        oldCache = node.isCache();
        oldCacheHint = node.getCacheHint();
        node.setCache(true);
        node.setCacheHint(CacheHint.SPEED);
    }
}
 
Example #30
Source File: JFXHighlighter.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
/**
 * highlights the matching text in the specified pane
 * @param pane node to search into its text
 * @param query search text
 */
public synchronized void highlight(Parent pane, String query) {
    if (this.parent != null && !boxes.isEmpty()) {
        clear();
    }
    if(query == null || query.isEmpty()) return;

    this.parent = pane;

    Set<Node> nodes = getTextNodes(pane);

    ArrayList<Rectangle> allRectangles = new ArrayList<>();
    for (Node node : nodes) {
        Text text = ((Text) node);
        final int beginIndex = text.getText().toLowerCase().indexOf(query.toLowerCase());
        if (beginIndex > -1 && node.impl_isTreeVisible()) {
            ArrayList<Bounds> boundingBoxes = getMatchingBounds(query, text);
            ArrayList<Rectangle> rectangles = new ArrayList<>();
            for (Bounds boundingBox : boundingBoxes) {
                HighLightRectangle rect = new HighLightRectangle(text);
                rect.setCacheHint(CacheHint.SPEED);
                rect.setCache(true);
                rect.setMouseTransparent(true);
                rect.setBlendMode(BlendMode.MULTIPLY);
                rect.fillProperty().bind(paintProperty());
                rect.setManaged(false);
                rect.setX(boundingBox.getMinX());
                rect.setY(boundingBox.getMinY());
                rect.setWidth(boundingBox.getWidth());
                rect.setHeight(boundingBox.getHeight());
                rectangles.add(rect);
                allRectangles.add(rect);
            }
            boxes.put(node, rectangles);
        }
    }

    JFXUtilities.runInFXAndWait(()-> getParentChildren(pane).addAll(allRectangles));
}