Co-authored-by: Fastium <Fastium@users.noreply.github.com>
This commit is contained in:
parent
9d4c6ecc7d
commit
2f45a5a342
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -1,10 +1,18 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Launch CompleteBankController",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "bank.CompleteBankController",
|
||||||
|
"projectName": "Lab15_OOP_90898795",
|
||||||
|
"vmArgs": "-enableassertions"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "java",
|
"type": "java",
|
||||||
"name": "Launch BankController",
|
"name": "Launch BankController",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mainClass": "bank.BankController",
|
"mainClass": "bank.CompleteBankController",
|
||||||
"projectName": "Lab15_OOP_fc166bd2",
|
"projectName": "Lab15_OOP_fc166bd2",
|
||||||
"vmArgs": "-enableassertions"
|
"vmArgs": "-enableassertions"
|
||||||
},
|
},
|
||||||
@ -57,8 +65,7 @@
|
|||||||
"mainClass": "GUI.GUI1",
|
"mainClass": "GUI.GUI1",
|
||||||
"projectName": "Lab15_OOP_90898795",
|
"projectName": "Lab15_OOP_90898795",
|
||||||
"liveshare.allowGuestDebugControl": true
|
"liveshare.allowGuestDebugControl": true
|
||||||
},
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@ -5,5 +5,10 @@
|
|||||||
"lib/**/*.jar"
|
"lib/**/*.jar"
|
||||||
],
|
],
|
||||||
"liveshare.shareExternalFiles": false,
|
"liveshare.shareExternalFiles": false,
|
||||||
"liveshare.allowGuestDebugControl": true
|
"liveshare.allowGuestDebugControl": true,
|
||||||
|
"cSpell.words": [
|
||||||
|
"Jframe",
|
||||||
|
"Jlogo",
|
||||||
|
"Jname"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -35,17 +35,18 @@ public class BillGui extends JFrame{
|
|||||||
|
|
||||||
//Create the button for print the bill
|
//Create the button for print the bill
|
||||||
JButton buttonPrint = new JButton("Print");
|
JButton buttonPrint = new JButton("Print");
|
||||||
buttonPrint.addActionListener(new ButtonListenerBill(this) {
|
buttonPrint.addActionListener(new ButtonListenerBill() {
|
||||||
//TODO : describe the prozess to print and resize the bill
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
|
|
||||||
|
// Create a new printer Job
|
||||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
PrinterJob pj = PrinterJob.getPrinterJob();
|
||||||
pj.setJobName("Bill");
|
pj.setJobName("Bill");
|
||||||
|
|
||||||
|
// Create a printable element from a JPanel. This method is just a copy, it resize but isn't perfect.
|
||||||
|
// It's just a first test. Should be improved
|
||||||
|
// TODO : improve this method
|
||||||
Printable printable = new Printable() {
|
Printable printable = new Printable() {
|
||||||
public int print(Graphics pg, PageFormat pf, int pageNum){
|
public int print(Graphics pg, PageFormat pf, int pageNum){
|
||||||
if (pageNum > 0) return Printable.NO_SUCH_PAGE;
|
if (pageNum > 0) return Printable.NO_SUCH_PAGE;
|
||||||
@ -63,24 +64,29 @@ public class BillGui extends JFrame{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create and set a A4 paper
|
||||||
Paper paper = new Paper();
|
Paper paper = new Paper();
|
||||||
paper.setImageableArea(0, 0,2480,3508);
|
paper.setImageableArea(0, 0,2480,3508);
|
||||||
paper.setSize(2480,3508);
|
paper.setSize(2480,3508);
|
||||||
|
|
||||||
PageFormat format = new PageFormat();
|
PageFormat format = new PageFormat();
|
||||||
format.setPaper(paper);
|
format.setPaper(paper);
|
||||||
format.setOrientation(PageFormat.PORTRAIT);
|
format.setOrientation(PageFormat.PORTRAIT);
|
||||||
|
|
||||||
|
// Set all settings about the printing function
|
||||||
pj.setPrintable (printable, format);
|
pj.setPrintable (printable, format);
|
||||||
|
|
||||||
|
// Launch the printer dialog for printing.
|
||||||
if (pj.printDialog() == false) return;
|
if (pj.printDialog() == false) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pj.print();
|
pj.print();
|
||||||
} catch (PrinterException ex) {}
|
} catch (PrinterException ex) {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.add(buttonPrint);
|
this.add(buttonPrint);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -89,14 +95,6 @@ public class BillGui extends JFrame{
|
|||||||
* listener to detect the button to print the bill
|
* listener to detect the button to print the bill
|
||||||
*/
|
*/
|
||||||
class ButtonListenerBill implements ActionListener {
|
class ButtonListenerBill implements ActionListener {
|
||||||
JFrame Jf;
|
|
||||||
/**
|
|
||||||
* initialize the listener
|
|
||||||
* @param Jf //TODO : do we always use the JFrame ?
|
|
||||||
*/
|
|
||||||
ButtonListenerBill(JFrame Jf){
|
|
||||||
this.Jf = Jf;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e){};
|
public void actionPerformed(ActionEvent e){};
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ public class HesSoGarage {
|
|||||||
//Create a new garage
|
//Create a new garage
|
||||||
GarageManager garageManager = new GarageManager();
|
GarageManager garageManager = new GarageManager();
|
||||||
String name = "<html><body><i>Garage manager</i><br>Prestations</body></html>";
|
String name = "<html><body><i>Garage manager</i><br>Prestations</body></html>";
|
||||||
String logoFilePath = "src/logo_garage.png"; //TODO redimensionnement automatique
|
String logoFilePath = "src/logo_garage.png";
|
||||||
//Create a new HMI for calculate and print the bill
|
//Create a new HMI for calculate and print the bill
|
||||||
new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimensionnement
|
new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ public class ManagerGui extends JFrame {
|
|||||||
ImageIcon logo;
|
ImageIcon logo;
|
||||||
String buttonNameQuit = "Quit";
|
String buttonNameQuit = "Quit";
|
||||||
String buttonNameBill = "Show bill";
|
String buttonNameBill = "Show bill";
|
||||||
|
double ratio = 207.0 / 163.0;
|
||||||
|
|
||||||
|
|
||||||
Vector<Row> prestations = new Vector<>();
|
Vector<Row> prestations = new Vector<>();
|
||||||
@ -41,6 +42,10 @@ public class ManagerGui extends JFrame {
|
|||||||
Jlogo = new JLabel(logo);
|
Jlogo = new JLabel(logo);
|
||||||
Jname = new JLabel(name);
|
Jname = new JLabel(name);
|
||||||
this.add(Jname);
|
this.add(Jname);
|
||||||
|
|
||||||
|
//logo = new ImageIcon(new ImageIcon(logoFilePath).getImage().getScaledInstance(207, 163, Image.SCALE_DEFAULT));
|
||||||
|
//Jlogo = new JLabel(logo);
|
||||||
|
Jlogo = resize(Jname, logoFilePath);
|
||||||
this.add(Jlogo);
|
this.add(Jlogo);
|
||||||
|
|
||||||
//Create rows for prestations
|
//Create rows for prestations
|
||||||
@ -87,6 +92,18 @@ public class ManagerGui extends JFrame {
|
|||||||
|
|
||||||
this.add(buttonBill);
|
this.add(buttonBill);
|
||||||
this.add(buttonQuit);
|
this.add(buttonQuit);
|
||||||
|
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JLabel resize(JLabel Jlogo, String logoFilePath){
|
||||||
|
//TODO put in listener for resize when frame is resized.
|
||||||
|
int width = (int)Jlogo.getSize().getWidth();
|
||||||
|
int height = (int)Jlogo.getSize().getHeight();
|
||||||
|
height = height > 0 ? height:65;
|
||||||
|
System.out.println(width + "x"+ height);
|
||||||
|
ImageIcon logo = new ImageIcon(new ImageIcon(logoFilePath).getImage().getScaledInstance((int) (height*ratio), height, Image.SCALE_DEFAULT));
|
||||||
|
return new JLabel(logo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user