Object Oriented Programming Articles

Page 467 of 589

How to add stroke and color to text in JavaFX?

Maruthi Krishna
Maruthi Krishna
Updated on 14-Apr-2020 3K+ Views

Since the javafx.scene.text.Text class in JavaFX inherits the Shape class it inherits all its members. You can modify the stroke and color of the text node by setting values to the stroke, stroke width and fill properties inherited by the Text class.Stroke Width − The stroke width property specifies/defines the width of the boundary line of a shape. You can set value to the width of the boundary using the setWidth() method of the Shape class.Fill − The fill property specifies/defines the color with which the interior area of the shape is to be filled. You can fill a particular ...

Read More

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

Maruthi Krishna
Maruthi Krishna
Updated on 14-Apr-2020 667 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
Maruthi Krishna
Updated on 14-Apr-2020 368 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 Union operation on 2D shapes in JavaFX

Maruthi Krishna
Maruthi Krishna
Updated on 14-Apr-2020 359 Views

This operation takes two or more shapes as inputs and returns the area occupied by them combined as shown below.The union() (static) method of the javafx.scene.shape.Shape class accepts two Shape objects and returns the result of the union 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 JavaFXUnionExample extends Application {    public void start(Stage stage) {       //Drawing circle1       Circle circle1 = new Circle();       circle1.setCenterX(230.0f);       circle1.setCenterY(100.0f);       circle1.setRadius(75.0f);       circle1.setFill(Color.DARKRED);       ...

Read More

What are various path elements in JavaFX?

Maruthi Krishna
Maruthi Krishna
Updated on 13-Apr-2020 329 Views

The javafx.scene.shape package provides classes using which you can draw various 2D shapes, but these are just primitive shapes like line, circle, polygon, and ellipse, etc… Therefore, if you want to draw complex custom shapes you need to use the Path class.The Path ClassThe Path class represents the geometrical outline of a shape using this class you can draw your custom path.To draw a custom path JavaFX provides various path elements and, all these are available as classes in the javafx.scene.shape package.LineTo − This is class represents the path element line. It helps you to draw a straight line from the ...

Read More

How to add a blur effect to a text node in JavaFX?

Maruthi Krishna
Maruthi Krishna
Updated on 13-Apr-2020 589 Views

You can add an effect to any node object in JavaFX using the setEffect() method. This method accepts an object of the Effect class and adds it to the current node.javafx.scene.effect.GaussianBlur.GaussianBlur class represents a blur effect that internally uses Gaussian convolution kernel. Therefore, to add a blur effect to a text node −Instantiate the Text class bypassing basic the x, y coordinates (position) and text string as arguments to the constructor.Set desired properties like font, stoke, etc.Create a blur effect by instantiating the GaussianBlur class.Set the created effect to the text node using the setEffect() method.Finally, add the created text node to ...

Read More

Explain the life cycle of a JavaFX Application

Maruthi Krishna
Maruthi Krishna
Updated on 13-Apr-2020 3K+ Views

The JavaFX Application class has three life cycle methods, which are −start() − The entry point method where the JavaFX graphics code is to be written.stop() − An empty method which can be overridden, here you can write the logic to stop the application.init() − An empty method which can be overridden, but you cannot create a stage or scene in this method.In addition to these, it provides a static method named launch() to launch JavaFX application.Since the launch() method is static, you need to call it from a static context (main generally). Whenever a JavaFX application is launched, the ...

Read More

Explain JavaFX Scene Graph

Maruthi Krishna
Maruthi Krishna
Updated on 13-Apr-2020 1K+ Views

In JavaFX, the GUI Applications were constructed using a Scene Graph. A scene graph is a data structure similar to tree, in modern graphical applications. It is the starting point of the application, and it is a collection of nodesTo display something in JavaFX You need to construct a scene graph using the nodes and set it to an object of the Stage class, the top level container of a JavaFX application.A node is a visual/graphical primitive object of a JavaFX application.Each node in the scene graph has a single parent, and the node which does not contain any parents ...

Read More

Explain the features of JavaFX

Maruthi Krishna
Maruthi Krishna
Updated on 13-Apr-2020 2K+ Views

Following are some of the important features of JavaFX −Written in Java − The JavaFX library is written in Java and is available for the languages that can be executed on a JVM, which include − Java, Groovy and JRuby. These JavaFX applications are also platform-independent.FXML − JavaFX features a language known as FXML, which is an HTML like declarative markup language. The sole purpose of this language is to define a user interface.Scene Builder − JavaFX provides an application named Scene Builder. On integrating this application in IDE’s such as Eclipse and NetBeans, the users can access the drag ...

Read More

How to blend to images using OpenCV Java?

Maruthi Krishna
Maruthi Krishna
Updated on 13-Apr-2020 924 Views

You can blend two images in OpenCV using the addWeighted() method of the Core class.This method accepts two Mat objects (representing the source and destination matrices) and two double values representing the desired weights of the images alpha, gamma and calculates the weighted sum of them.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.highgui.HighGui; import org.opencv.imgcodecs.Imgcodecs; public class AddingTwoImages {    public static void main( String[] args ) {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );       //Reading the input images       Mat src1 = Imgcodecs.imread("D://images//a1.jpg");       Mat src2 = Imgcodecs.imread("D://images//a2.jpg"); ...

Read More
Showing 4661–4670 of 5,881 articles
« Prev 1 465 466 467 468 469 589 Next »
Advertisements