Programming Articles - Page 2009 of 3366

How to draw a geometrical 2D shape in JavaFX?

Maruthi Krishna
Updated on 13-Apr-2020 12:17:13

453 Views

In general, a 2D shape is a geometrical figure that can be drawn on the XY plane, these include Line, Rectangle, Circle, etc.The javafx.scene.shape package provides you, various classes, each of them represents/defines a 2d geometrical object or, an operation on them. The class named Shape is the base class of all the 2-Dimensional shapes in JavaFX.Creating 2D shapesTo draw a 2D geometrical shape using JavaFX you need to −Instantiate the class − Instantiate the respective class. For example, if you want to draw a circle you need to instantiate the Circle class as shown below −//Drawing a Circle Circle ... Read More

How to Create the path element arc in JavaFX?

Maruthi Krishna
Updated on 13-Apr-2020 12:14:22

221 Views

This is class represents the path element arc. It helps you to draw an arc from the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the ArcTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created ArcTo object to the observable list using the add() method.Finally, add the path to the Group object.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.ArcTo; import javafx.scene.shape.LineTo; import javafx.scene.shape.MoveTo; import ... Read More

Remove Zero Sum Consecutive Nodes from Linked List in C++

Arnab Chakraborty
Updated on 30-Apr-2020 15:51:36

2K+ Views

Suppose we have given the head of a linked list; we have to repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. So after doing so, we have to return the head of the final linked list. So if the list is like [1, 2, -3, 3, 1], then the result will be [3, 1].To solve this, we will follow these steps −Create a node called dummy, and store 0 into it, set next of dummy := headcreate one map m, store dummy for the key 0 into m, set sum = 0while ... Read More

How to Create the path element cubic curve in JavaFX?

Maruthi Krishna
Updated on 13-Apr-2020 12:12:27

245 Views

This is class represents the path element cubic curve. It helps you to draw a cubic curve form the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the CubicCurve class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created CubicCurve object to the observable list using the add() method.Finally, add the path to the Group object.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.CubicCurveTo; import javafx.scene.shape.LineTo; import javafx.scene.shape.MoveTo; ... Read More

How to Create the path element quadratic curve in JavaFX?

Maruthi Krishna
Updated on 13-Apr-2020 12:10:40

192 Views

This is class represents the path element quadratic curve. It helps you to draw a quadratic curve form the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the QuadCurveTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created QuadCurveTo object to the observable list using the add() method.Finally, add the path to the Group object.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.LineTo; import javafx.scene.shape.MoveTo; import ... Read More

Swap For Longest Repeated Character Substring in C++

Arnab Chakraborty
Updated on 30-Apr-2020 15:46:05

573 Views

Suppose we have a string text, so we are allowed to swap two of the characters in the string. We have to find the length of the longest substring with repeated characters. So if the input is like “ababa”, then the result will be 3, as if we swap first b with last a, or the last b with first a, then the longest repeated character will be “aaa”, so the length is 3.To solve this, we will follow these steps −Define a map cnt, set ret := 1, j := 0, n := size of text, v := 0, ... Read More

Longest Common Subsequence in C++

Arnab Chakraborty
Updated on 30-Apr-2020 15:41:22

471 Views

Suppose we have two strings text1 and text2, we have to return the length of their longest common subsequence. The ubsequence of a string is a new string generated from the original string with some characters deleted without changing the relative order of the remaining characters. (So for example "abe" is a subsequence of "abcde" but "adc" is not). A common subsequence of two strings is a subsequence that is common to both strings. So If there is no common subsequence, return 0. If the input is like “abcde”, and “ace”, then the result will be 3.To solve this, we ... Read More

How to Create the path element vertical line in JavaFX?

Maruthi Krishna
Updated on 13-Apr-2020 12:08:38

302 Views

This is class represents the path element vertical line. It helps you to draw a vertical line from the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the VLineTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created VLineTo object to the observable list using the add() method.Finally, add the path to the Group object.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.HLineTo; import javafx.scene.shape.LineTo; import ... Read More

How to Create the path element horizontal line in JavaFX?

Maruthi Krishna
Updated on 13-Apr-2020 12:06:11

356 Views

This is class represents the path element horizontal line. It helps you to draw a horizontal line form the current coordinates to the specified (new) coordinates.To create a line path element −Instantiate the HLineTo class.Set values to the properties of this class using setter methods or, bypassing them to the constructor.Instantiate the Path class.Get the observable list object of the above-created Path using the getElements() method.Add the above created HLineTo object to the observable list using the add() method.Finally, add the path to the Group object.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.HLineTo; import javafx.scene.shape.LineTo; import ... Read More

Maximum of Absolute Value Expression in C++

Arnab Chakraborty
Updated on 30-Apr-2020 15:36:17

791 Views

Suppose we have two arrays of integers with equal lengths, we have to find the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|. Where the maximum value is taken over all 0

Advertisements