Skip to content

Commit

Permalink
Removed deprecated code related to border mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
salmonb committed Nov 16, 2023
1 parent 8660aee commit 92baeee
Showing 1 changed file with 0 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.webfx.kit.mapper.peers.javafxgraphics.gwt.html;

import dev.webfx.kit.mapper.peers.javafxgraphics.NodePeer;
import dev.webfx.kit.mapper.peers.javafxgraphics.base.NodePeerBase;
import dev.webfx.kit.mapper.peers.javafxgraphics.base.NodePeerMixin;
import dev.webfx.kit.mapper.peers.javafxgraphics.gwt.shared.HtmlSvgNodePeer;
Expand All @@ -14,13 +13,10 @@
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.effect.*;
import javafx.scene.text.TextAlignment;
import javafx.scene.transform.Transform;
import javafx.scene.transform.Translate;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -41,30 +37,6 @@ public void updateAllNodeTransforms(List<Transform> allNodeTransforms) {
if (!(container instanceof HTMLElement))
super.updateAllNodeTransforms(allNodeTransforms);
else {
// We fix here a difference in the behaviour between HTML & JavaFX regarding borders: in JavaFX borders are
// purely graphical with no impact on the coordinates, while HTML makes borders act like padding.
// For example, if a box has a 5px border, in HTML local coordinates (0,0) will start after the border, so
// at (5,5) from the left top box corner, while in JavaFX local coordinates (0,0) stay at the corner.
Parent parent = getNode().getParent();
if (parent != null) { // So checking if the parent has a border
NodePeer parentPeer = parent.getNodePeer();
if (parentPeer instanceof HtmlSvgNodePeer) {
Element parentContainer = ((HtmlSvgNodePeer) parentPeer).getVisibleContainer();
if (parentContainer instanceof HTMLElement) {
CSSStyleDeclaration style = ((HTMLElement) parentContainer).style;
// Measuring the left and top border width
double leftBorder = style.borderLeftWidth.isString() ? fromPx(style.borderLeftWidth.asString()) : style.borderLeftWidth.isDouble() ? style.borderLeftWidth.asDouble() : 0;
double topBorder = style.borderTopWidth.isString() ? fromPx(style.borderTopWidth.asString()) : style.borderTopWidth.isDouble() ? style.borderTopWidth.asDouble() : 0;
// If there is a border, we add a node translation to revert the HTML behaviour
if (leftBorder != 0 || topBorder != 0) {
// First making a copy because the original is an observable list bound for updates
allNodeTransforms = new ArrayList<>(allNodeTransforms);
// Adding the revert translation that will finally emulate the same behaviour as JavaFX
allNodeTransforms.add(0, new Translate(-leftBorder, -topBorder));
}
}
}
}
String transform = HtmlTransforms.toHtmlTransforms(allNodeTransforms);
CSSStyleDeclaration style = ((HTMLElement) container).style;
style.transform = transform;
Expand Down

0 comments on commit 92baeee

Please sign in to comment.