5

after reading the question it looks like I have asked the question which was already asked but believe me I have tried the possible solutions where in I didn't get the desired output....

First of all What I want to achieve ?

enter image description here

To achieve the AntiAliasing , I have tried some of the way like

  1. new Scene(,,,,SceneAntialiasing.BALANCED);
  2. shape[object].setSmooth(true);
  3. System.setProperty("prism.lcdtext", "false"); from the link How to force anti-aliasing in JavaFX fonts?
  4. I have tried to use SubScene as well , but it was somewhat improper way to go...

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

Please help me on 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;
}   
Community
  • 1
  • 1
Ankit Patel
  • 142
  • 1
  • 13

0 Answers0