Created
January 11, 2013 13:37
-
-
Save RCura/4510724 to your computer and use it in GitHub Desktop.
test javafx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.geocite.myprojet | |
import javafx.event.ActionEvent | |
import javafx.event.EventHandler | |
import javafx.scene.Group | |
import javafx.scene.Scene | |
import javafx.scene.control._ | |
import javafx.scene.effect.Lighting | |
import javafx.scene.paint.Color | |
import javafx.scene.text.Text | |
import javafx.stage.Stage | |
import javafx.application.Application | |
import javafx.scene.shape.Rectangle | |
import javafx.collections.FXCollections | |
import util.Random | |
import javafx.scene.chart.{XYChart, NumberAxis, LineChart} | |
/** | |
* Created with IntelliJ IDEA. | |
* User: paris | |
* Date: 08/01/13 | |
* Time: 10:31 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
class Launcher extends Application{ | |
def start(primaryStage:Stage ) { | |
val root : Group = new Group() | |
val scene_run : Scene = new Scene(root,800,400,Color.WHITESMOKE) | |
primaryStage.setScene(scene_run) | |
primaryStage.setTitle("Fenetre Principale") | |
/* | |
primaryStage.setMaxHeight(400) | |
primaryStage.setMaxWidth(800) | |
primaryStage.setMinHeight(400) | |
primaryStage.setMinWidth(800) | |
*/ | |
// BOUTON QUITTER | |
val button_Quit : Button = new Button("Quitter") | |
button_Quit.getAlignment | |
button_Quit.setLayoutY(340) | |
button_Quit.setLayoutX(700) | |
button_Quit.setStyle("-fx-font-size: 18;") | |
button_Quit.setDefaultButton(true) | |
button_Quit.setOnAction(new EventHandler[ActionEvent]() { | |
override def handle(t:ActionEvent) { | |
primaryStage.close() | |
} | |
}) | |
// DATA | |
var xData : List[Int] = List() | |
var yData : List[Int] = List() | |
var x = 0 | |
for( x <- 0 to 20 ){ | |
xData ::= (Random.nextDouble() * 100).toInt | |
yData ::= (Random.nextDouble() * 100).toInt | |
} | |
println(xData) | |
println(yData) | |
// LINECHART | |
/* | |
lineChart.setTitle("LineChart"); | |
XYChart.Series series = new XYChart.Series(); | |
series.setName("XYChart.Series"); | |
series.getData().add(new XYChart.Data("January", 100)); | |
series.getData().add(new XYChart.Data("February", 200)); | |
series.getData().add(new XYChart.Data("March", 50)); | |
series.getData().add(new XYChart.Data("April", 75)); | |
series.getData().add(new XYChart.Data("May", 110)); | |
series.getData().add(new XYChart.Data("June", 300)); | |
series.getData().add(new XYChart.Data("July", 111)); | |
series.getData().add(new XYChart.Data("August", 30)); | |
series.getData().add(new XYChart.Data("September", 75)); | |
series.getData().add(new XYChart.Data("October", 55)); | |
series.getData().add(new XYChart.Data("November", 225)); | |
series.getData().add(new XYChart.Data("December", 99)); | |
*/ | |
var xAxis = new NumberAxis() | |
xAxis.setLabel("X") | |
var yAxis = new NumberAxis() | |
yAxis.setLabel("Y") | |
var linechart = new LineChart(xAxis, yAxis) | |
linechart.setTitle("My Linechart") | |
var series = new XYChart.Series() | |
series.setName("XYChart.Series") | |
for (x <- 0 to 20){ | |
var myX = xData(x) | |
var myY = yData(x) | |
//println(myX + " " + myY) | |
var mySerie = new XYChart.Data() | |
mySerie.setXValue(myX) | |
mySerie.setYValue(myY) | |
// series.getData().add(mySerie) | |
} | |
root.getChildren().addAll(button_Quit, linechart) | |
primaryStage.show() | |
} | |
} | |
object Launcher extends App { | |
override def main(args: Array[String]) { | |
Application.launch(classOf[Launcher], args: _*) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment