Fixes issue 9792: The font size in the preview receipt of the edit sales panel is too small
authorAdrián Romero <adrianromero@openbravo.com>
Tue, 07 Jul 2009 10:36:13 +0200
changeset 488 d26c49c62434
parent 487 f62e4ef02806
child 489 19b2a548717c
Fixes issue 9792: The font size in the preview receipt of the edit sales panel is too small
src-pos/com/openbravo/pos/printer/printer/DevicePrinterPrinter.java
src-pos/com/openbravo/pos/printer/screen/DevicePrinterPanel.java
src-pos/com/openbravo/pos/printer/ticket/BasicTicket.java
src-pos/com/openbravo/pos/printer/ticket/BasicTicketForPrinter.java
src-pos/com/openbravo/pos/printer/ticket/BasicTicketForScreen.java
--- a/src-pos/com/openbravo/pos/printer/printer/DevicePrinterPrinter.java	Mon Jun 15 15:40:02 2009 +0200
+++ b/src-pos/com/openbravo/pos/printer/printer/DevicePrinterPrinter.java	Tue Jul 07 10:36:13 2009 +0200
@@ -26,6 +26,7 @@
 import java.awt.image.BufferedImage;
 import javax.swing.JComponent;
 import com.openbravo.pos.printer.DevicePrinter;
+import com.openbravo.pos.printer.ticket.BasicTicket;
 import com.openbravo.pos.printer.ticket.BasicTicketForPrinter;
 import com.openbravo.pos.util.ReportUtils;
 import com.openbravo.pos.util.SelectPrinter;
@@ -64,7 +65,7 @@
     /*name of a printer*/
     private String m_sName;
     /*a ticket to print*/
-    private BasicTicketForPrinter m_ticketcurrent;
+    private BasicTicket m_ticketcurrent;
     /*system printer*/
     private PrintService printservice;
 
--- a/src-pos/com/openbravo/pos/printer/screen/DevicePrinterPanel.java	Mon Jun 15 15:40:02 2009 +0200
+++ b/src-pos/com/openbravo/pos/printer/screen/DevicePrinterPanel.java	Tue Jul 07 10:36:13 2009 +0200
@@ -25,6 +25,7 @@
 import com.openbravo.pos.printer.*;
 import com.openbravo.pos.forms.AppLocal;
 import com.openbravo.pos.printer.ticket.BasicTicket;
+import com.openbravo.pos.printer.ticket.BasicTicketForScreen;
 
 public class DevicePrinterPanel extends javax.swing.JPanel implements DevicePrinter {
     
@@ -62,7 +63,7 @@
     
     // INTERFAZ PRINTER 2
     public void beginReceipt() {
-        m_ticketcurrent = new BasicTicket();
+        m_ticketcurrent = new BasicTicketForScreen();
     }
     public void printImage(BufferedImage image) {
         m_ticketcurrent.printImage(image);
--- a/src-pos/com/openbravo/pos/printer/ticket/BasicTicket.java	Mon Jun 15 15:40:02 2009 +0200
+++ b/src-pos/com/openbravo/pos/printer/ticket/BasicTicket.java	Tue Jul 07 10:36:13 2009 +0200
@@ -1,100 +1,95 @@
-//    Openbravo POS is a point of sales application designed for touch screens.
-//    Copyright (C) 2007-2009 Openbravo, S.L.
-//    http://www.openbravo.com/product/pos
-//
-//    This file is part of Openbravo POS.
-//
-//    Openbravo POS is free software: you can redistribute it and/or modify
-//    it under the terms of the GNU General Public License as published by
-//    the Free Software Foundation, either version 3 of the License, or
-//    (at your option) any later version.
-//
-//    Openbravo POS is distributed in the hope that it will be useful,
-//    but WITHOUT ANY WARRANTY; without even the implied warranty of
-//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//    GNU General Public License for more details.
-//
-//    You should have received a copy of the GNU General Public License
-//    along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.
-
-package com.openbravo.pos.printer.ticket;
-
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-
-public class BasicTicket implements PrintItem {
-
-    protected static Font BASEFONT;
-    protected static int FONTHEIGHT;
-    protected static double IMAGE_SCALE;
-
-    protected java.util.List<PrintItem> m_aCommands;
-    protected PrintItemLine pil;
-    protected int m_iBodyHeight;
-
-    static {
-        BASEFONT = new Font("Monospaced", Font.PLAIN, 12).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
-        FONTHEIGHT = 20;
-        IMAGE_SCALE = 1.0;
-    }
-
-    /** Creates a new instance of AbstractTicket */
-    public BasicTicket() {
-        m_aCommands = new ArrayList<PrintItem>();
-        pil = null;
-        m_iBodyHeight = 0;
-    }
-
-    public int getHeight() {
-        return m_iBodyHeight;
-    }
-
-    public void draw(Graphics2D g2d, int x, int y, int width) {
-
-        int currenty = y;
-        for (PrintItem pi : m_aCommands) {
-            pi.draw(g2d, x, currenty, width);
-            currenty += pi.getHeight();
-        }
-    }
-
-    public java.util.List<PrintItem> getCommands() {
-        return m_aCommands;
-    }
-
-    // INTERFAZ PRINTER 2
-    public void printImage(BufferedImage image) {
-
-        PrintItem pi = new PrintItemImage(image, IMAGE_SCALE);
-        m_aCommands.add(pi);
-        m_iBodyHeight += pi.getHeight();
-    }
-
-    public void printBarCode(String type, String position, String code) {
-
-        PrintItem pi = new PrintItemBarcode(type, position, code, IMAGE_SCALE);
-        m_aCommands.add(pi);
-        m_iBodyHeight += pi.getHeight();
-    }
-
-    public void beginLine(int iTextSize) {
-        pil = new PrintItemLine(iTextSize, BASEFONT, FONTHEIGHT);
-    }
-
-    public void printText(int iStyle, String sText) {
-        if (pil != null) {
-            pil.addText(iStyle, sText);
-        }
-    }
-
-    public void endLine() {
-        if (pil != null) {
-            m_aCommands.add(pil);
-            m_iBodyHeight += pil.getHeight();
-            pil = null;
-        }
-    }
-}
+//    Openbravo POS is a point of sales application designed for touch screens.
+//    Copyright (C) 2007-2009 Openbravo, S.L.
+//    http://www.openbravo.com/product/pos
+//
+//    This file is part of Openbravo POS.
+//
+//    Openbravo POS is free software: you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation, either version 3 of the License, or
+//    (at your option) any later version.
+//
+//    Openbravo POS is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//    GNU General Public License for more details.
+//
+//    You should have received a copy of the GNU General Public License
+//    along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.
+
+package com.openbravo.pos.printer.ticket;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+
+public abstract class BasicTicket implements PrintItem {
+
+    protected java.util.List<PrintItem> m_aCommands;
+    protected PrintItemLine pil;
+    protected int m_iBodyHeight;
+
+    /** Creates a new instance of AbstractTicket */
+    public BasicTicket() {
+        m_aCommands = new ArrayList<PrintItem>();
+        pil = null;
+        m_iBodyHeight = 0;
+    }
+
+    protected abstract Font getBaseFont();
+
+    protected abstract int getFontHeight();
+
+    protected abstract double getImageScale();
+
+    public int getHeight() {
+        return m_iBodyHeight;
+    }
+
+    public void draw(Graphics2D g2d, int x, int y, int width) {
+
+        int currenty = y;
+        for (PrintItem pi : m_aCommands) {
+            pi.draw(g2d, x, currenty, width);
+            currenty += pi.getHeight();
+        }
+    }
+
+    public java.util.List<PrintItem> getCommands() {
+        return m_aCommands;
+    }
+
+    // INTERFAZ PRINTER 2
+    public void printImage(BufferedImage image) {
+
+        PrintItem pi = new PrintItemImage(image, getImageScale());
+        m_aCommands.add(pi);
+        m_iBodyHeight += pi.getHeight();
+    }
+
+    public void printBarCode(String type, String position, String code) {
+
+        PrintItem pi = new PrintItemBarcode(type, position, code, getImageScale());
+        m_aCommands.add(pi);
+        m_iBodyHeight += pi.getHeight();
+    }
+
+    public void beginLine(int iTextSize) {
+        pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight());
+    }
+
+    public void printText(int iStyle, String sText) {
+        if (pil != null) {
+            pil.addText(iStyle, sText);
+        }
+    }
+
+    public void endLine() {
+        if (pil != null) {
+            m_aCommands.add(pil);
+            m_iBodyHeight += pil.getHeight();
+            pil = null;
+        }
+    }
+}
--- a/src-pos/com/openbravo/pos/printer/ticket/BasicTicketForPrinter.java	Mon Jun 15 15:40:02 2009 +0200
+++ b/src-pos/com/openbravo/pos/printer/ticket/BasicTicketForPrinter.java	Tue Jul 07 10:36:13 2009 +0200
@@ -25,14 +25,28 @@
 /**
  *
  * @author jaroslawwozniak
+ * @author adrianromero
  */
 public class BasicTicketForPrinter extends BasicTicket {
 
-    static {
-//        BASEFONT = new Font("Monospaced", Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.50));
-//        FONTHEIGHT = 14;
-        BASEFONT = new Font("Monospaced", Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
-        FONTHEIGHT = 12;
-        IMAGE_SCALE = 0.65;
+//        private static BASEFONT = new Font("Monospaced", Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.50));
+//        private static int FONTHEIGHT = 14;
+        private static Font BASEFONT = new Font("Monospaced", Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
+        private static int FONTHEIGHT = 12;
+        private static double IMAGE_SCALE = 0.65;
+
+    @Override
+    protected Font getBaseFont() {
+        return BASEFONT;
+    }
+
+    @Override
+    protected int getFontHeight() {
+        return FONTHEIGHT;
+    }
+
+    @Override
+    protected double getImageScale() {
+        return IMAGE_SCALE;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-pos/com/openbravo/pos/printer/ticket/BasicTicketForScreen.java	Tue Jul 07 10:36:13 2009 +0200
@@ -0,0 +1,45 @@
+//    Openbravo POS is a point of sales application designed for touch screens.
+//    Copyright (C) 2007-2009 Openbravo, S.L.
+//    http://www.openbravo.com/product/pos
+//
+//    This file is part of Openbravo POS.
+//
+//    Openbravo POS is free software: you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation, either version 3 of the License, or
+//    (at your option) any later version.
+//
+//    Openbravo POS is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//    GNU General Public License for more details.
+//
+//    You should have received a copy of the GNU General Public License
+//    along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.
+
+package com.openbravo.pos.printer.ticket;
+
+import java.awt.Font;
+import java.awt.geom.AffineTransform;
+
+public class BasicTicketForScreen extends BasicTicket {
+
+    private static Font BASEFONT = new Font("Monospaced", Font.PLAIN, 12).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
+    private static int FONTHEIGHT = 20;
+    private static double IMAGE_SCALE = 1.0;
+
+    @Override
+    protected Font getBaseFont() {
+        return BASEFONT;
+    }
+
+    @Override
+    protected int getFontHeight() {
+        return FONTHEIGHT;
+    }
+
+    @Override
+    protected double getImageScale() {
+        return IMAGE_SCALE;
+    }
+}