2023年3月4日17:58:32
parent
d8f2430e31
commit
e078a2d3c5
|
|
@ -0,0 +1,98 @@
|
|||
package com.zhangmeng.tools.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.zhangmeng.tools.date.ResultDate;
|
||||
import com.zhangmeng.tools.utils.JsoupUtil;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ColorPicker;
|
||||
import javafx.scene.control.DateCell;
|
||||
import javafx.scene.control.DatePicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.time.chrono.Chronology;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author : 芊芊墨客
|
||||
* @version : 1.0
|
||||
* @date : 2023-03-04 16:48
|
||||
*/
|
||||
@Slf4j
|
||||
public class DateController {
|
||||
|
||||
@FXML
|
||||
private DatePicker datePicker;
|
||||
|
||||
private List<ResultDate.DataBean> list = FXCollections.observableArrayList();
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
//OriginQuery": "2023年4月"
|
||||
public void getData() {
|
||||
String url = "https://opendata.baidu.com/api.php?tn=wisetpl&format=json&resource_id=39043&query=2023%E5%B9%B44%E6%9C%88&t=1677917334923";
|
||||
if (restTemplate == null){
|
||||
restTemplate = new RestTemplate();
|
||||
}
|
||||
ResultDate resultDate = restTemplate.getForObject(url, ResultDate.class);
|
||||
if (resultDate != null){
|
||||
List<ResultDate.DataBean> data = resultDate.getData();
|
||||
list.addAll(data);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
LocalDate now = LocalDate.now();
|
||||
int y = now.getYear();
|
||||
int m = now.getDayOfMonth();
|
||||
String date_string = String.format("%d年%d月", y, m);
|
||||
getData();
|
||||
|
||||
datePicker.setValue(now);
|
||||
datePicker.setPrefWidth(210);
|
||||
datePicker.setEditable(true);
|
||||
|
||||
datePicker.setOnAction(event -> log.info("datePicker.setOnAction"));
|
||||
datePicker.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||
int year = newValue.getYear();
|
||||
int month = newValue.getMonthValue();
|
||||
int day = newValue.getDayOfMonth();
|
||||
int week = newValue.getDayOfWeek().getValue();
|
||||
int dayOfYear = newValue.getDayOfYear();
|
||||
log.info(year + "年" + month + "月" + day + "日" + "星期" + week + "一年中的第" + dayOfYear + "天");
|
||||
});
|
||||
|
||||
datePicker.setDayCellFactory(new Callback<>() {
|
||||
@Override
|
||||
public DateCell call(DatePicker param) {
|
||||
return new DateCell() {
|
||||
@Override
|
||||
public void updateItem(LocalDate item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
this.setText(item.toString());
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -76,6 +76,11 @@ public class HomeController implements Serializable {
|
|||
@FXML
|
||||
private SplitPane splitPane;
|
||||
|
||||
@FXML
|
||||
public void date_query_menu_item(){
|
||||
load_small_tools(5);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void md5_menu_item() {
|
||||
boolean flag = false;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class SmallToolsController {
|
|||
private AnchorPane jwt_web;
|
||||
private AnchorPane color_choose;
|
||||
private AnchorPane qr_code;
|
||||
private AnchorPane date_query;
|
||||
|
||||
@FXML
|
||||
private ListView<ResourcesUtils.SmallTools> listView;
|
||||
|
|
@ -154,6 +155,15 @@ public class SmallToolsController {
|
|||
qr_code(flag);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void date_query_menu_item(){
|
||||
boolean flag = false;
|
||||
if (date_query != null){
|
||||
flag = true;
|
||||
}
|
||||
date_query(flag);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void base_62_menu_item(){
|
||||
load_codec_tools(0);
|
||||
|
|
@ -279,6 +289,13 @@ public class SmallToolsController {
|
|||
}
|
||||
qr_code(flag);
|
||||
}
|
||||
|
||||
if (newValue.getIndex() == 5) {
|
||||
if (date_query != null) {
|
||||
flag = true;
|
||||
}
|
||||
date_query(flag);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -290,6 +307,7 @@ public class SmallToolsController {
|
|||
case JWT_WEB -> new Image(ImagePath.path(ImagePath.ImagePathType.JWT_WEB));
|
||||
case COLOR_CHOOSE -> new Image(ImagePath.path(ImagePath.ImagePathType.COLOR_CHOOSE));
|
||||
case Qr_CODE -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
||||
case Date_Query -> new Image(ImagePath.path(ImagePath.ImagePathType.Qr_CODE));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -431,9 +449,26 @@ public class SmallToolsController {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
color_choose = root;
|
||||
qr_code = root;
|
||||
} else {
|
||||
root = color_choose;
|
||||
root = qr_code;
|
||||
}
|
||||
common_method();
|
||||
}
|
||||
|
||||
public void date_query(boolean flag){
|
||||
//默认选择第一个
|
||||
listView.getSelectionModel().select(4);
|
||||
|
||||
if (!flag) {
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("date"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
date_query = root;
|
||||
} else {
|
||||
root = date_query;
|
||||
}
|
||||
common_method();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -110,6 +110,7 @@ public class ResourcesUtils {
|
|||
JWT_WEB("json-web-token",2),
|
||||
COLOR_CHOOSE("颜色选择",3),
|
||||
Qr_CODE("生成二维码",4),
|
||||
Date_Query("生成二维码",5),
|
||||
;
|
||||
|
||||
SmallTools(String title, int index) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.DatePicker?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
|
||||
|
||||
<AnchorPane fx:controller="com.zhangmeng.tools.controller.DateController" prefHeight="649.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<DatePicker fx:id="datePicker" layoutX="269.0" layoutY="88.0" />
|
||||
<Label layoutX="179.0" layoutY="92.0" text="请选择日历:" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
<MenuItem mnemonicParsing="false" text="jwt工具" onAction="#jwt_menu_item"/>
|
||||
<MenuItem mnemonicParsing="false" text="颜色选择工具" onAction="#color_choose_menu_item"/>
|
||||
<MenuItem mnemonicParsing="false" text="二维码生成" onAction="#qr_code_menu_item"/>
|
||||
<MenuItem mnemonicParsing="false" text="时间工具" onAction="#date_query_menu_item"/>
|
||||
</items>
|
||||
</Menu>
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
<MenuItem mnemonicParsing="false" text="jwt工具" onAction="#jwt_menu_item"/>
|
||||
<MenuItem mnemonicParsing="false" text="颜色选择工具" onAction="#color_choose_menu_item"/>
|
||||
<MenuItem mnemonicParsing="false" text="二维码生成" onAction="#qr_code_menu_item"/>
|
||||
<MenuItem mnemonicParsing="false" text="时间工具" onAction="#date_query_menu_item"/>
|
||||
</items>
|
||||
</Menu>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue