-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Indent and BulletFactory and updated ParStyle to accommodate Indent
- Loading branch information
Showing
7 changed files
with
127 additions
and
10 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/BulletFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.fxmisc.richtext.demo.richtext; | ||
|
||
import java.util.function.IntFunction; | ||
|
||
import org.fxmisc.richtext.GenericStyledArea; | ||
|
||
import javafx.geometry.Insets; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.ContentDisplay; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.VBox; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Circle; | ||
import javafx.scene.shape.Rectangle; | ||
|
||
public class BulletFactory implements IntFunction<Node> | ||
{ | ||
private GenericStyledArea<ParStyle,?,?> area; | ||
|
||
public BulletFactory( GenericStyledArea<ParStyle,?,?> area ) | ||
{ | ||
this.area = area; | ||
} | ||
|
||
@Override | ||
public Node apply( int value ) | ||
{ | ||
if ( value < 0 ) return null; | ||
|
||
ParStyle ps = area.getParagraph( value ).getParagraphStyle(); | ||
if ( ! ps.indent.isPresent() ) return null; | ||
|
||
return createBullet( ps.indent.get() ); | ||
} | ||
|
||
private Node createBullet(Indent in) { | ||
Node result; | ||
switch( in.level ) { | ||
case 1 : { | ||
Circle c = new Circle(2.5); | ||
c.setFill(Color.BLACK); | ||
c.setStroke(Color.BLACK); | ||
result = c; | ||
} | ||
break; | ||
|
||
case 2 : { | ||
Circle c = new Circle(2.5); | ||
c.setFill(Color.WHITE); | ||
c.setStroke(Color.BLACK); | ||
result = c; | ||
} | ||
break; | ||
|
||
case 3 : { | ||
Rectangle r = new Rectangle(5, 5); | ||
r.setFill(Color.BLACK); | ||
r.setStroke(Color.BLACK); | ||
result = r; | ||
} | ||
break; | ||
|
||
default : { | ||
Rectangle r = new Rectangle(5, 5); | ||
r.setFill(Color.WHITE); | ||
r.setStroke(Color.BLACK); | ||
result = r; | ||
} | ||
break; | ||
} | ||
|
||
Label l = new Label( " ", result ); | ||
l.setPadding( new Insets( 0, 0, 0, in.level*in.width ) ); | ||
l.setContentDisplay( ContentDisplay.LEFT ); | ||
return new VBox( 0, l ); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/Indent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.fxmisc.richtext.demo.richtext; | ||
|
||
public class Indent | ||
{ | ||
double width = 15; | ||
int level = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+644 Bytes
...x-demos/src/main/resources/org/fxmisc/richtext/demo/richtext/decreaseIndent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+627 Bytes
...x-demos/src/main/resources/org/fxmisc/richtext/demo/richtext/increaseIndent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters