Skip to content

Commit 98ac9eb

Browse files
committed
Updated to match API changes
1 parent bebcc92 commit 98ac9eb

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

richtextfx/src/main/java/org/fxmisc/richtext/TextFlowExt.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ int getLineCount() {
3737
}
3838

3939
int getLineStartPosition(int charIdx) {
40-
return textLayout().getTextLine( getLineOfCharacter(charIdx) ).getStart();
40+
return textLayout().getTextLine( getLineOfCharacter(charIdx), false ).start();
4141
}
4242

4343
int getLineEndPosition(int charIdx) {
4444
int line = getLineOfCharacter( charIdx );
45-
int end = textLayout().getTextLine( line ).getEnd();
45+
int end = textLayout().getTextLine( line, false ).end();
4646
if ( line < (getLineCount() - 1) ) end--; // trailing space
4747
return end;
4848
}
4949

5050
int getLineOfCharacter(int charIdx) {
5151
var layout = textLayout();
5252
return IntStream.range( 0, getLineCount() )
53-
.filter( l -> charIdx < layout.getTextLine( l ).getEnd() )
53+
.filter( l -> charIdx < layout.getTextLine( l, false ).end() )
5454
.findFirst().orElse( Math.max(0,getLineCount()-1) );
5555
}
5656

@@ -154,22 +154,22 @@ PathElement[] getUnderlineShape(int from, int to, double offset, double waveRadi
154154
}
155155

156156
CharacterHit hitLine(double x, int lineIndex) {
157-
Rectangle2D r = textLayout().getTextLine( lineIndex ).getBounds();
157+
Rectangle2D r = textLayout().getTextLine( lineIndex, false ).bounds();
158158
double y = r.getMinY() + r.getHeight() / 2.0;
159159
return hit( x, y, lineIndex );
160160
}
161161

162162
CharacterHit hit(double x, double y) {
163163
var layout = textLayout();
164164
int line = IntStream.range( 0, getLineCount() )
165-
.filter( l -> y < layout.getTextLine( l ).getBounds().getMaxY() )
165+
.filter( l -> y < layout.getTextLine( l, true ).bounds().getMaxY() )
166166
.findFirst().orElse( Math.max(0,getLineCount()-1) );
167167
return hit( x, y, line );
168168
}
169169

170170
CharacterHit hit(double x, double y, int line) {
171171

172-
Rectangle2D lineBounds = textLayout().getTextLine( line ).getBounds();
172+
Rectangle2D lineBounds = textLayout().getTextLine( line, false ).bounds();
173173
HitInfo hit = hitTest(new Point2D(x, y));
174174
int charIdx = hit.getCharIndex();
175175
boolean leading = hit.isLeading();
@@ -181,7 +181,7 @@ CharacterHit hit(double x, double y, int line) {
181181
if ( ! leading && getLineCount() > 1) {
182182
// If this is a wrapped paragraph and hit character is at end of hit line, make sure that the
183183
// "character hit" stays at the end of the hit line (and not at the beginning of the next line).
184-
leading = (getLineOfCharacter(charIdx) + 1 < getLineCount() && charIdx + 1 >= textLayout().getTextLine( line ).getEnd());
184+
leading = (getLineOfCharacter(charIdx) + 1 < getLineCount() && charIdx + 1 >= textLayout().getTextLine( line, false ).end());
185185
}
186186

187187
if(x < lineBounds.getMinX() || x > lineBounds.getMaxX()) {

richtextfx/src/main/java/org/fxmisc/richtext/TextFlowLayout.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ float getLineCenter( int lineNo ) {
4242

4343
@Deprecated
4444
int getLineLength( int lineNo ) {
45-
return getTextLine( lineNo ).getLength();
45+
return getTextLine( lineNo, false ).length();
4646
}
4747

4848

49-
TextFlowSpan getLineSpan( int lineNo ) {
49+
TextFlowSpan getTextLine( int lineNo, boolean includeLineSpacing ) {
5050
return (lineNo >= 0 && getTextLineCount() > 0) ? lineMetrics.get( lineNo ) : EMPTY_SPAN;
5151
}
5252

@@ -55,7 +55,7 @@ TextFlowSpan getLineSpan( int lineNo ) {
5555
TextFlowSpan getLineSpan( float y ) {
5656
final int lastLine = getTextLineCount();
5757
if ( lastLine < 1 ) return EMPTY_SPAN;
58-
return lineMetrics.stream().filter( tfs -> y < tfs.getBounds().getMaxY() )
58+
return lineMetrics.stream().filter( tfs -> y < tfs.bounds().getMaxY() )
5959
.findFirst().orElse( lineMetrics.get( Math.max(0,lastLine-1) ) );
6060
}
6161

@@ -143,7 +143,7 @@ else if ( nodeMinY >= prevMaxY ) { // Node is on
143143
private void adjustLineMetrics( int length, double width, double height ) {
144144
TextFlowSpan span = lineMetrics.get( lineMetrics.size()-1 );
145145
span.addLengthAndWidth( length, width );
146-
if ( height > span.getHeight() ) {
146+
if ( height > span.height() ) {
147147
span.setHeight( height );
148148
}
149149
}

richtextfx/src/main/java/org/fxmisc/richtext/TextFlowSpan.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ class TextFlowSpan
1919
y = minY;
2020
}
2121

22-
Rectangle2D getBounds() {
22+
Rectangle2D bounds() {
2323
if ( bounds == null ) {
2424
bounds = new Rectangle2D( 0, y, width, height );
2525
}
2626
return bounds;
2727
}
2828

29-
float getCenterY() {
29+
float centerY() {
3030
return (float) (y + height / 2);
3131
}
3232

33-
int getStart() { return start; }
34-
int getLength() { return length; }
35-
int getEnd() { return start + length; }
36-
double getHeight() { return height; }
37-
double getWidth() { return width; }
33+
int start() { return start; }
34+
int length() { return length; }
35+
int end() { return start + length; }
36+
double height() { return height; }
37+
double width() { return width; }
3838

3939
void setHeight( double h ) { height = h; bounds = null; }
4040

0 commit comments

Comments
 (0)