How to achieve anti-aliasing in javaFX? I applied some tricks ... but that didn't work

after reading the question, it seems that I asked a question that was already asked, but believe me, I tried possible solutions in which I did not get the desired result ....

First of all, what do I want to achieve?

enter image description here

To achieve AntiAliasing, I tried using one of the methods, for example

  • new scene (,, SceneAntialiasing.BALANCED);
  • form [object] .setSmooth (true);
  • System.setProperty ("prism.lcdtext", "false"); from the link How to smooth anti-aliasing in JavaFX fonts?
  • I also tried using SubScene, but that was a slightly wrong way ...

But none of the above solutions work for me ... So, I am posting SSCVE ...

Please help me with this ...

Thanks in advance...

Sscve

the CreateScene method in UI class which extends JFXPanel looks like .... private Scene createScene() { Group rootNode = new Group(); //System.setProperty("prism.lcdtext", "false"); double StrokeWidth = 1.0; double yPosition = 20.0; //textFontsize = textFontsize + 0.7 ; // straight Vertical Lines rootNode.getChildren().add(createLines(35.0, yPosition+20, 35.0, yPosition+150, StrokeWidth,"GREEN")); rootNode.getChildren().add(createLines(25.0, yPosition+20, 25, yPosition+150, StrokeWidth,"BLACK")); rootNode.getChildren().add(createLines(30.0, yPosition+20, 30, yPosition+150, StrokeWidth,"BLUE")); // straight horizontal lines rootNode.getChildren().add(createLines(80.0, yPosition+30, 240, yPosition+30, StrokeWidth,"RED")); rootNode.getChildren().add(createLines(80.0, yPosition+40, 240, yPosition+40, StrokeWidth,"GREEN")); rootNode.getChildren().add(createLines(80.0, yPosition+50, 240, yPosition+50, StrokeWidth,"BLACK")); // create slope lines rootNode.getChildren().add(createLines(420.0, yPosition+20, 470, yPosition+150, StrokeWidth,"BLACK")); rootNode.getChildren().add(createLines(430.0, yPosition+20, 480, yPosition+150, StrokeWidth,"RED")); rootNode.getChildren().add(createLines(440.0, yPosition+20, 490, yPosition+150, StrokeWidth,"BLUE")); rootNode.getChildren().add(createLines(450.0, yPosition+20, 500, yPosition+150, StrokeWidth,"GREEN")); double textFontsize = 12.0; String fontColor = "RED"; String font ="Arial"; int count = 5; String newLine = null; if(count == 5) { newLine = "\n\n\n\n\n"; } rootNode.getChildren().add(createText(50,yPosition+230,font,textFontsize, newLine+"15352465 \n" + "Circle is "+StrokeWidth+" . "+"Font name is "+font+" . Minimum visible font size is 0.7 ." + "\n The Font size for text is "+textFontsize+". ",fontColor, StrokeWidth)); ScrollPane scroll = new ScrollPane(); scroll.setHbarPolicy(ScrollBarPolicy.ALWAYS); scroll.setVbarPolicy(ScrollBarPolicy.NEVER); scroll.setContent(rootNode); //iv.setClip(new Rectangle(0,20,250,200)); Scene sc = new Scene(scroll, 500,500,false,SceneAntialiasing.BALANCED); SceneAntialiasing value = sc.getAntiAliasing(); return sc; } public Line createLines(double startX, double startY, double endX, double endY, double strokeWidth, String strokeColor) { Line line = new Line(startX-0.5, startY-0.5, endX-0.5, endY-0.5); if(strokeColor.equals("BLUE")) { line.setStroke(javafx.scene.paint.Color.BLUE); } else if(strokeColor.equals("RED")) { line.setStroke(javafx.scene.paint.Color.RED); } else if(strokeColor.equals("GREEN")) { line.setStroke(javafx.scene.paint.Color.GREEN); } else if(strokeColor.equals("BLACK")) { line.setStroke(javafx.scene.paint.Color.BLACK); } line.setStrokeWidth(strokeWidth); //line.setSmooth(true); return line; } public Text createText(double xParam, double yParam, String fontType, double fontSize, String text, String strokeColor, double StrokeWidth) { Text txt = new Text(text); txt.setX(xParam); txt.setY(yParam); if(fontType.equals("Comic Sans MS")) { txt.setFont(Font.font(fontType,FontWeight.BOLD, fontSize)); } else { txt.setFont(Font.font(fontType, fontSize)); } //txt.setStrokeWidth(StrokeWidth); if(strokeColor.equals("BLUE")) { txt.setFill(Color.BLUE); } else if(strokeColor.equals("RED")) { txt.setFill(javafx.scene.paint.Color.RED); } else if(strokeColor.equals("GREEN")) { txt.setFill(javafx.scene.paint.Color.GREEN); } else if(strokeColor.equals("BLACK")) { txt.setFill(javafx.scene.paint.Color.BLACK); } else if(strokeColor.equals("BROWN")) { txt.setFill(javafx.scene.paint.Color.BROWN); } // txt.setFontSmoothingType(FontSmoothingType.LCD); // txt.setStrokeType(StrokeType.INSIDE); return txt; } 
+7
javafx-2 javafx-8
source share

No one has answered this question yet.

See similar questions:

17
How to force anti-aliasing in JavaFX fonts?

or similar:

4
JavaFX Bindings.size () stops working after some events
3
Is it possible to disable anti-aliasing for a path form in JavaFX?
2
How to achieve collision detection in translation translation (in JavaFX)?
one
JavaFx: How to apply validation on two GridPanes nodes at the same time?
0
Why don't JavaFx Media Player and Media View work on some Labtops and work on others?
0
How to work with canvas and text in javafx
0
How to rotate svg in javafx using some RPMs
0
How to switch workspaces in JavaFX
0
How to achieve the following structure in javafx?
0
JavaFX: how to check anti-aliasing support

All Articles