Spring 2019-2020 Java Programming course lab -- Chongqing University. Include my source codes and lab reports.

Overview

JAVA_GUI_File_Manager

Spring 2019-2020 JAVA Programming course homeworks -- Chongqing University. Include my source codes and reports.

Contents:

  1. Draw on the class architecture of Experiment 1 to construct a set of drawing classes, including Shape, a derived class of Shape and graphics class;

  2. OpenGLApp of Experiment 1 was changed to a derived class of Jframe class, including Graphics class instance as data member, and a specific layout manager was used to build the main window. Corresponding controls were created in the window to allow users to select the shape, line color and fill color of the currently drawn graph.

  3. Add corresponding event monitoring and corresponding methods (processing user input), such as the shape of the drawing graph, line color, fill color selection change;

  4. Reload the paintComponent (Graphics G) method of the main window, which is used to draw the Graphics class instance data in the main window. During the drawing process, call the draw() method of these Graphics data, and you can pass the G of the main window to the draw method of each Graphics element class.

  5. Perform related processing methods in the MouseListener interface registered in the main window. According to the current user's choice, implement functions similar to the Painter tool in the Window attachment, such as drawing the specified graph and moving the graph.

  6. Using SOCK and multithreading mechanism, modify program structure to realize the design and implementation of a Network whiteboard program based on Java SOCK (multi-user cooperative whiteboard drawing program).

Design of Classes

Using the class architecture of Experiment 1 as reference, we construct the drawing class set, shape, the derived class of Shape and graphics class. On this basis, Client, Server and SocketThread classes for network connection and image transmission are added. The design of the class follows the MVC design specification, dependency inversion specification and single function specification. The overview diagram of package and class is as follows:

(1) Shape

IsSelected is an abstract class that contains a Boolean variable, isSelected, that marks whether the graph isSelected or not;

Abstract methods draw() is used to output the graph and getCN() is used to return the graph category. The selected method determines whether the graph is selected. The print method is used to output information to the command line during debugging. All subclasses that inherit from Shape must implement these methods.

(2) Myline class

Public int aX,aY,bX,bY; public int ps; They represent the xy coordinates of the two vertices of the line, and the selected points on the line.

Member function: The draw method uses the position information of the object itself to draw the final image on the artboard; The selected method is used to receive the selection box and determine whether the current line is in the selection box and which point is selected by the selection box. The print method is used to print information to the command line. CN() is used to return the type of the graph; The x and y methods return the position information of the current moment line.

(3) MyRectangle class:

Public int x,y,width,height;

public boolean isFilled;

public int ps; Represents the rectangle's vertex XY coordinates, width and height, whether the marker is filled, and the point at which the rectangle is selected.

Member function: The draw method uses the position information of the object itself to draw the final image on the artboard; The selected method is used to receive the selection box and determine whether the current rectangle is in the selection box and which point is selected by the selection box. The print method is used to print information to the command line. CN() is used to return the type of the graph; The x and y methods return the position of the current rectangle.

MyOval class:

Public int x,y,width,height;

public boolean isFilled; Represents the vertex xy coordinates of the ellipse, the width and height, and whether the mark is filled.

Member function: The draw method uses the position information of the object itself to draw the final image on the artboard; The selected method is used to receive the selection box and determine whether the current ellipse is in the selection box. The print method is used to print information to the command line. CN() is used to return the type of the graph; The x and y methods return the position of the current ellipse.

(5) MyTriangle class:

Public int ax,ay,bx,by,cx,cy;

public boolean isFilled;

public int ps; Each represents the xy coordinates of the three vertices of the triangle, whether the marker is filled, and the selected point of the triangle.

Member function: The draw method uses the position information of the object itself to draw the final image on the artboard; The selected method is used to receive the selection box and determine whether the current triangle is in the selection box and which point is selected by the selection box. The print method is used to print information to the command line. CN() is used to return the type of the graph; The x and y methods return the position information of the current triangle.

(6) Graphic class

Performs most of the operations stored in graphics for processing.

Maintains a List of shapes for storing graphs.

Maintains a MyRectangle class variable chooseField to store selection box objects.

Maintain four integer oldMouseX oldMouseY, nowMouseX, nowMouseY, X, Y, is used to monitor the location of the mouse, the location of the updated graphics.

Override the paint method to draw in real time the intermediate process diagram of the current drawing, and the selection box in real time if in selection mode. Make the experience of drawing very smooth and coherent.

Implement addShape method, which is used to determine the final position information of the graph being drawn when the mouse is released, and then use this position information to call the constructor of the corresponding graph to construct the graph object, and store it in the Shapes table. Also, in select mode, the position of the select box will be updated when the mouse is released.

Implement selectShape method, in the selection mode, using our selection box as a parameter, to determine whether each graph object in the List is located in the selection box. It should be noted that, if mode is not selected, each graph object is left unchecked to conform to our design logic.

Implement the delete method so that we can delete the currently selected graph by clicking the Delete button in select mode.

The change method is implemented so that we can modify the selected graph in the selection mode.

Implement the setStroke method to update the brush thickness in real time.

The MousePressed, MouseREleased, and MouseDragged methods will be overhauled, update the position of the mouse, and call the appropriate method.

(7)OpenGLApp class:

Acts as a controller class that implements the main interface and implements all operations that interact with the user.

The object place of the Graphic class is maintained as the main interface for drawing.

Maintain a lot of attribute variables, used to control the drawing color, brush thickness and other attributes, used to control the transmission of information and other operations.

In the main interface, JAVA Swing is used for GUI layout, making the interface simple and beautiful, and the operation logic is clear. The vector icon used in button construction comes from Alibaba's open source vector icon library IconsFront.

Multiple listeners are implemented to monitor the click of each button.

(8) Client class:

The initial construction of the client, the client's service start function StartClient, the function ClientRecive to receive the transmitted data, and the client's image sending function ClientImageSend.

(9) Server class:

The initial construction of the client and the StartServer function of the client are realized.

(10)SocketThread class:

The initial construction of the client, the client's service start function StartClient, the function ServerRecive receiving transmission data, and the client's image sending function ServerImageSend function are realized.

Design of Process

In the OpenGLApp class, the Main function is the entry to the program;

The OpenGLApp Graphic member variable can be initialized by calling the constructor of the OpenGLApp class from the Main function. After initialization, you can operate on it. You can instantiate some of the various Shape class objects and then use the Add method to add them to the Shape array of the Graphic class object for subsequent operations. You can call the paint method in the Main function to draw all the images, or you can call the change method in the Main function to update the object.

See codes and corresponding lab reports in the folder of each lab project.

You might also like...

A sideproject to learn more about object-oriented programming, design patterns and Java meanwhile studying an OOP-course.

MyBank Description A console application that simulates a bank with very simple functions. Potential story could be an employee using this application

Mar 23, 2022

The Java implementation of "A Survey of Trajectory Distance Measures and Performance Evaluation". VLDBJ 2020

The Java implementation of

A Survey of Trajectory Distance Measures and Performance Evaluation The Java implementation of the following paper: Han Su, Shuncheng Liu, Bolong Zhen

Oct 19, 2022

This repository contains source code examples to support my course Spring Data JPA and Hibernate Beginner to Guru

Spring Data JPA - Spring Data JPA This repository contains source code examples to support my course Spring Data JPA and Hibernate Beginner to Guru Co

Aug 24, 2022

Solution of all the lectures of "Programming In Java course" (CSE310)

Solution of all the lectures of "Programming In Java course" (CSE310)

May 18, 2022

A mod that delays your chat messages so that they are delayed in reports

A mod that delays your chat messages so that they are delayed in reports

A mod that delays your chat messages so that they are delayed in reports. Making it harder for Mojang to validate, and hopefully a temporary solution to Fabricated chat reports

Aug 16, 2022

Java-Programs---For-Practice is one of the Java Programming Practice Series By Shaikh Minhaj ( minhaj-313 ). This Series will help you to level up your Programming Skills. This Java Programs are very much helpful for Beginners.

Java-Programs---For-Practice is one of the Java Programming Practice Series By Shaikh Minhaj ( minhaj-313 ).  This Series will help you to level up your Programming Skills. This Java Programs are very much helpful for Beginners.

Java-Programs---For-Practice is one of the Java Programming Practice Series By Shaikh Minhaj ( minhaj-313 ). This Series will help you to level up your Programming Skills. This Java Programs are very much helpful for Beginners. If You Have any doubt or query you can ask me here or you can also ask me on My LinkedIn Profile

Nov 8, 2022

Source code of course - Building Real-Time REST APIs with Spring Boot

springboot-blog-rest-api Learn how to build real-time REST APIs with Spring Boot by building a complete Blog App. Source code of Popular Building Real

Jan 6, 2023

Source code of Spring boot + Apache Kafka Udemy Course

Spring Boot + Apache Kafka - The Quickstart Practical Guide- Udemy course Course link: https://www.udemy.com/course/spring-boot-and-apache-kafka/?refe

Dec 21, 2022

Object Oriented Programming Course - Fall Semester 2021

Object Oriented Programming Course (Fall Semester 2021) This repository will store the code we use during the lectures and the exercises sessions of t

Jul 10, 2022
Owner
Chase/Jiaxuan Cai
CQU_CS undergraduate Computational Biology, Deep Learning and Coding Theory
Chase/Jiaxuan Cai
Dynamic Reports using Jasper Reports

DynamicJasper DynamicJasper (DJ) is an API that hides the complexity of JasperReports, it helps developers to save time when designing simple/medium c

intive-FDV 218 Dec 28, 2022
This repo contains all the materials for placement as well as Practical lab codes for all subjects and notes. For students graduating in 2023

UEMK_PLACEMENT_2023 This repo contains all the materials for placement as well as Practical lab codes for all subjects and notes. For students graduat

Shambashib Majumdar 8 Mar 5, 2022
OBJECT ORIENTED PROGRAMING IN JAVA Coursera SPECIALIZATION by DUKE UNIVERSITY & UNIVERSITY OF CALIFORNIA, SAN DIEGO

COURSERA Object Oriented Programming in Java Object Oriented Programming in Java -> by Duke University & University of California, San Diego Java Prog

Farhan Sheth 6 Dec 29, 2022
CSL304: OOPM (Java) Lab [OOPM Lab]

OOPM-JAVA-LAB CSL304: OOPM LAB [SEMESTER III] Syllabus OOPM (JAVA) - Reference Books OOPM Lab 1D Array 2D Array Abstract Class Accept Input From User

AMEY THAKUR 8 Nov 8, 2022
Teaching repository for the undergraduate course in Operations Research at Technical University Munich.

Tutorial for Operations Research SS22 Konstantin Kuchenmeister Teaching repository for the undergraduate course in Operations Research at Technical Un

Konstantin Kuchenmeister 9 Aug 27, 2022
For Jack language. Most of codes were commented with their usage, which can be useful for beginner to realize the running principle of a compiler for object-oriented programming language.

Instructions: Download the Java source codes Store these codes into a local folder and open this folder Click the right key of mouse and click ‘Open i

gooooooood 1.1k Jan 5, 2023
Three Java projects assigned for the Introduction to Object-Oriented Programming (CMPE 160) course in the Spring 2021 semester.

CMPE160-projects Three Java projects assigned for the Introduction to Object-Oriented Programming (CMPE 160) course in the Spring 2021 semester. These

Aras Güngöre 21 Dec 6, 2022
SpringBlade 是一个由商业级项目升级优化而来的SpringCloud分布式微服务架构、SpringBoot单体式微服务架构并存的综合型项目,采用Java8 API重构了业务代码,完全遵循阿里巴巴编码规范。采用Spring Boot 2.4 、Spring Cloud 2020 、Mybatis 等核心技术,同时提供基于React和Vue的两个前端框架用于快速搭建企业级的SaaS多租户微服务平台。

SpringBlade微服务开发平台 采用前后端分离的模式,前端开源两个框架:Sword (基于 React、Ant Design)、Saber (基于 Vue、Element-UI) 后端采用SpringCloud全家桶,并同时对其基础组件做了高度的封装,单独开源出一个框架:BladeTool B

Chill 5.9k Jan 7, 2023
Source codes of book Java Concurrency In Practice, rebuild by maven.

Introduction Source codes of book: Java Concurrency In Practice(2011, Brain Goetz etc. jcip for short.), rebuild from https://jcip.net/ with maven. Mo

Sam Sune 2 Jun 9, 2022
循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

mrbird 24.8k Jan 6, 2023