From 0b3158e06069c15a008fd16ddafd74557bd4d885 Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 1 Sep 2017 19:18:07 +0300 Subject: [PATCH] Add more text properties --- .../hotarufx/visual/objects/TextNode.java | 33 ++++++++++++++++++- app/src/main/resources/main.hfx | 4 +-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/annimon/hotarufx/visual/objects/TextNode.java b/app/src/main/java/com/annimon/hotarufx/visual/objects/TextNode.java index c41f547..c83e96c 100644 --- a/app/src/main/java/com/annimon/hotarufx/visual/objects/TextNode.java +++ b/app/src/main/java/com/annimon/hotarufx/visual/objects/TextNode.java @@ -7,6 +7,7 @@ import com.annimon.hotarufx.visual.TimeLine; import com.annimon.hotarufx.visual.visitors.NodeVisitor; import javafx.scene.text.Font; import javafx.scene.text.Text; +import javafx.scene.text.TextBoundsType; import static com.annimon.hotarufx.visual.PropertyType.*; public class TextNode extends ShapeNode { @@ -16,6 +17,8 @@ public class TextNode extends ShapeNode { private PropertyTimelineHolder x, y; private PropertyTimelineHolder textProperty; private PropertyTimelineHolder font; + private PropertyTimelineHolder lineSpacing, wrappingWidth; + private PropertyTimelineHolder strikethrough, underline; public TextNode() { this(new Text()); @@ -28,6 +31,10 @@ public class TextNode extends ShapeNode { y = PropertyTimelineHolder.empty(); textProperty = PropertyTimelineHolder.empty(); font = PropertyTimelineHolder.empty(); + lineSpacing = PropertyTimelineHolder.empty(); + wrappingWidth = PropertyTimelineHolder.empty(); + strikethrough = PropertyTimelineHolder.empty(); + underline = PropertyTimelineHolder.empty(); } public PropertyTimeline xProperty() { @@ -46,6 +53,22 @@ public class TextNode extends ShapeNode { return font.setIfEmptyThenGet(text::fontProperty); } + public PropertyTimeline lineSpacingProperty() { + return lineSpacing.setIfEmptyThenGet(text::lineSpacingProperty); + } + + public PropertyTimeline wrappingWidthProperty() { + return wrappingWidth.setIfEmptyThenGet(text::wrappingWidthProperty); + } + + public PropertyTimeline strikethroughProperty() { + return strikethrough.setIfEmptyThenGet(text::strikethroughProperty); + } + + public PropertyTimeline underlineProperty() { + return underline.setIfEmptyThenGet(text::underlineProperty); + } + @Override public void buildTimeline(TimeLine timeline) { super.buildTimeline(timeline); @@ -53,6 +76,10 @@ public class TextNode extends ShapeNode { y.applyIfPresent(timeline); textProperty.applyIfPresent(timeline); font.applyIfPresent(timeline); + lineSpacing.applyIfPresent(timeline); + wrappingWidth.applyIfPresent(timeline); + strikethrough.applyIfPresent(timeline); + underline.applyIfPresent(timeline); } @Override @@ -61,7 +88,11 @@ public class TextNode extends ShapeNode { .add("x", NUMBER, this::xProperty) .add("y", NUMBER, this::yProperty) .add("text", STRING, this::textProperty) - .add("font", FONT, this::fontProperty); + .add("font", FONT, this::fontProperty) + .add("lineSpacing", NUMBER, this::lineSpacingProperty) + .add("wrappingWidth", NUMBER, this::wrappingWidthProperty) + .add("strikethrough", BOOLEAN, this::strikethroughProperty) + .add("underline", BOOLEAN, this::underlineProperty); } @Override diff --git a/app/src/main/resources/main.hfx b/app/src/main/resources/main.hfx index b694cc9..d94e3ae 100644 --- a/app/src/main/resources/main.hfx +++ b/app/src/main/resources/main.hfx @@ -16,7 +16,6 @@ A@fill B = rectangle({ x: -50, y: -50, - visible: 0, width: 100, height: 100, fill: "green" @@ -46,7 +45,8 @@ C = text({ fill: "white", stroke: "black", font: 100, - clip: CLIP + underline: 1 + clip: CLIP, }) C@layoutX .add(100, 0)