Found 155 Articles for JavaFX

How to color the plotted area of a JavaFX xy-chart?

Maruthi Krishna
Updated on 19-May-2020 12:27:56

342 Views

All the XY charts have an abstract method named layoutPlotChildren(). To color the plotted area (region) of an XY chart one way is to override this method. Generally, it is called to update and layout the plot of children.In the body of this method −Get the series data.Extract the plotted points.Draw a polygon in the plotted area using the extracted points.Set the desired color to the polygon.Exampleimport javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.chart.LineChart; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart; import javafx.scene.chart.XYChart.Series; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; public class EnhancingGraphPlot extends Application {    public void start(Stage ... Read More

How to set a particular color as background to a JavaFX chart?

Maruthi Krishna
Updated on 19-May-2020 12:24:30

694 Views

The javafx.scene.chart package provides classes to create various charts namely − line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc.You can create the required chart by instantiating the respective class.Setting background image and the color −The -fx-background-color class of JavaFX CSS is used to set a colored background to a chart.The -fx-background-color (of the region chart-plot-background) class of JavaFX CSS is used to set the back ground color.JavaFX Scene class has an observable list to hold all the required style sheets. You can get this list using the getStylesheets() method.To set an image as a background ... Read More

How to set a background image to a JavaFX chart?

Maruthi Krishna
Updated on 19-May-2020 12:21:52

3K+ Views

The javafx.scene.chart package provides classes to create various charts namely − line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc.You can create the required chart by instantiating the respective class.Setting background image and the colorThe -fx-background-image class of JavaFX CSS is used to set an image as a background to a chart.The -fx-background-color (of the region chart-plot-background) class of JavaFX CSS is used to set the back ground color.JavaFX Scene class has an observable list to hold all the required style sheets. You can get this list using the getStylesheets() method.To set an image as a ... Read More

How to change the color of X and Y axis lines in a JavaFX char?

Maruthi Krishna
Updated on 19-May-2020 12:19:29

528 Views

The javafx.scene.chart package provides classes to create various charts namely &minusl line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc.Except for pie chart, all other charts are plotted on the XY planes. You can create the required XY chart by instantiating the respective class.Changing the color of axis lines −The fx-border-color class of JavaFX CSS is used to set the color of the border of a node.The -fx-border-width class of JavaFX CSS is used to set the width of the border of a node.The setStyle() method of the Node (Base class of all the nodes) class ... Read More

How to create/save the image of a JavaFX pie chart without actually showing the window?

Maruthi Krishna
Updated on 19-May-2020 12:17:14

1K+ Views

The javafx.scene.chart package of JavaFX provides classes to create various charts namely: line chart, area chart, bar chart, pie chart, bubble chart, scatter chart, etc..To create either of these charts you need to −Instantiate the respective class.Set the required properties.Create a layout/group object to hold the chart.Add the layout/group object to the scene.Show the scene by invoking the show() method.This will show the desired chart on the JavaFX window.Saving the image without showing the windowThe snapshot() method of the Scene class takes a snapshot of the current scene and returns it as a WritableImage Object.Using the FromFXImage() method of the ... Read More

JavaFX example to apply multiple transformations on a node

Maruthi Krishna
Updated on 19-May-2020 12:14:05

144 Views

Transformation refers to a change on the node is in the XY plane. JavaFX supports four basic transforms namely −Scale − Increase or decrease the size.Rotate − Movement of the coordinates of a node around a fixed point with an angle.Translate − Movement of the node in the XY plane.Shear − Displacement of an object in a fixed direction such that its shape is slanted.Every node in JavaFX contains an observable list to hold all the transforms to be applied on a node. You can get this list using the getTransforms() method. You can also add multiple transforms to a node.ExampleThe ... Read More

What is scale transformation in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:45:24

259 Views

A scale transform refers to minimizing or maximizing the size of an object. In JavaFX, you can scale a node using an object of the javafx.scene.transform.Translate class. Internally this class multiplies each unit in the coordinate system with the given factor.This class contains six properties (double) type −Three (pivotZ, pivotY, pivotZ) specifying the x, y, z coordinates of the pivot point (about which the scaling occurs). You can set values to these properties using the setPivotX(), setPivotY() and, setPivotZ() methods respectively.Three properties specifying the scale factors along the x, y, and, z axes. You can set values to these properties ... Read More

What is shear transform in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:42:30

183 Views

Displacement of an object in a fixed direction such that its shape is slanted is known as shear transform. This is also known as skewing.In JavaFX using the object of the javafx.scene.transform.Shear class, you can skew a node along the required axis. Internally this class rotates the specified axis such that X and Y axes are no longer perpendicular.This class contains four properties −The pivotX property (double) specifying the x coordinates of the shear pivot point. You can set the value to this property using the setPivotX() method.The pivotY property (double) specifying the y coordinates of the shear pivot point. ... Read More

How to rotate a node in JavaFX?

Maruthi Krishna
Updated on 19-May-2020 07:39:12

2K+ Views

If you move an object in the XY plane around a fixed point with an angle it is known as rotation.In JavaFX using the object of the javafx.scene.transform.Rotate class, you can rotate a node. This class internally rotates the coordinate space of the node around a given fixed point, this makes the node to appear rotated.This class contains five properties −The angle property (double) specifying the angle of rotation. You can set the value to this property using the setAngle() method.The axis property (Point3D) specifying the axis of rotation. You can set the value to this property using the setAxis() ... Read More

How to move (translate) a JavaFX node from one position to another?

Maruthi Krishna
Updated on 19-May-2020 07:36:27

2K+ Views

If you move an object on the XY plane from one position to another it is known as translation. You can translate an object along either X-Axis to Y-Axis.In JavaFX using the object of the javafx.scene.transform.Translate class you can translate a node from one position to another. This class contains three properties (double) representing the distance of the desired position from the original position along X, Y, Z plane respectively.Every node in JavaFX contains an observable list to hold all the transforms to be applied on a node. You can get this list using the getTransforms() method.To move a Node ... Read More

Previous 1 ... 5 6 7 8 9 ... 16 Next
Advertisements