リビジョン 89092ba0
| src/com/torutk/tinymap/TinyMapApp.java | ||
|---|---|---|
|
Scene scene = new Scene(root);
|
||
|
|
||
|
stage.setScene(scene);
|
||
|
stage.setTitle("Tiny Map Viewer");
|
||
|
stage.show();
|
||
|
}
|
||
|
|
||
| src/com/torutk/tinymap/TinyMapView.fxml | ||
|---|---|---|
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
||
|
<?import java.lang.*?>
|
||
|
<?import java.util.*?>
|
||
|
<?import javafx.scene.*?>
|
||
|
<?import javafx.scene.control.*?>
|
||
|
<?import javafx.scene.layout.*?>
|
||
|
<?import javafx.scene.canvas.Canvas?>
|
||
|
<?import javafx.scene.control.Button?>
|
||
|
<?import javafx.scene.control.ComboBox?>
|
||
|
<?import javafx.scene.control.Label?>
|
||
|
<?import javafx.scene.layout.AnchorPane?>
|
||
|
|
||
|
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.torutk.tinymap.TinyMapViewController">
|
||
|
<AnchorPane id="AnchorPane" fx:id="rootPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.60" fx:controller="com.torutk.tinymap.TinyMapViewController">
|
||
|
<children>
|
||
|
<Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />
|
||
|
<Label layoutX="126" layoutY="120" minHeight="16" minWidth="69" fx:id="label" />
|
||
|
<Button fx:id="button" layoutX="241.0" layoutY="161.0" onAction="#loadShapefile" text="読み込み" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="17.0" />
|
||
|
<Label fx:id="scaleLabel" layoutX="241.0" layoutY="14.0" minHeight="16" minWidth="69" text="1:10000000" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="14.0" />
|
||
|
<Canvas fx:id="mapCanvas" height="200.0" width="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="120.0" AnchorPane.topAnchor="0.0" />
|
||
|
<ComboBox fx:id="projectionComboBox" layoutX="239.0" layoutY="47.0" prefHeight="25.0" prefWidth="77.0" AnchorPane.rightAnchor="4.0" AnchorPane.topAnchor="47.0" />
|
||
|
</children>
|
||
|
</AnchorPane>
|
||
| src/com/torutk/tinymap/TinyMapViewController.java | ||
|---|---|---|
|
import javafx.event.ActionEvent;
|
||
|
import javafx.fxml.FXML;
|
||
|
import javafx.fxml.Initializable;
|
||
|
import javafx.scene.canvas.Canvas;
|
||
|
import javafx.scene.canvas.GraphicsContext;
|
||
|
import javafx.scene.control.ComboBox;
|
||
|
import javafx.scene.control.Label;
|
||
|
import javafx.scene.layout.Pane;
|
||
|
import javafx.scene.paint.Color;
|
||
|
|
||
|
/**
|
||
|
*
|
||
| ... | ... | |
|
public class TinyMapViewController implements Initializable {
|
||
|
|
||
|
@FXML
|
||
|
private Label label;
|
||
|
|
||
|
private Label scaleLabel;
|
||
|
@FXML
|
||
|
private ComboBox projectionComboBox;
|
||
|
@FXML
|
||
|
private Canvas mapCanvas;
|
||
|
@FXML
|
||
|
private void handleButtonAction(ActionEvent event) {
|
||
|
private Pane rootPane;
|
||
|
@FXML
|
||
|
private void loadShapefile(ActionEvent event) {
|
||
|
System.out.println("You clicked me!");
|
||
|
label.setText("Hello World!");
|
||
|
clearMapCanvas();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 地図表示領域を背景色(海)で塗りつぶす。
|
||
|
*/
|
||
|
private void clearMapCanvas() {
|
||
|
GraphicsContext gc = mapCanvas.getGraphicsContext2D();
|
||
|
gc.setFill(Color.MIDNIGHTBLUE);
|
||
|
gc.fillRect(0, 0, mapCanvas.getWidth(), mapCanvas.getHeight());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void initialize(URL url, ResourceBundle rb) {
|
||
|
// TODO
|
||
|
mapCanvas.widthProperty().bind(rootPane.widthProperty().subtract(120));
|
||
|
mapCanvas.heightProperty().bind(rootPane.heightProperty());
|
||
|
}
|
||
|
|
||
|
}
|
||
FXMLのレイアウトとコントローラへのバインディングを記述