AL-Library

AnLa Java Library :)))


Java Doc Tiếng Việt  ·  Java Doc English

GitHub license JDK
YourGPT Face Detection Face Recognition



1. Overview / Tổng quan

Tiếng Việt

AL-Library là một dự án cá nhân. Về cơ bản, nó là một thư viện bao hàm nhiều thư viện khác giúp việc sử dụng dễ dàng hơn.

Thư viện cung cấp các phương thức để bạn có thể làm việc cơ bản trong Java như: hỗ trợ các Thành phần Swing, Băm mật mã học, dịch vụ gửi email SMTP, trò chuyện với AI bot, nhận diện khuôn mặt, nhận dạng khuôn mặt… và hơn thế nữa… Dành lời cảm ơn to lớn đến với Raven, người đàn ông tuyệt vời cùng các dự án Java Swing UI của anh ấy.

Nếu bạn gặp bất kì vấn đề gì hoặc có mong muốn gì, đừng ngần ngại mà hãy liên hệ tôi, tôi sẽ phản hồi sớm nhất có thể.

English

AL-Library is a personal project. It’s basically a library that includes many other libraries that make it easier to use.

The library provides methods for you to do basic work in Java such as: Swing Components support, Cryptographic Hashing, SMTP email service, chat with AI bot, face detection, face recognition… and more… Big thanks to Raven who great man with his Java Swing UI projects.

If you have any problems or have any wishes, do not hesitate to contact me, I will respond as soon as possible.

2 Update Policy / Chính Sách Cập Nhật

Tiếng Việt

Quan trọng: Dự án này tuân theo chính sách Cập Nhật Bắt Buộc. Điều này có nghĩa là:

3. Features / Tính năng

anlavn.ai - Cung cấp các thư viện liên quan đến AI / Provide AI related libraries
  1. YourGPT
anlavn.file - Cung cấp các thư viện liên quan đến tập tin / Provides file related libraries
  1. Excel
  2. Log
  3. NativeLibrary
  4. ObjectData
  5. Properties
  6. Raw
  7. Zip
anlavn.hash - Cung cấp các thư viện liên quan đến hàm băm mật mã học / Provides cryptographic hash function related libraries
  1. AES
  2. BCrypt
  3. MD5
  4. SHA256
anlavn.net - Cung cấp các thư viện liên quan đến Internet / Provide Internet related libraries
  1. DocNet
  2. Email
  3. License
  4. Network
  5. RandomORG
anlavn.opencv - Cung cấp các thư viện liên quan đến OpenCV / Provide OpenCV related libraries
  1. FaceDetection
  2. FaceRecognition
anlavn.ui - Cung cấp các thư viện liên quan đến UI / Provide UI related libraries
  1. AvatarPanel (Add to Palette from JAR)
  2. ChatBox (Add to Palette from JAR)
  3. ComboBox (Add to Palette from JAR)
  4. ImagePanel (Add to Palette from JAR)
  5. LiquidProgress (Add to Palette from JAR)
  6. Mode
  7. Notification
  8. ProgressBar (Add to Palette from JAR)
  9. ScrollBar
  10. DateChooser
  11. TimePicker
  12. JnaFileChooser
Java Doc
  1. English
  2. Tiếng Việt

4. Quick Guide / Hướng dẫn nhanh

See details in project example / Xem chi tiết trong dự án mẫu

API_KEY


4.1.1 YourGPT

⚠️ Để sử dụng phiên bản tuỳ chỉnh của LlaMa, vui lòng build thủ công / To use a custom version of LlaMa, please build manually ⚠️

🫙 Sử dụng tính năng này với tệp Jar / Use this feature with Jar files 🫙

image

import anlavn.ai.YourGPT;

YourGPT.API_KEY = "alk~XXX...XXX";          // Add api key to use
YourGPT.loadModule();                       // Load module default.
YourGPT.params.put("--host", "localhost");  // Run at localhost
YourGPT.params.put("--port", "3000");       // Run at port 3000
YourGPT.params.put("-ngl", "25");           // Number of GPU player - Allows offloading some layers to the GPU for computation
YourGPT.params.put("-c", "2048");           // Context size - Set the size of the prompt context
YourGPT.start();            // Start YGPT process with previous parameters.
Thread.sleep(60000);        // Wait 60s.
YourGPT.destroy();          // Forcibly destroy YGPT process.

See more / Xem thêm ExampleYourGPT, YGPT Client


4.2.1 Excel

import anlavn.file.Excel;
		
//Write
ArrayList<Object[]> myData = new ArrayList<>();         //declare array to store data to write to Excel file
myData.add(new Object[]{4, 68.11, "AnLaVN", true});     //add data
myData.add(new Object[]{3, 69.11, "AnLaVN", false});    //add data
Excel.WriteExcel("myExcel.xlsx", "mySheet", myData.iterator()); //convert to Iterator and write to Excel file
		
//Read
Iterator<Object[]> myExcel = Excel.ReadExcel("myExcel.xlsx", "mySheet");    //declare Iterator to store data from Excel file
while (myExcel.hasNext()) { //loop to take every row from Iterator
	Object[] row = myExcel.next();  //get row data
	System.out.println(row[0]+" | "+row[1]+" | "+row[2]+" | "+row[3]);  //print it
}

See more / Xem thêm ExampleExcel


4.2.2 Log

import anlavn.file.Log;

Log.add("Your text");   //write text to log file, will auto create as Logs folder.
System.out.println("File path: " + Log.getFilePath());  //print path of log file.
Log.closeFile();    //close file if your dont use anymore.

See more / Xem thêm ExampleLog


4.2.3 NativeLibrary

import anlavn.file.NativeLibrary;

NativeLibrary.load("path/YourLib.dll");

See more / Xem thêm ExampleNativeLibrary


4.2.4 ObjectData

import anlavn.file.ObjectData;

ObjectData.writeData("myFile.dat", new myObject("AnLaVN", 19)); //write new object to myFile.dat
myObject myobj = (myObject) ObjectData.readData("myFile.dat");  //read object from myFile.dat, store in myobj variable
System.out.println("My name: " + myobj.getName());  //print value of object
System.out.println("My age: " + myobj.getAge());

The myObject class.

import java.io.Serializable;
//Make sure your class have 'implements Serializable'
public class myObject implements Serializable{
	private String name;
	private int age;

	public myObject() {}
	public myObject(String name, int age) {
		this.name = name;
		this.age = age;
	}
	public String getName() {   return name;    }
	public int getAge()     {   return age;     }
}

See more / Xem thêm ExampleObjectData


4.2.5 Properties

import anlavn.file.Properties;

String lang = "EN"; //"VN" if you want using vietnamese languages, "EN" if you want english
Properties proper = new Properties("src/example/anlavn/file/myProperties_" + lang + ".properties");    //load properties file
System.out.println("Properties of hello key: " + proper.getString("hello"));    //print value of key in file

The myProperties_VN.properties file image
The myProperties_EN.properties file image
See more / Xem thêm ExampleProperties


4.2.6 Raw

import anlavn.file.Raw;

Raw raw = new Raw("myFile.txt");    //create myFile.txt
raw.writeData("your text"); //write data to file
System.out.println(raw.readData()); //read data from file
raw.closeFile();    //close file if you dont use anymore

See more / Xem thêm ExampleRaw


4.2.7 Zip

import anlavn.file.Zip;

Zip.extract("myFileZip.zip", "ZipFolder");  //Extract myFileZip.zip to ZipFolder directory

See more / Xem thêm ExampleZip


4.3.1 AES

import anlavn.hash.AES;

String 	orgStr = "This is original string.", //declare original string need to hash
	myKey  = "This is key to hash ",     //declare my security key to hash string
	hashStr= AES.encrypt(orgStr, myKey); //hash original string with security key
System.out.println("Hash AES of orgStr: " + hashStr);   //print hash string
System.out.println("My original string: " + AES.Decrypt(hashStr, myKey));   //decrypt hash string and print it

See more / Xem thêm ExampleAES


4.3.2 BCrypt

import anlavn.hash.BCrypt;

String orgStr = "This is original string.",               	//declare original string need to hash
      hashStr = BCrypt.encrypt(orgStr, BCrypt.genSalt());   //hash original string, only supports encryption.
System.out.println("Hash BCrypt of orgStr: " + hashStr);	//print hash string
System.out.println("is orgStr match: " + BCrypt.check(orgStr, hashStr));  //check if original string is match with hash string

See more / Xem thêm ExampleBCrypt


4.3.3 MD5

import anlavn.hash.MD5;
	
String	orgStr = "This is original string.", //declare original string need to hash
	hashStr= MD5.encrypt(orgStr); 		//hash original string, only supports encryption, decryption it is impossible.
System.out.println("Hash MD5 of orgStr: " + hashStr);   //print hash string

See more / Xem thêm ExampleMD5


4.3.4 SHA256

import anlavn.hash.SHA;
import anlavn.hash.SHA.Types;
	
String orgStr = "This is original string.", //declare original string need to hash
      hashStr = SHA.encrypt(Types.SHA_256, orgStr); //hash original string, only supports encryption, decryption it is impossible.
System.out.println("Hash SHA256 of orgStr: " + hashStr);   //print hash string

See more / Xem thêm ExampleSHA


4.4.1 DocNet

import anlavn.net.DocNet;

DocNet docnet = new DocNet("https://raw.githubusercontent.com/AnLaVN/AL-Library/Releases/LICENSE.md"); //set address of network document
System.out.println(docnet.readAllLine());   //read all line in network document
docnet.saveAs();    //save document to file in local

See more / Xem thêm ExampleDocNet


4.4.2 Email

import anlavn.net.Email;

Email mail = new Email("youremail@domain.com", "yourpass");  //setup your SMTP service
        
mail.setEmail("Tittle Email", "<h1>Chào cậu, đây là email gửi từ bình an</h1>");    //setup your email content
mail.addSetTO("yourfriend1@gmail.com", "yourfriend12@gmail.com");                   //setup set type TO
mail.addSetTO(new HashSet<>(Arrays.asList("yourfriend1@gmail.com", "yourfriend12@gmail.com")));
mail.addSetCC("yourfriend13@fpt.edu.vn");
mail.addSetAttachments("C:/path/to/your/file.png", "C:/path/to/your/meme.gif");
mail.sendEmail();

See more / Xem thêm ExampleEmail


4.4.3 License

import anlavn.net.License;

static { 
	// Check the license authority before run code. The program will continue if enough permissions. Else stop/delete the program.
    License.check("alk~1G3oYHyo2RMU/CDNbFA9HdvTFV0GUXZOydsoHcN8S7xNE08AvtsAwn8R1KN4Q6Dz");
}

Using License Generator tool to generate LicenseKey

See more / Xem thêm ExampleLicense


4.4.4 Network

import anlavn.net.Network;
import static anlavn.net.Network.Key.*;
	
System.out.println("My IPv4: " + Network.myIPv4());             //print my public ip, not local ip
System.out.println("My Wlan: " + Network.myWLAN().get(SSID));   //print wlan ssid name

See more / Xem thêm ExampleNetwork


4.4.5 RandomORG

import anlavn.net.RandomORG;
	
System.out.println(RandomORG.getInteger(0, 10, 10));            //get a truly random integer from 0 to 10 in decimal
System.out.println(RandomORG.getSequence(0, 10));               //get truly random order integer from 0 to 10
System.out.println(RandomORG.getString(10, true, true, true));  //get a truly random string with digit, upper, lower case and length equal 10
System.out.println(RandomORG.getQuota());                       //get number quota bits remaining of your IP address.

See more / Xem thêm ExampleRandomORG


4.5.1 FaceDetection

image

import anlavn.opencv.FaceDetection;

FaceDetection.API_KEY = "alk~XXX...XXX";    // Add api key to use
FaceDetection.loadModule();                 // Load module default
FaceDetection.setDetectPanel(myPanel, 20);  // Set JPanel where will display video capture from camera with rounded corners

FaceDetection.setDetector(true);  			// Detect face and display with green rectangle and thickness 2px
//FaceDetection.setDetector(false, Color.GREEN, 2); // Not detect face and not display any rectangle no matter what color and how thick it is 

FaceDetection.start(0);  					// Start face detection from camera 0
//FaceDetection.end();   					// End face detection

See more / Xem thêm ExampleFaceDetection


4.5.2 FaceRecognition

⚠️ Tính năng này chỉ dành cho hệ điều hành Windows / This feature is only for Windows operating system ⚠️

image

import anlavn.opencv.FaceRecognition;

FaceRecognition.API_KEY = "alk~XXX...XXX";// Add api key to use
FaceRecognition.loadModule();             // Load module default.
//set image for original face and test face using URL.
FaceRecognition.setImageOrginal("https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTNU14t4OtvdSZf-rTJAQWI6LdTIw5nYCYT1V3SfHgWja6cYMbG");
FaceRecognition.setImageTesting("https://nld.mediacdn.vn/2021/1/5/d9db633fe9c98429ec9025ca0950f241-16098228091571816318835.jpg");
//set a RequirementPercent for face recognition, the higher the stricter
FaceRecognition.setRequirementPercent(60.0);
//recognition and get result
FaceRecognition.Result result = FaceRecognition.recognition(); 
System.out.println(result.state);        // Get result state
System.out.println(result.percentMatch); // Fet percent match
System.out.println(result.isMatch);      // true if percentMatch higher or equal RequirementPercent

See more / Xem thêm ExampleFaceRecognition


4.6.1 AvatarPanel

import anlavn.ui.AvatarPanel;

AvatarPanel avatar = new AvatarPanel();
avatar.setPic("myImage.png"); //set picture for panel from file
avatar.setPic("https://i.pinimg.com/564x/b7/d2/62/b7d262d9ab6397f959a2030f65947b4f.jpg"); //set picture for panel from url

See more / Xem thêm ExampleAvatarPanel


4.6.2 ChatBox

import anlavn.ui.ChatBox;
	
ChatBox chat = new ChatBox();
chat.addRightBubble("this is right side text"); //add bubble text in right side
chat.addLeftBubble("this is left side text"); //add bubble text in left side
chat.addNotifiBox("this is notification text"); //add notification text in center

See more / Xem thêm ExampleChatBox


4.6.3 ComboBox

import anlavn.ui.ComboBox;

ComboBox comboBox = new ComboBox();
comboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "item 1", "item2" })); //use as normal combobox

See more / Xem thêm ExampleComboBox


4.6.4 ImagePanel

ImagePanel image = new ImagePanel(); image.setPic(“myImage.png”); //set picture for panel from file

See more / Xem thêm [ExampleImagePanel](https://github.com/AnLaVN/AL-Library/blob/Releases/AL-Library_Example/src/example/anlavn/ui/ExampleImagePanel.java)

---

### 4.6.5 LiquidProgress
- Lớp LiquidProgress hỗ trợ xuất thanh tiến trình dạng chất lỏng hiện đại.
- The LiquidProgress supports to export modern liquid progress.

``` java
import anlavn.ui.LiquidProgress;

LiquidProgress liquidProgress = new LiquidProgress();
liquidProgress1.setValue(50);

See more / Xem thêm ExampleLiquidProgress


4.6.6 Mode

import anlavn.ui.Mode;
	
Mode.setMode(true); //set true is dark mode, false is light
Mode.setModeComponent(yourComponent); //set the component will apply mode change

See more / Xem thêm ExampleMode


4.6.7 Notification

//setup the notification will popup Notification noti = new Notification(this, Notification.Type.WARNING, Notification.Location.TOP_CENTER, “Notification”); noti.showNotification(); //show popup Notification

See more / Xem thêm [ExampleNotification](https://github.com/AnLaVN/AL-Library/blob/Releases/AL-Library_Example/src/example/anlavn/ui/ExampleNotification.java)

---

### 4.6.8 ProgressBar
- Lớp ProgressBar hỗ trợ xuất thanh tiến trình hiện đại.
- The ProgressBar supports to export modern progress bar.

``` java
import anlavn.ui.ProgressBar;
	
ProgressBar progressBar1 = new ProgressBar();
progressBar1.setValue(50);

See more / Xem thêm ExampleProgressBar


4.6.9 ScrollBar

import anlavn.ui.ScrollBar;

yourJScrollPanel.setVerticalScrollBar(new ScrollBar());

See more / Xem thêm ExampleScrollBar


4.6.10 DateChooser

import anlavn.ui.datechooser.DateChooser;

DateChooser dateChooser = new DateChooser();
dateChooser.setReferenceLabel(yourLabel); //set JLabel where will display day was choose
dateChooser.showPopup();  //show day chooser as popup

See more / Xem thêm ExampleDateChooser


4.6.11 TimePicker

import anlavn.ui.timechooser.TimePicker;

TimePicker timePicker = new TimePicker();
timePicker.setDisplayTextLabel(yourLabel); //set JLabel where will display day was choose
//show time picker as popup as position
timePicker.showPopup(this,
	(getWidth() - timePicker.getPreferredSize().width) / 2,
	(getHeight() - timePicker.getPreferredSize().height) / 2);

See more / Xem thêm ExampleTimePicker


4.6.12 JnaFileChooser

import anlavn.ui.filechooser.JnaFileChooser;
	
JnaFileChooser SelectPic = new JnaFileChooser();
SelectPic.addFilter("Image", "jpeg", "jpg", "png"); //add file filter for file chooser
if(SelectPic.showOpenDialog(this)){ //if choose file
	System.out.println(SelectPic.getSelectedFile().getAbsolutePath());	//get absolute path of choose file
}

See more / Xem thêm ExampleJnaFileChooser


5. Download / Tải xuống

5.1 External JAR



5.2 Maven Central Repository



io.github.AnLaVN AL-Library_VN 6.70.10.2

- AL-Library English Version 
```xml
<dependency>
	<groupId>io.github.AnLaVN</groupId>
	<artifactId>AL-Library_EN</artifactId>
	<version>6.70.10.2</version>
</dependency>

5.4 Star History

Star History Chart