リビジョン 138d6c03
| src/main/java/com/torutk/spectrum/data/FileFinder.java | ||
|---|---|---|
|
package com.torutk.spectrum.data;
|
||
|
|
||
|
import java.io.FileNotFoundException;
|
||
|
import java.io.IOException;
|
||
|
import java.nio.file.Files;
|
||
|
import java.nio.file.Path;
|
||
|
import java.util.stream.Stream;
|
||
|
|
||
|
/**
|
||
|
* Find file utility class.
|
||
|
*/
|
||
|
public class FileFinder {
|
||
|
/**
|
||
|
* Find file by name from specified path within specified max depth.
|
||
|
*
|
||
|
* @param from search from this directory
|
||
|
* @param name of file to be found
|
||
|
* @param maxDepth search till this depth
|
||
|
* @return found path
|
||
|
* @throws IOException file not found, or cannot access file system
|
||
|
*/
|
||
|
public static Path find(Path from, String name, int maxDepth) throws IOException {
|
||
|
try (Stream<Path> stream = Files.find(from, maxDepth, (path, attr) ->
|
||
|
path.getFileName().toString().equalsIgnoreCase(name))) {
|
||
|
return stream.findFirst().orElseThrow(() -> new FileNotFoundException(name));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| src/main/java/com/torutk/spectrum/view/SpectrumFileViewApp.java | ||
|---|---|---|
|
package com.torutk.spectrum.view;
|
||
|
|
||
|
import com.torutk.spectrum.data.FileFinder;
|
||
|
import javafx.application.Application;
|
||
|
import javafx.fxml.FXMLLoader;
|
||
|
import javafx.scene.Parent;
|
||
|
import javafx.scene.Scene;
|
||
|
import javafx.stage.Stage;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.nio.file.Path;
|
||
|
import java.nio.file.Paths;
|
||
|
import java.util.ResourceBundle;
|
||
|
import java.util.logging.LogManager;
|
||
|
import java.util.logging.Logger;
|
||
|
|
||
|
/**
|
||
|
* Spectrum analyzer's data viewer.
|
||
|
* Read a data file from Glowlink's Model 1030/8000, and view.
|
||
|
*/
|
||
|
public class SpectrumFileViewApp extends Application {
|
||
|
private static final Logger logger = Logger.getLogger(SpectrumFileViewApp.class.getName());
|
||
|
private static final String CSS_FILENAME = "SpectrumFileView.css";
|
||
|
|
||
|
@Override
|
||
|
public void start(Stage primaryStage) throws Exception {
|
||
|
Parent root = FXMLLoader.load(SpectrumFileViewApp.class.getResource("SpectrumFileView.fxml"));
|
||
|
var resource = ResourceBundle.getBundle("com.torutk.spectrum.view.SpectrumFileViewApp");
|
||
|
Parent root = FXMLLoader.load(
|
||
|
SpectrumFileViewApp.class.getResource("SpectrumFileView.fxml"), resource
|
||
|
);
|
||
|
var scene = new Scene(root);
|
||
|
setupStylesheet(scene);
|
||
|
primaryStage.setScene(scene);
|
||
|
primaryStage.setTitle(String.format("%s %s",
|
||
|
resource.getString("spectrum.view.title"),
|
||
|
resource.getString("spectrum.view.version")
|
||
|
));
|
||
|
primaryStage.show();
|
||
|
logger.info("Spectrum File Viewer started.");
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Load css file and apply to the specified scene.
|
||
|
* At 1st, read from the classpath of this class.
|
||
|
* 2nd, if exist in current directory, read from there.
|
||
|
*
|
||
|
* @param scene to be applied css file
|
||
|
*/
|
||
|
private void setupStylesheet(Scene scene) {
|
||
|
scene.getStylesheets().add(getClass().getResource(CSS_FILENAME).toExternalForm());
|
||
|
try {
|
||
|
Path cssFile = FileFinder.find(Paths.get(".."), CSS_FILENAME, 3);
|
||
|
scene.getStylesheets().add(cssFile.toUri().toString());
|
||
|
} catch (IOException ex) {
|
||
|
logger.config("No custom css file found.");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Initialize log configuration.
|
||
|
*
|
||
|
* Logging configuration can be applied from file or class specified by system property.
|
||
|
* If system property is not specified, then read file named 'logging.properties'
|
||
|
* from the directory of this application class.
|
||
|
*/
|
||
|
private static void setupLogging() {
|
||
|
if (System.getProperty("java.util.logging.config.file") == null
|
||
|
&& System.getProperty("java.util.logging.config.class") == null) {
|
||
|
try (InputStream resource = SpectrumFileViewApp.class.getResourceAsStream("logging.properties")) {
|
||
|
if (resource != null) {
|
||
|
LogManager.getLogManager().readConfiguration(resource);
|
||
|
}
|
||
|
} catch (IOException ex) {
|
||
|
logger.config("no logging.properties read from classpath.");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void logConfig() {
|
||
|
logger.config("Java VM Version = " + Runtime.version());
|
||
|
logger.config("OS = " + System.getProperty("os.name"));
|
||
|
logger.config("Current directory = " + System.getProperty("user.dir"));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Entry point of this application.
|
||
|
*
|
||
|
* @param args command-line options
|
||
|
*/
|
||
|
public static void main(String[] args) {
|
||
|
setupLogging();
|
||
|
logConfig();
|
||
|
launch(args);
|
||
|
}
|
||
|
}
|
||
| src/main/java/com/torutk/spectrum/view/SpectrumFileViewController.java | ||
|---|---|---|
|
package com.torutk.spectrum.view;
|
||
|
|
||
|
import javafx.event.ActionEvent;
|
||
|
import javafx.fxml.FXML;
|
||
|
import javafx.fxml.Initializable;
|
||
|
|
||
|
import java.net.URL;
|
||
| ... | ... | |
|
public class SpectrumFileViewController implements Initializable {
|
||
|
private ResourceBundle resources;
|
||
|
|
||
|
@FXML
|
||
|
private void open(ActionEvent ev) {
|
||
|
|
||
|
}
|
||
|
|
||
|
@FXML
|
||
|
private void export(ActionEvent ev) {
|
||
|
|
||
|
}
|
||
|
|
||
|
@FXML
|
||
|
private void showHelp(ActionEvent ev) {
|
||
|
|
||
|
}
|
||
|
|
||
|
@FXML
|
||
|
private void updateSettings(ActionEvent event) {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||
|
resources = resourceBundle;
|
||
| src/main/java/module-info.java | ||
|---|---|---|
|
module com.torutk.spectrum {
|
||
|
requires javafx.controls;
|
||
|
requires javafx.fxml;
|
||
|
requires java.logging;
|
||
|
opens com.torutk.spectrum.view to javafx.graphics, javafx.fxml;
|
||
|
}
|
||
| src/main/resources/com/torutk/spectrum/view/SpectrumFileView.css | ||
|---|---|---|
|
.chart-series-line {
|
||
|
-fx-stroke-width: 0.75px;
|
||
|
}
|
||
|
|
||
|
.label:haze {
|
||
|
-fx-opacity: 0.2;
|
||
|
}
|
||
|
|
||
|
.toggle-button:selected {
|
||
|
-fx-text-fill: gray;
|
||
|
}
|
||
|
|
||
|
.chart-legend-item-symbol {
|
||
|
-fx-background-radius: 0;
|
||
|
-fx-background-insets: 0;
|
||
|
-fx-shape: "M0,5 L0,7 L12,7 L12,5 Z";
|
||
|
-fx-scale-shape: false;
|
||
|
}
|
||
|
.default-color0.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_1;
|
||
|
}
|
||
|
.default-color1.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_2;
|
||
|
}
|
||
|
.default-color2.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_3;
|
||
|
}
|
||
|
.default-color3.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_4;
|
||
|
}
|
||
|
.default-color4.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_5;
|
||
|
}
|
||
|
.default-color5.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_6;
|
||
|
}
|
||
|
.default-color6.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_7;
|
||
|
}
|
||
|
.default-color7.chart-legend-item-symbol {
|
||
|
-fx-background-color: CHART_COLOR_8;
|
||
|
}
|
||
|
|
||
|
.chart-legend-item:hover {
|
||
|
-fx-text-fill: MediumVioletRed;
|
||
|
}
|
||
|
|
||
|
.context-menu {
|
||
|
-fx-font-size: 12px;
|
||
|
}
|
||
|
|
||
|
#detrend-file-label {
|
||
|
-fx-border-color: gray;
|
||
|
-fx-border-radius: 3;
|
||
|
}
|
||
| src/main/resources/com/torutk/spectrum/view/SpectrumFileView.fxml | ||
|---|---|---|
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
||
|
<?import javafx.scene.chart.*?>
|
||
|
<?import javafx.scene.layout.*?>
|
||
|
<?import javafx.geometry.Insets?>
|
||
|
<?import javafx.scene.chart.LineChart?>
|
||
|
<?import javafx.scene.chart.NumberAxis?>
|
||
|
<?import javafx.scene.control.Button?>
|
||
|
<?import javafx.scene.control.CheckBox?>
|
||
|
<?import javafx.scene.control.Label?>
|
||
|
<?import javafx.scene.control.TextField?>
|
||
|
<?import javafx.scene.control.ToggleButton?>
|
||
|
<?import javafx.scene.control.ToolBar?>
|
||
|
<?import javafx.scene.control.Tooltip?>
|
||
|
<?import javafx.scene.layout.BorderPane?>
|
||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||
|
<?import javafx.scene.layout.GridPane?>
|
||
|
<?import javafx.scene.layout.HBox?>
|
||
|
<?import javafx.scene.layout.Pane?>
|
||
|
<?import javafx.scene.layout.RowConstraints?>
|
||
|
<?import javafx.scene.layout.VBox?>
|
||
|
|
||
|
|
||
|
<BorderPane xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.torutk.spectrum.view.SpectrumFileViewController">
|
||
|
<BorderPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.torutk.spectrum.view.SpectrumFileViewController">
|
||
|
<center>
|
||
|
<LineChart BorderPane.alignment="CENTER">
|
||
|
<LineChart fx:id="chart" createSymbols="false" horizontalZeroLineVisible="false" prefHeight="371.0" prefWidth="500.0" title="%spectrum.view.chart.title" BorderPane.alignment="CENTER">
|
||
|
<xAxis>
|
||
|
<NumberAxis side="BOTTOM" />
|
||
|
<NumberAxis animated="false" autoRanging="false" label="%spectrum.view.chart.xaxis" side="BOTTOM" fx:id="xAxis" />
|
||
|
</xAxis>
|
||
|
<yAxis>
|
||
|
<NumberAxis side="LEFT" />
|
||
|
<NumberAxis fx:id="yAxis" animated="false" autoRanging="false" label="%spectrum.view.chart.yaxis" side="LEFT" />
|
||
|
</yAxis>
|
||
|
</LineChart>
|
||
|
</center>
|
||
|
<right>
|
||
|
<VBox fx:id="rightPane" prefHeight="200.0" spacing="2.0" BorderPane.alignment="CENTER">
|
||
|
<children>
|
||
|
<GridPane vgap="2.0">
|
||
|
<columnConstraints>
|
||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="96.0" />
|
||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="72.0" />
|
||
|
</columnConstraints>
|
||
|
<rowConstraints>
|
||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||
|
</rowConstraints>
|
||
|
<children>
|
||
|
<Label text="%spectrum.view.start_frequency" />
|
||
|
<Label text="%spectrum.view.stop_frequency" GridPane.rowIndex="1" />
|
||
|
<TextField fx:id="startFrequencyField" GridPane.columnIndex="1" />
|
||
|
<TextField fx:id="stopFrequencyField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||
|
<Label text="%spectrum.view.reference_level" GridPane.rowIndex="2" />
|
||
|
<Label text="%spectrum.view.scale" GridPane.rowIndex="3" />
|
||
|
<TextField fx:id="referenceLevelField" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||
|
<TextField fx:id="scaleField" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||
|
<Button fx:id="updateButton" mnemonicParsing="false" onAction="#updateSettings" text="%spectrum.view.update" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||
|
</children>
|
||
|
<VBox.margin>
|
||
|
<Insets bottom="2.0" left="4.0" right="4.0" top="2.0" />
|
||
|
</VBox.margin>
|
||
|
</GridPane>
|
||
|
<HBox spacing="4.0">
|
||
|
<children>
|
||
|
<CheckBox fx:id="detrendCheckBox" mnemonicParsing="false" text="%spectrum.view.detrend" />
|
||
|
<Label id="detrend-file-label" fx:id="detrendFileLabel" alignment="CENTER" maxWidth="1.7976931348623157E308" prefHeight="17.0" prefWidth="39.0" text="+" HBox.hgrow="ALWAYS" />
|
||
|
</children>
|
||
|
<VBox.margin>
|
||
|
<Insets left="4.0" right="4.0" />
|
||
|
</VBox.margin>
|
||
|
</HBox>
|
||
|
<CheckBox fx:id="rcFilterCheckbox" mnemonicParsing="false" selected="true" text="%spectrum.view.rcfilter">
|
||
|
<VBox.margin>
|
||
|
<Insets left="4.0" right="4.0" top="8.0" />
|
||
|
</VBox.margin>
|
||
|
</CheckBox>
|
||
|
</children></VBox>
|
||
|
</right>
|
||
|
<top>
|
||
|
<ToolBar BorderPane.alignment="CENTER">
|
||
|
<items>
|
||
|
<Button mnemonicParsing="false" onAction="#open" text="%spectrum.view.toolbar.open">
|
||
|
<tooltip>
|
||
|
<Tooltip text="%spectrum.view.toolbar.open.tooltip" />
|
||
|
</tooltip>
|
||
|
</Button>
|
||
|
<Button mnemonicParsing="false" onAction="#export" text="%spectrum.view.toolbar.export">
|
||
|
<tooltip>
|
||
|
<Tooltip text="%spectrum.view.toolbar.export.tooltip" />
|
||
|
</tooltip>
|
||
|
</Button>
|
||
|
<Pane HBox.hgrow="ALWAYS" />
|
||
|
<Button mnemonicParsing="false" onAction="#showHelp" text="%spectrum.view.toolbar.help">
|
||
|
<tooltip>
|
||
|
<Tooltip text="%spectrum.view.toolbar.help.tooltip" />
|
||
|
</tooltip>
|
||
|
</Button>
|
||
|
<ToggleButton fx:id="rightPaneToggleButton" mnemonicParsing="false" text="%spectrum.view.toolbar.setting">
|
||
|
<tooltip>
|
||
|
<Tooltip text="%spectrum.view.toolbar.setting.tooltip" />
|
||
|
</tooltip></ToggleButton>
|
||
|
</items>
|
||
|
</ToolBar>
|
||
|
</top>
|
||
|
</BorderPane>
|
||
| src/main/resources/com/torutk/spectrum/view/SpectrumFileViewApp.properties | ||
|---|---|---|
|
spectrum.view.version = #VERSION_TO_BE_REPLACED#
|
||
|
spectrum.view.title = Spectrum Viewer
|
||
|
spectrum.view.toolbar.db = Show Database
|
||
|
spectrum.view.toolbar.db.tooltip = Show/Hide Database catalog pane in left side
|
||
|
spectrum.view.toolbar.open = Open
|
||
|
spectrum.view.toolbar.open.tooltip = Read DAT file saved on Glowlink
|
||
|
spectrum.view.toolbar.export = Export
|
||
|
spectrum.view.toolbar.export.tooltip = Export each spectrum to CSV file in specified directory
|
||
|
spectrum.view.toolbar.help = Help
|
||
|
spectrum.view.toolbar.help.tooltip = Show help in platform PDF viewer
|
||
|
spectrum.view.toolbar.setting = Show Settings
|
||
|
spectrum.view.toolbar.setting.tooltip = Show/Hide Settings pane in right side
|
||
|
spectrum.view.filechooser.title = Open Spectrum Trace Files
|
||
|
spectrum.view.directorychooser.title = Select Folder to Export Spectrum Trace CSV Files
|
||
|
spectrum.view.chart.title = Spectrum
|
||
|
spectrum.view.chart.xaxis = Frequency [MHz]
|
||
|
spectrum.view.chart.yaxis = Power [dBm]
|
||
|
spectrum.view.chart.legend.menu.remove = Remove from chart
|
||
|
spectrum.view.chart.legend.menu.register = Register database
|
||
|
spectrum.view.registerdb.succeeded = Succeeded to register {0} with database
|
||
|
spectrum.view.registerdb.failed = Failed to register {0} with database
|
||
|
spectrum.view.start_frequency = Start Frequency
|
||
|
spectrum.view.stop_frequency = Stop Frequency
|
||
|
spectrum.view.reference_level = Reference Level
|
||
|
spectrum.view.scale = Scale
|
||
|
spectrum.view.update = Update
|
||
|
spectrum.view.detrend = Detrend
|
||
|
spectrum.view.rcfilter = Apply RC Filter
|
||
|
spectrum.registerview.title = Register spectrum and observation to the database
|
||
|
spectrum.registerview.spectrum.label = Spectrum name
|
||
|
spectrum.registerview.site.label = Site
|
||
|
spectrum.registerview.equipment.label = Equipment
|
||
|
spectrum.registerview.satellite.label = Satellite
|
||
|
spectrum.registerview.polarizationtype.label = Polarization type
|
||
|
spectrum.registerview.azimuth.label = Azimuth
|
||
|
spectrum.registerview.elevation.label = Elevation
|
||
|
spectrum.registerview.polarization.label = Polarization
|
||
|
spectrum.registerview.timestamp.label = Timestamp
|
||
|
spectrum.regsiterview.register.button = Register database
|
||
| src/main/resources/com/torutk/spectrum/view/SpectrumFileViewApp_ja.properties | ||
|---|---|---|
|
spectrum.view.title = 周波数解析表示
|
||
|
spectrum.view.toolbar.db = DB表示
|
||
|
spectrum.view.toolbar.db.tooltip = データベース領域を左脇に表示する
|
||
|
spectrum.view.toolbar.open = 開く
|
||
|
spectrum.view.toolbar.open.tooltip = Glowlink計測器で保存したデータファイルを読み込む
|
||
|
spectrum.view.toolbar.export = 出力
|
||
|
spectrum.view.toolbar.export.tooltip = 指定した保管先へCSVファイル形式で出力する
|
||
|
spectrum.view.toolbar.setting = 設定表示
|
||
|
spectrum.view.toolbar.setting.tooltip = 設定領域を右脇に表示する
|
||
|
spectrum.view.toolbar.help = 取説
|
||
|
spectrum.view.toolbar.help.tooltip = 取説を外部PDFツール上に表示する
|
||
|
spectrum.view.filechooser.title = Glowlink計測器で保存したデータファイルを開く
|
||
|
spectrum.view.directorychooser.title = 周波数解析をCSV形式で保存するディレクトリを選択
|
||
|
spectrum.view.chart.title = 周波数解析
|
||
|
spectrum.view.chart.xaxis = 周波数 [MHz]
|
||
|
spectrum.view.chart.yaxis = 電力 [dBm]
|
||
|
spectrum.view.chart.legend.menu.remove = グラフから削除
|
||
|
spectrum.view.chart.legend.menu.register = データベースへ登録
|
||
|
spectrum.view.registerdb.succeeded = {0}をデータベースへ登録しました
|
||
|
spectrum.view.registerdb.failed = {0}をデータベースに登録できませんでした
|
||
|
spectrum.view.start_frequency = 開始周波数
|
||
|
spectrum.view.stop_frequency = 終了周波数
|
||
|
spectrum.view.reference_level = 基準レベル
|
||
|
spectrum.view.scale = スケール
|
||
|
spectrum.view.update = 更新
|
||
|
spectrum.view.detrend = 変動除去
|
||
|
spectrum.view.rcfilter = 平滑(RC)フィルタ適用
|
||
|
spectrum.registerview.title = スペクトラムと観測データをデータベースへ登録
|
||
|
spectrum.registerview.spectrum.label = スペクトラム名
|
||
|
spectrum.registerview.site.label = 観測地
|
||
|
spectrum.registerview.equipment.label = 観測機器
|
||
|
spectrum.registerview.satellite.label = 衛星
|
||
|
spectrum.registerview.polarizationtype.label = 偏波方式
|
||
|
spectrum.registerview.azimuth.label = 方位角
|
||
|
spectrum.registerview.elevation.label = 仰角
|
||
|
spectrum.registerview.polarization.label = 偏波回転角
|
||
|
spectrum.registerview.timestamp.label = 観測日時
|
||
|
spectrum.regsiterview.register.button = データベース登録
|
||
| src/main/resources/com/torutk/spectrum/view/logging.properties | ||
|---|---|---|
|
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
||
|
.level = INFO
|
||
|
com.torutk.spectrum.level = FINE
|
||
|
|
||
|
java.util.logging.ConsoleHandler.level = FINE
|
||
|
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
||
|
|
||
|
java.util.logging.SimpleFormatter.format = %1$tT.%1$tL %4$s %3$s - %5$s %6$s%n
|
||
|
|
||
|
java.util.logging.FileHandler.level = ALL
|
||
|
java.util.logging.FileHandler.pattern = SpectrumFileViewApp.log
|
||
|
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
||
Add UI layout with resource bundle and css, and logging