From 470044ff13f81a75c8fb261964b479b9f5708293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Thu, 19 May 2022 09:10:46 +0200 Subject: [PATCH] only ugly full screen --- .vscode/launch.json | 7 +++ bin/BillGUI/BillGui$1$1.class | Bin 0 -> 1714 bytes bin/BillGUI/BillGui$1.class | Bin 0 -> 1891 bytes bin/BillGUI/BillGui.class | Bin 1151 -> 1254 bytes bin/BillGUI/ButtonListenerBill.class | Bin 570 -> 570 bytes bin/BillGUI/HesSoGarage.class | Bin 863 -> 813 bytes bin/BillGUI/Impression1.class | Bin 1568 -> 0 bytes src/BillGUI/BillGui.java | 62 ++++++++++++++++++++++----- src/BillGUI/HesSoGarage.java | 3 +- src/BillGUI/Impression1.java | 47 -------------------- 10 files changed, 59 insertions(+), 60 deletions(-) create mode 100644 bin/BillGUI/BillGui$1$1.class create mode 100644 bin/BillGUI/BillGui$1.class delete mode 100644 bin/BillGUI/Impression1.class delete mode 100644 src/BillGUI/Impression1.java diff --git a/.vscode/launch.json b/.vscode/launch.json index 56147c4..bbb66eb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,12 @@ { "configurations": [ + { + "type": "java", + "name": "Launch HesSoGarage", + "request": "launch", + "mainClass": "BillGUI.HesSoGarage", + "projectName": "Lab15_OOP_90898795" + }, { "type": "java", "name": "Launch HesSoGarage", diff --git a/bin/BillGUI/BillGui$1$1.class b/bin/BillGUI/BillGui$1$1.class new file mode 100644 index 0000000000000000000000000000000000000000..b28fa7adc19c57fcf206def4e9e00ddcc20da993 GIT binary patch literal 1714 zcmZux>r&fB6#mvXVP#VY2^2R8NmDnq4T)kmG%cc}fVn6&;FbhJdX?q1En;MkB%srW z$RqR#@~1P@>9jMM{O;5A2|7KyI5yyDW>>rC?4JF;bNlDNzg`1)fae+_43`((W^?t4 zWvKswo6e{68e$A1d-kDiG;ObLY*zM!6KY5>Oem>+6dG;c^+Ka8XS>oA42iJe2I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0p z1KM#F-Msay2fd_m-pPxMiCZ*jlIQ$^Ya5f@H%@W$9K(C#XBgQ$hrM@(@fjm!baeFM zb}urgm`WLMo}Zj!ngZFGSSpq>PH`_4<2gThI~6;{(&Q;te}ZwsJO2w}Gw~C;+`|(* z!xrP$!OozA=LigpLQiuKCvuR~F=TNEv;5CtiTSQ$0bgK|+Bxd4U>~bdf^!i%PAx%) zQeV=Gfv4EPL#En;Z9Kv*{S8v@D|}7fEWPdFF|qxI-iOfoFF)fZgo$rW^qct3gl#eu z4 E0MG}zj{pDw literal 0 HcmV?d00001 diff --git a/bin/BillGUI/BillGui.class b/bin/BillGUI/BillGui.class index e03197504113e0d3cd518fdd29d14a30f8b0db62..eb0dd1b0782e200995c968aba1d4542db18d9b1e 100644 GIT binary patch delta 359 zcmZ9G%}&BV6otRGh)~f4@h2F6qG5q-D$!Jhg-8)B6kHLvmZTw7=z zsTo!#pUIDHZ9g7kPBx6jPg?gm_sYqXVlEw-a&SG7dzCZMDoN2rA}q=8lB8H>OLUJF za;##oPJuKQ8#rvzW}6#!=&;M3ctD*Y4N5{e`p@H>vQ&~RbreN7PDub2iL^N6LP9lx dtWo1qf;DV;tO}?huFHV=J1xtR6P1oh^9R;7K)L_` delta 255 zcmXAi%Syvw6okM0iN!>rYLQk^7lKl|iGuY~!Arf=)FL7jw`NgFB*tREcIO+o>5~+t zf(vo&gZLQgh?_YKXTF&)_h;1m{C;}}HaQ!3jw$D=Q5@Hrfgjv%U?F_OTf$~fYTtHF`sG0$YIT+X&xEa_P_<$^F22LQGfk6vm4ub-NB9Oi9rJZ+-njV delta 200 zcmZ3>cAt&w)W2Q(7#JAL8MHTYu`(%gQdOvAP~8oLC8l)*iT5*ie)#0c%-f*i}p4KN$u?nvc4OEYM2I}?4eS!=cd_X1(P*M|YycPiJ)gD3s diff --git a/bin/BillGUI/Impression1.class b/bin/BillGUI/Impression1.class deleted file mode 100644 index 10a72e271e58ad1da3422a38ff69b75a6b940565..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1568 zcmZux-%}e^7(F-Huw_}Gg%$`U1xl+)z{W;xmDDP20E3}Mp^WzJl3vnnH`&bY_Q&7h zn=j7z0C{@h5=WcxWRfFn!PS{q2Xf zQmx$$RTOza=cWxyVCt!SAzziEmtLn;+G)s+@@Xu#-zYvLa86G39B%P60q(Ek4b-uY9z5I<;qnD7cpbw zl0Y``zFpbHEan8pTPm)#$w%w)tw1_oFzNFyE}!y$=imZzF0NovU^EV8C-P;i*nPfQ zEgXzOVA;he90zHvxVVPv0_RNS4c`}-IZK?vfxu+l>!=6M+lMOL*F-qWdeD^qfebzU z?i;Q6i5Cf6s-Lj|oPlUjj)B%EdeD>V9tm6?xZW0nAy$_n5QF1Lx5|%ol|;J}q;i#k z<9o4eKHHVuKB-A*7N()XBaT!tb8)E6;hoyl`&B6%IJkw6ZQMR%JiS5h1cxp@!Fq2z zjl{@h%@+o=`duXMiUz*p;#1t^+D0linLRyoL!5^4w6o9Xa~B)9CopE*RZsc>_2fQ0 z(y&z*W7srr&P!0Kg#nS%O)~IlaCnyH1GXGX@QhfGZ0rimCu*NU6BxPUb-b8e&Gy>( z|Cih}kjB?89%zb!vv&4^=V4QAd3u-55B*Tw&}Fd9O-&<(3~b(@SC(g*_c6G%kMm{m zHG%WIeb2ZI|F7hJM8K|Dx~$<-P{jwdAa{HGV9hG#!it&mOZ7R30`6Ez#>7H*#9!^R~d1Q zG1o~kZ%7vDC2m4;0bAH6l7%^Zfg0;h@Uw$2iK(g0BK0pzSX9+U-Nr3W!^Q+pj^?XA w-7Ti+?wsOpXcSj}#nKzTQihZ!2P$Dvi&5&Jm73{ACnOwv!*OZMJ(IWpA7`&%mH+?% diff --git a/src/BillGUI/BillGui.java b/src/BillGUI/BillGui.java index d9bc9ae..d7e3b3d 100644 --- a/src/BillGUI/BillGui.java +++ b/src/BillGUI/BillGui.java @@ -3,6 +3,8 @@ package BillGUI; import java.awt.*; import java.awt.event.*; import javax.swing.*; +import java.awt.print.*; +import java.awt.image.BufferedImage; public class BillGui extends JFrame{ String bill; @@ -26,18 +28,52 @@ public class BillGui extends JFrame{ this.add(jP); JButton buttonPrint = new JButton("Print"); - buttonPrint.addActionListener(new Impression1(jP)); - /* + buttonPrint.addActionListener( + new ButtonListenerBill(this) { @Override public void actionPerformed(ActionEvent e){ - // TO-DO : print the pdf - }; - });*/ + + PrinterJob pj = PrinterJob.getPrinterJob(); + pj.setJobName("Bill"); + + Printable printable = new Printable() { + public int print(Graphics pg, PageFormat pf, int pageNum){ + if (pageNum > 0) return Printable.NO_SUCH_PAGE; + + Dimension size = jP.getSize(); + BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); + + jP.print(bufferedImage.getGraphics()); + + Graphics2D g2 = (Graphics2D) pg; + g2.translate(pf.getImageableX(), pf.getImageableY()); + g2.drawImage(bufferedImage, 0, 0, (int) pf.getWidth(), (int) pf.getHeight(), null); + + return Printable.PAGE_EXISTS; + } + }; + + Paper paper = new Paper(); + paper.setImageableArea(0, 0,2480,3508); + paper.setSize(2480,3508); + + PageFormat format = new PageFormat(); + format.setPaper(paper); + format.setOrientation(PageFormat.PORTRAIT); + + pj.setPrintable (printable, format); + + if (pj.printDialog() == false) return; + + try { + pj.print(); + } catch (PrinterException ex) {} + } + }); this.add(buttonPrint); - - } + } /** @@ -51,8 +87,12 @@ class ButtonListenerBill implements ActionListener { } @Override - public void actionPerformed(ActionEvent e){ - - }; - + public void actionPerformed(ActionEvent e){ }; } + + + + + + + diff --git a/src/BillGUI/HesSoGarage.java b/src/BillGUI/HesSoGarage.java index 4721167..ca1569d 100644 --- a/src/BillGUI/HesSoGarage.java +++ b/src/BillGUI/HesSoGarage.java @@ -3,10 +3,9 @@ package BillGUI; public class HesSoGarage { public static void main(String[] args) { GarageManager garageManager = new GarageManager(); - ManagerGui managerGui; String name = "\033[3mGarage manager\033[0m\nPrestations"; //TODO résoudre en italique String logoFilePath = "src/logo_garage.png"; //TODO redimensionnement automatique - managerGui = new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimmensionnement + new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimensionnement } } diff --git a/src/BillGUI/Impression1.java b/src/BillGUI/Impression1.java deleted file mode 100644 index 770ad96..0000000 --- a/src/BillGUI/Impression1.java +++ /dev/null @@ -1,47 +0,0 @@ -package BillGUI; -//TODO all - -import java.awt.*; -import java.awt.event.*; -import java.awt.print.*; -import javax.swing.*; - - -public class Impression1 extends JPanel implements Printable, ActionListener{ - - /** **/ - -JPanel frameToPrint; - - public int print(Graphics g, PageFormat pf, int page) throws PrinterException { - - if (page > 0) { - return NO_SUCH_PAGE; - } - - Graphics2D g2d = (Graphics2D) g; - g2d.translate(pf.getImageableX(), pf.getImageableY()); - - frameToPrint.printAll(g); - - return PAGE_EXISTS; - } - - public void actionPerformed(ActionEvent e) { - PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(this); - boolean ok = job.printDialog(); - if (ok) { - try { - job.print(); - } catch (PrinterException ex) { - } - } - } - - public Impression1(JPanel f) { - frameToPrint = f; - } - - } -