JavaFX 加载 fxml 文件

news2024/9/23 9:35:27

JavaFX 加载 fxml 文件主要有两种方式,第一种方式通过 FXMLLoader 类直接加载 fxml 文件,简单直接,但是有些控件目前还不知道该如何获取,所以只能显示,目前无法处理。第二种方式较为复杂,但是可以使用与 fxml 文件对应的 ***Controller 类可以操作 fxml 文件中的所有控件。现将两种方式介绍如下:

方式一:

  1. 创建 fxml 的 UI 文件
  2. 将 fxml 文件放置到对应位置
  3. FXMLLoader 加载文件显示

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.*?>


<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button fx:id="ownedNone" alignment="CENTER" mnemonicParsing="false" text="Owned None" />
      <Button fx:id="nonownedNone" mnemonicParsing="false" text="Non-owned None" />
      <Button fx:id="ownedWindowModal" mnemonicParsing="false" text="Owned Window Modal" />
      <Button mnemonicParsing="false" text="Button" />
      <Button mnemonicParsing="false" text="Button" />
   </children>
</VBox>

UI 显示:

java加载 fxml 文件:

package ch04;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Cursor;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;

/**
 * @author qiaowei
 * @version 1.0
 * @package ch04
 * @date 2020/5/24
 * @description
 */
public class LoadFXMLTest extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage)  {
        try {
            useFXMLLoader(primaryStage);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    
    /**
      @class      LoadFXMLTest
      @date       2020/5/24
      @author     qiaowei
      @version    1.0
      @brief      使用FXMLLoader加载fxml文件并生成相应的java类
      @param      primaryStage Application创建的Stage实例
     */
    public void useFXMLLoader(Stage primaryStage) throws Exception {
        Parent root =
                FXMLLoader.load(getClass().getResource("/sources/StageModalityWindow.fxml"));

        // 根据控件在窗体控件的添加顺序编号获取
        // Button ownedNone = (Button) ((VBox) root).getChildren().get(0);
        Button ownedNone = (Button) root.lookup("#ownedNone");
        ownedNone.setOnAction(e -> resetWindowTitle(primaryStage, "hello ownedNone"));

        Button ownedWindowModal = (Button) root.lookup("#ownedWindowModal");
        ownedWindowModal.setOnAction(e -> resetWindowTitle(primaryStage, "ownedWindowModal"));

        int width = ((int) ((VBox) root).getPrefWidth());
        int height = ((int) ((VBox) root).getPrefHeight());
//
        Scene scene = new Scene(root, width, height);
//        Scene scene = new Scene(root);
//        Button ownedNoneButton = ((VBox) root).getChildren().get(1);

        primaryStage.setTitle("StageModality");
        primaryStage.setScene(scene);

        primaryStage.show();
    }

    /**
     @class        StageModalityApp
     @date         2020/3/6
     @author       qiaowei
     @version      1.0
     @description  根据窗口拥有者和模式设置窗口状态
     @param        owner 窗口的父控件
     @param        modality 窗口的模式
     */
    private void showDialog(Window owner, Modality modality) {
        // Create a new stage with specified owner and modality
        Stage stage = new Stage();
        stage.initOwner(owner);
        stage.initModality(modality);
        Label modalityLabel = new Label(modality.toString());
        Button closeButton = new Button("Close");
        closeButton.setOnAction(e -> stage.close());

        VBox root = new VBox();
        root.getChildren().addAll(modalityLabel, closeButton);
        Scene scene = new Scene(root, 200, 100);

        // 设置鼠标在scene的显示模式
        scene.setCursor(Cursor.HAND);

        stage.setScene(scene);
        stage.setTitle("A Dialog Box");
        stage.show();
    }

    private void resetWindowTitle(Stage stage, String title) {
        stage.setTitle(title);
    }
}

根据 fxml 中控件的 “fx:id” 属性获取控件,并添加触发事件。通过 button 修改窗体的 title

注意两点:

  1. fxml 的存放路径,不同位置加载 String 不同。
  2. fxml 加载后返回的是 root 实例,需要放置到 sence 实例中再显示。
  3. 在通过 fxml 中控件的 id 返回控件时,id 前要加 #字符。

第二种方式

  1. 创建 fxml 文件,在 fxml 文件的顶层控件设置 “fx:controller”,属性值 =“完整的包路径.***Controller”

在完整的包路径下创建 ***Controller 类,在 fxml 文件中定义的控件和方法前都加 “@FXML”,注意两个文件中的对应控件、方法名称必须保持一致。

注意:***Controller 类在这里只继承 Objec,这样其中的控件都自动绑定到 fxml 中的控件,不会出现控件为 null 的情况。退出程序按钮。不添加 "@FXML" 注解,系统认为时类自己添加的控件,不会与 fxml 文件中同名控件绑定,系统不会自动初始化,值为 null;添加 "@FXML" 注解,系统会自动绑定到 fxml 文件中的同名控件,会自动给初始化为 MenuItem 的实例。注意字段与方法的区别,如果在 fxml 中定义方法,在 java 文件中必须有同名的方法,而且方法前要加 "@FXML" 注释。

 

示例如下:创建一个有 menuBar、menuItem 的窗体,在 fxml 中定义 menuItem 的 id 和 Action,在 ***Controller 中操作控件 menuItem 和 Action。

fmxl 文件,其中 openItem 没有设置 onAction,closeItem 设置 onAction,注意之后的两种处理方式。

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane prefHeight="400.0" 
            prefWidth="600.0" 
            xmlns="http://javafx.com/javafx/10.0.2-internal" 
            xmlns:fx="http://javafx.com/fxml/1" 
            fx:controller="ch06.VHFFrameController">
   <children>
      <MenuBar fx:id="menuBar" layoutY="2.0" AnchorPane.topAnchor="2.0">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
                <MenuItem fx:id="openItem" mnemonicParsing="false" text="Open" />
                <MenuItem fx:id="closeItem" mnemonicParsing="false" onAction="#exitApp" text="Exit" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Edit">
            <items>
              <MenuItem mnemonicParsing="false" text="Delete" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
      <Separator prefWidth="200.0" />
   </children>
</AnchorPane>

 对应的 ***Controller 类,openItem 通过在 setStage 方法中绑定 setOnAction(不能在构造函数中进行绑定,只能通过其它方法绑定!!!),closeItem 通过 fxml 文件中的设置直接绑定了 exitApp 方法(注:两个 MenuItem 控件通过不同的方法进行动作绑定,一个在 fxml 文件中绑定,一个在类文件中绑定)

注意:fxml 文件中设置的控件、方法在 ***Controller 类中要通过 “@FXML” 标识方法、字段在绑定,且方法、字段名称完全一致。

package ch06;

import javafx.fxml.FXML;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;

/**
  @package      ch06 
  @file         VHFFrameController.java
  @date         2020/5/27
  @author       qiaowei
  @version      1.0
  @description  与VHFFFrame.fxml文件对应的Controller类
 */
public class VHFFrameController {
    
    public VHFFrameController() {
        operator = Operator.instance();
    }
    
    /**
      @class      VHFFrameController
      @date       2020/5/27
      @author     qiaowei
      @version    1.0
      @brief      打开文件选择窗口
     */
//    @FXML
    public void openChooser() {
        if (isStage()) {
            operator.openFile(primaryStage);       
        }
    }
    
    /**
      @class      VHFFrameController
      @date       2020/5/27
      @author     qiaowei
      @version    1.0
      @brief      设置primaryStage字段实例,当字段已经设置过,跳过设置步骤
      @param      primaryStage 从主程序传来的主primaryStage实例
     */
    public void setStage(Stage primaryStage) {
        if ( !isStage()) {
            this.primaryStage = primaryStage;
        }

        openItem.setOnAction(e -> openChooser());
    }
    
    /**
      @class      VHFFrameController
      @date       2020/5/27
      @author     qiaowei
      @version    1.0
      @brief      退出程序
     */
    @FXML
    private void exitApp() {
        operator.exitApp();
    }
    
    /**
      @class      VHFFrameController
      @date       2020/5/27
      @author     qiaowei
      @version    1.0
      @brief      判断primaryStage实例是否为null,为null时,返回false;反之返回true;
      @return     true primaryStage不为null;反之返回false
     */
    private boolean isStage() {
        boolean flag = false;
        if (null != primaryStage) {
            flag = true;
        } else {
            flag = false;
        }
        
        return flag;
    }
    
    @FXML
    private MenuItem openItem;
    
    @FXML
    private MenuItem closeItem;
    
    @FXML
    private MenuBar menuBar;

    private static Operator operator;
    
    private Stage primaryStage;
}

 具体操作类 Operator,实现退出程序,打开 FileChooser 窗体两个功能:

package ch06;

import javafx.application.Platform;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

import java.io.File;

/**
 * @author qiaowei
 * @version 1.0
 * @package ch06
 * @date 2020/5/27
 * @description
 */
public class Operator {
    
    private Operator() {
        
    }
    
    public static Operator instance() {
        if (null == OPERATOR) {
            OPERATOR = new Operator();
        }
        
        return OPERATOR;
    }
    
    public void openFile(Stage stage) {
        FileChooser chooser = new FileChooser();

        File file = chooser.showOpenDialog(stage);
    }
    
    public void exitApp() {
        Platform.exit();
    }
    
    private static Operator OPERATOR = null;
}

JavaFX 运行类:

package ch06;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 * @author qiaowei
 * @version 1.0
 * @package ch06
 * @date 2020/5/27
 * @description
 */
public class VHFApp extends Application {

    public static void main(String[] args) {
        try {
            Application.launch(VHFApp.class, args);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        FXMLLoader fxmlLoader = 
                new FXMLLoader(getClass().getResource("/sources/VHFFrame.fxml"));
        Parent root = fxmlLoader.load();
//        Parent root = 
//                FXMLLoader.load(getClass().getResource("/sources/VHFFrame.fxml"));

        int width = ((int) ((AnchorPane) root).getPrefWidth());
        int height = ((int) ((AnchorPane) root).getPrefHeight());

        Scene scene = new Scene(root, width, height);

        primaryStage.setTitle("VHFApplication");
        primaryStage.setScene(scene);
        
        VHFFrameController controller = fxmlLoader.getController();
        controller.setStage(primaryStage);

        primaryStage.show();
    }
    
//    private static VHFFrameController controller = new VHFFrameController();
}

实现如下:

示例 2:

文件树图:

 fxml 文件:指定对应的 Controller 文件,对控件 exitItem 制定了对应的方法 exitApplication。

 

<?xml version="1.0" encoding="UTF-8"?>

<!--
  Copyright (c) 2015, 2019, Gluon and/or its affiliates.
  All rights reserved. Use is subject to license terms.

  This file is available and licensed under the following license:

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:

  - Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  - Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the distribution.
  - Neither the name of Oracle Corporation nor the names of its
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>

<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ui.MainWindowController">
  <children>
    <MenuBar VBox.vgrow="NEVER">
      <menus>
        <Menu mnemonicParsing="false" text="File">
          <items>
            <MenuItem mnemonicParsing="false" text="New" />
            <MenuItem fx:id="openItem" mnemonicParsing="false" text="Open…" />
            <Menu mnemonicParsing="false" text="Open Recent" />
            <SeparatorMenuItem mnemonicParsing="false" />
            <MenuItem mnemonicParsing="false" text="Close" />
            <MenuItem mnemonicParsing="false" text="Save" />
            <MenuItem mnemonicParsing="false" text="Save As…" />
            <MenuItem mnemonicParsing="false" text="Revert" />
            <SeparatorMenuItem mnemonicParsing="false" />
            <MenuItem mnemonicParsing="false" text="Preferences…" />
            <SeparatorMenuItem mnemonicParsing="false" />
            <MenuItem fx:id="exitItem" mnemonicParsing="false" onAction="#exitApplication" text="Quit" />
          </items>
        </Menu>
        <Menu mnemonicParsing="false" text="Edit">
          <items>
            <MenuItem mnemonicParsing="false" text="Undo" />
            <MenuItem mnemonicParsing="false" text="Redo" />
            <SeparatorMenuItem mnemonicParsing="false" />
            <MenuItem mnemonicParsing="false" text="Cut" />
            <MenuItem mnemonicParsing="false" text="Copy" />
            <MenuItem mnemonicParsing="false" text="Paste" />
            <MenuItem mnemonicParsing="false" text="Delete" />
            <SeparatorMenuItem mnemonicParsing="false" />
            <MenuItem mnemonicParsing="false" text="Select All" />
            <MenuItem mnemonicParsing="false" text="Unselect All" />
          </items>
        </Menu>
        <Menu mnemonicParsing="false" text="Help">
          <items>
            <MenuItem mnemonicParsing="false" text="About MyHelloApp" />
          </items>
        </Menu>
      </menus>
    </MenuBar>
    <AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
         <children>
            <TextArea layoutX="178.0" layoutY="73.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
         </children>
    </AnchorPane>
  </children>
</VBox>

对应的 Controller:在退出程序过程中,对 openItem 按钮是否为 null 进行测试,有 @FXML 注解时,openItem 被自动绑定实例,不为 null;当注释调 @FXML 注解后,openItem 没有自动绑定实例,为 null。如果要在 Controller 类中对控件进行操作,可以实现 initialize 方法和 @FXML 注解。这样保证控件已经绑定实例,可以对比 initialize 和 setupAttributes 方法,两者中 openItem 控件的情况。FXMLLoader 首先调用默认构造函数,然后调用 initialize 方法,从而创建相应控制器的实例。首先调用构造函数,然后填充所有 @FXML 带注释的字段,最后调用 initialize ()。因此,构造函数无法访问引用在 fxml 文件中定义的组件的 @FXML 注解字段,而 initialize 方法可以访问这些注解字段。

package ui;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.MenuItem;

import java.net.URL;
import java.util.ResourceBundle;


/**************************************************************************************************
 * @copyright 2003-2022
 * @package   ui
 * @file      MainWindowController.java
 * @date      2022/5/2 22:54
 * @author    qiao wei
 * @version   1.0
 * @brief     MainWindow.fxml的绑定类。
 * @history
**************************************************************************************************/
public class MainWindowController {
    
    public MainWindowController() {
        setupAttributes();
    }

    @FXML
    public void initialize() {
        if (null != openItem) {
            openItem.setOnAction(e -> exitApplication());
        }
    }

    public void setupAttributes() {
        if (null != openItem) {
            openItem.setOnAction(e -> openFile());
        }
        
    }
    
    private void openFile() {
        
    }
    
    @FXML
    private void exitApplication() {
        if (null != openItem) {
            System.out.println("测试@FXML注释作用");
        }
        
        Platform.exit();
    }
    
    @FXML
    private MenuItem openItem;
    
    /**********************************************************************************************
     * @date   2022/5/2 22:48
     * @author qiao wei
     * @brief  退出程序按钮。不添加"@FXML"注解,系统认为时类自己添加的控件,不会与fxml文件中同名控件绑定,系统
     *         不会自动初始化,值为null;添加"@FXML"注解,系统会自动绑定到fxml文件中的同名控件,会自动给初始化
     *         为MenuItem的实例。注意字段与方法的区别,如果在fxml中定义方法,在java文件中必须有同名的方法,而且
     *         方法前要加"@FXML"注释。
    **********************************************************************************************/
    @FXML
    private MenuItem exitItem;
}

启动类:

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Screen;
import javafx.stage.Stage;
import ui.MainWindowController;


/**************************************************************************************************
 @Copyright 2003-2022
 @package PACKAGE_NAME
 @date 2022/5/2
 @author qiao wei
 @version 1.0
 @brief TODO
 @history
 *************************************************************************************************/
public class Main extends Application {

    public static void main(String[] args) {
        try {
            Application.launch(Main.class, args);
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        FXMLLoader fxmlLoader =
                new FXMLLoader(getClass().getResource("/fxml/MainWindow.fxml"));

        Parent root = fxmlLoader.load();
//        MainWindowController controller = fxmlLoader.getController();

        Rectangle2D rectangle2D = Screen.getPrimary().getBounds();
        
        // 获取窗体左上角初始坐标
        double xPosition = rectangle2D.getWidth() / 5;
        double yPosition = rectangle2D.getHeight() / 5;

        // 获取窗体尺寸
        int width = (int) rectangle2D.getWidth() * 2 / 3;
        int height = (int) rectangle2D.getHeight() * 2 / 3;

        // 设置窗体起始坐标、尺寸
        primaryStage.setScene(new Scene(root, width, height));
        primaryStage.setX(xPosition);
        primaryStage.setY(yPosition);
        primaryStage.setTitle("Radar Track Application");

        primaryStage.show();
    }
}

运行结果:

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/931372.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

mysql 逻辑架构

连接层 客户端和服务器建立连接&#xff0c;客户端发送sql 到 服务器端 服务层 引擎层 查看现有的 存储引擎 show engines&#xff1b; 存储层

电子器件系列56:ltc1799(定时器)

定时IC芯片是一种具有定时功能的集成电路&#xff0c;常用于计时、时钟、频率合成等应用。以下是一些常见的定时IC芯片&#xff1a; 1. 555定时器芯片&#xff1a;最常见的定时IC芯片之一&#xff0c;可用于产生各种定时信号和脉冲。 2. 556双555定时器芯片&#xff1a;由两个5…

OLED透明屏曲面技术:创新突破引领显示行业未来

OLED透明屏曲面技术作为一项重要的显示技术创新&#xff0c;正在成为显示行业的焦点&#xff0c;其引人注目的优势和广泛应用领域使其备受关注。 本文将详细介绍OLED透明屏曲面技术的优势、应用领域以及市场前景&#xff0c;同时展望其未来的发展趋势&#xff0c;以期带给读者…

数据工厂调研及结果展示

数据工厂 一、背景 在开发自测、测试迭代测试、产品验收的过程中&#xff0c;都需要各种各样的前置数据&#xff0c;大致分为如下几类&#xff1a; 账号&#xff08;实名、权益等级、注册等&#xff09; 货源&#xff08;优货、急走、相似、一手、普通货源等&#xff09; …

Linux下Qt配置opencv环境(ippicv,ffmpeg手动配置)

1.opencv配置使用问题 opencv在cmake的时候有两个问题&#xff0c;ippicv长时间卡住下载失败&#xff0c;ffmpeg不会卡住但是也不会配置成功。所以这两个包只能手动下载安装。 ippicv是什么 OpenCV设计用于高效的计算&#xff0c;十分强调实时应用的开发。它由C语言编写并进行了…

腾讯云服务器地域有什么区别?怎么选择合适?

腾讯云服务器地域有什么区别&#xff1f;怎么选择比较好&#xff1f;地域选择就近原则&#xff0c;距离地域越近网络延迟越低&#xff0c;速度越快。关于地域的选择还有很多因素&#xff0c;地域节点选择还要考虑到网络延迟速度方面、内网连接、是否需要备案、不同地域价格因素…

聚观早报 | 青瓷游戏上半年营收3.34亿元;如祺出行冲击IPO

【聚观365】8月26日消息 青瓷游戏上半年营收3.34亿元 如祺出行冲击IPO 索尼互动娱乐将收购Audeze 昆仑万维上半年净利润3.6亿元 T-Mobile计划在未来五周内裁员5000人 青瓷游戏上半年营收3.34亿元 青瓷游戏发布截至2023年6月30日止的中期业绩&#xff0c;财报显示&#xf…

聚类分析 | MATLAB实现基于DBSCAD密度聚类算法可视化

聚类分析 | MATLAB实现基于LP拉普拉斯映射的聚类可视化 目录 聚类分析 | MATLAB实现基于LP拉普拉斯映射的聚类可视化效果一览基本介绍程序设计参考资料 效果一览 基本介绍 基于DBSCAD密度聚类算法可视化&#xff0c;MATLAB程序。 使用带有KD树加速的dbscan_with_kdtree函数进行…

AI绘画 | Discord的最强7款AI插件整理汇总

hi&#xff0c;同学们&#xff0c;我是赤辰&#xff0c;本周起&#xff0c;我们将开启AI工具教程篇的栏目&#xff0c;每天会更新1篇AI教程或推荐实用AI工具&#xff0c;文章底部准备了粉丝福利&#xff0c;看完可以领取&#xff01; 今天给大家整理了Discord的最强7款AI插件汇…

ai课堂行为分析检测评估

ai课堂行为分析检测评估系统通过yolo网络模型算法&#xff0c;ai课堂行为分析检测评估算法利用摄像头采集学生的图像&#xff0c;视线跟踪技术的智能教学系统由情感模型、教师模型、学生模型和课程模型四个模型组成。用户端的视线及表情信息通过摄像头采集并传递到情感模型情感…

日常踩坑记录

本篇文章主要介绍一下最近的开发中用到的些小问题。问题不大&#xff0c;但有些小细节&#xff0c;记录一下&#xff0c;有遇到的朋友可以看一下&#xff0c;有更好的解决方法欢迎分享。 浏览器记住密码自动填充表单 这个问题我在火狐浏览器遇到了。我登录系统时选择了浏览器…

【MySQL系列】统计函数(count,sum,avg)详解

&#x1f490; &#x1f338; &#x1f337; &#x1f340; &#x1f339; &#x1f33b; &#x1f33a; &#x1f341; &#x1f343; &#x1f342; &#x1f33f; &#x1f344;&#x1f35d; &#x1f35b; &#x1f364; &#x1f4c3;个人主页 &#xff1a;阿然成长日记 …

SpringBoot源码剖析

SpringBoot概念 什么是SpringBoot spring官方的网站&#xff1a;https://spring.io/ 翻译&#xff1a;通过Spring Boot&#xff0c;可以轻松地创建独立的&#xff0c;基于生产级别的基于Spring的应用程序&#xff0c;并且可以“运行”它们 其实Spring Boot 的设计是为了让你…

js中?.、??、??=的用法及使用场景

上面这个错误&#xff0c;相信前端开发工程师应该经常遇到吧&#xff0c;要么是自己考虑不全造成的&#xff0c;要么是后端开发人员丢失数据或者传输错误数据类型造成的。因此对数据访问时的非空判断就变成了一件很繁琐且重要的事情&#xff0c;下面就介绍ES6一些新的语法来方便…

分布式 - 服务器Nginx:一小时入门系列之TCP反向代理和负载均衡

文章目录 1. HTTP反向代理和TCP反向代理2. http 块和 stream 块3. TCP反向代理配置4. TCP 负载均衡 1. HTTP反向代理和TCP反向代理 Nginx可以作为HTTP反向代理和TCP反向代理。 HTTP反向代理是指Nginx作为Web服务器的代理服务器&#xff0c;接收客户端的HTTP请求&#xff0c;然…

AI智能工服识别算法

AI智能工服识别算法通过yolov5python网络深度学习算法模型&#xff0c;AI智能工服识别算法通过摄像头对现场区域利用算法分析图像中的工服特征进行分析实时监测工作人员的工服穿戴情况&#xff0c;识别出是否规范穿戴工服&#xff0c;及时发现不规范穿戴行为&#xff0c;提醒相…

cortex-A7 UART总线实验---STM32MP157

实验目的&#xff1a;实现字符/字符串收发 一&#xff0c;总线相关 1&#xff0c;总线&#xff1a;各个部件之间传输的一种媒介 芯片内部总线&#xff1a;核与芯片内部控制器进行连接 A7---AHB4总线---GPIO控制器 A7---AHB4总线---RCC控制器 芯片外部总线&#xff1a;SOC…

C# winform加载yolov8模型测试(附例程)

第一步&#xff1a;在NuGet中下载Yolov8.Net 第二步&#xff1a;引用 using Yolov8Net; 第三步&#xff1a;加载模型 private IPredictor yolov8 YoloV8Predictor.Create("D:\\0MyWork\\Learn\\vs2022\\yolov_onnx\\best.onnx", mylabel); 第四步&#xff1a;图…

速卖通产品权重打造,自养号补单技术策略

跨境电商市场的竞争确实很激烈&#xff0c;中小卖家要在速卖通上获得一席之地确实有一定难度。虽然补单可以提升销量和排名&#xff0c;但是目前的测评市场确实存在一些问题&#xff0c;选择一个成熟的服务商进行补单是非常重要的。 在选择服务商时&#xff0c;确保他们的技术…

【android12-linux-5.1】【ST芯片】HAL移植后开机卡死

按照ST的官方readme移植HAL后开机一直卡在android界面&#xff0c;看logcat提示写文件时errorcode&#xff1a;-13。查下资料大致明白13错误码是权限不足&#xff0c;浏览代码在写文件的接口加日志后&#xff0c;发现是需要写iio:device*/buffer/enable这类文件的时候报错的。千…