use of javafx.geometry.BoundingBox in project jphp by jphp-compiler.
the class DndTabPaneFactory method handleOutline.
private static MarkerFeedback handleOutline(Pane layoutNode, FeedbackData data) {
TabOutlineMarker marker = null;
for (Node n : layoutNode.getChildren()) {
if (n instanceof TabOutlineMarker) {
marker = (TabOutlineMarker) n;
}
}
if (marker == null) {
marker = new TabOutlineMarker(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
marker.setManaged(false);
marker.setMouseTransparent(true);
layoutNode.getChildren().add(marker);
} else {
marker.updateBounds(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
marker.setVisible(true);
}
final TabOutlineMarker fmarker = marker;
return new MarkerFeedback(data) {
@Override
public void hide() {
fmarker.setVisible(false);
}
};
}
use of javafx.geometry.BoundingBox in project FXGL by AlmasB.
the class HitBox method readObject.
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
name = (String) in.readObject();
bounds = new BoundingBox(in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble());
Dimension2D size = new Dimension2D(in.readDouble(), in.readDouble());
ShapeType type = (ShapeType) in.readObject();
switch(type) {
case CIRCLE:
shape = BoundingShape.circle(size.getWidth() / 2);
break;
case POLYGON:
shape = BoundingShape.box(size.getWidth(), size.getHeight());
break;
case CHAIN:
int length = in.readInt();
Point2D[] points = new Point2D[length];
for (int i = 0; i < length; i++) {
points[i] = new Point2D(in.readDouble(), in.readDouble());
}
shape = BoundingShape.chain(points);
break;
default:
throw new IllegalArgumentException("Unknown shape type");
}
}
use of javafx.geometry.BoundingBox in project gs-ui-javafx by graphstream.
the class FxTextBox method setText.
/**
* Changes the text and compute its bounds. This method tries to avoid recomputing bounds
* if the text does not really changed.
*/
public void setText(String text, Backend backend) {
if (text != null && text.length() > 0) {
if (textData != text || !textData.equals(text)) {
this.textData = text;
this.text = new Text(text);
this.text.setBoundsType(TextBoundsType.LOGICAL);
this.bounds = this.text.getBoundsInLocal();
} else {
this.textData = null;
this.text = null;
this.bounds = new BoundingBox(0, 0, 0, 0);
}
}
}
use of javafx.geometry.BoundingBox in project RichTextFX by FXMisc.
the class GenericStyledArea method getCharacterBoundsOnScreen.
@Override
public Optional<Bounds> getCharacterBoundsOnScreen(int from, int to) {
if (from < 0) {
throw new IllegalArgumentException("From is negative: " + from);
}
if (from > to) {
throw new IllegalArgumentException(String.format("From is greater than to. from=%s to=%s", from, to));
}
if (to > getLength()) {
throw new IllegalArgumentException(String.format("To is greater than area's length. length=%s, to=%s", getLength(), to));
}
// no bounds exist if range is just a newline character
if (getText(from, to).equals("\n")) {
return Optional.empty();
}
// if 'from' is the newline character at the end of a multi-line paragraph, it returns a Bounds that whose
// minX & minY are the minX and minY of the paragraph itself, not the newline character. So, ignore it.
int realFrom = getText(from, from + 1).equals("\n") ? from + 1 : from;
Position startPosition = offsetToPosition(realFrom, Bias.Forward);
int startRow = startPosition.getMajor();
Position endPosition = startPosition.offsetBy(to - realFrom, Bias.Forward);
int endRow = endPosition.getMajor();
if (startRow == endRow) {
return getRangeBoundsOnScreen(startRow, startPosition.getMinor(), endPosition.getMinor());
} else {
Optional<Bounds> rangeBounds = getRangeBoundsOnScreen(startRow, startPosition.getMinor(), getParagraph(startRow).length());
for (int i = startRow + 1; i <= endRow; i++) {
Optional<Bounds> nextLineBounds = getRangeBoundsOnScreen(i, 0, i == endRow ? endPosition.getMinor() : getParagraph(i).length());
if (nextLineBounds.isPresent()) {
if (rangeBounds.isPresent()) {
Bounds lineBounds = nextLineBounds.get();
rangeBounds = rangeBounds.map(b -> {
double minX = Math.min(b.getMinX(), lineBounds.getMinX());
double minY = Math.min(b.getMinY(), lineBounds.getMinY());
double maxX = Math.max(b.getMaxX(), lineBounds.getMaxX());
double maxY = Math.max(b.getMaxY(), lineBounds.getMaxY());
return new BoundingBox(minX, minY, maxX - minX, maxY - minY);
});
} else {
rangeBounds = nextLineBounds;
}
}
}
return rangeBounds;
}
}
use of javafx.geometry.BoundingBox in project TestFX by TestFX.
the class BoundsLocatorImpl method limitToVisibleBounds.
private Bounds limitToVisibleBounds(Bounds boundsInScene, Scene scene) {
Bounds sceneBounds = new BoundingBox(0, 0, scene.getWidth(), scene.getHeight());
Bounds visibleBounds = intersectBounds(boundsInScene, sceneBounds);
if (!areBoundsVisible(visibleBounds)) {
throw new BoundsLocatorException("bounds are not visible in Scene");
}
return visibleBounds;
}
Aggregations