added splitpane

This commit is contained in:
aj 2018-04-17 17:36:44 -07:00
parent c9cc980e88
commit fab130968c
6 changed files with 203 additions and 24 deletions

View File

@ -1,18 +1,28 @@
package sarsoo.fmframework.fx; package sarsoo.fmframework.fx;
import java.io.IOException;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import sarsoo.fmframework.util.Reference;
public class FmFramework extends Application { public class FmFramework extends Application {
private Stage stage;
private Scene rootScene;
@Override @Override
public void start(Stage stage) throws Exception { public void start(Stage stage) throws Exception {
this.stage = stage;
Parent root = FXMLLoader.load(getClass().getResource("ui/main.fxml")); Parent root = FXMLLoader.load(getClass().getResource("ui/main.fxml"));
Scene scene = new Scene(root, 800, 400); Scene scene = new Scene(root, 800, 400);
rootScene = scene;
// scene.getStylesheets().add("styles/style.css"); // scene.getStylesheets().add("styles/style.css");
stage.setTitle("FM Framework"); stage.setTitle("FM Framework");
@ -25,4 +35,11 @@ public class FmFramework extends Application {
launch(args); launch(args);
} }
public void changeScene() throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("ui/changed.fxml"));
}
} }

View File

@ -0,0 +1,18 @@
package sarsoo.fmframework.fx;
import javafx.fxml.FXML;
import javafx.scene.control.*;
public class Stats {
/*@FXML
private static Label scrobblesToday;
*//**
* @param scrobbles
*//*
public static void updateScrobblesToday(int scrobbles) {
// scrobblesToday.setText(Integer.toString(scrobbles));
}*/
}

View File

@ -1,21 +1,75 @@
package sarsoo.fmframework.fx.controller; package sarsoo.fmframework.fx.controller;
import java.text.NumberFormat;
import java.util.ArrayList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.scene.control.Button; import sarsoo.fmframework.util.FMObjList;
import sarsoo.fmframework.util.Getter;
import sarsoo.fmframework.util.Reference;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.chart.*;
import javafx.collections.ObservableList;
import javafx.collections.FXCollections;
public class ControllerMain { public class ControllerMain {
@FXML @FXML
private Button changeScene; private Label labelStatsScrobblesToday;
private int clicked = 0;
@FXML @FXML
protected void handleButtonClick(ActionEvent event) { private Label labelStatsUsername;
JOptionPane.showMessageDialog(null, "Changed");
@FXML
private Label labelStatsScrobblesTotal;
@FXML
private PieChart pieChartGenres;
@FXML
public void initialize() {
Reference.setUserName("sarsoo");
labelStatsScrobblesToday.setText(Integer.toString(Getter.getScrobblesToday(Reference.getUserName())));
labelStatsUsername.setText(Reference.getUserName());
// updateGenrePieChart();
labelStatsScrobblesTotal.setText(NumberFormat.getInstance().format(Getter.getScrobbles(Reference.getUserName())));
} }
public void updateGenrePieChart() {
String[] names = {
"rock",
"rap",
"classic rock",
"pop punk",
"electronic",
"metal",
"grime",
"classic rap",
"indie",
"jazz",
"blues",
"core"
};
ObservableList<PieChart.Data> pieChartData =
FXCollections.observableArrayList(
// new PieChart.Data("rap", Getter.getUserTag(Reference.getUserName(), "rap").getTotalUserScrobbles()),
new PieChart.Data("rock", Getter.getUserTag(Reference.getUserName(), "rap").getTotalUserScrobbles()));
pieChartGenres = new PieChart(pieChartData);
}
} }

View File

@ -0,0 +1,13 @@
.vBoxStats{
-fx-background-color: #001a44;
}
.gridPane{
-fx-background-color: #a2aec1;
}
.vBoxStatsLabel{
-fx-text-fill: white;
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label text="CHANGED" />
</children>
</VBox>

View File

@ -1,25 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import java.lang.*?> <?import java.lang.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<BorderPane fx:id="borderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.ControllerMain">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.ControllerMain"> <top>
<center> <MenuBar fx:id="menuBar" BorderPane.alignment="CENTER">
<GridPane BorderPane.alignment="CENTER"> <menus>
<columnConstraints> <Menu fx:id="menuLookup" mnemonicParsing="false" text="Lookup">
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <items>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <MenuItem fx:id="menuItemTrack" mnemonicParsing="false" text="Track" />
</columnConstraints> <MenuItem fx:id="menuItemAlbum" mnemonicParsing="false" text="Album" />
<rowConstraints> <MenuItem fx:id="menuItemArtist" mnemonicParsing="false" text="Artist" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> </items>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> </Menu>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <Menu mnemonicParsing="false" text="Edit">
</rowConstraints> <items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<bottom>
<VBox fx:id="vBoxStats" prefHeight="19.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<children> <children>
<Button fx:id="changeScene" mnemonicParsing="false" onAction="#handleButtonClick" text="Change Scene" GridPane.halignment="CENTER" GridPane.rowIndex="1" /> <FlowPane fx:id="flowPlaneStats" alignment="TOP_RIGHT" prefHeight="20.0" prefWidth="600.0" styleClass="vBoxStats" stylesheets="@../styles/mainPane.css" VBox.vgrow="NEVER">
<children>
<Label fx:id="labelStatsUsername" styleClass="vBoxStatsLabel" stylesheets="@../styles/mainPane.css" text="user" />
<Label fx:id="labelStatsScrobblesToday" styleClass="vBoxStatsLabel" stylesheets="@../styles/mainPane.css" text="scrobblesToday" />
<Label fx:id="labelStatsSlash" styleClass="vBoxStatsLabel" stylesheets="@../styles/mainPane.css" text="/" />
<Label fx:id="labelStatsScrobblesTotal" styleClass="vBoxStatsLabel" stylesheets="@../styles/mainPane.css" text="scrobblesTotal" />
</children> </children>
</GridPane> </FlowPane>
</children>
</VBox>
</bottom>
<center>
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
<tabs>
<Tab fx:id="tabHome" closable="false" text="home">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<SplitPane fx:id="splitPaneHome" dividerPositions="0.6237458193979933" prefHeight="327.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<Accordion fx:id="accordionCharts" prefHeight="325.0" prefWidth="222.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<panes>
<TitledPane fx:id="titledPaneGenres" animated="false" text="genres">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<PieChart fx:id="pieChartGenres" layoutX="-189.0" layoutY="-102.0" prefHeight="249.0" prefWidth="220.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane fx:id="titledPaneRap" animated="false" text="rap">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<PieChart prefHeight="274.0" prefWidth="220.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>
</content>
</Tab>
</tabs></TabPane>
</center> </center>
</BorderPane> </BorderPane>