mirror of
https://github.com/aNNiMON/HotaruFX.git
synced 2024-09-19 14:14:21 +03:00
Add more text properties
This commit is contained in:
parent
094954794e
commit
0b3158e060
@ -7,6 +7,7 @@ import com.annimon.hotarufx.visual.TimeLine;
|
|||||||
import com.annimon.hotarufx.visual.visitors.NodeVisitor;
|
import com.annimon.hotarufx.visual.visitors.NodeVisitor;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
import javafx.scene.text.TextBoundsType;
|
||||||
import static com.annimon.hotarufx.visual.PropertyType.*;
|
import static com.annimon.hotarufx.visual.PropertyType.*;
|
||||||
|
|
||||||
public class TextNode extends ShapeNode {
|
public class TextNode extends ShapeNode {
|
||||||
@ -16,6 +17,8 @@ public class TextNode extends ShapeNode {
|
|||||||
private PropertyTimelineHolder<Number> x, y;
|
private PropertyTimelineHolder<Number> x, y;
|
||||||
private PropertyTimelineHolder<String> textProperty;
|
private PropertyTimelineHolder<String> textProperty;
|
||||||
private PropertyTimelineHolder<Font> font;
|
private PropertyTimelineHolder<Font> font;
|
||||||
|
private PropertyTimelineHolder<Number> lineSpacing, wrappingWidth;
|
||||||
|
private PropertyTimelineHolder<Boolean> strikethrough, underline;
|
||||||
|
|
||||||
public TextNode() {
|
public TextNode() {
|
||||||
this(new Text());
|
this(new Text());
|
||||||
@ -28,6 +31,10 @@ public class TextNode extends ShapeNode {
|
|||||||
y = PropertyTimelineHolder.empty();
|
y = PropertyTimelineHolder.empty();
|
||||||
textProperty = PropertyTimelineHolder.empty();
|
textProperty = PropertyTimelineHolder.empty();
|
||||||
font = PropertyTimelineHolder.empty();
|
font = PropertyTimelineHolder.empty();
|
||||||
|
lineSpacing = PropertyTimelineHolder.empty();
|
||||||
|
wrappingWidth = PropertyTimelineHolder.empty();
|
||||||
|
strikethrough = PropertyTimelineHolder.empty();
|
||||||
|
underline = PropertyTimelineHolder.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyTimeline<Number> xProperty() {
|
public PropertyTimeline<Number> xProperty() {
|
||||||
@ -46,6 +53,22 @@ public class TextNode extends ShapeNode {
|
|||||||
return font.setIfEmptyThenGet(text::fontProperty);
|
return font.setIfEmptyThenGet(text::fontProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PropertyTimeline<Number> lineSpacingProperty() {
|
||||||
|
return lineSpacing.setIfEmptyThenGet(text::lineSpacingProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyTimeline<Number> wrappingWidthProperty() {
|
||||||
|
return wrappingWidth.setIfEmptyThenGet(text::wrappingWidthProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyTimeline<Boolean> strikethroughProperty() {
|
||||||
|
return strikethrough.setIfEmptyThenGet(text::strikethroughProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyTimeline<Boolean> underlineProperty() {
|
||||||
|
return underline.setIfEmptyThenGet(text::underlineProperty);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTimeline(TimeLine timeline) {
|
public void buildTimeline(TimeLine timeline) {
|
||||||
super.buildTimeline(timeline);
|
super.buildTimeline(timeline);
|
||||||
@ -53,6 +76,10 @@ public class TextNode extends ShapeNode {
|
|||||||
y.applyIfPresent(timeline);
|
y.applyIfPresent(timeline);
|
||||||
textProperty.applyIfPresent(timeline);
|
textProperty.applyIfPresent(timeline);
|
||||||
font.applyIfPresent(timeline);
|
font.applyIfPresent(timeline);
|
||||||
|
lineSpacing.applyIfPresent(timeline);
|
||||||
|
wrappingWidth.applyIfPresent(timeline);
|
||||||
|
strikethrough.applyIfPresent(timeline);
|
||||||
|
underline.applyIfPresent(timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +88,11 @@ public class TextNode extends ShapeNode {
|
|||||||
.add("x", NUMBER, this::xProperty)
|
.add("x", NUMBER, this::xProperty)
|
||||||
.add("y", NUMBER, this::yProperty)
|
.add("y", NUMBER, this::yProperty)
|
||||||
.add("text", STRING, this::textProperty)
|
.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
|
@Override
|
||||||
|
@ -16,7 +16,6 @@ A@fill
|
|||||||
B = rectangle({
|
B = rectangle({
|
||||||
x: -50,
|
x: -50,
|
||||||
y: -50,
|
y: -50,
|
||||||
visible: 0,
|
|
||||||
width: 100,
|
width: 100,
|
||||||
height: 100,
|
height: 100,
|
||||||
fill: "green"
|
fill: "green"
|
||||||
@ -46,7 +45,8 @@ C = text({
|
|||||||
fill: "white",
|
fill: "white",
|
||||||
stroke: "black",
|
stroke: "black",
|
||||||
font: 100,
|
font: 100,
|
||||||
clip: CLIP
|
underline: 1
|
||||||
|
clip: CLIP,
|
||||||
})
|
})
|
||||||
C@layoutX
|
C@layoutX
|
||||||
.add(100, 0)
|
.add(100, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user