Found 7442 Articles for Java

Explain the stroke Dash Offset property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:43:39

592 Views

If the stroke used is a dashing pattern. the strokeDashOffset property specifies the offset into the dashing pattern. i.e. the dash phase defines the point in the dashing pattern that will correspond to the beginning of the stroke.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.stage.Stage; public class StrokeDashOffset extends Application {    public void start(Stage stage) {       Line shape1 = new Line(25.0, 50.0, 565.0, 50.0);       shape1.setStroke(Color.BROWN);       shape1.setStrokeWidth(10);       shape1.getStrokeDashArray().addAll(80.0, 70.0, 60.0, 50.0, 40.0);       shape1.setStrokeDashOffset(5);       Polygon shape2 = ... Read More

Explain the smooth property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:41:38

312 Views

The smooth property specifies whether antialiasing hints are used or not. You can set the value to this property using the setSmooth() method of the javafx.scene.shape.Shape class.This method accepts a boolean value and if you pass true the edges of the shape will be smoothened.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.shape.StrokeLineJoin; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class SmoothExample extends Application {    public void start(Stage stage) {       Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12);       Text label2 = new Text("Smooth: true");       ... Read More

Explain the Stroke Line Cap property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:38:12

468 Views

The Stroke Line Cap specifies/defines the end cap style of the line. You can set the Stroke Line Cap value using the setStrokeLineCap() method of the javafx.scene.shape.Shape class.Java FX supports three kinds of stroke line caps represented by three constants of the Enum named StrokeLineCap they are −BUTT − This type ends the unclosed subpaths without any decoration.ROUND − This type ends the unclosed paths with a round projection.SQUARE − This type ends the unclosed paths with a square projection.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.StrokeLineCap; import javafx.scene.shape.StrokeType; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import ... Read More

Explain the Stroke Miter Limit property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:35:12

294 Views

The Stroke Miter Limit property specifies/defines the limit for the stroke line join in the StrokeLineJoin.MITER style. You can set this value using the setStrokeMiterLimit() method of the javafx.scene.shape.Shape class.This method accepts a double value and limits the stroke miter limit to the given value. If the given value is less than 1.0. It is considered as 1.0.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.shape.StrokeLineJoin; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class StrokeMiterExample extends Application {    public void start(Stage stage) {       Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, ... Read More

Explain the Stroke Line Join property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:31:57

372 Views

In shapes formed by joining more than one line, the stroke line join property specifies/defines the shape of the joint of the two lines. You can set the stoke line join using the setStrokeLineJoin() method.Java FX supports three kinds of stroke line joins represented by three constants of the Enum named StrokeLineJoin they are −BEVEL − In this type, the outside edges of the intersection are connected with a line segment.MITER − In this type, the outside edges of the intersection are joined together forming a sharp edge.ROUND − In this type, the outside edges of the intersection are joined ... Read More

Explain the Stroke property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:28:48

1K+ Views

The stroke property specifies/defines the color of the boundary of a shape. You can set the color of the boundary using the setStroke() method of the javafx.scene.shape.Shape class.This method accepts a Color value as a parameter and sets the given color to the boundary of a shape.By default, the value of this property for the shapes (objects) line, path and polyline is null and, for all the remaining shapes the default value of this property is Color.BLACK.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class ... Read More

Explain the Fill property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:24:47

843 Views

The fill property specifies/defines the color with which the interior area of the shape is to be filled. You can fill a particular shape with the desired color using the fill() method of the javafx.scene.shape.Shape class.By default, the value of this property for the shapes (objects) line, path and polyline are Color.BLACK and, for all the remaining shapes the default value of this property is null i.e. they will not be filled with any color (they will be left opaque).Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Line; import javafx.scene.shape.Polygon; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import ... Read More

Explain the Stroke Width property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:21:06

2K+ Views

The stroke width property specifies the width of the boundary line of a shape. You can set the width using the setWidth() method of the javafx.scene.shape.Shape class. This method accepts double value as a parameter and draws a boundary of the specified width.If you haven’t passed any value as a parameter to this method it considers the width as 1.0 by default.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class StrokeWidthExample extends Application {    public void start(Stage stage) {       Font font = Font.font("verdana", ... Read More

Explain the Stroke Type property of 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:18:15

407 Views

The stroke type property of a shape specifies the type of its boundary line. You can set the stroke type using the setStrokeType() method of the javafx.scene.shape.Shape class.JavaFX supports three kinds of strokes represented by three constants of the Enum named StrokeType they are −StrokeType.INSIDE − Draws the boundary inside the shape.StrokeType.OUTSIDE − Draws the boundary outside the shape.StrokeType.CENTERED − Draws the boundary such that the edge of the shape passes through the center of it.To set a boundary to a shape you need to pass either of these values as a parameter to the setStrokeType()method.Exampleimport javafx.application.Application; import javafx.scene.Group; import ... Read More

Explain the Subtract operation on 2D shapes in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 07:15:23

443 Views

This operation takes two or more shapes as an input. Then, it returns the area of the first shape excluding the area overlapped by the second one as shown below.The subtract() (static) method of the javafx.scene.shape.Shape class accepts two Shape objects and returns the result of the subtract operation of the given objects.Exampleimport javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.shape.Circle; import javafx.scene.shape.Shape; public class JavaFXSubtractExample extends Application {    public void start(Stage stage) {       //Drawing circle1       Circle circle1 = new Circle();       circle1.setCenterX(230.0f);       circle1.setCenterY(100.0f);   ... Read More

Advertisements