Java Doc Tiếng Việt
·
Java Doc English
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.
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à:
- Luôn Luôn Cập Nhật: Người dùng bắt buộc phải nâng cấp lên phiên bản mới nhất khi có bản phát hành mới. Các phiên bản cũ sẽ không được hỗ trợ hoặc bảo trì.
- Các bản cập nhật mới sẽ chứa các bản vá lỗi, cải tiến hiệu suất và tính năng mới nhất. Việc không cập nhật có thể dẫn đến các vấn đề bảo mật và hoạt động không ổn định.
- Chúng tôi không chịu trách nhiệm về bất kỳ sự cố nào xảy ra nếu bạn sử dụng phiên bản cũ. Để đảm bảo trải nghiệm tốt nhất, hãy luôn cập nhật lên phiên bản mới nhất.
English
Important: This project follows a Mandatory Update policy. This means:
- Always Stay Updated: Users are required to upgrade to the latest version upon each new release. Older versions will not be supported or maintained.
- New updates contain critical bug fixes, performance improvements, and the latest features. Failure to update may result in security vulnerabilities and unstable operation.
- We do not take responsibility for any issues that arise from using outdated versions. To ensure the best experience, always update to the latest version.
See details in project example / Xem chi tiết trong dự án mẫu
⚠️ Để 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 🫙
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
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
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
import anlavn.file.NativeLibrary;
NativeLibrary.load("path/YourLib.dll");
See more / Xem thêm ExampleNativeLibrary
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
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
The myProperties_EN.properties file
See more / Xem thêm ExampleProperties
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
import anlavn.file.Zip;
Zip.extract("myFileZip.zip", "ZipFolder"); //Extract myFileZip.zip to ZipFolder directory
See more / Xem thêm ExampleZip
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
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
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
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
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
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
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
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
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
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
⚠️ Tính năng này chỉ dành cho hệ điều hành Windows / This feature is only for Windows operating system ⚠️
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
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
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
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
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
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
//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
import anlavn.ui.ScrollBar;
yourJScrollPanel.setVerticalScrollBar(new ScrollBar());
See more / Xem thêm ExampleScrollBar
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
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
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
- AL-Library English Version
```xml
<dependency>
<groupId>io.github.AnLaVN</groupId>
<artifactId>AL-Library_EN</artifactId>
<version>6.70.10.2</version>
</dependency>