mirror of
https://github.com/tiennm99/BSK-All-in-One-Clinic-Management-System.git
synced 2026-10-14 06:17:18 +00:00
[add] invoice med content, test side bar animation
This commit is contained in:
1 parent
ecc839f0c7
commit
be52882bbb
6 files changed
+179
-12
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -130,6 +130,8 @@ public class CheckUpPage extends JPanel {
|
||||
sidebar.add(label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Make the sidebar scrollable
|
||||
JScrollPane sidebarScrollPane = new JScrollPane(sidebar);
|
||||
sidebarScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
+55
-12
@@ -2,9 +2,12 @@ package BsK.client.ui.component.CheckUpPage.PrintDialog;
|
||||
|
||||
import com.itextpdf.io.image.ImageData;
|
||||
import com.itextpdf.io.image.ImageDataFactory;
|
||||
import com.itextpdf.kernel.font.PdfFont;
|
||||
import com.itextpdf.kernel.font.PdfFontFactory;
|
||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
||||
import com.itextpdf.layout.Document;
|
||||
import com.itextpdf.layout.borders.Border;
|
||||
import com.itextpdf.layout.element.*;
|
||||
import com.itextpdf.layout.element.Image;
|
||||
import com.itextpdf.layout.property.UnitValue;
|
||||
@@ -108,22 +111,64 @@ public class MedicalInvoiceWithGUI {
|
||||
PdfDocument pdfDoc = new PdfDocument(writer);
|
||||
Document document = new Document(pdfDoc);
|
||||
|
||||
|
||||
String boldFontPath = "src/main/java/BsK/client/ui/assets/font/SVN-Arial Bold.ttf"; // Update with your font path
|
||||
PdfFont boldFont = PdfFontFactory.createFont(boldFontPath, "Identity-H", true);
|
||||
|
||||
String fontPath = "src/main/java/BsK/client/ui/assets/font/SVN-Arial Regular.ttf"; // Update with your font path
|
||||
PdfFont font = PdfFontFactory.createFont(fontPath, "Identity-H", true);
|
||||
|
||||
// Add logo
|
||||
String logoPath = "/Users/lethanhdat/Documents/GitHub/ldS_BsK/src/main/java/BsK/client/ui/assets/icon/add.png"; // Path to your logo
|
||||
ImageData imageData = ImageDataFactory.create(logoPath);
|
||||
Image logo = new Image(imageData).scaleToFit(100, 100);
|
||||
Image logo = new Image(imageData).scaleToFit(75, 75);
|
||||
logo.setFixedPosition(50, 750);
|
||||
document.add(logo);
|
||||
|
||||
// Add clinic information
|
||||
String clinicInfo = "Your Clinic Name\n123 Clinic Street\nCity, State, ZIP\nPhone: (123) 456-7890\nEmail: clinic@example.com";
|
||||
Paragraph clinicInfoParagraph = new Paragraph(clinicInfo).setTextAlignment(com.itextpdf.layout.property.TextAlignment.RIGHT);
|
||||
String clinicInfo = "Phòng khám BSK\nĐức Hòa Long An\nPhone: (123) 456-7890\nNgày khám: 30 tháng 2 năm 2025\n\n";
|
||||
Paragraph clinicInfoParagraph = new Paragraph(clinicInfo)
|
||||
.setTextAlignment(com.itextpdf.layout.property.TextAlignment.RIGHT)
|
||||
.setFont(font);
|
||||
document.add(clinicInfoParagraph);
|
||||
|
||||
// Add patient and doctor names
|
||||
String patientDoctorInfo = "Patient: John Doe\nDoctor: Dr. Jane Smith";
|
||||
Paragraph patientDoctorParagraph = new Paragraph(patientDoctorInfo);
|
||||
document.add(patientDoctorParagraph);
|
||||
// Add title
|
||||
String title = "Toa thuốc\n\n";
|
||||
Paragraph titleParagraph = new Paragraph(title)
|
||||
.setFontSize(24).setFont(boldFont)
|
||||
.setTextAlignment(com.itextpdf.layout.property.TextAlignment.CENTER);
|
||||
document.add(titleParagraph);
|
||||
|
||||
// Create a table with 2 columns, each taking 50% of the width
|
||||
Table patientDoctorTable = new Table(UnitValue.createPercentArray(new float[]{50, 50}))
|
||||
.setWidth(UnitValue.createPercentValue(100));
|
||||
|
||||
// Add patient and doctor information in the first column (left-aligned)
|
||||
Cell patientDoctorCell = new Cell()
|
||||
.add(new Paragraph("Họ tên bệnh nhân: Lê Nguyễn A\nSố điện thoại: 0123456789\n" +
|
||||
"Địa chỉ: 123 Patient Street"))
|
||||
.setTextAlignment(com.itextpdf.layout.property.TextAlignment.LEFT)
|
||||
.setBorder(Border.NO_BORDER)
|
||||
.setFont(font);
|
||||
patientDoctorTable.addCell(patientDoctorCell);
|
||||
|
||||
// Add date and invoice information in the second column (right-aligned)
|
||||
Cell moreInfoCell = new Cell()
|
||||
.add(new Paragraph("Phái: Nam\nTuổi: 25\nNgày sinh: 01/01/2000\n" +
|
||||
"Bác sĩ: Nguyễn Văn B"))
|
||||
.setTextAlignment(com.itextpdf.layout.property.TextAlignment.LEFT)
|
||||
.setBorder(Border.NO_BORDER)
|
||||
.setFont(font);
|
||||
patientDoctorTable.addCell(moreInfoCell);
|
||||
|
||||
// Add the table to the document
|
||||
document.add(patientDoctorTable);
|
||||
|
||||
// Diagnosis and notes
|
||||
String diagnosisNotes = "Chẩn đoán: Cảm cúm\nGhi chú: Nghỉ ngơi và uống nhiều nước";
|
||||
Paragraph diagnosisNotesParagraph = new Paragraph(diagnosisNotes).setFont(font);
|
||||
document.add(diagnosisNotesParagraph);
|
||||
|
||||
|
||||
// Add services and medicine table
|
||||
Table table = new Table(UnitValue.createPercentArray(new float[]{4, 2, 2}))
|
||||
@@ -139,13 +184,11 @@ public class MedicalInvoiceWithGUI {
|
||||
table.addCell("$10");
|
||||
document.add(table);
|
||||
|
||||
// Add diagnosis and notes
|
||||
String diagnosisNotes = "Diagnosis: Flu\nNotes: Rest and hydration recommended";
|
||||
Paragraph diagnosisNotesParagraph = new Paragraph(diagnosisNotes);
|
||||
document.add(diagnosisNotesParagraph);
|
||||
|
||||
// Add signature area
|
||||
Paragraph signatureArea = new Paragraph("\n\n\nSignature: ________________________");
|
||||
Paragraph signatureArea = new Paragraph("\n\n\nChữ Ký: ________________________")
|
||||
.setFont(font)
|
||||
.setTextAlignment(com.itextpdf.layout.property.TextAlignment.RIGHT);
|
||||
document.add(signatureArea);
|
||||
|
||||
document.close();
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package BsK.client.ui.component.CheckUpPage;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class SidebarAnimationDemo {
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
JFrame frame = new JFrame("Sidebar Animation");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(800, 500);
|
||||
frame.setLayout(new BorderLayout());
|
||||
|
||||
// Sidebar with gradient
|
||||
JPanel sidebar = new JPanel() {
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
Color color1 = new Color(63, 81, 181);
|
||||
Color color2 = new Color(33, 150, 243);
|
||||
GradientPaint gp = new GradientPaint(0, 0, color1, 0, height, color2);
|
||||
g2d.setPaint(gp);
|
||||
g2d.fillRect(0, 0, width, height);
|
||||
}
|
||||
};
|
||||
sidebar.setLayout(new GridLayout(15, 1));
|
||||
sidebar.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||
sidebar.setPreferredSize(new Dimension(0, 500)); // Initially hidden
|
||||
|
||||
// Sidebar items
|
||||
String[] sidebarItems = {"Thống kê", "Thăm khám", "Dữ liệu bệnh nhân", "Kho", "Người dùng", "Thông tin"};
|
||||
String[] destination = {"DashboardPage", "CheckUpPage", "PatientDataPage", "InventoryPage", "UserPage", "InfoPage"};
|
||||
for (int i = 0; i < sidebarItems.length; i++) {
|
||||
String item = sidebarItems[i];
|
||||
String dest = destination[i];
|
||||
JLabel label = new JLabel(item);
|
||||
label.setForeground(Color.WHITE);
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
label.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
|
||||
// Add hover and click effects
|
||||
label.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(java.awt.event.MouseEvent e) {
|
||||
System.out.println("Navigating to: " + dest);
|
||||
// mainFrame.showPage(dest); // Example navigation call
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(java.awt.event.MouseEvent e) {
|
||||
label.setForeground(new Color(200, 230, 255)); // Highlight on hover
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(java.awt.event.MouseEvent e) {
|
||||
label.setForeground(Color.WHITE); // Restore original color
|
||||
}
|
||||
});
|
||||
|
||||
sidebar.add(label);
|
||||
}
|
||||
|
||||
frame.add(sidebar, BorderLayout.WEST);
|
||||
|
||||
// Main content with toggle button
|
||||
JPanel mainContent = new JPanel(new BorderLayout());
|
||||
JLabel contentLabel = new JLabel("Main Content Area");
|
||||
contentLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
mainContent.add(contentLabel, BorderLayout.CENTER);
|
||||
|
||||
JButton toggleButton = new JButton("Toggle Sidebar");
|
||||
mainContent.add(toggleButton, BorderLayout.SOUTH);
|
||||
|
||||
frame.add(mainContent, BorderLayout.CENTER);
|
||||
|
||||
// Sidebar animation variables
|
||||
boolean[] isSidebarOpen = {false}; // Track the sidebar state
|
||||
|
||||
// Toggle button action
|
||||
toggleButton.addActionListener(e -> {
|
||||
new Timer(10, event -> {
|
||||
int currentWidth = sidebar.getWidth();
|
||||
if (!isSidebarOpen[0]) {
|
||||
if (currentWidth < 200) { // Expand to target width
|
||||
sidebar.setPreferredSize(new Dimension(currentWidth + 10, 500));
|
||||
sidebar.revalidate();
|
||||
} else {
|
||||
isSidebarOpen[0] = true;
|
||||
((Timer) event.getSource()).stop();
|
||||
}
|
||||
} else {
|
||||
if (currentWidth > 0) { // Retract to hidden
|
||||
sidebar.setPreferredSize(new Dimension(currentWidth - 10, 500));
|
||||
sidebar.revalidate();
|
||||
} else {
|
||||
isSidebarOpen[0] = false;
|
||||
((Timer) event.getSource()).stop();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
|
||||
frame.setVisible(true);
|
||||
|
||||
// Animate sidebar on startup
|
||||
Timer timer = new Timer(10, event -> {
|
||||
int currentWidth = sidebar.getWidth();
|
||||
if (currentWidth < 200) { // Target width
|
||||
sidebar.setPreferredSize(new Dimension(currentWidth + 10, 500));
|
||||
sidebar.revalidate();
|
||||
} else {
|
||||
((Timer) event.getSource()).stop(); // Stop animation
|
||||
}
|
||||
});
|
||||
timer.start();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user