WordMiniTestingScreen

这是一个用于英语单词测试的迷你屏幕应用程序,支持通过键盘快捷键进行单词切换和详细模式查看等功能,具备良好的用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

public class WordMiniTestingScreen extends BaseScreen implements MouseMotionListener{
	private static final long serialVersionUID = 1L;
	protected float initOpac = 1;//0.45f;// 0.25f;
	private WordMiniTestingScreen thisFrame ;
	private MiniMouseListener mouseListener ;
	private Point movePoint = new Point();
	private JLabel lbl_result;
	private JLabel lbl_currentWordIndex;
	private JLabel lbl_x;
	private JLabel lbl_totalWords;
	private JLabel lbl_previous;
	private JLabel lbl_next;
	private JLabel lbl_commit;
	private JLabel lbl_detailModel;
	private JLabel lbl_exit;
	private WordInputJTextPane txt_wordEN;
	private OneLineJTextArea txt_wordCN;
	private JCheckBox jcb_forgetTag;
	private WordTestingScreen detalFrame;
	private JLabel lbl_process;
	
	// data
	private WordSearchScreen parentFrame;
	private List<Word> dataList ;
	
	// business
	private WordTestScreenService service = new WordTestScreenService();
	Integer currIndex = -1;
	private Word currWord = null;
	private WordTestingKeyListener wordTestingKeyListener = new WordTestingKeyListener();
//	public static void main(String[] args) {
//		new WordMiniTestingScreen().setVisible(true);
//	}
	
//	public WordMiniTestingScreen(){
//		initialJFrame();
//	}
	
	boolean commitFlag = true;
	class WordTestingKeyListener implements KeyListener{
		private boolean ctrl_flag = false;
		private boolean alt_flag = false;
		public void keyPressed(KeyEvent e) {
			if(e.getKeyCode() == 17){
				ctrl_flag = true;
			}
			if(e.getKeyCode() == 18){
				alt_flag = true;
			}
			
			if((ctrl_flag || alt_flag) && e.getKeyCode() == 39 ){ // -->
				nextWord();
			}else if((ctrl_flag || alt_flag)  && e.getKeyCode() == 37){ // <--
				prevWord();
			}else if((ctrl_flag || alt_flag)  && e.getKeyCode() == 68){
				detailModel();
			}else if((ctrl_flag || alt_flag)  && e.getKeyCode() == 70){
				ctrl_flag = alt_flag = false;
				thisFrame.setExtendedState(JFrame.ICONIFIED);
			}else if(ctrl_flag && e.getKeyCode() == 83){
				txt_wordEN.setText(currWord.getFldWorden());
			}
		}

		@Override
		public void keyReleased(KeyEvent e) {
			if(e.getKeyCode() == 17){
				ctrl_flag = false;
			}else if(e.getKeyCode() == 18){
				alt_flag = false;
			}
			if(e.getKeyCode() == 10){
				txt_wordEN.setText(txt_wordEN.getText().replace("\r", "").replace("\n", ""));
				nextWord();
			}
			if(ctrl_flag && e.getKeyCode() == 83){
				txt_wordEN.setText("");
			}
		}

		@Override
		public void keyTyped(KeyEvent e) {
			
		}
		
	}
	
	public WordMiniTestingScreen(WordSearchScreen parentFrame, WordTestingScreen detalFrame) {
		super(parentFrame);
		this.detalFrame = detalFrame;
		this.parentFrame = parentFrame ;
		initialJFrame();
	}
	
	@SuppressWarnings("restriction")
	private void initialJFrame(){
		thisFrame = this;
		super.setSubFrame(thisFrame);
		thisFrame.setUndecorated(true);
		 
		thisFrame.setSize(new Dimension(800, 50));
		mouseListener = new MiniMouseListener(thisFrame);
		thisFrame.addMouseMotionListener(thisFrame);
		thisFrame.addMouseListener(mouseListener);
		com.sun.awt.AWTUtilities.setWindowOpacity(thisFrame,initOpac);
		initialData();
		initialBody();
		refreshUI();
	}
	public void refreshUI() {
		if(currIndex<0){
			return;
		}
		currWord = dataList.get(currIndex);
//		// test result
		currWord.setFldErrorfag(wordHanders[currIndex].handlerResult());
//		
		if(currWord.getFldErrorfag().equals("1")){
			lbl_result.setText("[ E ]");
		}else if(currWord.getFldErrorfag().equals("0")){
			lbl_result.setText("[ R ]");
		}else{
			lbl_result.setText("[ - ]");
		}

		lbl_currentWordIndex.setText((currIndex+1)+"");
		lbl_totalWords.setText("" + dataList.size());
//		
//		txt_symbol.setText(currWord.getFldSymbol());
//		
		txt_wordEN.setText(txt_wordEN.getWordBuffer()[currIndex]);
		txt_wordEN.setRightWordEn(currWord.getFldWorden());
		txt_wordEN.setText(currWord.getFldWorden());
//		
		String wordCN = currWord.getFldWordcn().replace('\t', '\n');
		txt_wordCN.setText(wordCN.substring(0,wordCN.length()-1));
		txt_wordCN.startDisplay();
//		
//		txt_showCondition.setText(service.getConditionString(parentFrame.conditionMap));
//		
		Object[] infos = service.getProgressInfo(dataList);
		String processInfo = ((String) infos[1]).replace("progress:", "").replace("right:", "").replace(" ", "").replace("%", "");
		lbl_process.setText(processInfo);
		
		jcb_forgetTag.setSelected(("1".equals(currWord.getFldForgettag())?true:false));
		
		if(commitFlag && (double)infos[0] == 100){
			int option = JOptionPane.showConfirmDialog(this,"你已完成所有练习,现在需要提交吗?",  "已完成", JOptionPane.YES_NO_OPTION);
			if(option == JOptionPane.YES_OPTION){
				commit();
			}else{
				commitFlag = false;
			}
		}
	}

	private void initialData() {
		thisFrame.dataList = detalFrame.dataList;
		thisFrame.commitFlag = detalFrame.commitFlag;
//		service.initialTestFlag(dataList);
		if(dataList.size()>0){
			currIndex = detalFrame.currIndex;
			currWord = dataList.get(currIndex);
		}
	}
	
	private void initialBody() {
		ComponentFactory compFactory = new ComponentFactory();
		Font btnFont = new Font("Arial", Font.BOLD, 11);
		
		lbl_previous = new JLabel("<<");
		lbl_previous.setFont(btnFont);
		ComponentUtil.setBounds(20, 20, thisFrame, lbl_previous, ComponentUtil.INNER_LEFT_TOP, 5);
		lbl_previous.setLocation(lbl_previous.getX()+5, lbl_previous.getY());
		lbl_previous.addMouseListener(mouseListener);
		thisFrame.add(lbl_previous);
		
		lbl_result = new JLabel("[ R ]");
		lbl_result.setFont(btnFont);
		ComponentUtil.setBounds(25, 20, lbl_previous, lbl_result, ComponentUtil.RIGHT_CENTER);
		thisFrame.add(lbl_result);
		
		lbl_next = new JLabel(">>");
		lbl_next.setFont(btnFont);
		ComponentUtil.setBounds(25, 20, lbl_result, lbl_next, ComponentUtil.RIGHT_CENTER,2);
		lbl_next.addMouseListener(mouseListener);
		thisFrame.add(lbl_next);
		
		txt_wordEN = compFactory.getWordInputTextPane();
		txt_wordEN.setBackground(thisFrame.getBackground());
		ComponentUtil.setBounds(620, 18, lbl_next, txt_wordEN, ComponentUtil.RIGHT_CENTER);
		txt_wordEN.setWordBuffer(detalFrame.txt_wordEN.getWordBuffer());
		txt_wordEN.addKeyListener(wordTestingKeyListener);
		thisFrame.add(txt_wordEN);
		
		jcb_forgetTag = new JCheckBox("F");
		ComponentUtil.setBounds(35, 20, txt_wordEN, jcb_forgetTag, ComponentUtil.RIGHT_CENTER,5);
		jcb_forgetTag.addMouseListener(mouseListener);
		thisFrame.add(jcb_forgetTag);
		
		lbl_commit = new JLabel("C");
		ComponentUtil.setBounds(10, 20, jcb_forgetTag, lbl_commit, ComponentUtil.RIGHT_CENTER,5);
		lbl_commit.addMouseListener(mouseListener);
		thisFrame.add(lbl_commit);
		
		lbl_exit = new JLabel("E");
		ComponentUtil.setBounds(10, 20, lbl_commit, lbl_exit, ComponentUtil.RIGHT_CENTER,7);
		lbl_exit.addMouseListener(mouseListener);
		thisFrame.add(lbl_exit);
		
		lbl_detailModel = new JLabel("D");
		ComponentUtil.setBounds(10, 20, lbl_exit, lbl_detailModel, ComponentUtil.RIGHT_CENTER,7);
		lbl_detailModel.addMouseListener(mouseListener);
		thisFrame.add(lbl_detailModel);
		
		// line2
		lbl_currentWordIndex = new JLabel("10");
		ComponentUtil.setBounds(30, 20, lbl_previous, lbl_currentWordIndex, ComponentUtil.BOTTOM_LEFT,1);
		lbl_currentWordIndex.setLocation(lbl_currentWordIndex.getX()-6, lbl_currentWordIndex.getY());
		lbl_currentWordIndex.setHorizontalAlignment(SwingConstants.CENTER);
		thisFrame.add(lbl_currentWordIndex);
		
		lbl_x = new JLabel("/");
		ComponentUtil.setBounds(5, 20, lbl_currentWordIndex, lbl_x, ComponentUtil.RIGHT_CENTER,2);
		thisFrame.add(lbl_x);
		
		lbl_totalWords = new JLabel("50");
		lbl_totalWords.setHorizontalAlignment(SwingConstants.CENTER);
		ComponentUtil.setBounds(30, 20, lbl_x, lbl_totalWords, ComponentUtil.RIGHT_CENTER);
		thisFrame.add(lbl_totalWords);
		
		txt_wordCN = new OneLineJTextArea(); //compFactory.getJTextArea();
		txt_wordCN.setBackground(thisFrame.getBackground());
		JScrollPane scrollWordCN = compFactory.getScrollableJTextArea(txt_wordCN, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER, JScrollPane.VERTICAL_SCROLLBAR_NEVER);
		ComponentUtil.setBounds(620, 18, lbl_totalWords, scrollWordCN, ComponentUtil.RIGHT_CENTER,11);
		thisFrame.add(scrollWordCN);
		
		lbl_process = new JLabel("100 / 100");
//		lbl_process.setBorder(new LineBorder(Color.red));
		ComponentUtil.setBounds(80, 20, scrollWordCN, lbl_process, ComponentUtil.RIGHT_CENTER,8);
		thisFrame.add(lbl_process);
	}
	
	public void mouseDragged(MouseEvent me) {
		thisFrame.setLocation(thisFrame.getX()+ (me.getX()-(int)movePoint.getX()), thisFrame.getY() + (me.getY()-(int)movePoint.getY()));
	}
	public void mouseMoved(MouseEvent arg0) {
		movePoint.setLocation(arg0.getX(), arg0.getY());
	}
	
	private void saveUserInput(){
		if(currIndex < 0){
			return;
		}
		currWord = dataList.get(currIndex);
		currWord.setFldErrorfag(txt_wordEN.handlerResult());
		txt_wordEN.getWordBuffer()[currIndex] = txt_wordEN.getText();
	}
	
	private void prevWord(){
		if(dataList.size()<=0){
			return ;
		}
		saveUserInput();
		if(currIndex -1 <0){
			currIndex = dataList.size()-1;
		}else{
			currIndex--;
		}
		refreshUI();
	}
	
	private void nextWord(){
		if(dataList.size()<=0){
			return ;
		}
		saveUserInput();
		if(currIndex +1 >= dataList.size()){
			currIndex = 0;
		}else{
			currIndex++;
		}
		refreshUI();
	}
	
	private void commit() {
		String result = service.getResult(dataList);
		JOptionPane.showMessageDialog(null,result ,"测试完成" , JOptionPane.INFORMATION_MESSAGE); 
		parentFrame.search();
		parentFrame.setVisible(true);
		thisFrame.dispose();	
		detalFrame.dispose();
	}

	private void detailModel() {
		detalFrame.jcb_miniModel.setSelected(false);
		detalFrame.currIndex = thisFrame.currIndex;
		detalFrame.commitFlag = thisFrame.commitFlag;
		detalFrame.refreshUI();
		detalFrame.setVisible(true);
		thisFrame.setVisible(false);
	}
	@SuppressWarnings("restriction")
	class MiniMouseListener implements MouseListener {
		WordMiniTestingScreen thisFrame;

		public MiniMouseListener(WordMiniTestingScreen thisFrame) {
			this.thisFrame = thisFrame;
		}

		public void mouseClicked(MouseEvent e) {
			String actionCommand = "";
			if (e.getComponent() instanceof JLabel) {
				actionCommand = ((JLabel) e.getComponent()).getText();
			} else if (e.getComponent() instanceof JCheckBox) {
				actionCommand = ((JCheckBox) e.getComponent()).getText();
			} else {
				System.out.println("no jlabel source");
				return;
			}
			if (actionCommand.equals("<<")) {
				prevWord();
			} else if (actionCommand.equals(">>")) {
				nextWord();
			} else if (actionCommand.equals("C")) {
				saveUserInput();
				refreshUI();
				commit();
			} else if (actionCommand.equals("E")) {
				thisFrame.exitScreen();
				detalFrame.dispose();
			} else if (actionCommand.equals("D")) {
				detailModel();
			} else if (actionCommand.equalsIgnoreCase("F")) {
				if(jcb_forgetTag.isSelected()){
					currWord.setFldForgettag("1");
				}else{
					currWord.setFldForgettag("0");
				}
			}
		}

		@Override
		public void mouseEntered(MouseEvent e) {
			if (e.getComponent() instanceof Component) {
				com.sun.awt.AWTUtilities.setWindowOpacity(thisFrame, 0.8f);
			}
			if (e.getComponent() instanceof JLabel) {
				e.getComponent().setForeground(Color.PINK);
			}
		}

		@Override
		public void mouseExited(MouseEvent e) {
			boolean isOutside = outsideOfFrame(thisFrame, e.getXOnScreen(), e.getYOnScreen());
			if (isOutside) {
				com.sun.awt.AWTUtilities.setWindowOpacity(thisFrame, thisFrame.initOpac);
			}
			if (e.getComponent() instanceof JLabel) {
				e.getComponent().setForeground(Color.BLACK);
			}
		}

		private boolean outsideOfFrame(JFrame frame, int pointX, int pointY) {
			int localX = (int) frame.getLocation().getX();
			int localY = (int) frame.getLocation().getY();
			int width = frame.getWidth();
			int height = frame.getHeight();
			if (pointX <= localX || pointX >= (localX + width) || pointY <= localY || pointY >= (localY + height)) {
				return true;
			}
			return false;
		}

		@Override
		public void mousePressed(MouseEvent arg0) {
		}

		@Override
		public void mouseReleased(MouseEvent arg0) {
		}
	}
}

资源下载链接为: https://pan.quark.cn/s/5c50e6120579 在Android移动应用开发中,定位功能扮演着极为关键的角色,尤其是在提供导航、本地搜索等服务时,它能够帮助应用获取用户的位置信息。以“baiduGPS.rar”为例,这是一个基于百度地图API实现定位功能的示例项目,旨在展示如何在Android应用中集成百度地图的GPS定位服务。以下是对该技术的详细阐述。 百度地图API简介 百度地图API是由百度提供的一系列开放接口,开发者可以利用这些接口将百度地图的功能集成到自己的应用中,涵盖地图展示、定位、路径规划等多个方面。借助它,开发者能够开发出满足不同业务需求的定制化地图应用。 Android定位方式 Android系统支持多种定位方式,包括GPS(全球定位系统)和网络定位(通过Wi-Fi及移动网络)。开发者可以根据应用的具体需求选择合适的定位方法。在本示例中,主要采用GPS实现高精度定位。 权限声明 在Android应用中使用定位功能前,必须在Manifest.xml文件中声明相关权限。例如,添加<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />,以获取用户的精确位置信息。 百度地图SDK初始化 集成百度地图API时,需要在应用启动时初始化地图SDK。通常在Application类或Activity的onCreate()方法中调用BMapManager.init(),并设置回调监听器以处理初始化结果。 MapView的创建 在布局文件中添加MapView组件,它是地图显示的基础。通过设置其属性(如mapType、zoomLevel等),可以控制地图的显示效果。 定位服务的管理 使用百度地图API的LocationClient类来管理定位服务
资源下载链接为: https://pan.quark.cn/s/0c983733fad2 自助打印系统源码是一个包含完整打印服务软件开发代码的压缩包,旨在为用户提供便捷的打印方式。用户无需借助电脑等设备,只需在支持该系统的终端操作即可完成打印。深入分析源码有助于我们理解系统架构和功能实现,对学习和定制打印系统极具价值。 系统架构:该系统由前端用户界面、后端服务器处理逻辑和数据库三部分构成。前端负责用户交互,如文件选择、支付方式选择等;后端处理用户请求,包括文件上传、打印任务调度、费用计算等;数据库则用于存储用户信息、打印记录和配置数据。 文件管理:源码包含文件上传、存储和检索模块。用户可选择本地文件或云存储中的文件进行打印,系统需支持多种文件格式,并具备安全的文件存储机制以保护用户数据安全。 支付集成:系统需与第三方支付平台(如支付宝、微信支付)集成,实现在线支付功能,涉及API调用、交易状态跟踪和错误处理。 打印作业管理:系统需管理打印作业,包括作业提交、队列排序、打印状态更新、错误处理等,并可能提供作业预览功能,让用户在打印前查看效果。 硬件接口:为与打印机通信,源码包含特定的硬件驱动程序或API接口,需适应不同品牌和型号的打印机,确保打印质量和效率。 用户认证与权限控制:系统需识别并验证用户身份,可能采用账号密码、二维码扫描等方式。不同用户可能有不同的打印权限,如打印份数限制、彩色打印权限等。 日志与统计:源码包含日志记录功能,用于监控系统运行状况和故障排查。统计功能可帮助管理者了解打印业务的使用情况,如打印量、费用收入等。 安全性:源码安全性至关重要,需防止未授权访问和数据泄露。开发者可能采用加密技术保护用户数据,并定期进行安全更新和漏洞修复。 扩展性与可维护性:优秀的源码设计应具备良好的结构和模块化,便于未来功能扩展和问题修复,例如轻松添加新功能,支持更多文件格式
资源下载链接为: https://pan.quark.cn/s/00cceecb854d 这个项目名为“mnist-nnet-hls-zynq7020-fpga prj”,是一个与机器学习相关的工程,专注于利用高级综合(HLS)技术将针对MNIST数据集设计的神经网络(nnet)实现在Zynq 7020 FPGA平台上,以加速图像识别任务。项目提供的压缩包包含所有相关代码文件,如C/C++源码、HLS接口定义、Vivado HLS项目文件、硬件描述语言代码(Verilog或VHDL)及配置文件等,用户可通过这些代码理解、实现或修改设计流程。 项目标签“mnist-nnet-hls-z”进一步明确了其关注点:MNIST数据集、HLS技术以及Zynq目标平台。MNIST是用于手写数字识别的知名训练数据集;HLS可将高级编程语言转化为硬件描述语言;Zynq 7020是Xilinx的SoC FPGA,融合了ARM处理器与可编程逻辑。文件名中提到的“vivado”指的是Xilinx的Vivado设计套件,它是一个用于FPGA设计、实现、仿真和调试的集成开发环境,其中的Vivado HLS工具能够将C、C++或SystemC编写的算法自动转换为硬件描述语言代码。 项目可能的实施步骤如下:首先,对MNIST数据集进行预处理,如归一化、降维等,使其适配神经网络模型输入;其次,构建适用于手写数字识别的神经网络模型,例如卷积神经网络(CNN)或全连接网络(FCN);接着,运用HLS工具将神经网络模型转化为硬件描述,并优化性能与资源利用率;然后,在Vivado环境中,将生成的硬件描述代码映射到Zynq 7020的FPGA部分,进行时序分析与综合优化;此外,由于Zynq是SoC,包含处理器系统,还需编写控制软件来管理与调度FPGA上的硬件加速器,可能涉及OpenCV、OpenCL等库的使用;之后,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值