[SOLVED] Java javaFx junit graph 1.javafx.scene.shape.polygonupload.java,1

$25

File Name: Java_javaFx_junit_graph_1.javafx.scene.shape.polygonupload.java,1.zip
File Size: 612.3 KB

5/5 - (1 vote)

1.javafx.scene.shape.polygonupload.java,1

2. ExpenditureTestsjunit testExpenditure.javaprivate String descriptionprivate int valueget
Java APIjava.util.ArrayssortExpenditure
Arrays.sortexpendituresExpenditure exp1Expenditure exp2-> exp2.getValue -exp1.getValue;
ExpenditureWaffle.javaWaffle-1other= 8;2

3. PieTestsjunit test2 Pie.javaExpenditure public void startStage stagethrows Exception
javafx.scence.shape.PieChartjavafx.scene.shape.Circlejavafx.scene.shape.Line javafx.scence.text.Text
23

4. debugDisplayFunctionArea.javax displayFunctionAreax-> x * x * x-8 * x * x-29500; 4 6 x x

import java.util.function.Function;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Polyline;

/**
* xx * xx[ab]
* xyafabfb
*/

public class DisplayFunctionArea extends Application {

/**
* X_SIZE 600
*/

public static final int X_SIZE = 600;

/**
* Y_SIZE 600
*/

public static final int Y_SIZE = 600;

/**
* f startmain
*/

private static Function f;

/**
* astartmain
*/

private static double a;

/**
* bstartmain
*/

private static double b;
/**
* min[ab]f
*/

private static double min;

/**
* max[ab]f
*/

private static double max;

/**
* n[ab]n
*/

private static int n;

/**
* The polyline will be the approximation of the function and be displayed.
*/
private static Polyline polyline;

/**
* polyline
*/

private static Polygon polygon;

/**
* polygonx
*/

public static Color areaColour = Color.YELLOW;

/**
* [ab]fx
*
* @param f
* @param n
* @param a x
* @param b X
* @return fx[a , b]n
*/

public static Polygon functionToPolygon(Function f, int n, double a, double b) {
if (a >= b) {
throw new IllegalArgumentException();
} else {
double[] points = new double[2 * (n + 1) + 4];
double x, y;
/*
* xyabn-1 x_iy_i
*/

for (int i = 0; i <= n; i++) {x = a + (b – a) * i / n;y = f.apply(x);points[2 * i] = x;points[2 * i + 1] = y;}/* */return new Polygon(points);}}/** * [ab]f ** @param f * @param n * @param a x * @param b X * @return [ab]fn */public static Polyline functionToPolyline(Function f, int n, double a, double b) {
if (a >= b) {
throw new IllegalArgumentException();
} else {
double[] points = new double[2 * (n + 1)];
double x, y;
/*
* xyabn-1 x_iy_i
*/

for (int i = 0; i <= n; i++) {x = a + (b – a) * i / n;y = f.apply(x);points[2 * i] = x;points[2 * i + 1] = y;}/* */Polyline result = new Polyline(points);result.setStrokeWidth(3);return result;}}/** * x0[minmax ] @ param rootX */public static void drawXAxis(Group root) {if (min < 0 && 0 < max) {Line line = new Line(0, (max – 0) * Y_SIZE / (max – min), X_SIZE, (max – 0) * Y_SIZE / (max – min));line.setStrokeWidth(2);root.getChildren().add(line);}}/** * y0[ab] ** @param root y */public static void drawYAxis(Group root) {if (a < 0 && 0 < b) {Line line = new Line((b – 0) * X_SIZE / (b – a), 0, (b – 0) * X_SIZE / (b – a), Y_SIZE);line.setStrokeWidth(2);root.getChildren().add(line);}}/** * @param stage */@Overridepublic void start(Stage stage) throws Exception {// Group root = new Group();root.getChildren().add(polyline);root.getChildren().add(polygon);drawXAxis(root);drawYAxis(root);// Scene scene = new Scene(root, X_SIZE, Y_SIZE);// stage.setTitle(“Function Graph”);stage.setScene(scene);stage.show();}/** * abn ** @param f * @param numberOfValues * @param left * @param right */public static void displayFunctionArea(Function f, double left, double right, int numberOfValues) {
a = left;
b = right;
n = numberOfValues;
polyline = functionToPolyline(f, numberOfValues, left, right);
polygon = functionToPolygon(f, numberOfValues, left, right);
polygon.setFill(areaColour);
}

/*
*
*/
public static void main(String[] args) {
displayFunctionArea(x -> x * x * x 8 * x * x, -2, 9, 500);
launch(args);
}
}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Java javaFx junit graph 1.javafx.scene.shape.polygonupload.java,1
$25