5.0 Source Code
Committing 5.0 Source Code
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public abstract class BaseAnimator implements DisplayAnimator {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String baseLine1;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String baseLine2;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String currentLine1;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String currentLine2;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BaseAnimator() {
|
||||
baseLine1 = null;
|
||||
baseLine2 = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param line1
|
||||
* @param line2
|
||||
*/
|
||||
public BaseAnimator(String line1, String line2) {
|
||||
baseLine1 = line1;
|
||||
baseLine2 = line2;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getLine1() {
|
||||
return currentLine1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getLine2() {
|
||||
return currentLine2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class BlinkAnimator extends BaseAnimator {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param line1
|
||||
* @param line2
|
||||
*/
|
||||
public BlinkAnimator(String line1, String line2) {
|
||||
baseLine1 = DeviceTicket.alignLeft(line1, 20);
|
||||
baseLine2 = DeviceTicket.alignLeft(line2, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
@Override
|
||||
public void setTiming(int i) {
|
||||
|
||||
if ((i % 10) < 5) {
|
||||
currentLine1 = "";
|
||||
currentLine2 = "";
|
||||
} else {
|
||||
currentLine1 = baseLine1;
|
||||
currentLine2 = baseLine2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class CurtainAnimator extends BaseAnimator {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param line1
|
||||
* @param line2
|
||||
*/
|
||||
public CurtainAnimator(String line1, String line2) {
|
||||
baseLine1 = DeviceTicket.alignLeft(line1, 20);
|
||||
baseLine2 = DeviceTicket.alignLeft(line2, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
@Override
|
||||
public void setTiming(int i) {
|
||||
|
||||
int j = i / 2;
|
||||
|
||||
if (j < 10) {
|
||||
currentLine1 = DeviceTicket.alignCenter(baseLine1.substring(10 - j, 10 + j), 20);
|
||||
currentLine2 = DeviceTicket.alignCenter(baseLine2.substring(10 - j, 10 + j), 20);
|
||||
} else {
|
||||
currentLine1 = baseLine1;
|
||||
currentLine2 = baseLine2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface DeviceDisplay {
|
||||
|
||||
// INTERFAZ DESCRIPCION
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDisplayDescription();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JComponent getDisplayComponent();
|
||||
|
||||
// INTERFAZ VISOR
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
public void writeVisor(int animation, String sLine1, String sLine2);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
public void writeVisor(String sLine1, String sLine2);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void clearVisor();
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class DeviceDisplayBase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final int ANIMATION_NULL = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final int ANIMATION_FLYER = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final int ANIMATION_SCROLL = 2;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final int ANIMATION_BLINK = 3;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final int ANIMATION_CURTAIN = 4;
|
||||
|
||||
private DeviceDisplayImpl impl;
|
||||
private DisplayAnimator anim;
|
||||
private javax.swing.Timer m_tTimeTimer;
|
||||
private int counter = 0;
|
||||
|
||||
/** Creates a new instance of DeviceDisplayBase
|
||||
* @param impl */
|
||||
public DeviceDisplayBase(DeviceDisplayImpl impl) {
|
||||
this.impl = impl;
|
||||
anim = new NullAnimator("", "");
|
||||
m_tTimeTimer = new javax.swing.Timer(50, new PrintTimeAction());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
public void writeVisor(int animation, String sLine1, String sLine2) {
|
||||
|
||||
m_tTimeTimer.stop();
|
||||
switch (animation) {
|
||||
case ANIMATION_FLYER:
|
||||
anim = new FlyerAnimator(sLine1, sLine2);
|
||||
break;
|
||||
case ANIMATION_SCROLL:
|
||||
anim = new ScrollAnimator(sLine1, sLine2);
|
||||
break;
|
||||
case ANIMATION_BLINK:
|
||||
anim = new BlinkAnimator(sLine1, sLine2);
|
||||
break;
|
||||
case ANIMATION_CURTAIN:
|
||||
anim = new CurtainAnimator(sLine1, sLine2);
|
||||
break;
|
||||
default: // ANIMATION_NULL
|
||||
anim = new NullAnimator(sLine1, sLine2);
|
||||
break;
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
anim.setTiming(counter);
|
||||
impl.repaintLines();
|
||||
|
||||
if (animation != ANIMATION_NULL) {
|
||||
counter = 0;
|
||||
m_tTimeTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
public void writeVisor(String sLine1, String sLine2) {
|
||||
writeVisor(ANIMATION_NULL, sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void clearVisor() {
|
||||
writeVisor(ANIMATION_NULL, "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getLine1() {
|
||||
return anim.getLine1();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getLine2() {
|
||||
return anim.getLine2();
|
||||
}
|
||||
|
||||
private class PrintTimeAction implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
counter ++;
|
||||
anim.setTiming(counter);
|
||||
impl.repaintLines();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface DeviceDisplayImpl {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void repaintLines();
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DeviceDisplayNull implements DeviceDisplay {
|
||||
|
||||
private String m_sName;
|
||||
private String m_sDescription;
|
||||
|
||||
/** Creates a new instance of DeviceDisplayNull */
|
||||
public DeviceDisplayNull() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/** Creates a new instance of DeviceDisplayNull
|
||||
* @param desc */
|
||||
public DeviceDisplayNull(String desc) {
|
||||
m_sName = AppLocal.getIntString("display.null");
|
||||
m_sDescription = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayDescription() {
|
||||
return m_sDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public javax.swing.JComponent getDisplayComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void clearVisor() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(String sLine1, String sLine2) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(int animation, String sLine1, String sLine2) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface DeviceFiscalPrinter {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getFiscalName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JComponent getFiscalComponent();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void beginReceipt();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void endReceipt();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sproduct
|
||||
* @param dprice
|
||||
* @param dunits
|
||||
* @param taxinfo
|
||||
*/
|
||||
public void printLine(String sproduct, double dprice, double dunits, int taxinfo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param smessage
|
||||
*/
|
||||
public void printMessage(String smessage);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sPayment
|
||||
* @param dpaid
|
||||
*/
|
||||
public void printTotal(String sPayment, double dpaid);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void printZReport();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void printXReport();
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DeviceFiscalPrinterNull implements DeviceFiscalPrinter {
|
||||
|
||||
/** Creates a new instance of DeviceFiscalPrinterNull */
|
||||
public DeviceFiscalPrinterNull() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param desc
|
||||
*/
|
||||
public DeviceFiscalPrinterNull(String desc) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getFiscalName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getFiscalComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sproduct
|
||||
* @param dprice
|
||||
* @param dunits
|
||||
* @param taxinfo
|
||||
*/
|
||||
@Override
|
||||
public void printLine(String sproduct, double dprice, double dunits, int taxinfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param smessage
|
||||
*/
|
||||
@Override
|
||||
public void printMessage(String smessage) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sPayment
|
||||
* @param dpaid
|
||||
*/
|
||||
@Override
|
||||
public void printTotal(String sPayment, double dpaid) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printZReport() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printXReport() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface DevicePrinter {
|
||||
|
||||
// Font Sizes
|
||||
public static final int SIZE_0 = 0;
|
||||
public static final int SIZE_1 = 1;
|
||||
public static final int SIZE_2 = 2;
|
||||
public static final int SIZE_3 = 3;
|
||||
|
||||
// Font Enhancers
|
||||
public static final int STYLE_PLAIN = 0;
|
||||
public static final int STYLE_BOLD = 1;
|
||||
public static final int STYLE_UNDERLINE = 2;
|
||||
|
||||
// Layout
|
||||
public static final int ALIGN_LEFT = 0;
|
||||
public static final int ALIGN_RIGHT = 1;
|
||||
public static final int ALIGN_CENTER = 2;
|
||||
|
||||
public static final String POSITION_BOTTOM = "bottom";
|
||||
public static final String POSITION_NONE = "none";
|
||||
|
||||
// Barcodes
|
||||
public static final String BARCODE_EAN8 = "EAN8";
|
||||
public static final String BARCODE_EAN13 = "EAN13";
|
||||
public static final String BARCODE_UPCA = "UPC-A";
|
||||
public static final String BARCODE_UPCE = "UPC-E";
|
||||
public static final String BARCODE_CODE128 = "CODE128";
|
||||
public static final String BARCODE_CODE39 = "CODE39";
|
||||
|
||||
public String getPrinterName();
|
||||
public String getPrinterDescription();
|
||||
public JComponent getPrinterComponent();
|
||||
|
||||
// Initialise
|
||||
public void reset();
|
||||
public void beginReceipt();
|
||||
|
||||
// Graphic renders
|
||||
public void printImage(BufferedImage image);
|
||||
public void printLogo();
|
||||
public void printBarCode(String type, String position, String code);
|
||||
|
||||
// Do TextLine
|
||||
public void beginLine(int iTextSize);
|
||||
public void printText(int iStyle, String sText);
|
||||
public void endLine();
|
||||
|
||||
// Close
|
||||
public void endReceipt();
|
||||
|
||||
// Transact
|
||||
public void openDrawer();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DevicePrinterNull implements DevicePrinter {
|
||||
|
||||
private String m_sName;
|
||||
private String m_sDescription;
|
||||
|
||||
/** Creates a new instance of DevicePrinterNull */
|
||||
public DevicePrinterNull() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/** Creates a new instance of DevicePrinterNull
|
||||
* @param desc */
|
||||
public DevicePrinterNull(String desc) {
|
||||
m_sName = AppLocal.getIntString("printer.null");
|
||||
m_sDescription = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterDescription() {
|
||||
return m_sDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public javax.swing.JComponent getPrinterComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarCode(String type, String position, String code) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void printImage(java.awt.image.BufferedImage image) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iTextSize
|
||||
*/
|
||||
@Override
|
||||
public void beginLine(int iTextSize) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iStyle
|
||||
* @param sText
|
||||
*/
|
||||
@Override
|
||||
public void printText(int iStyle, String sText) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endLine() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void openDrawer() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printLogo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import com.unicenta.pos.forms.AppProperties;
|
||||
import com.unicenta.pos.printer.escpos.*;
|
||||
import com.unicenta.pos.printer.javapos.DeviceDisplayJavaPOS;
|
||||
import com.unicenta.pos.printer.javapos.DeviceFiscalPrinterJavaPOS;
|
||||
import com.unicenta.pos.printer.javapos.DevicePrinterJavaPOS;
|
||||
import com.unicenta.pos.printer.printer.DevicePrinterPrinter;
|
||||
import com.unicenta.pos.printer.screen.DeviceDisplayPanel;
|
||||
import com.unicenta.pos.printer.screen.DeviceDisplayWindow;
|
||||
import com.unicenta.pos.printer.screen.DevicePrinterPanel;
|
||||
import com.unicenta.pos.util.StringParser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
@Slf4j
|
||||
public class DeviceTicket {
|
||||
|
||||
private DeviceFiscalPrinter m_deviceFiscal;
|
||||
private DeviceDisplay m_devicedisplay;
|
||||
private DevicePrinter m_nullprinter;
|
||||
private Map<String, DevicePrinter> m_deviceprinters;
|
||||
private List<DevicePrinter> m_deviceprinterslist;
|
||||
|
||||
/**
|
||||
* Creates a new instance of DeviceTicket
|
||||
*/
|
||||
public DeviceTicket() {
|
||||
// Una impresora solo de pantalla.
|
||||
|
||||
m_deviceFiscal = new DeviceFiscalPrinterNull();
|
||||
|
||||
m_devicedisplay = new DeviceDisplayNull();
|
||||
|
||||
m_nullprinter = new DevicePrinterNull();
|
||||
m_deviceprinters = new HashMap<>();
|
||||
m_deviceprinterslist = new ArrayList<>();
|
||||
|
||||
DevicePrinter p = new DevicePrinterPanel();
|
||||
m_deviceprinters.put("1", p);
|
||||
m_deviceprinterslist.add(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
* @param props
|
||||
*/
|
||||
public DeviceTicket(Component parent, AppProperties props) {
|
||||
|
||||
PrinterWritterPool pws = new PrinterWritterPool();
|
||||
|
||||
// La impresora fiscal
|
||||
StringParser sf = new StringParser(props.getProperty("machine.fiscalprinter"));
|
||||
String sFiscalType = sf.nextToken(':');
|
||||
String sFiscalParam1 = sf.nextToken(',');
|
||||
try {
|
||||
if ("javapos".equals(sFiscalType)) {
|
||||
m_deviceFiscal = new DeviceFiscalPrinterJavaPOS(sFiscalParam1);
|
||||
} else {
|
||||
m_deviceFiscal = new DeviceFiscalPrinterNull();
|
||||
}
|
||||
} catch (TicketPrinterException e) {
|
||||
m_deviceFiscal = new DeviceFiscalPrinterNull(e.getMessage());
|
||||
}
|
||||
|
||||
StringParser sd = new StringParser(props.getProperty("machine.display"));
|
||||
String sDisplayType = sd.nextToken(':');
|
||||
String sDisplayParam1 = sd.nextToken(',');
|
||||
String sDisplayParam2 = sd.nextToken(',');
|
||||
|
||||
if ("serial".equals(sDisplayType)
|
||||
|| "rxtx".equals(sDisplayType)
|
||||
|| "file".equals(sDisplayType)) {
|
||||
sDisplayParam2 = sDisplayParam1;
|
||||
sDisplayParam1 = sDisplayType;
|
||||
sDisplayType = "epson";
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
switch (sDisplayType) {
|
||||
case "screen":
|
||||
m_devicedisplay = new DeviceDisplayPanel();
|
||||
break;
|
||||
case "window":
|
||||
m_devicedisplay = new DeviceDisplayWindow();
|
||||
break;
|
||||
case "epson":
|
||||
m_devicedisplay = new DeviceDisplayESCPOS(
|
||||
pws.getPrinterWritter(sDisplayParam1, sDisplayParam2)
|
||||
, new UnicodeTranslatorInt());
|
||||
break;
|
||||
case "surepos":
|
||||
m_devicedisplay = new DeviceDisplaySurePOS(
|
||||
pws.getPrinterWritter(sDisplayParam1, sDisplayParam2));
|
||||
break;
|
||||
case "ld200":
|
||||
m_devicedisplay = new DeviceDisplayESCPOS(
|
||||
pws.getPrinterWritter(sDisplayParam1, sDisplayParam2)
|
||||
, new UnicodeTranslatorEur());
|
||||
break;
|
||||
case "javapos":
|
||||
m_devicedisplay = new DeviceDisplayJavaPOS(sDisplayParam1);
|
||||
break;
|
||||
default:
|
||||
m_devicedisplay = new DeviceDisplayNull();
|
||||
break;
|
||||
}
|
||||
} catch (TicketPrinterException e) {
|
||||
log.error(e.getMessage());
|
||||
m_devicedisplay = new DeviceDisplayNull(e.getMessage());
|
||||
}
|
||||
|
||||
m_nullprinter = new DevicePrinterNull();
|
||||
|
||||
m_deviceprinters = new HashMap<>();
|
||||
m_deviceprinterslist = new ArrayList<>();
|
||||
|
||||
// Empezamos a iterar por las impresoras...
|
||||
int iPrinterIndex = 1;
|
||||
String sPrinterIndex = Integer.toString(iPrinterIndex);
|
||||
String sprinter = props.getProperty("machine.printer");
|
||||
|
||||
while (sprinter != null && !"".equals(sprinter)) {
|
||||
|
||||
StringParser sp = new StringParser(sprinter);
|
||||
String sPrinterType = sp.nextToken(':');
|
||||
String sPrinterParam1 = sp.nextToken(',');
|
||||
String sPrinterParam2 = sp.nextToken(',');
|
||||
|
||||
|
||||
if ("serial".equals(sPrinterType)
|
||||
|| "rxtx".equals(sPrinterType)
|
||||
|| "file".equals(sPrinterType)) {
|
||||
sPrinterParam2 = sPrinterParam1;
|
||||
sPrinterParam1 = sPrinterType;
|
||||
sPrinterType = "epson";
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
switch (sPrinterType) {
|
||||
case "screen":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterPanel());
|
||||
break;
|
||||
case "printer":
|
||||
// backward compatibility
|
||||
if (sPrinterParam2 == null || sPrinterParam2.equals("")
|
||||
|| sPrinterParam2.equals("true")) {
|
||||
sPrinterParam2 = "receipt";
|
||||
} else if (sPrinterParam2.equals("false")) {
|
||||
sPrinterParam2 = "standard";
|
||||
}
|
||||
addPrinter(sPrinterIndex, new DevicePrinterPrinter(parent, sPrinterParam1,
|
||||
Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".x")),
|
||||
Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".y")),
|
||||
Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".width")),
|
||||
Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".height")),
|
||||
props.getProperty("paper." + sPrinterParam2 + ".mediasizename")
|
||||
));
|
||||
break;
|
||||
case "epson":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterESCPOS(
|
||||
pws.getPrinterWritter(sPrinterParam1, sPrinterParam2)
|
||||
, new CodesEpson(), new UnicodeTranslatorInt()));
|
||||
break;
|
||||
case "tmu220":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterESCPOS(
|
||||
pws.getPrinterWritter(sPrinterParam1, sPrinterParam2)
|
||||
, new CodesTMU220(), new UnicodeTranslatorInt()));
|
||||
break;
|
||||
case "star":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterESCPOS(
|
||||
pws.getPrinterWritter(sPrinterParam1, sPrinterParam2)
|
||||
, new CodesStar(), new UnicodeTranslatorStar()));
|
||||
break;
|
||||
case "ithaca":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterESCPOS(
|
||||
pws.getPrinterWritter(sPrinterParam1, sPrinterParam2)
|
||||
, new CodesIthaca(), new UnicodeTranslatorInt()));
|
||||
break;
|
||||
case "surepos":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterESCPOS(
|
||||
pws.getPrinterWritter(sPrinterParam1, sPrinterParam2)
|
||||
, new CodesSurePOS(), new UnicodeTranslatorSurePOS()));
|
||||
break;
|
||||
case "plain":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterPlain(
|
||||
pws.getPrinterWritter(sPrinterParam1, sPrinterParam2)));
|
||||
break;
|
||||
case "javapos":
|
||||
addPrinter(sPrinterIndex, new DevicePrinterJavaPOS(
|
||||
sPrinterParam1, sPrinterParam2));
|
||||
break;
|
||||
}
|
||||
} catch (TicketPrinterException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
iPrinterIndex++;
|
||||
sPrinterIndex = Integer.toString(iPrinterIndex);
|
||||
sprinter = props.getProperty("machine.printer." + sPrinterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void addPrinter(String sPrinterIndex, DevicePrinter p) {
|
||||
m_deviceprinters.put(sPrinterIndex, p);
|
||||
m_deviceprinterslist.add(p);
|
||||
}
|
||||
|
||||
private static class PrinterWritterPool {
|
||||
|
||||
private final Map<String, PrinterWritter> m_apool = new HashMap<>();
|
||||
|
||||
public PrinterWritter getPrinterWritter(String con, String port) throws TicketPrinterException {
|
||||
|
||||
String skey = con + "-->" + port;
|
||||
PrinterWritter pw = (PrinterWritter) m_apool.get(skey);
|
||||
if (pw == null) {
|
||||
|
||||
switch (con) {
|
||||
case "serial":
|
||||
case "rxtx":
|
||||
pw = new PrinterWritterRXTX(port);
|
||||
m_apool.put(skey, pw);
|
||||
break;
|
||||
case "file":
|
||||
pw = new PrinterWritterFile(port);
|
||||
m_apool.put(skey, pw);
|
||||
break;
|
||||
default:
|
||||
throw new TicketPrinterException();
|
||||
}
|
||||
}
|
||||
return pw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Fiscal printer
|
||||
*/
|
||||
public DeviceFiscalPrinter getFiscalPrinter() {
|
||||
return m_deviceFiscal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Device display
|
||||
*/
|
||||
public DeviceDisplay getDeviceDisplay() {
|
||||
return m_devicedisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @return Device printer
|
||||
*/
|
||||
public DevicePrinter getDevicePrinter(String key) {
|
||||
DevicePrinter printer = m_deviceprinters.get(key);
|
||||
return printer == null ? m_nullprinter : printer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Device printer list
|
||||
*/
|
||||
public List<DevicePrinter> getDevicePrinterAll() {
|
||||
return m_deviceprinterslist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iSize
|
||||
* @param cWhiteChar
|
||||
* @return Spacing string length
|
||||
*/
|
||||
public static String getWhiteString(int iSize, char cWhiteChar) {
|
||||
|
||||
char[] cFill = new char[iSize];
|
||||
for (int i = 0; i < iSize; i++) {
|
||||
cFill[i] = cWhiteChar;
|
||||
}
|
||||
return new String(cFill);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iSize
|
||||
* @return Space sizing
|
||||
*/
|
||||
public static String getWhiteString(int iSize) {
|
||||
|
||||
return getWhiteString(iSize, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sLine
|
||||
* @param iSize
|
||||
* @return Barcode bar inter-spacing
|
||||
*/
|
||||
public static String alignBarCode(String sLine, int iSize) {
|
||||
|
||||
if (sLine.length() > iSize) {
|
||||
return sLine.substring(sLine.length() - iSize);
|
||||
} else {
|
||||
return getWhiteString(iSize - sLine.length(), '0') + sLine;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sLine
|
||||
* @param iSize
|
||||
* @return Reduce spacing
|
||||
*/
|
||||
public static String alignLeft(String sLine, int iSize) {
|
||||
|
||||
if (sLine.length() > iSize) {
|
||||
return sLine.substring(0, iSize);
|
||||
} else {
|
||||
return sLine + getWhiteString(iSize - sLine.length());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sLine
|
||||
* @param iSize
|
||||
* @return Add spacing
|
||||
*/
|
||||
public static String alignRight(String sLine, int iSize) {
|
||||
|
||||
if (sLine.length() > iSize) {
|
||||
return sLine.substring(sLine.length() - iSize);
|
||||
} else {
|
||||
return getWhiteString(iSize - sLine.length()) + sLine;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sLine
|
||||
* @param iSize
|
||||
* @return Adjusts Left/Right spacing
|
||||
*/
|
||||
public static String alignCenter(String sLine, int iSize) {
|
||||
|
||||
if (sLine.length() > iSize) {
|
||||
return alignRight(sLine.substring(0, (sLine.length() + iSize) / 2), iSize);
|
||||
} else {
|
||||
return alignRight(sLine + getWhiteString((iSize - sLine.length()) / 2), iSize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sLine
|
||||
* @return Equalise Left/Right spacing
|
||||
*/
|
||||
public static String alignCenter(String sLine) {
|
||||
return alignCenter(sLine, 42);
|
||||
}
|
||||
|
||||
// JG 16 May 12 public static final byte[] transNumber(String sCad) {
|
||||
|
||||
/**
|
||||
* @param sCad
|
||||
* @return Convert number to string
|
||||
*/
|
||||
public static byte[] transNumber(String sCad) {
|
||||
|
||||
if (sCad == null) {
|
||||
return null;
|
||||
} else {
|
||||
byte bAux[] = new byte[sCad.length()];
|
||||
for (int i = 0; i < sCad.length(); i++) {
|
||||
bAux[i] = transNumberChar(sCad.charAt(i));
|
||||
}
|
||||
return bAux;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sChar
|
||||
* @return Convert hex to character
|
||||
*/
|
||||
public static byte transNumberChar(char sChar) {
|
||||
switch (sChar) {
|
||||
case '0':
|
||||
return 0x30;
|
||||
case '1':
|
||||
return 0x31;
|
||||
case '2':
|
||||
return 0x32;
|
||||
case '3':
|
||||
return 0x33;
|
||||
case '4':
|
||||
return 0x34;
|
||||
case '5':
|
||||
return 0x35;
|
||||
case '6':
|
||||
return 0x36;
|
||||
case '7':
|
||||
return 0x37;
|
||||
case '8':
|
||||
return 0x38;
|
||||
case '9':
|
||||
return 0x39;
|
||||
default:
|
||||
return 0x30;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public interface DisplayAnimator {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void setTiming(int i);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getLine1();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getLine2();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class FlyerAnimator extends BaseAnimator {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param line1
|
||||
* @param line2
|
||||
*/
|
||||
public FlyerAnimator(String line1, String line2) {
|
||||
baseLine1 = DeviceTicket.alignLeft(line1, 20);
|
||||
baseLine2 = DeviceTicket.alignLeft(line2, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
@Override
|
||||
public void setTiming(int i) {
|
||||
|
||||
if (i < 20) {
|
||||
currentLine1 = DeviceTicket.alignRight(baseLine1.substring(0, i), 20);
|
||||
currentLine2 = DeviceTicket.alignRight(baseLine2.substring(0, i), 20);
|
||||
} else {
|
||||
currentLine1 = baseLine1;
|
||||
currentLine2 = baseLine2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class NullAnimator implements DisplayAnimator {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String currentLine1;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected String currentLine2;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param line1
|
||||
* @param line2
|
||||
*/
|
||||
public NullAnimator(String line1, String line2) {
|
||||
currentLine1 = DeviceTicket.alignLeft(line1, 20);
|
||||
currentLine2 = DeviceTicket.alignLeft(line2, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
@Override
|
||||
public void setTiming(int i) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getLine1() {
|
||||
return currentLine1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getLine2() {
|
||||
return currentLine2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class ScrollAnimator extends BaseAnimator {
|
||||
|
||||
private int msglength;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param line1
|
||||
* @param line2
|
||||
*/
|
||||
public ScrollAnimator(String line1, String line2) {
|
||||
msglength = Math.max(line1.length(), line2.length());
|
||||
baseLine1 = DeviceTicket.alignLeft(line1, msglength);
|
||||
baseLine2 = DeviceTicket.alignLeft(line2, msglength);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
@Override
|
||||
public void setTiming(int i) {
|
||||
int j = (i / 2) % (msglength + 20);
|
||||
if (j < 20) {
|
||||
currentLine1 = DeviceTicket.alignLeft(DeviceTicket.getWhiteString(20 - j) + baseLine1, 20);
|
||||
currentLine2 = DeviceTicket.alignLeft(DeviceTicket.getWhiteString(20 - j) + baseLine2, 20);
|
||||
} else {
|
||||
currentLine1 = DeviceTicket.alignLeft(baseLine1.substring(j - 20), 20);
|
||||
currentLine2 = DeviceTicket.alignLeft(baseLine2.substring(j - 20), 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,506 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import com.unicenta.pos.forms.DataLogicSystem;
|
||||
import com.unicenta.pos.ticket.TicketInfo;
|
||||
import java.applet.Applet;
|
||||
import java.applet.AudioClip;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class TicketParser extends DefaultHandler {
|
||||
|
||||
private static SAXParser m_sp = null;
|
||||
|
||||
private DeviceTicket m_printer;
|
||||
private DataLogicSystem m_system;
|
||||
|
||||
private StringBuilder text;
|
||||
|
||||
private String bctype;
|
||||
private String bcposition;
|
||||
private int m_iTextAlign;
|
||||
private int m_iTextLength;
|
||||
private int m_iTextStyle;
|
||||
private int size;
|
||||
|
||||
private StringBuilder m_sVisorLine;
|
||||
private int m_iVisorAnimation;
|
||||
private String m_sVisorLine1;
|
||||
private String m_sVisorLine2;
|
||||
|
||||
private double m_dValue1;
|
||||
private double m_dValue2;
|
||||
private int attribute3;
|
||||
|
||||
private int m_iOutputType;
|
||||
private static final int OUTPUT_NONE = 0;
|
||||
private static final int OUTPUT_DISPLAY = 1;
|
||||
private static final int OUTPUT_TICKET = 2;
|
||||
private static final int OUTPUT_FISCAL = 3;
|
||||
private DevicePrinter m_oOutputPrinter;
|
||||
private DateFormat df= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
private Date today;
|
||||
private String cUser;
|
||||
private String ticketId;
|
||||
private String pickupId;
|
||||
|
||||
|
||||
/** Creates a new instance of TicketParser
|
||||
* @param printer
|
||||
* @param system */
|
||||
public TicketParser(DeviceTicket printer, DataLogicSystem system) {
|
||||
m_printer = printer;
|
||||
m_system = system;
|
||||
today = Calendar.getInstance().getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sIn
|
||||
* @param ticket
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public void printTicket(String sIn, TicketInfo ticket) throws TicketPrinterException {
|
||||
// cUser=ticket.getUser().getName();
|
||||
cUser=ticket.getName();
|
||||
ticketId=Integer.toString(ticket.getTicketId());
|
||||
pickupId=Integer.toString(ticket.getPickupId());
|
||||
|
||||
if (ticket.getTicketId()==0){
|
||||
ticketId="No Sale";
|
||||
}
|
||||
if (ticket.getPickupId()==0){
|
||||
pickupId="No PickupId";
|
||||
}
|
||||
printTicket(new StringReader(sIn));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sIn
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public void printTicket(String sIn) throws TicketPrinterException {
|
||||
printTicket(new StringReader(sIn));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param in
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public void printTicket(Reader in) throws TicketPrinterException {
|
||||
|
||||
try {
|
||||
|
||||
if (m_sp == null) {
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
m_sp = spf.newSAXParser();
|
||||
}
|
||||
m_sp.parse(new InputSource(in), this);
|
||||
|
||||
} catch (ParserConfigurationException ePC) {
|
||||
throw new TicketPrinterException(LocalRes.getIntString("exception.parserconfig") , ePC);
|
||||
} catch (SAXException eSAX) {
|
||||
throw new TicketPrinterException(LocalRes.getIntString("exception.xmlfile") , eSAX);
|
||||
} catch (IOException eIO) {
|
||||
throw new TicketPrinterException(LocalRes.getIntString("exception.iofile") , eIO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDocument() throws SAXException {
|
||||
// inicalizo las variables pertinentes
|
||||
text = null;
|
||||
bctype = null;
|
||||
bcposition = null;
|
||||
m_sVisorLine = null;
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endDocument() throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException{
|
||||
String openDate = df.format(today);
|
||||
Date dNow = new Date();
|
||||
|
||||
switch (m_iOutputType) {
|
||||
case OUTPUT_NONE:
|
||||
switch (qName) {
|
||||
case "opendrawer":
|
||||
m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1")).openDrawer();
|
||||
// Cashdrawer has been activated record the data in the table
|
||||
try {
|
||||
m_system.execDrawerOpened(
|
||||
//new Object[] {df.format(dNow),cUser,ticketId});
|
||||
new Object[] {cUser,ticketId});
|
||||
} catch (BasicException ex) {}
|
||||
break;
|
||||
case "play":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "ticket":
|
||||
m_iOutputType = OUTPUT_TICKET;
|
||||
m_oOutputPrinter = m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1"));
|
||||
m_oOutputPrinter.beginReceipt();
|
||||
break;
|
||||
case "display":
|
||||
m_iOutputType = OUTPUT_DISPLAY;
|
||||
String animation = attributes.getValue("animation");
|
||||
if ("scroll".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_SCROLL;
|
||||
} else if ("flyer".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_FLYER;
|
||||
} else if ("blink".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_BLINK;
|
||||
} else if ("curtain".equals(animation)) {
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_CURTAIN;
|
||||
} else { // "none"
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
}
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_oOutputPrinter = null;
|
||||
break;
|
||||
case "fiscalreceipt":
|
||||
m_iOutputType = OUTPUT_FISCAL;
|
||||
m_printer.getFiscalPrinter().beginReceipt();
|
||||
break;
|
||||
case "fiscalzreport":
|
||||
m_printer.getFiscalPrinter().printZReport();
|
||||
break;
|
||||
case "fiscalxreport":
|
||||
m_printer.getFiscalPrinter().printXReport();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_TICKET:
|
||||
if (null != qName)switch (qName) {
|
||||
case "logo":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "image":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "barcode":
|
||||
text = new StringBuilder();
|
||||
bctype = attributes.getValue("type");
|
||||
bcposition = attributes.getValue("position");
|
||||
break;
|
||||
case "line":
|
||||
m_oOutputPrinter.beginLine(parseInt(attributes.getValue("size"), DevicePrinter.SIZE_0));
|
||||
break;
|
||||
case "text":
|
||||
text = new StringBuilder();
|
||||
m_iTextStyle = ("true".equals(attributes.getValue("bold"))
|
||||
? DevicePrinter.STYLE_BOLD : DevicePrinter.STYLE_PLAIN)
|
||||
| ("true".equals(attributes.getValue("underline"))
|
||||
? DevicePrinter.STYLE_UNDERLINE : DevicePrinter.STYLE_PLAIN);
|
||||
String sAlign = attributes.getValue("align");
|
||||
if (null == sAlign) {
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
} else switch (sAlign) {
|
||||
case "right":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_RIGHT;
|
||||
break;
|
||||
case "center":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_CENTER;
|
||||
break;
|
||||
default:
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
m_iTextLength = parseInt(attributes.getValue("length"), 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_DISPLAY:
|
||||
if (null != qName) switch (qName) {
|
||||
case "line":
|
||||
// line 1 or 2 of the display
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "line1":
|
||||
// linea 1 del visor
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "line2":
|
||||
// linea 2 del visor
|
||||
m_sVisorLine = new StringBuilder();
|
||||
break;
|
||||
case "text":
|
||||
text = new StringBuilder();
|
||||
String sAlign = attributes.getValue("align");
|
||||
if (null == sAlign) {
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
} else switch (sAlign) {
|
||||
case "right":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_RIGHT;
|
||||
break;
|
||||
case "center":
|
||||
m_iTextAlign = DevicePrinter.ALIGN_CENTER;
|
||||
break;
|
||||
default:
|
||||
m_iTextAlign = DevicePrinter.ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
m_iTextLength = parseInt(attributes.getValue("length"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_FISCAL:
|
||||
if (null != qName)
|
||||
switch (qName) {
|
||||
case "line":
|
||||
text = new StringBuilder();
|
||||
m_dValue1 = parseDouble(attributes.getValue("price"));
|
||||
m_dValue2 = parseDouble(attributes.getValue("units"), 1.0);
|
||||
attribute3 = parseInt(attributes.getValue("tax"));
|
||||
break;
|
||||
case "message":
|
||||
text = new StringBuilder();
|
||||
break;
|
||||
case "total":
|
||||
text = new StringBuilder();
|
||||
m_dValue1 = parseDouble(attributes.getValue("paid"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
|
||||
switch (m_iOutputType) {
|
||||
case OUTPUT_NONE:
|
||||
if ("play".equals(qName)) {
|
||||
try {
|
||||
AudioClip oAudio = Applet.newAudioClip(getClass().getClassLoader().getResource(text.toString()));
|
||||
oAudio.play();
|
||||
} catch (Exception fnfe) {
|
||||
//throw new ResourceNotFoundException( fnfe.getMessage() );
|
||||
}
|
||||
text = null;
|
||||
}
|
||||
break;
|
||||
|
||||
// Added 23.05.13 used by star TSP700 to print stored logo image JDL
|
||||
case OUTPUT_TICKET:
|
||||
if ("logo".equals(qName)){
|
||||
m_oOutputPrinter.printLogo();
|
||||
// }
|
||||
}else if ("image".equals(qName)){
|
||||
try {
|
||||
// BufferedImage image = ImageIO.read(getClass().getClassLoader().getResourceAsStream(text.toString()));
|
||||
BufferedImage image = m_system.getResourceAsImage(text.toString());
|
||||
|
||||
if (image == null) {
|
||||
image = decodeToImage(text.toString());
|
||||
}
|
||||
if (image != null) {
|
||||
m_oOutputPrinter.printImage(image);
|
||||
}
|
||||
|
||||
} catch (Exception fnfe) {
|
||||
//throw new ResourceNotFoundException( fnfe.getMessage() );
|
||||
}
|
||||
text = null;
|
||||
} else if ("barcode".equals(qName)) {
|
||||
m_oOutputPrinter.printBarCode(bctype, bcposition, text.toString());
|
||||
text = null;
|
||||
} else if ("text".equals(qName)) {
|
||||
if (m_iTextLength > 0) {
|
||||
switch(m_iTextAlign) {
|
||||
case DevicePrinter.ALIGN_RIGHT:
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignRight(text.toString(), m_iTextLength));
|
||||
break;
|
||||
case DevicePrinter.ALIGN_CENTER:
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignCenter(text.toString(), m_iTextLength));
|
||||
break;
|
||||
default: // DevicePrinter.ALIGN_LEFT
|
||||
m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignLeft(text.toString(), m_iTextLength));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
m_oOutputPrinter.printText(m_iTextStyle, text.toString());
|
||||
}
|
||||
text = null;
|
||||
} else if ("line".equals(qName)) {
|
||||
m_oOutputPrinter.endLine();
|
||||
} else if ("ticket".equals(qName)) {
|
||||
m_oOutputPrinter.endReceipt();
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_DISPLAY:
|
||||
if ("line".equals(qName)) { // line 1 or 2 of the display
|
||||
if (m_sVisorLine1 == null) {
|
||||
m_sVisorLine1 = m_sVisorLine.toString();
|
||||
} else {
|
||||
m_sVisorLine2 = m_sVisorLine.toString();
|
||||
}
|
||||
m_sVisorLine = null;
|
||||
} else if ("line1".equals(qName)) { // linea 1 del visor
|
||||
m_sVisorLine1 = m_sVisorLine.toString();
|
||||
m_sVisorLine = null;
|
||||
} else if ("line2".equals(qName)) { // linea 2 del visor
|
||||
m_sVisorLine2 = m_sVisorLine.toString();
|
||||
m_sVisorLine = null;
|
||||
} else if ("text".equals(qName)) {
|
||||
if (m_iTextLength > 0) {
|
||||
switch(m_iTextAlign) {
|
||||
case DevicePrinter.ALIGN_RIGHT:
|
||||
m_sVisorLine.append(DeviceTicket.alignRight(text.toString(), m_iTextLength));
|
||||
break;
|
||||
case DevicePrinter.ALIGN_CENTER:
|
||||
m_sVisorLine.append(DeviceTicket.alignCenter(text.toString(), m_iTextLength));
|
||||
break;
|
||||
default: // DevicePrinter.ALIGN_LEFT
|
||||
m_sVisorLine.append(DeviceTicket.alignLeft(text.toString(), m_iTextLength));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
m_sVisorLine.append(text);
|
||||
}
|
||||
text = null;
|
||||
} else if ("display".equals(qName)) {
|
||||
m_printer.getDeviceDisplay().writeVisor(m_iVisorAnimation, m_sVisorLine1, m_sVisorLine2);
|
||||
m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL;
|
||||
m_sVisorLine1 = null;
|
||||
m_sVisorLine2 = null;
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
m_oOutputPrinter = null;
|
||||
}
|
||||
break;
|
||||
case OUTPUT_FISCAL:
|
||||
if ("fiscalreceipt".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().endReceipt();
|
||||
m_iOutputType = OUTPUT_NONE;
|
||||
} else if ("line".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printLine(text.toString(), m_dValue1, m_dValue2, attribute3);
|
||||
text = null;
|
||||
} else if ("message".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printMessage(text.toString());
|
||||
text = null;
|
||||
} else if ("total".equals(qName)) {
|
||||
m_printer.getFiscalPrinter().printTotal(text.toString(), m_dValue1);
|
||||
text = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
if (text != null) {
|
||||
text.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
private int parseInt(String sValue, int iDefault) {
|
||||
try {
|
||||
return Integer.parseInt(sValue);
|
||||
} catch (NumberFormatException eNF) {
|
||||
return iDefault;
|
||||
}
|
||||
}
|
||||
|
||||
private int parseInt(String sValue) {
|
||||
return parseInt(sValue, 0);
|
||||
}
|
||||
|
||||
private double parseDouble(String sValue, double ddefault) {
|
||||
try {
|
||||
return Double.parseDouble(sValue);
|
||||
} catch (NumberFormatException eNF) {
|
||||
return ddefault;
|
||||
}
|
||||
}
|
||||
|
||||
private double parseDouble(String sValue) {
|
||||
return parseDouble(sValue, 0.0);
|
||||
}
|
||||
|
||||
private String readString(String sValue, String sDefault) {
|
||||
if (sValue == null || sValue.equals("")) {
|
||||
return sDefault;
|
||||
} else {
|
||||
return sValue;
|
||||
}
|
||||
}
|
||||
private static BufferedImage decodeToImage(String imageString) {
|
||||
|
||||
BufferedImage image = null;
|
||||
byte[] imageByte;
|
||||
try {
|
||||
Base64.Decoder decoder = Base64.getMimeDecoder();
|
||||
imageByte = decoder.decode(imageString);
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
|
||||
image = ImageIO.read(bis);
|
||||
bis.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return image;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class TicketPrinterException extends java.lang.Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TicketPrinterException() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public TicketPrinterException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param msg
|
||||
* @param cause
|
||||
*/
|
||||
public TicketPrinterException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.DeviceTicket;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class Codes {
|
||||
|
||||
/** Creates a new instance of Codes */
|
||||
public Codes() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getInitSequence();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getSize0();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getSize1();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getSize2();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getSize3();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getBoldSet();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getBoldReset();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getUnderlineSet();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getUnderlineReset();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getOpenDrawer();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getCutReceipt();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getNewLine();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getImageHeader();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getImageWidth();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getImageLogo();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param out
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
public void printBarcode(PrinterWritter out, String type, String position, String code) {
|
||||
|
||||
if (DevicePrinter.BARCODE_EAN13.equals(type)) {
|
||||
|
||||
out.write(getNewLine());
|
||||
|
||||
out.write(ESCPOS.BAR_HEIGHT);
|
||||
if (DevicePrinter.POSITION_NONE.equals(position)) {
|
||||
out.write(ESCPOS.BAR_POSITIONNONE);
|
||||
} else {
|
||||
out.write(ESCPOS.BAR_POSITIONDOWN);
|
||||
}
|
||||
out.write(ESCPOS.BAR_HRIFONT1);
|
||||
out.write(ESCPOS.BAR_CODE02);
|
||||
out.write(DeviceTicket.transNumber(DeviceTicket.alignBarCode(code,13).substring(0,12)));
|
||||
out.write(new byte[] { 0x00 });
|
||||
|
||||
out.write(getNewLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
public byte[] transImage(BufferedImage image) {
|
||||
|
||||
CenteredImage centeredimage = new CenteredImage(image, getImageWidth());
|
||||
|
||||
// Imprimo los par\u00e1metros en cu\u00e1druple
|
||||
int iWidth = (centeredimage.getWidth() + 7) / 8; // n\u00famero de bytes
|
||||
int iHeight = centeredimage.getHeight();
|
||||
|
||||
// Array de datos
|
||||
byte[] bData = new byte[getImageHeader().length + 4 + iWidth * iHeight];
|
||||
|
||||
// Comando de impresion de imagen
|
||||
System.arraycopy(getImageHeader(), 0, bData, 0, getImageHeader().length);
|
||||
|
||||
int index = getImageHeader().length;
|
||||
|
||||
// Dimension de la imagen
|
||||
// JG note: nested ++'s not good construct need change later
|
||||
bData[index ++] = (byte) (iWidth % 256);
|
||||
bData[index ++] = (byte) (iWidth / 256);
|
||||
bData[index ++] = (byte) (iHeight % 256);
|
||||
bData[index ++] = (byte) (iHeight / 256);
|
||||
|
||||
// Raw data
|
||||
// JG note: nested ++'s and var assignments not good construct need change later
|
||||
int iRGB;
|
||||
int p;
|
||||
for (int i = 0; i < centeredimage.getHeight(); i++) {
|
||||
for (int j = 0; j < centeredimage.getWidth(); j = j + 8) {
|
||||
p = 0x00;
|
||||
for (int d = 0; d < 8; d ++) {
|
||||
p = p << 1;
|
||||
if (centeredimage.isBlack(j + d, i)) {
|
||||
p = p | 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
bData[index ++] = (byte) p;
|
||||
}
|
||||
}
|
||||
return bData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected class CenteredImage {
|
||||
|
||||
private BufferedImage image;
|
||||
private int width;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
* @param width
|
||||
*/
|
||||
public CenteredImage(BufferedImage image, int width) {
|
||||
this.image = image;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getHeight() {
|
||||
return image.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return
|
||||
*/
|
||||
public boolean isBlack(int x, int y) {
|
||||
|
||||
int centeredx = x + (image.getWidth() - width) / 2;
|
||||
if (centeredx < 0 || centeredx >= image.getWidth() || y < 0 || y >= image.getHeight()) {
|
||||
return false;
|
||||
} else {
|
||||
int rgb = image.getRGB(centeredx, y);
|
||||
|
||||
int gray = (int)(0.30 * ((rgb >> 16) & 0xff) +
|
||||
0.59 * ((rgb >> 8) & 0xff) +
|
||||
0.11 * (rgb & 0xff));
|
||||
|
||||
return gray < 128;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class CodesEpson extends Codes {
|
||||
|
||||
private static final byte[] INITSEQUENCE = {};
|
||||
|
||||
private static final byte[] CHAR_SIZE_0 = {0x1D, 0x21, 0x00};
|
||||
private static final byte[] CHAR_SIZE_1 = {0x1D, 0x21, 0x01};
|
||||
private static final byte[] CHAR_SIZE_2 = {0x1D, 0x21, 0x30};
|
||||
private static final byte[] CHAR_SIZE_3 = {0x1D, 0x21, 0x31};
|
||||
|
||||
public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01};
|
||||
public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00};
|
||||
|
||||
public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01};
|
||||
public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00};
|
||||
|
||||
private static final byte[] OPEN_DRAWER = {0x1B, 0x70, 0x00, 0x32, -0x06};
|
||||
private static final byte[] PARTIAL_CUT_1 = {0x1B, 0x69};
|
||||
private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x03};
|
||||
private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return
|
||||
private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00};
|
||||
|
||||
/** Creates a new instance of CodesEpson */
|
||||
public CodesEpson() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getInitSequence() { return INITSEQUENCE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize0() { return CHAR_SIZE_0; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize1() { return CHAR_SIZE_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize2() { return CHAR_SIZE_2; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize3() { return CHAR_SIZE_3; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldSet() { return BOLD_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldReset() { return BOLD_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineSet() { return UNDERLINE_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineReset() { return UNDERLINE_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getOpenDrawer() { return OPEN_DRAWER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCutReceipt() { return PARTIAL_CUT_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getNewLine() { return NEW_LINE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageHeader() { return IMAGE_HEADER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getImageWidth() { return 256; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageLogo(){ return IMAGE_LOGO; }
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class CodesIthaca extends Codes {
|
||||
|
||||
private static final byte[] INITSEQUENCE = {};
|
||||
|
||||
private static final byte[] CHAR_SIZE_0 = {0x1D, 0x21, 0x00};
|
||||
private static final byte[] CHAR_SIZE_1 = {0x1D, 0x21, 0x01};
|
||||
private static final byte[] CHAR_SIZE_2 = {0x1D, 0x21, 0x30};
|
||||
private static final byte[] CHAR_SIZE_3 = {0x1D, 0x21, 0x31};
|
||||
|
||||
public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01};
|
||||
public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00};
|
||||
public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01};
|
||||
public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00};
|
||||
|
||||
private static final byte[] OPEN_DRAWER = {0x1B, 0x78, 0x01};
|
||||
private static final byte[] PARTIAL_CUT = {0x1B, 0x50, 0x00};
|
||||
private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x03};
|
||||
private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return
|
||||
|
||||
private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00};
|
||||
/** Creates a new instance of CodesIthaca */
|
||||
public CodesIthaca() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getInitSequence() { return INITSEQUENCE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize0() { return CHAR_SIZE_0; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize1() { return CHAR_SIZE_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize2() { return CHAR_SIZE_2; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize3() { return CHAR_SIZE_3; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldSet() { return BOLD_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldReset() { return BOLD_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineSet() { return UNDERLINE_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineReset() { return UNDERLINE_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getOpenDrawer() { return OPEN_DRAWER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCutReceipt() { return PARTIAL_CUT; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getNewLine() { return NEW_LINE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageHeader() { return IMAGE_HEADER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getImageWidth() { return 256; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageLogo(){ return IMAGE_LOGO; }
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.DeviceTicket;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class CodesStar extends Codes {
|
||||
|
||||
// set line interspacing to 4mm
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] INITSEQUENCE = {0x1B, 0x7A, 0x01};
|
||||
|
||||
private static final byte[] CHAR_SIZE_0 = {0x1B, 0x69, 0x00, 0x00};
|
||||
private static final byte[] CHAR_SIZE_1 = {0x1B, 0x69, 0x01, 0x00};
|
||||
private static final byte[] CHAR_SIZE_2 = {0x1B, 0x69, 0x00, 0x01};
|
||||
private static final byte[] CHAR_SIZE_3 = {0x1B, 0x69, 0x01, 0x01};
|
||||
|
||||
private static final byte[] BOLD_SET = {0x1B, 0x45};
|
||||
private static final byte[] BOLD_RESET = {0x1B, 0x46};
|
||||
|
||||
private static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01};
|
||||
private static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00};
|
||||
|
||||
private static final byte[] OPEN_DRAWER = {0x1C};
|
||||
private static final byte[] PARTIAL_CUT = {0x1B, 0x64, 0x30};
|
||||
private static final byte[] IMAGE_BEGIN = {0x1B, 0x30};
|
||||
private static final byte[] IMAGE_END = {0x1B, 0x7A, 0x01};
|
||||
private static final byte[] IMAGE_HEADER = {0x1B, 0x4B};
|
||||
private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70,0x01, 0x00};
|
||||
private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return
|
||||
|
||||
|
||||
/** Creates a new instance of CodesStar */
|
||||
public CodesStar() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getInitSequence() { return INITSEQUENCE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize0() { return CHAR_SIZE_0; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize1() { return CHAR_SIZE_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize2() { return CHAR_SIZE_2; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize3() { return CHAR_SIZE_3; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldSet() { return BOLD_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldReset() { return BOLD_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineSet() { return UNDERLINE_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineReset() { return UNDERLINE_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getOpenDrawer() { return OPEN_DRAWER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCutReceipt() { return PARTIAL_CUT; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getNewLine() { return NEW_LINE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageHeader() { return IMAGE_HEADER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getImageWidth() { return 192; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageLogo(){ return IMAGE_LOGO; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] transImage(BufferedImage image) {
|
||||
|
||||
CenteredImage centeredimage = new CenteredImage(image, getImageWidth());
|
||||
|
||||
int iWidth = centeredimage.getWidth();
|
||||
int iHeight = (centeredimage.getHeight() + 7) / 8; //
|
||||
|
||||
// Array de datos
|
||||
byte[] bData = new byte[
|
||||
IMAGE_BEGIN.length +
|
||||
(getImageHeader().length + 2 + iWidth + getNewLine().length) * iHeight +
|
||||
IMAGE_END.length];
|
||||
|
||||
// Comando de impresion de imagen
|
||||
|
||||
int index = 0;
|
||||
|
||||
System.arraycopy(IMAGE_BEGIN, 0, bData, index, IMAGE_BEGIN.length);
|
||||
index += IMAGE_BEGIN.length;
|
||||
|
||||
// Raw data
|
||||
int p;
|
||||
for (int i = 0; i < centeredimage.getHeight(); i += 8) {
|
||||
System.arraycopy(getImageHeader(), 0, bData, index, getImageHeader().length);
|
||||
index += getImageHeader().length;
|
||||
|
||||
// Line Dimension
|
||||
// JG note: nested ++'s not good construct need change later
|
||||
bData[index ++] = (byte) (iWidth % 256);
|
||||
bData[index ++] = (byte) (iWidth / 256);
|
||||
|
||||
for (int j = 0; j < centeredimage.getWidth(); j++) {
|
||||
p = 0x00;
|
||||
for (int d = 0; d < 8; d ++) {
|
||||
p = p << 1;
|
||||
if (centeredimage.isBlack(j, i + d)) {
|
||||
p = p | 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
bData[index ++] = (byte) p;
|
||||
}
|
||||
System.arraycopy(getNewLine(), 0, bData, index, getNewLine().length);
|
||||
index += getNewLine().length;
|
||||
|
||||
}
|
||||
|
||||
System.arraycopy(IMAGE_END, 0, bData, index, IMAGE_END.length);
|
||||
index += IMAGE_END.length;
|
||||
|
||||
return bData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param out
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarcode(PrinterWritter out, String type, String position, String code) {
|
||||
|
||||
if (DevicePrinter.BARCODE_EAN13.equals(type)) {
|
||||
|
||||
// out.write(getNewLine());
|
||||
|
||||
out.write(new byte[] {0x1B, 0x1D, 0x61, 0x01}); // Align center
|
||||
|
||||
out.write(new byte[] {0x1B, 0x62, 0x03});
|
||||
if (DevicePrinter.POSITION_NONE.equals(position)) {
|
||||
out.write(new byte[]{0x01});
|
||||
} else {
|
||||
out.write(new byte[]{0x02});
|
||||
}
|
||||
out.write(new byte[]{0x02}); // dots
|
||||
out.write(new byte[]{0x50}); // height
|
||||
out.write(DeviceTicket.transNumber(DeviceTicket.alignBarCode(code,13).substring(0,12)));
|
||||
out.write(new byte[] { 0x1E }); // end char
|
||||
|
||||
out.write(new byte[] {0x1B, 0x1D, 0x61, 0x00}); // Align left
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class CodesSurePOS extends Codes {
|
||||
|
||||
private static final byte[] INITSEQUENCE = {};
|
||||
|
||||
private static final byte[] CHAR_SIZE_0 = {0x1D, 0x21, 0x00};
|
||||
private static final byte[] CHAR_SIZE_1 = {0x1D, 0x21, 0x01};
|
||||
private static final byte[] CHAR_SIZE_2 = {0x1D, 0x21, 0x30};
|
||||
private static final byte[] CHAR_SIZE_3 = {0x1D, 0x21, 0x31};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00};
|
||||
|
||||
private static final byte[] OPEN_DRAWER = {0x1B, 0x70, 0x00, 0x32, -0x06};
|
||||
private static final byte[] PARTIAL_CUT_1 = {0x1B, 0x69};
|
||||
private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x02};
|
||||
private static final byte[] NEW_LINE = {0x0D}; // Print and carriage return
|
||||
|
||||
private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00};
|
||||
/** Creates a new instance of CodesEpson */
|
||||
public CodesSurePOS() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getInitSequence() { return INITSEQUENCE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize0() { return CHAR_SIZE_0; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize1() { return CHAR_SIZE_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize2() { return CHAR_SIZE_2; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize3() { return CHAR_SIZE_3; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldSet() { return BOLD_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldReset() { return BOLD_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineSet() { return UNDERLINE_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineReset() { return UNDERLINE_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getOpenDrawer() { return OPEN_DRAWER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCutReceipt() { return PARTIAL_CUT_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getNewLine() { return NEW_LINE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageHeader() { return IMAGE_HEADER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getImageWidth() { return 256; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageLogo(){ return IMAGE_LOGO; }
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class CodesTMU220 extends Codes {
|
||||
|
||||
private static final byte[] INITSEQUENCE = {};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] CHAR_SIZE_0 = {0x1B, 0x21, 0x01}; // This sets 7x9 font
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] CHAR_SIZE_1 = {0x1B, 0x21, 0x11}; // This sets double hight 7x9 font
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] CHAR_SIZE_2 = {0x1B, 0x21, 0x21}; // This sets 7x9 double width font
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] CHAR_SIZE_3 = {0x1B, 0x21, 0x31}; // This sets 7x9 double width/hight font
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00};
|
||||
|
||||
private static final byte[] OPEN_DRAWER = {0x1B, 0x70, 0x00, 0x32, -0x06};
|
||||
private static final byte[] PARTIAL_CUT_1 = {0x1B, 0x69};
|
||||
private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x03};
|
||||
private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return
|
||||
|
||||
private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00};
|
||||
/** Creates a new instance of CodesTMU220 */
|
||||
public CodesTMU220() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getInitSequence() { return INITSEQUENCE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize0() { return CHAR_SIZE_0; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize1() { return CHAR_SIZE_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize2() { return CHAR_SIZE_2; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getSize3() { return CHAR_SIZE_3; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldSet() { return BOLD_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBoldReset() { return BOLD_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineSet() { return UNDERLINE_SET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getUnderlineReset() { return UNDERLINE_RESET; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getOpenDrawer() { return OPEN_DRAWER; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCutReceipt() { return PARTIAL_CUT_1; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getNewLine() { return NEW_LINE; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageHeader() { return IMAGE_HEADER; } // Not used
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getImageWidth() { return 256; }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param oImage
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] transImage(BufferedImage oImage) {
|
||||
// Nothing to print
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getImageLogo(){ return IMAGE_LOGO; }
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.printer.DeviceTicket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DeviceDisplayESCPOS extends DeviceDisplaySerial {
|
||||
|
||||
private UnicodeTranslator trans;
|
||||
|
||||
/** Creates a new instance of DeviceDisplayESCPOS
|
||||
* @param display
|
||||
* @param trans */
|
||||
public DeviceDisplayESCPOS(PrinterWritter display, UnicodeTranslator trans) {
|
||||
this.trans = trans;
|
||||
init(display);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void initVisor() {
|
||||
display.init(ESCPOS.INIT);
|
||||
display.write(ESCPOS.SELECT_DISPLAY); // Al visor
|
||||
display.write(trans.getCodeTable());
|
||||
display.write(ESCPOS.VISOR_HIDE_CURSOR);
|
||||
display.write(ESCPOS.VISOR_CLEAR);
|
||||
display.write(ESCPOS.VISOR_HOME);
|
||||
display.flush();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void clearLines() {
|
||||
// display.write(ESCPOS.SELECT_DISPLAY);
|
||||
// display.write(ESCPOS.VISOR_CLEAR);
|
||||
// display.write(ESCPOS.VISOR_HOME);
|
||||
// display.flush();
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void repaintLines() {
|
||||
|
||||
display.write(ESCPOS.SELECT_DISPLAY);
|
||||
display.write(ESCPOS.VISOR_CLEAR);
|
||||
display.write(ESCPOS.VISOR_HOME);
|
||||
display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine1(), 20)));
|
||||
display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine2(), 20)));
|
||||
display.flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.printer.DeviceDisplay;
|
||||
import com.unicenta.pos.printer.DeviceDisplayBase;
|
||||
import com.unicenta.pos.printer.DeviceDisplayImpl;
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public abstract class DeviceDisplaySerial implements DeviceDisplay, DeviceDisplayImpl {
|
||||
|
||||
private String m_sName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected PrinterWritter display;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected DeviceDisplayBase m_displaylines;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DeviceDisplaySerial() {
|
||||
m_displaylines = new DeviceDisplayBase(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param display
|
||||
*/
|
||||
protected void init(PrinterWritter display) {
|
||||
m_sName = AppLocal.getIntString("printer.serial");
|
||||
this.display = display;
|
||||
initVisor();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public javax.swing.JComponent getDisplayComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(int animation, String sLine1, String sLine2) {
|
||||
m_displaylines.writeVisor(animation, sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(String sLine1, String sLine2) {
|
||||
m_displaylines.writeVisor(sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void clearVisor() {
|
||||
m_displaylines.clearVisor();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract void initVisor();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.printer.DeviceTicket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class DeviceDisplaySurePOS extends DeviceDisplaySerial {
|
||||
|
||||
private UnicodeTranslator trans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param display
|
||||
*/
|
||||
public DeviceDisplaySurePOS(PrinterWritter display) {
|
||||
trans = new UnicodeTranslatorSurePOS();
|
||||
init(display);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void initVisor() {
|
||||
display.write(new byte[]{0x00, 0x01}); // IBM Mode
|
||||
display.write(new byte[]{0x02}); // Set the code page
|
||||
display.write(trans.getCodeTable());
|
||||
display.write(new byte[]{0x11}); // HIDE CURSOR
|
||||
display.write(new byte[]{0x14}); // HIDE CURSOR
|
||||
display.write(new byte[]{0x10, 0x00}); // VISOR HOME
|
||||
display.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void repaintLines() {
|
||||
display.write(new byte[]{0x10, 0x00}); // VISOR HOME
|
||||
display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine1(), 20)));
|
||||
display.write(new byte[]{0x10, 0x14});
|
||||
display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine2(), 20)));
|
||||
display.flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DevicePrinterESCPOS implements DevicePrinter {
|
||||
|
||||
private PrinterWritter m_CommOutputPrinter;
|
||||
private Codes m_codes;
|
||||
private UnicodeTranslator m_trans;
|
||||
|
||||
// private boolean m_bInline;
|
||||
private String m_sName;
|
||||
|
||||
|
||||
// Creates new TicketPrinter
|
||||
|
||||
/**
|
||||
*
|
||||
* @param CommOutputPrinter
|
||||
* @param codes
|
||||
* @param trans
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public DevicePrinterESCPOS(PrinterWritter CommOutputPrinter, Codes codes, UnicodeTranslator trans) throws TicketPrinterException {
|
||||
|
||||
m_sName = AppLocal.getIntString("printer.serial");
|
||||
m_CommOutputPrinter = CommOutputPrinter;
|
||||
m_codes = codes;
|
||||
m_trans = trans;
|
||||
|
||||
// Inicializamos la impresora
|
||||
m_CommOutputPrinter.init(ESCPOS.INIT);
|
||||
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); // A la impresora
|
||||
m_CommOutputPrinter.init(m_codes.getInitSequence());
|
||||
m_CommOutputPrinter.write(m_trans.getCodeTable());
|
||||
|
||||
m_CommOutputPrinter.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getPrinterComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void printImage(BufferedImage image) {
|
||||
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
m_CommOutputPrinter.write(m_codes.transImage(image));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printLogo() {
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
m_CommOutputPrinter.write(m_codes.getImageLogo());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarCode(String type, String position, String code) {
|
||||
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
m_codes.printBarcode(m_CommOutputPrinter, type, position, code);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iTextSize
|
||||
*/
|
||||
@Override
|
||||
public void beginLine(int iTextSize) {
|
||||
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
|
||||
if (iTextSize == DevicePrinter.SIZE_0) {
|
||||
m_CommOutputPrinter.write(m_codes.getSize0());
|
||||
} else if (iTextSize == DevicePrinter.SIZE_1) {
|
||||
m_CommOutputPrinter.write(m_codes.getSize1());
|
||||
} else if (iTextSize == DevicePrinter.SIZE_2) {
|
||||
m_CommOutputPrinter.write(m_codes.getSize2());
|
||||
} else if (iTextSize == DevicePrinter.SIZE_3) {
|
||||
m_CommOutputPrinter.write(m_codes.getSize3());
|
||||
} else {
|
||||
m_CommOutputPrinter.write(m_codes.getSize0());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iStyle
|
||||
* @param sText
|
||||
*/
|
||||
@Override
|
||||
public void printText(int iStyle, String sText) {
|
||||
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
|
||||
if ((iStyle & DevicePrinter.STYLE_BOLD) != 0) {
|
||||
m_CommOutputPrinter.write(m_codes.getBoldSet());
|
||||
}
|
||||
if ((iStyle & DevicePrinter.STYLE_UNDERLINE) != 0) {
|
||||
m_CommOutputPrinter.write(m_codes.getUnderlineSet());
|
||||
}
|
||||
m_CommOutputPrinter.write(m_trans.transString(sText));
|
||||
if ((iStyle & DevicePrinter.STYLE_UNDERLINE) != 0) {
|
||||
m_CommOutputPrinter.write(m_codes.getUnderlineReset());
|
||||
}
|
||||
if ((iStyle & DevicePrinter.STYLE_BOLD) != 0) {
|
||||
m_CommOutputPrinter.write(m_codes.getBoldReset());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endLine() {
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
m_CommOutputPrinter.write(m_codes.getNewLine());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
|
||||
m_CommOutputPrinter.write(m_codes.getNewLine());
|
||||
m_CommOutputPrinter.write(m_codes.getNewLine());
|
||||
m_CommOutputPrinter.write(m_codes.getNewLine());
|
||||
m_CommOutputPrinter.write(m_codes.getNewLine());
|
||||
m_CommOutputPrinter.write(m_codes.getNewLine());
|
||||
|
||||
m_CommOutputPrinter.write(m_codes.getCutReceipt());
|
||||
m_CommOutputPrinter.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void openDrawer() {
|
||||
|
||||
m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
|
||||
System.out.print(m_codes.getOpenDrawer());
|
||||
|
||||
m_CommOutputPrinter.write(m_codes.getOpenDrawer());
|
||||
m_CommOutputPrinter.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DevicePrinterPlain implements DevicePrinter {
|
||||
|
||||
private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return
|
||||
|
||||
private final PrinterWritter out;
|
||||
private final UnicodeTranslator trans;
|
||||
|
||||
// Creates new TicketPrinter
|
||||
|
||||
/**
|
||||
*
|
||||
* @param CommOutputPrinter
|
||||
* @throws TicketPrinterException
|
||||
*/
|
||||
public DevicePrinterPlain(PrinterWritter CommOutputPrinter) throws TicketPrinterException {
|
||||
|
||||
out = CommOutputPrinter;
|
||||
trans = new UnicodeTranslatorStar(); // The star translator stands for the 437 int char page
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterName() {
|
||||
return "Plain";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getPrinterComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void printImage(BufferedImage image) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printLogo(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarCode(String type, String position, String code) {
|
||||
if (! DevicePrinter.POSITION_NONE.equals(position)) {
|
||||
out.write(code);
|
||||
out.write(NEW_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iTextSize
|
||||
*/
|
||||
@Override
|
||||
public void beginLine(int iTextSize) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iStyle
|
||||
* @param sText
|
||||
*/
|
||||
@Override
|
||||
public void printText(int iStyle, String sText) {
|
||||
out.write(trans.transString(sText));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endLine() {
|
||||
out.write(NEW_LINE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
out.write(NEW_LINE);
|
||||
out.write(NEW_LINE);
|
||||
out.write(NEW_LINE);
|
||||
out.write(NEW_LINE);
|
||||
out.write(NEW_LINE);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void openDrawer() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class ESCPOS {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final byte[] INIT = {0x1B, 0x40};
|
||||
public static final byte[] SELECT_PRINTER = {0x1B, 0x3D, 0x01};
|
||||
public static final byte[] SELECT_DISPLAY = {0x1B, 0x3D, 0x02};
|
||||
public static final byte[] HT = {0x09}; // Horizontal Tab
|
||||
// public static final byte[] LF = {0x0A}; // Print and line feed
|
||||
public static final byte[] FF = {0x0C}; //
|
||||
// public static final byte[] CR = {0x0D}; // Print and carriage return
|
||||
public static final byte[] CHAR_FONT_0 = {0x1B, 0x4D, 0x00};
|
||||
public static final byte[] CHAR_FONT_1 = {0x1B, 0x4D, 0x01};
|
||||
public static final byte[] CHAR_FONT_2 = {0x1B, 0x4D, 0x30};
|
||||
public static final byte[] CHAR_FONT_3 = {0x1B, 0x4D, 0x31};
|
||||
public static final byte[] BAR_HEIGHT = {0x1D, 0x68, 0x40};
|
||||
public static final byte[] BAR_POSITIONDOWN = {0x1D, 0x48, 0x02};
|
||||
public static final byte[] BAR_POSITIONNONE = {0x1D, 0x48, 0x00};
|
||||
public static final byte[] BAR_HRIFONT1 = {0x1D, 0x66, 0x01};
|
||||
public static final byte[] BAR_CODE02 = {0x1D, 0x6B, 0x02}; // 12 numeros fijos
|
||||
public static final byte[] VISOR_HIDE_CURSOR = {0x1F, 0x43, 0x00};
|
||||
public static final byte[] VISOR_SHOW_CURSOR = {0x1F, 0x43, 0x01};
|
||||
public static final byte[] VISOR_HOME = {0x0B};
|
||||
public static final byte[] VISOR_CLEAR = {0x0C};
|
||||
public static final byte[] CODE_TABLE_00 = {0x1B, 0x74, 0x00};
|
||||
public static final byte[] CODE_TABLE_13 = {0x1B, 0x74, 0x13};
|
||||
private ESCPOS() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class PrinterWritter {
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
private ExecutorService exec;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PrinterWritter() {
|
||||
exec = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
protected abstract void internalWrite(byte[] data);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected abstract void internalFlush();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected abstract void internalClose();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void init(final byte[] data) {
|
||||
if (!initialized) {
|
||||
write(data);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sValue
|
||||
*/
|
||||
public void write(String sValue) {
|
||||
write(sValue.getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void write(final byte[] data) {
|
||||
exec.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
internalWrite(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void flush() {
|
||||
exec.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
internalFlush();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void close() {
|
||||
exec.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
internalClose();
|
||||
}
|
||||
});
|
||||
exec.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class PrinterWritterFile extends PrinterWritter {
|
||||
|
||||
private String m_sFilePrinter;
|
||||
private OutputStream m_out;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sFilePrinter
|
||||
*/
|
||||
public PrinterWritterFile(String sFilePrinter) {
|
||||
m_sFilePrinter = sFilePrinter;
|
||||
m_out = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
protected void internalWrite(byte[] data) {
|
||||
try {
|
||||
if (m_out == null) {
|
||||
m_out = new FileOutputStream(m_sFilePrinter); // No poner append = true.
|
||||
}
|
||||
m_out.write(data);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected void internalFlush() {
|
||||
try {
|
||||
if (m_out != null) {
|
||||
m_out.flush();
|
||||
m_out.close();
|
||||
m_out = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected void internalClose() {
|
||||
try {
|
||||
if (m_out != null) {
|
||||
m_out.flush();
|
||||
m_out.close();
|
||||
m_out = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
// import javax.comm.*; // Java comm library
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import gnu.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class PrinterWritterRXTX extends PrinterWritter /* implements SerialPortEventListener */ {
|
||||
|
||||
private CommPortIdentifier m_PortIdPrinter;
|
||||
private CommPort m_CommPortPrinter;
|
||||
|
||||
private String m_sPortPrinter;
|
||||
private OutputStream m_out;
|
||||
|
||||
/** Creates a new instance of PrinterWritterComm
|
||||
* @param sPortPrinter
|
||||
* @throws com.unicenta.pos.printer.TicketPrinterException */
|
||||
public PrinterWritterRXTX(String sPortPrinter) throws TicketPrinterException {
|
||||
m_sPortPrinter = sPortPrinter;
|
||||
m_out = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
protected void internalWrite(byte[] data) {
|
||||
try {
|
||||
if (m_out == null) {
|
||||
m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortPrinter); // Tomamos el puerto
|
||||
m_CommPortPrinter = m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto
|
||||
|
||||
m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura
|
||||
|
||||
if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_SERIAL) {
|
||||
((SerialPort)m_CommPortPrinter).setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // Configuramos el puerto
|
||||
((SerialPort)m_CommPortPrinter).setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN); // this line prevents the printer tmu220 to stop printing after +-18 lines printed
|
||||
// this line prevents the printer tmu220 to stop printing after +-18 lines printed. Bug 8324
|
||||
// But if added a regression error appears. Bug 9417, Better to keep it commented.
|
||||
// ((SerialPort)m_CommPortPrinter).setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
|
||||
// Not needed to set parallel properties
|
||||
// } else if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
|
||||
// ((ParallelPort)m_CommPortPrinter).setMode(1);
|
||||
|
||||
}
|
||||
}
|
||||
m_out.write(data);
|
||||
// JG 16 May 12 use multicatch
|
||||
} catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected void internalFlush() {
|
||||
try {
|
||||
if (m_out != null) {
|
||||
m_out.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected void internalClose() {
|
||||
try {
|
||||
if (m_out != null) {
|
||||
m_out.flush();
|
||||
m_out.close();
|
||||
m_out = null;
|
||||
m_CommPortPrinter = null;
|
||||
m_PortIdPrinter = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Adrian Romero Corchado.
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
import javax.print.Doc;
|
||||
import javax.print.DocFlavor;
|
||||
import javax.print.DocPrintJob;
|
||||
import javax.print.PrintException;
|
||||
import javax.print.PrintService;
|
||||
import javax.print.PrintServiceLookup;
|
||||
import javax.print.SimpleDoc;
|
||||
import javax.print.attribute.DocAttributeSet;
|
||||
import javax.print.attribute.HashDocAttributeSet;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.standard.DocumentName;
|
||||
import javax.print.attribute.standard.JobName;
|
||||
|
||||
public final class PrinterWritterRaw extends PrinterWritter {
|
||||
|
||||
private byte[] m_printData;
|
||||
private PrintService m_printService;
|
||||
private final DocFlavor m_docFlavor;
|
||||
private PrinterBuffer m_buff = null;
|
||||
private OutputStream m_out;
|
||||
|
||||
public PrinterWritterRaw(String sRawPrinter) {
|
||||
m_printData = null;
|
||||
m_docFlavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
|
||||
m_buff = new PrinterBuffer();
|
||||
|
||||
init();
|
||||
|
||||
PrintService[] services = PrintServiceLookup.lookupPrintServices(m_docFlavor, null);
|
||||
for (PrintService ps : services) {
|
||||
if (ps.getName().contains(sRawPrinter)) {
|
||||
// if we have found the prineter the start our print routine
|
||||
m_printService = ps;
|
||||
write(ESCPOS.INIT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
byte[] inicode = concatByteArrays(ESCPOS.SELECT_PRINTER, new UnicodeTranslatorInt().getCodeTable());
|
||||
m_printData = concatByteArrays(inicode, m_printData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] data) {
|
||||
m_printData = concatByteArrays(m_printData, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String sValue) {
|
||||
m_buff.putData(sValue.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void internalWrite(byte[] data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void internalClose() {
|
||||
try {
|
||||
if (m_out != null) {
|
||||
m_out.flush();
|
||||
m_out.close();
|
||||
m_out = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void internalFlush() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
printJob();
|
||||
}
|
||||
|
||||
private byte[] concatByteArrays(byte[] a, byte[] b) {
|
||||
if (a == null) {
|
||||
return b;
|
||||
}
|
||||
if (b == null) {
|
||||
return a;
|
||||
}
|
||||
byte[] concat = new byte[a.length + b.length];
|
||||
System.arraycopy(a, 0, concat, 0, a.length);
|
||||
System.arraycopy(b, 0, concat, a.length, b.length);
|
||||
return concat;
|
||||
}
|
||||
|
||||
private void printJob() {
|
||||
if (null != m_printService) {
|
||||
try {
|
||||
DocPrintJob pj = m_printService.createPrintJob();
|
||||
DocAttributeSet docattributes = new HashDocAttributeSet();
|
||||
|
||||
docattributes.add(new DocumentName("Ticket", Locale.getDefault()));
|
||||
PrintRequestAttributeSet jobattributes = new HashPrintRequestAttributeSet();
|
||||
|
||||
jobattributes.add(new JobName("unicenta", Locale.getDefault()));
|
||||
Doc doc = new SimpleDoc(m_printData, m_docFlavor, docattributes);
|
||||
pj.print(doc, jobattributes);
|
||||
} catch (PrintException ex) {
|
||||
} finally {
|
||||
m_printData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PrinterBuffer {
|
||||
|
||||
private final LinkedList m_list;
|
||||
|
||||
/**
|
||||
* Creates a new instance of PrinterBuffer
|
||||
*/
|
||||
public PrinterBuffer() {
|
||||
m_list = new LinkedList();
|
||||
}
|
||||
|
||||
public synchronized void putData(Object data) {
|
||||
m_list.addFirst(data);
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
public synchronized Object getData() {
|
||||
while (m_list.isEmpty()) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
notifyAll();
|
||||
return m_list.removeLast();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class UnicodeTranslator {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract byte[] getCodeTable();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sCad
|
||||
* @return
|
||||
*/
|
||||
public final byte[] transString(String sCad) {
|
||||
|
||||
if (sCad == null) {
|
||||
return null;
|
||||
} else {
|
||||
byte bAux[] = new byte[sCad.length()];
|
||||
for( int i = 0; i < sCad.length(); i++) {
|
||||
bAux[i] = transChar(sCad.charAt(i));
|
||||
}
|
||||
return bAux;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sChar
|
||||
* @return
|
||||
*/
|
||||
public abstract byte transChar(char sChar);
|
||||
|
||||
// case '\u0000': return -0x80; // 0x80 :
|
||||
// case '\u0000': return -0x7F; // 0x81 :
|
||||
// case '\u0000': return -0x7E; // 0x82 :
|
||||
// case '\u0000': return -0x7D; // 0x83 :
|
||||
// case '\u0000': return -0x7C; // 0x84 :
|
||||
// case '\u0000': return -0x7B; // 0x85 :
|
||||
// case '\u0000': return -0x7A; // 0x86 :
|
||||
// case '\u0000': return -0x79; // 0x87 :
|
||||
// case '\u0000': return -0x78; // 0x88 :
|
||||
// case '\u0000': return -0x77; // 0x89 :
|
||||
// case '\u0000': return -0x76; // 0x8A :
|
||||
// case '\u0000': return -0x75; // 0x8B :
|
||||
// case '\u0000': return -0x74; // 0x8C :
|
||||
// case '\u0000': return -0x73; // 0x8D :
|
||||
// case '\u0000': return -0x72; // 0x8E :
|
||||
// case '\u0000': return -0x71; // 0x8F :
|
||||
// case '\u0000': return -0x70; // 0x90 :
|
||||
// case '\u0000': return -0x6F; // 0x91 :
|
||||
// case '\u0000': return -0x6E; // 0x92 :
|
||||
// case '\u0000': return -0x6D; // 0x93 :
|
||||
// case '\u0000': return -0x6C; // 0x94 :
|
||||
// case '\u0000': return -0x6B; // 0x95 :
|
||||
// case '\u0000': return -0x6A; // 0x96 :
|
||||
// case '\u0000': return -0x69; // 0x97 :
|
||||
// case '\u0000': return -0x68; // 0x98 :
|
||||
// case '\u0000': return -0x67; // 0x99 :
|
||||
// case '\u0000': return -0x66; // 0x9A :
|
||||
// case '\u0000': return -0x65; // 0x9B :
|
||||
// case '\u0000': return -0x64; // 0x9C :
|
||||
// case '\u0000': return -0x63; // 0x9D :
|
||||
// case '\u0000': return -0x62; // 0x9E :
|
||||
// case '\u0000': return -0x61; // 0x9F :
|
||||
// case '\u0000': return -0x60; // 0xA0 :
|
||||
// case '\u0000': return -0x5F; // 0xA1 :
|
||||
// case '\u0000': return -0x5E; // 0xA2 :
|
||||
// case '\u0000': return -0x5D; // 0xA3 :
|
||||
// case '\u0000': return -0x5C; // 0xA4 :
|
||||
// case '\u0000': return -0x5B; // 0xA5 :
|
||||
// case '\u0000': return -0x5A; // 0xA6 :
|
||||
// case '\u0000': return -0x59; // 0xA7 :
|
||||
// case '\u0000': return -0x58; // 0xA8 :
|
||||
// case '\u0000': return -0x57; // 0xA9 :
|
||||
// case '\u0000': return -0x56; // 0xAA :
|
||||
// case '\u0000': return -0x55; // 0xAB :
|
||||
// case '\u0000': return -0x54; // 0xAC :
|
||||
// case '\u0000': return -0x53; // 0xAD :
|
||||
// case '\u0000': return -0x52; // 0xAE :
|
||||
// case '\u0000': return -0x51; // 0xAF :
|
||||
// case '\u0000': return -0x50; // 0xB0 :
|
||||
// case '\u0000': return -0x4F; // 0xB1 :
|
||||
// case '\u0000': return -0x4E; // 0xB2 :
|
||||
// case '\u0000': return -0x4D; // 0xB3 :
|
||||
// case '\u0000': return -0x4C; // 0xB4 :
|
||||
// case '\u0000': return -0x4B; // 0xB5 :
|
||||
// case '\u0000': return -0x4A; // 0xB6 :
|
||||
// case '\u0000': return -0x49; // 0xB7 :
|
||||
// case '\u0000': return -0x48; // 0xB8 :
|
||||
// case '\u0000': return -0x47; // 0xB9 :
|
||||
// case '\u0000': return -0x46; // 0xBA :
|
||||
// case '\u0000': return -0x45; // 0xBB :
|
||||
// case '\u0000': return -0x44; // 0xBC :
|
||||
// case '\u0000': return -0x43; // 0xBD :
|
||||
// case '\u0000': return -0x42; // 0xBE :
|
||||
// case '\u0000': return -0x41; // 0xBF :
|
||||
// case '\u0000': return -0x40; // 0xC0 :
|
||||
// case '\u0000': return -0x3F; // 0xC1 :
|
||||
// case '\u0000': return -0x3E; // 0xC2 :
|
||||
// case '\u0000': return -0x3D; // 0xC3 :
|
||||
// case '\u0000': return -0x3C; // 0xC4 :
|
||||
// case '\u0000': return -0x3B; // 0xC5 :
|
||||
// case '\u0000': return -0x3A; // 0xC6 :
|
||||
// case '\u0000': return -0x39; // 0xC7 :
|
||||
// case '\u0000': return -0x38; // 0xC8 :
|
||||
// case '\u0000': return -0x37; // 0xC9 :
|
||||
// case '\u0000': return -0x36; // 0xCA :
|
||||
// case '\u0000': return -0x35; // 0xCB :
|
||||
// case '\u0000': return -0x34; // 0xCC :
|
||||
// case '\u0000': return -0x33; // 0xCD :
|
||||
// case '\u0000': return -0x32; // 0xCE :
|
||||
// case '\u0000': return -0x31; // 0xCF :
|
||||
// case '\u0000': return -0x30; // 0xD0 :
|
||||
// case '\u0000': return -0x2F; // 0xD1 :
|
||||
// case '\u0000': return -0x2E; // 0xD2 :
|
||||
// case '\u0000': return -0x2D; // 0xD3 :
|
||||
// case '\u0000': return -0x2C; // 0xD4 :
|
||||
// case '\u0000': return -0x2B; // 0xD5 :
|
||||
// case '\u0000': return -0x2A; // 0xD6 :
|
||||
// case '\u0000': return -0x29; // 0xD7 :
|
||||
// case '\u0000': return -0x28; // 0xD8 :
|
||||
// case '\u0000': return -0x27; // 0xD9 :
|
||||
// case '\u0000': return -0x26; // 0xDA :
|
||||
// case '\u0000': return -0x25; // 0xDB :
|
||||
// case '\u0000': return -0x24; // 0xDC :
|
||||
// case '\u0000': return -0x23; // 0xDD :
|
||||
// case '\u0000': return -0x22; // 0xDE :
|
||||
// case '\u0000': return -0x21; // 0xDF :
|
||||
// case '\u0000': return -0x20; // 0xE0 :
|
||||
// case '\u0000': return -0x2F; // 0xE1 :
|
||||
// case '\u0000': return -0x1E; // 0xE2 :
|
||||
// case '\u0000': return -0x1D; // 0xE3 :
|
||||
// case '\u0000': return -0x1C; // 0xE4 :
|
||||
// case '\u0000': return -0x1B; // 0xE5 :
|
||||
// case '\u0000': return -0x1A; // 0xE6 :
|
||||
// case '\u0000': return -0x19; // 0xE7 :
|
||||
// case '\u0000': return -0x18; // 0xE8 :
|
||||
// case '\u0000': return -0x17; // 0xE9 :
|
||||
// case '\u0000': return -0x16; // 0xEA :
|
||||
// case '\u0000': return -0x15; // 0xEB :
|
||||
// case '\u0000': return -0x14; // 0xEC :
|
||||
// case '\u0000': return -0x13; // 0xED :
|
||||
// case '\u0000': return -0x12; // 0xEE :
|
||||
// case '\u0000': return -0x11; // 0xEF :
|
||||
// case '\u0000': return -0x10; // 0xF0 :
|
||||
// case '\u0000': return -0x0F; // 0xF1 :
|
||||
// case '\u0000': return -0x0E; // 0xF2 :
|
||||
// case '\u0000': return -0x0D; // 0xF3 :
|
||||
// case '\u0000': return -0x0C; // 0xF4 :
|
||||
// case '\u0000': return -0x0B; // 0xF5 :
|
||||
// case '\u0000': return -0x0A; // 0xF6 :
|
||||
// case '\u0000': return -0x09; // 0xF7 :
|
||||
// case '\u0000': return -0x08; // 0xF8 :
|
||||
// case '\u0000': return -0x07; // 0xF9 :
|
||||
// case '\u0000': return -0x06; // 0xFA :
|
||||
// case '\u0000': return -0x05; // 0xFB :
|
||||
// case '\u0000': return -0x04; // 0xFC :
|
||||
// case '\u0000': return -0x03; // 0xFD :
|
||||
// case '\u0000': return -0x02; // 0xFE :
|
||||
// case '\u0000': return -0x01; // 0xFF :
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class UnicodeTranslatorEur extends UnicodeTranslator {
|
||||
|
||||
/** Creates a new instance of UnicodeTranslatorEur */
|
||||
public UnicodeTranslatorEur() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCodeTable() {
|
||||
return ESCPOS.CODE_TABLE_13;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sChar
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte transChar(char sChar) {
|
||||
if ((sChar >= 0x0000) && (sChar < 0x0080)) {
|
||||
return (byte) sChar;
|
||||
} else {
|
||||
switch (sChar) {
|
||||
case '\u00e1': return -0x60; // a acute
|
||||
case '\u00e9': return -0x7E; // e acute
|
||||
case '\u00ed': return -0x5F; // i acute
|
||||
case '\u00f3': return -0x5E; // o acute
|
||||
case '\u00fa': return -0x5D; // u acute
|
||||
case '\u00fc': return -0x7F; // u dieresis
|
||||
case '\u00f1': return -0x5C; // n tilde
|
||||
case '\u00d1': return -0x5B; // N tilde
|
||||
|
||||
case '\u00c1': return 0x41; // A acute
|
||||
case '\u00c9': return 0x45; // E acute
|
||||
case '\u00cd': return 0x49; // I acute
|
||||
case '\u00d3': return 0x4F; // O acute
|
||||
case '\u00da': return 0x55; // U acute
|
||||
case '\u00dc': return -0x66; // U dieresis
|
||||
case '\u00bf': return -0x58; // abrir interrogacion
|
||||
case '\u00a1': return -0x53; // abrir admiracion
|
||||
case '\u20ac': return -0x12; // Euro Sign
|
||||
|
||||
|
||||
default: return 0x3F; // ? Not valid character.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class UnicodeTranslatorInt extends UnicodeTranslator {
|
||||
|
||||
/** Creates a new instance of UnicodeTranslatorInt */
|
||||
public UnicodeTranslatorInt() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCodeTable() {
|
||||
return ESCPOS.CODE_TABLE_13;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sChar
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte transChar(char sChar) {
|
||||
if ((sChar >= 0x0000) && (sChar < 0x0080)) {
|
||||
return (byte) sChar;
|
||||
} else {
|
||||
switch (sChar) {
|
||||
case '\u00c7': return -0x80;
|
||||
case '\u00fc': return -0x7F; // u dieresis
|
||||
case '\u00e2': return -0x7D;
|
||||
case '\u00e4': return -0x7C;
|
||||
case '\u00e0': return -0x7B;
|
||||
case '\u00E5': return -0x7A; // ao
|
||||
case '\u00e7': return -0x79;
|
||||
case '\u00ea': return -0x78;
|
||||
case '\u00eb': return -0x77;
|
||||
case '\u00e8': return -0x76;
|
||||
case '\u00ef': return -0x75;
|
||||
case '\u00ee': return -0x74;
|
||||
case '\u00ec': return -0x73;
|
||||
case '\u00c4': return -0x72;
|
||||
case '\u00C5': return -0x71; // Ao
|
||||
|
||||
case '\u00c9': return -0x70; // E acute
|
||||
case '\u00E6': return -0x6F; // ae
|
||||
case '\u00C6': return -0x6E; // AE
|
||||
case '\u00f4': return -0x6D;
|
||||
case '\u00f6': return -0x6C;
|
||||
case '\u00f2': return -0x6B;
|
||||
case '\u00fb': return -0x6A;
|
||||
case '\u00f9': return -0x69;
|
||||
case '\u00ff': return -0x68;
|
||||
case '\u00d6': return -0x67;
|
||||
case '\u00dc': return -0x66; // U dieresis
|
||||
case '\u00F8': return -0x65; // o/
|
||||
case '\u00A3': return -0x64; // L- Libra esterlina
|
||||
case '\u00D8': return -0x63; // O/
|
||||
case '\u00D7': return -0x62; // X
|
||||
// case '': return -0x61; // f
|
||||
|
||||
case '\u00e1': return -0x60; // a acute
|
||||
case '\u00e9': return -0x7E; // e acute
|
||||
case '\u00ed': return -0x5F; // i acute
|
||||
case '\u00f3': return -0x5E; // o acute
|
||||
case '\u00fa': return -0x5D; // u acute
|
||||
case '\u00f1': return -0x5C; // n tilde
|
||||
case '\u00d1': return -0x5B; // N tilde
|
||||
case '\u00aa': return -0x5A;
|
||||
case '\u00ba': return -0x59;
|
||||
case '\u00bf': return -0x58; // abrir interrogacion
|
||||
case '\u00AE': return -0x57; // (R) Registrado
|
||||
case '\u00ac': return -0x56; // Not sign
|
||||
case '\u00BD': return -0x55; // 1/2
|
||||
case '\u00BC': return -0x54; // 1/4
|
||||
case '\u00a1': return -0x53; // abrir admiracion
|
||||
case '\u00AB': return -0x52; // <<
|
||||
case '\u00BB': return -0x51; // >>
|
||||
|
||||
case '\u2591': return -0x50; // Light shade
|
||||
case '\u2592': return -0x4F; // Medium shade
|
||||
case '\u2593': return -0x4E; // Dark shade
|
||||
case '\u2502': return -0x4D; // BOX DRAWINGS LIGHT VERTICAL
|
||||
case '\u2524': return -0x4C; // BOX DRAWINGS LIGHT VERTICAL AND LEFT
|
||||
case '\u00c1': return -0x4B; // A acute
|
||||
case '\u00c2': return -0x4A;
|
||||
case '\u00c0': return -0x49;
|
||||
case '\u00A9': return -0x48; // (c) Copyright
|
||||
case '\u2563': return -0x47; // BOX DRAWINGS DOUBLE VERTICAL AND LEFT
|
||||
case '\u2551': return -0x46; // BOX DRAWINGS DOUBLE VERTICAL
|
||||
case '\u2557': return -0x45; // BOX DRAWINGS DOUBLE DOWN AND LEFT
|
||||
case '\u255D': return -0x44; // BOX DRAWINGS DOUBLE UP AND LEFT
|
||||
case '\u00A2': return -0x43; // Cent Sign
|
||||
case '\u00A5': return -0x42; // Yen Sign
|
||||
case '\u2510': return -0x41; // BOX DRAWINGS LIGHT DOWN AND LEFT
|
||||
|
||||
case '\u2514': return -0x40; // BOX DRAWINGS LIGHT UP ANDRIGHT
|
||||
// case '': return -0x3F; //
|
||||
// case '': return -0x3E; //
|
||||
// case '': return -0x3D; //
|
||||
// case '': return -0x3C; //
|
||||
// case '': return -0x3B; //
|
||||
// case '': return -0x3A; //
|
||||
// case '': return -0x39; //
|
||||
// case '': return -0x38; //
|
||||
// case '': return -0x37; //
|
||||
// case '': return -0x36; //
|
||||
// case '': return -0x35; //
|
||||
// case '': return -0x34; //
|
||||
// case '': return -0x33; //
|
||||
// case '': return -0x32; //
|
||||
// case '': return -0x31; //
|
||||
|
||||
// case '': return -0x30; //
|
||||
// case '': return -0x2F; //
|
||||
case '\u00ca': return -0x2E; //
|
||||
case '\u00cb': return -0x2D; //
|
||||
case '\u00c8': return -0x2C; //
|
||||
case '\u20ac': return -0x2B; // Euro Sign
|
||||
case '\u00cd': return -0x2A; // I acute
|
||||
case '\u00ce': return -0x29; //
|
||||
case '\u00cf': return -0x28; //
|
||||
// case '': return -0x27; //
|
||||
// case '': return -0x26; //
|
||||
// case '': return -0x25; //
|
||||
// case '': return -0x24; //
|
||||
case '|': return -0x23; //
|
||||
case '\u00cc': return -0x22; //
|
||||
// case '': return -0x21; //
|
||||
|
||||
case '\u00d3': return -0x20; // O acute
|
||||
// case '': return -0x1F; //
|
||||
case '\u00d4': return -0x1E; //
|
||||
case '\u00d2': return -0x1D; //
|
||||
// case '': return -0x1C; //
|
||||
// case '': return -0x1B; //
|
||||
// case '': return -0x1A; //
|
||||
// case '': return -0x19; //
|
||||
// case '': return -0x18; //
|
||||
case '\u00da': return -0x17; // U acute
|
||||
case '\u00db': return -0x16; //
|
||||
case '\u00d9': return -0x15; //
|
||||
case '\u00fd': return -0x14; //
|
||||
case '\u00dd': return -0x13; //
|
||||
// case '': return -0x12; //
|
||||
case '\u00b4': return -0x11; //
|
||||
|
||||
// case '': return -0x10; //
|
||||
// case '': return -0x0F; //
|
||||
// case '': return -0x0E; //
|
||||
// case '': return -0x0D; //
|
||||
// case '': return -0x0C; //
|
||||
// case '': return -0x0B; //
|
||||
// case '': return -0x0A; //
|
||||
// case '': return -0x09; //
|
||||
// case '': return -0x08; //
|
||||
case '\u00a8': return -0x07; //
|
||||
// case '': return -0x06; //
|
||||
// case '': return -0x05; //
|
||||
// case '': return -0x04; //
|
||||
// case '': return -0x03; //
|
||||
// case '': return -0x02; //
|
||||
// case ' ': return -0x01; // SP
|
||||
|
||||
default: return 0x3F; // ? Not valid character.
|
||||
|
||||
// Old translation
|
||||
// case '\u00aa' : return (byte) 0xA6;
|
||||
// case '\u00ba' : return (byte) 0xA7;
|
||||
// case '\u00a1' : return (byte) 0xAD;
|
||||
// case '\u00bf' : return (byte) 0xA8;
|
||||
// case '\u00b7' : return (byte) 0xF9;
|
||||
// case '\u00f1' : return (byte) 0xA4;
|
||||
// case '\u00d1' : return (byte) 0xA5;
|
||||
// case '\u00e1' : return (byte) 0xA0;
|
||||
// case '\u00c1' : return (byte) 0x86;
|
||||
// case '\u00e9' : return (byte) 0x82;
|
||||
// case '\u00c9' : return (byte) 0x90;
|
||||
// case '\u00ed' : return (byte) 0xA1;
|
||||
// case '\u00cd' : return (byte) 0x8B;
|
||||
// case '\u00f3' : return (byte) 0xA2;
|
||||
// case '\u00d3' : return (byte) 0x9F;
|
||||
// case '\u00fa' : return (byte) 0xA3;
|
||||
// case '\u00da' : return (byte) 0x96;
|
||||
// case '\u00fc' : return (byte) 0x81;
|
||||
// case '\u00dc' : return (byte) 0x9A;
|
||||
// default: return (byte) sChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class UnicodeTranslatorStar extends UnicodeTranslator {
|
||||
|
||||
/** Creates a UnicodeTranslatorStar instance of UnicodeTranslatorInt */
|
||||
public UnicodeTranslatorStar() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCodeTable() {
|
||||
return new byte[] {0x1B, 0x1D, 0x74, 0x01}; // Select code page 437
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sChar
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte transChar(char sChar) {
|
||||
if ((sChar >= 0x0000) && (sChar < 0x0080)) {
|
||||
return (byte) sChar;
|
||||
} else {
|
||||
switch (sChar) {
|
||||
case '\u00c1': return 0x41; // A acute
|
||||
case '\u00c9': return 0x45; // E acute
|
||||
case '\u00cd': return 0x49; // I acute
|
||||
case '\u00d3': return 0x4F; // O acute
|
||||
case '\u00da': return 0x55; // U acute
|
||||
|
||||
|
||||
case '\u00C7': return -0x80; // 0x80 : C cedilla
|
||||
case '\u00FC': return -0x7F; // 0x81 : u dieresis
|
||||
case '\u00E9': return -0x7E; // 0x82 : e acute
|
||||
// case '\u0000': return -0x7D; // 0x83 :
|
||||
case '\u00E4': return -0x7C; // 0x84 : a dieresis
|
||||
// case '\u0000': return -0x7B; // 0x85 :
|
||||
case '\u00E5': return -0x7A; // 0x86 : a circle
|
||||
case '\u00E7': return -0x79; // 0x87 : c cedilla
|
||||
// case '\u0000': return -0x78; // 0x88 :
|
||||
// case '\u0000': return -0x77; // 0x89 :
|
||||
// case '\u0000': return -0x76; // 0x8A :
|
||||
// case '\u0000': return -0x75; // 0x8B :
|
||||
// case '\u0000': return -0x74; // 0x8C :dieresis
|
||||
// case '\u0000': return -0x73; // 0x8D :
|
||||
case '\u00C4': return -0x72; // 0x8E : A dieresis
|
||||
case '\u00C5': return -0x71; // 0x8F : A circle
|
||||
// case '\u0000': return -0x70; // 0x90 :
|
||||
// case '\u0000': return -0x6F; // 0x91 :
|
||||
// case '\u0000': return -0x6E; // 0x92 :
|
||||
// case '\u0000': return -0x6D; // 0x93 :
|
||||
case '\u00F6': return -0x6C; // 0x94 : o dieresis
|
||||
// case '\u0000': return -0x6B; // 0x95 :
|
||||
// case '\u0000': return -0x6A; // 0x96 :
|
||||
// case '\u0000': return -0x69; // 0x97 :
|
||||
// case '\u0000': return -0x68; // 0x98 :
|
||||
case '\u00D6': return -0x67; // 0x99 : O dieresis
|
||||
case '\u00DC': return -0x66; // 0x9A : U dieresesis
|
||||
// case '\u0000': return -0x65; // 0x9B :
|
||||
case '\u00A3': return -0x64; // 0x9C : Pound currency
|
||||
case '\u00A5': return -0x63; // 0x9D : Yen currency
|
||||
// case '\u0000': return -0x62; // 0x9E :
|
||||
// case '\u0000': return -0x61; // 0x9F :
|
||||
case '\u00E1': return -0x60; // 0xA0 : a acute
|
||||
case '\u00ED': return -0x5F; // 0xA1 : i acute
|
||||
case '\u00F3': return -0x5E; // 0xA2 : o acute
|
||||
case '\u00FA': return -0x5D; // 0xA3 : u acute
|
||||
case '\u00F1': return -0x5C; // 0xA4 : n tilde
|
||||
case '\u00D1': return -0x5B; // 0xA5 : N tilde
|
||||
// case '\u0000': return -0x5A; // 0xA6 :
|
||||
// case '\u0000': return -0x59; // 0xA7 :
|
||||
case '\u00BF': return -0x58; // 0xA8 : open ?
|
||||
// case '\u0000': return -0x57; // 0xA9 :
|
||||
// case '\u0000': return -0x56; // 0xAA :
|
||||
// case '\u0000': return -0x55; // 0xAB :
|
||||
// case '\u0000': return -0x54; // 0xAC :
|
||||
case '\u00A1': return -0x53; // 0xAD : open !
|
||||
// case '\u0000': return -0x52; // 0xAE :
|
||||
// case '\u0000': return -0x51; // 0xAF :
|
||||
// case '\u0000': return -0x50; // 0xB0 :
|
||||
// case '\u0000': return -0x4F; // 0xB1 :
|
||||
// case '\u0000': return -0x4E; // 0xB2 :
|
||||
// case '\u0000': return -0x4D; // 0xB3 :
|
||||
// case '\u0000': return -0x4C; // 0xB4 :
|
||||
// case '\u0000': return -0x4B; // 0xB5 :
|
||||
// case '\u0000': return -0x4A; // 0xB6 :
|
||||
// case '\u0000': return -0x49; // 0xB7 :
|
||||
// case '\u0000': return -0x48; // 0xB8 :
|
||||
// case '\u0000': return -0x47; // 0xB9 :
|
||||
// case '\u0000': return -0x46; // 0xBA :
|
||||
// case '\u0000': return -0x45; // 0xBB :
|
||||
// case '\u0000': return -0x44; // 0xBC :
|
||||
// case '\u0000': return -0x43; // 0xBD :
|
||||
// case '\u0000': return -0x42; // 0xBE :
|
||||
// case '\u0000': return -0x41; // 0xBF :
|
||||
// case '\u0000': return -0x40; // 0xC0 :
|
||||
// case '\u0000': return -0x3F; // 0xC1 :
|
||||
// case '\u0000': return -0x3E; // 0xC2 :
|
||||
// case '\u0000': return -0x3D; // 0xC3 :
|
||||
// case '\u0000': return -0x3C; // 0xC4 :
|
||||
// case '\u0000': return -0x3B; // 0xC5 :
|
||||
// case '\u0000': return -0x3A; // 0xC6 :
|
||||
// case '\u0000': return -0x39; // 0xC7 :
|
||||
// case '\u0000': return -0x38; // 0xC8 :
|
||||
// case '\u0000': return -0x37; // 0xC9 :
|
||||
// case '\u0000': return -0x36; // 0xCA :
|
||||
// case '\u0000': return -0x35; // 0xCB :
|
||||
// case '\u0000': return -0x34; // 0xCC :
|
||||
// case '\u0000': return -0x33; // 0xCD :
|
||||
// case '\u0000': return -0x32; // 0xCE :
|
||||
// case '\u0000': return -0x31; // 0xCF :
|
||||
// case '\u0000': return -0x30; // 0xD0 :
|
||||
// case '\u0000': return -0x2F; // 0xD1 :
|
||||
// case '\u0000': return -0x2E; // 0xD2 :
|
||||
// case '\u0000': return -0x2D; // 0xD3 :
|
||||
// case '\u0000': return -0x2C; // 0xD4 :
|
||||
// case '\u0000': return -0x2B; // 0xD5 :
|
||||
// case '\u0000': return -0x2A; // 0xD6 :
|
||||
// case '\u0000': return -0x29; // 0xD7 :
|
||||
// case '\u0000': return -0x28; // 0xD8 :
|
||||
// case '\u0000': return -0x27; // 0xD9 :
|
||||
// case '\u0000': return -0x26; // 0xDA :
|
||||
// case '\u0000': return -0x25; // 0xDB :
|
||||
// case '\u0000': return -0x24; // 0xDC :
|
||||
// case '\u0000': return -0x23; // 0xDD :
|
||||
// case '\u0000': return -0x22; // 0xDE :
|
||||
// case '\u0000': return -0x21; // 0xDF :
|
||||
// case '\u0000': return -0x20; // 0xE0 :
|
||||
// case '\u0000': return -0x2F; // 0xE1 :
|
||||
// case '\u0000': return -0x1E; // 0xE2 :
|
||||
// case '\u0000': return -0x1D; // 0xE3 :
|
||||
// case '\u0000': return -0x1C; // 0xE4 :
|
||||
// case '\u0000': return -0x1B; // 0xE5 :
|
||||
// case '\u0000': return -0x1A; // 0xE6 :
|
||||
// case '\u0000': return -0x19; // 0xE7 :
|
||||
// case '\u0000': return -0x18; // 0xE8 :
|
||||
// case '\u0000': return -0x17; // 0xE9 :
|
||||
// case '\u0000': return -0x16; // 0xEA :
|
||||
// case '\u0000': return -0x15; // 0xEB :
|
||||
// case '\u0000': return -0x14; // 0xEC :
|
||||
// case '\u0000': return -0x13; // 0xED :
|
||||
case '\u20AC': return -0x12; // 0xEE : euro sign
|
||||
// case '\u0000': return -0x11; // 0xEF :
|
||||
// case '\u0000': return -0x10; // 0xF0 :
|
||||
// case '\u0000': return -0x0F; // 0xF1 :
|
||||
// case '\u0000': return -0x0E; // 0xF2 :
|
||||
// case '\u0000': return -0x0D; // 0xF3 :
|
||||
// case '\u0000': return -0x0C; // 0xF4 :
|
||||
// case '\u0000': return -0x0B; // 0xF5 :
|
||||
// case '\u0000': return -0x0A; // 0xF6 :
|
||||
// case '\u0000': return -0x09; // 0xF7 :
|
||||
// case '\u0000': return -0x08; // 0xF8 :
|
||||
// case '\u0000': return -0x07; // 0xF9 :
|
||||
// case '\u0000': return -0x06; // 0xFA :
|
||||
// case '\u0000': return -0x05; // 0xFB :
|
||||
// case '\u0000': return -0x04; // 0xFC :
|
||||
// case '\u0000': return -0x03; // 0xFD :
|
||||
// case '\u0000': return -0x02; // 0xFE :
|
||||
// case '\u0000': return -0x01; // 0xFF :
|
||||
default: return 0x3F; // ? Not valid character.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.escpos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class UnicodeTranslatorSurePOS extends UnicodeTranslator {
|
||||
|
||||
/** Creates a new instance of UnicodeTranslatorInt */
|
||||
public UnicodeTranslatorSurePOS() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte[] getCodeTable() {
|
||||
return new byte[] {0x02}; // Multilingual International 858
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sChar
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public byte transChar(char sChar) {
|
||||
if ((sChar >= 0x0000) && (sChar < 0x0080)) {
|
||||
return (byte) sChar;
|
||||
} else {
|
||||
switch (sChar) {
|
||||
case '\u00c7': return -0x80;
|
||||
case '\u00fc': return -0x7F; // u dieresis
|
||||
case '\u00e2': return -0x7D;
|
||||
case '\u00e4': return -0x7C;
|
||||
case '\u00e0': return -0x7B;
|
||||
case '\u00E5': return -0x7A; // ao
|
||||
case '\u00e7': return -0x79;
|
||||
case '\u00ea': return -0x78;
|
||||
case '\u00eb': return -0x77;
|
||||
case '\u00e8': return -0x76;
|
||||
case '\u00ef': return -0x75;
|
||||
case '\u00ee': return -0x74;
|
||||
case '\u00ec': return -0x73;
|
||||
case '\u00c4': return -0x72;
|
||||
case '\u00C5': return -0x71; // Ao
|
||||
|
||||
case '\u00c9': return -0x70; // E acute
|
||||
case '\u00E6': return -0x6F; // ae
|
||||
case '\u00C6': return -0x6E; // AE
|
||||
case '\u00f4': return -0x6D;
|
||||
case '\u00f6': return -0x6C;
|
||||
case '\u00f2': return -0x6B;
|
||||
case '\u00fb': return -0x6A;
|
||||
case '\u00f9': return -0x69;
|
||||
case '\u00ff': return -0x68;
|
||||
case '\u00d6': return -0x67;
|
||||
case '\u00dc': return -0x66; // U dieresis
|
||||
case '\u00F8': return -0x65; // o/
|
||||
case '\u00A3': return -0x64; // L- Libra esterlina
|
||||
case '\u00D8': return -0x63; // O/
|
||||
case '\u00D7': return -0x62; // X
|
||||
// case '': return -0x61; // f
|
||||
|
||||
case '\u00e1': return -0x60; // a acute
|
||||
case '\u00e9': return -0x7E; // e acute
|
||||
case '\u00ed': return -0x5F; // i acute
|
||||
case '\u00f3': return -0x5E; // o acute
|
||||
case '\u00fa': return -0x5D; // u acute
|
||||
case '\u00f1': return -0x5C; // n tilde
|
||||
case '\u00d1': return -0x5B; // N tilde
|
||||
case '\u00aa': return -0x5A;
|
||||
case '\u00ba': return -0x59;
|
||||
case '\u00bf': return -0x58; // abrir interrogacion
|
||||
case '\u00AE': return -0x57; // (R) Registrado
|
||||
case '\u00ac': return -0x56; // Not sign
|
||||
case '\u00BD': return -0x55; // 1/2
|
||||
case '\u00BC': return -0x54; // 1/4
|
||||
case '\u00a1': return -0x53; // abrir admiracion
|
||||
case '\u00AB': return -0x52; // <<
|
||||
case '\u00BB': return -0x51; // >>
|
||||
|
||||
case '\u2591': return -0x50; // Light shade
|
||||
case '\u2592': return -0x4F; // Medium shade
|
||||
case '\u2593': return -0x4E; // Dark shade
|
||||
case '\u2502': return -0x4D; // BOX DRAWINGS LIGHT VERTICAL
|
||||
case '\u2524': return -0x4C; // BOX DRAWINGS LIGHT VERTICAL AND LEFT
|
||||
case '\u00c1': return -0x4B; // A acute
|
||||
case '\u00c2': return -0x4A;
|
||||
case '\u00c0': return -0x49;
|
||||
case '\u00A9': return -0x48; // (c) Copyright
|
||||
case '\u2563': return -0x47; // BOX DRAWINGS DOUBLE VERTICAL AND LEFT
|
||||
case '\u2551': return -0x46; // BOX DRAWINGS DOUBLE VERTICAL
|
||||
case '\u2557': return -0x45; // BOX DRAWINGS DOUBLE DOWN AND LEFT
|
||||
case '\u255D': return -0x44; // BOX DRAWINGS DOUBLE UP AND LEFT
|
||||
case '\u00A2': return -0x43; // Cent Sign
|
||||
case '\u00A5': return -0x42; // Yen Sign
|
||||
case '\u2510': return -0x41; // BOX DRAWINGS LIGHT DOWN AND LEFT
|
||||
|
||||
case '\u2514': return -0x40; // BOX DRAWINGS LIGHT UP ANDRIGHT
|
||||
// case '': return -0x3F; //
|
||||
// case '': return -0x3E; //
|
||||
// case '': return -0x3D; //
|
||||
// case '': return -0x3C; //
|
||||
// case '': return -0x3B; //
|
||||
// case '': return -0x3A; //
|
||||
// case '': return -0x39; //
|
||||
// case '': return -0x38; //
|
||||
// case '': return -0x37; //
|
||||
// case '': return -0x36; //
|
||||
// case '': return -0x35; //
|
||||
// case '': return -0x34; //
|
||||
// case '': return -0x33; //
|
||||
// case '': return -0x32; //
|
||||
// case '': return -0x31; //
|
||||
|
||||
// case '': return -0x30; //
|
||||
// case '': return -0x2F; //
|
||||
case '\u00ca': return -0x2E; //
|
||||
case '\u00cb': return -0x2D; //
|
||||
case '\u00c8': return -0x2C; //
|
||||
case '\u20ac': return (byte) 0xD5; // Euro Sign
|
||||
case '\u00cd': return -0x2A; // I acute
|
||||
case '\u00ce': return -0x29; //
|
||||
case '\u00cf': return -0x28; //
|
||||
// case '': return -0x27; //
|
||||
// case '': return -0x26; //
|
||||
// case '': return -0x25; //
|
||||
// case '': return -0x24; //
|
||||
case '|': return -0x23; //
|
||||
case '\u00cc': return -0x22; //
|
||||
// case '': return -0x21; //
|
||||
|
||||
case '\u00d3': return -0x20; // O acute
|
||||
// case '': return -0x1F; //
|
||||
case '\u00d4': return -0x1E; //
|
||||
case '\u00d2': return -0x1D; //
|
||||
// case '': return -0x1C; //
|
||||
// case '': return -0x1B; //
|
||||
// case '': return -0x1A; //
|
||||
// case '': return -0x19; //
|
||||
// case '': return -0x18; //
|
||||
case '\u00da': return -0x17; // U acute
|
||||
case '\u00db': return -0x16; //
|
||||
case '\u00d9': return -0x15; //
|
||||
case '\u00fd': return -0x14; //
|
||||
case '\u00dd': return -0x13; //
|
||||
// case '': return -0x12; //
|
||||
case '\u00b4': return -0x11; //
|
||||
|
||||
// case '': return -0x10; //
|
||||
// case '': return -0x0F; //
|
||||
// case '': return -0x0E; //
|
||||
// case '': return -0x0D; //
|
||||
// case '': return -0x0C; //
|
||||
// case '': return -0x0B; //
|
||||
// case '': return -0x0A; //
|
||||
// case '': return -0x09; //
|
||||
// case '': return -0x08; //
|
||||
case '\u00a8': return -0x07; //
|
||||
// case '': return -0x06; //
|
||||
// case '': return -0x05; //
|
||||
// case '': return -0x04; //
|
||||
// case '': return -0x03; //
|
||||
// case '': return -0x02; //
|
||||
// case ' ': return -0x01; // SP
|
||||
|
||||
default: return 0x3F; // ? Not valid character.
|
||||
|
||||
// Old translation
|
||||
// case '\u00aa' : return (byte) 0xA6;
|
||||
// case '\u00ba' : return (byte) 0xA7;
|
||||
// case '\u00a1' : return (byte) 0xAD;
|
||||
// case '\u00bf' : return (byte) 0xA8;
|
||||
// case '\u00b7' : return (byte) 0xF9;
|
||||
// case '\u00f1' : return (byte) 0xA4;
|
||||
// case '\u00d1' : return (byte) 0xA5;
|
||||
// case '\u00e1' : return (byte) 0xA0;
|
||||
// case '\u00c1' : return (byte) 0x86;
|
||||
// case '\u00e9' : return (byte) 0x82;
|
||||
// case '\u00c9' : return (byte) 0x90;
|
||||
// case '\u00ed' : return (byte) 0xA1;
|
||||
// case '\u00cd' : return (byte) 0x8B;
|
||||
// case '\u00f3' : return (byte) 0xA2;
|
||||
// case '\u00d3' : return (byte) 0x9F;
|
||||
// case '\u00fa' : return (byte) 0xA3;
|
||||
// case '\u00da' : return (byte) 0x96;
|
||||
// case '\u00fc' : return (byte) 0x81;
|
||||
// case '\u00dc' : return (byte) 0x9A;
|
||||
// default: return (byte) sChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.javapos;
|
||||
|
||||
import com.unicenta.pos.printer.DeviceDisplay;
|
||||
import com.unicenta.pos.printer.DeviceDisplayBase;
|
||||
import com.unicenta.pos.printer.DeviceDisplayImpl;
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import jpos.JposException;
|
||||
import jpos.LineDisplay;
|
||||
import jpos.LineDisplayConst;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DeviceDisplayJavaPOS implements DeviceDisplay, DeviceDisplayImpl {
|
||||
|
||||
private String m_sName;
|
||||
private LineDisplay m_ld;
|
||||
|
||||
private DeviceDisplayBase m_displaylines;
|
||||
|
||||
/** Creates a new instance of DeviceDisplayJavaPOS
|
||||
* @param sDeviceName
|
||||
* @throws com.unicenta.pos.printer.TicketPrinterException */
|
||||
public DeviceDisplayJavaPOS(String sDeviceName) throws TicketPrinterException {
|
||||
m_sName = sDeviceName;
|
||||
|
||||
m_ld = new LineDisplay();
|
||||
try {
|
||||
m_ld.open(m_sName);
|
||||
m_ld.claim(10000);
|
||||
m_ld.setDeviceEnabled(true);
|
||||
} catch (JposException e) {
|
||||
throw new TicketPrinterException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
m_displaylines = new DeviceDisplayBase(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public javax.swing.JComponent getDisplayComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(int animation, String sLine1, String sLine2) {
|
||||
m_displaylines.writeVisor(animation, sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(String sLine1, String sLine2) {
|
||||
m_displaylines.writeVisor(sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void clearVisor() {
|
||||
m_displaylines.clearVisor();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void repaintLines() {
|
||||
try {
|
||||
m_ld.displayTextAt(0, 0, m_displaylines.getLine1(), LineDisplayConst.DISP_DT_NORMAL);
|
||||
m_ld.displayTextAt(1, 0, m_displaylines.getLine2(), LineDisplayConst.DISP_DT_NORMAL);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize() throws Throwable {
|
||||
|
||||
m_ld.setDeviceEnabled(false);
|
||||
m_ld.release();
|
||||
m_ld.close();
|
||||
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,73,0,0,2,15"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="*X Report"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="30" y="10" width="130" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="*Receipt Title"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="10" y="60" width="470" height="260"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="true"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextField" name="jTextField1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jTextField1"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="30" width="260" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jCheckBox1"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[0, 0, 0, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="290" y="30" width="110" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jTextField2"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="60" width="260" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jCheckBox2"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[0, 0, 0, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="290" y="60" width="110" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jTextField3"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="90" width="260" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField4">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jTextField4"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="120" width="260" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="jTextField5">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jTextField5"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="150" width="260" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jCheckBox3"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[0, 0, 0, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="290" y="90" width="110" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox4">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jCheckBox4"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[0, 0, 0, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="290" y="120" width="110" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="jCheckBox5">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jCheckBox5"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[0, 0, 0, 0]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="290" y="150" width="110" height="25"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="*Z Report"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="220" width="130" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,323 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.javapos;
|
||||
|
||||
import com.unicenta.pos.printer.DeviceFiscalPrinter;
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import com.unicenta.pos.util.RoundUtils;
|
||||
import javax.swing.JComponent;
|
||||
import jpos.FiscalPrinter;
|
||||
import jpos.JposException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DeviceFiscalPrinterJavaPOS extends javax.swing.JPanel implements DeviceFiscalPrinter {
|
||||
|
||||
private String m_sName;
|
||||
|
||||
private FiscalPrinter m_fiscal;
|
||||
|
||||
/** Creates new form DeviceFiscalPrinterJavaPOSPanel
|
||||
* @param sDeviceFiscalPrinterName
|
||||
* @throws com.unicenta.pos.printer.TicketPrinterException */
|
||||
public DeviceFiscalPrinterJavaPOS(String sDeviceFiscalPrinterName) throws TicketPrinterException {
|
||||
m_sName = sDeviceFiscalPrinterName;
|
||||
|
||||
|
||||
m_fiscal = new FiscalPrinter();
|
||||
try {
|
||||
m_fiscal.open(m_sName);
|
||||
m_fiscal.claim(10000);
|
||||
m_fiscal.setDeviceEnabled(true);
|
||||
// m_printer.setMapMode(POSPrinterConst.PTR_MM_METRIC); // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units
|
||||
|
||||
m_fiscal.setCheckTotal(false);
|
||||
|
||||
} catch (JposException e) {
|
||||
throw new TicketPrinterException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
initComponents();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getFiscalName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getFiscalComponent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
try {
|
||||
m_fiscal.beginFiscalReceipt(true);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
try {
|
||||
m_fiscal.endFiscalReceipt(false);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sproduct
|
||||
* @param dprice
|
||||
* @param dunits
|
||||
* @param taxinfo
|
||||
*/
|
||||
@Override
|
||||
public void printLine(String sproduct, double dprice, double dunits, int taxinfo) {
|
||||
try {
|
||||
m_fiscal.printRecItem(sproduct, roundFiscal(dprice * dunits), (int)(dunits * 1000), taxinfo, roundFiscal(dprice), "");
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param smessage
|
||||
*/
|
||||
@Override
|
||||
public void printMessage(String smessage) {
|
||||
try {
|
||||
m_fiscal.printRecMessage(smessage);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sPayment
|
||||
* @param dpaid
|
||||
*/
|
||||
@Override
|
||||
public void printTotal(String sPayment, double dpaid) {
|
||||
try {
|
||||
// el primer valor es el total calculado por la aplicacion.
|
||||
// al poner 0 no se debe chequear: CAPCHECKTOTAL = false.
|
||||
m_fiscal.printRecTotal(0, roundFiscal(dpaid), sPayment);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printZReport() {
|
||||
try {
|
||||
m_fiscal.printZReport();
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printXReport() {
|
||||
try {
|
||||
m_fiscal.printXReport();
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize() throws Throwable {
|
||||
|
||||
m_fiscal.setDeviceEnabled(false);
|
||||
m_fiscal.release();
|
||||
m_fiscal.close();
|
||||
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
private int roundFiscal(double value) {
|
||||
return (int) Math.floor(RoundUtils.round(value) * 10000.0 + 0.5);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jTextField1 = new javax.swing.JTextField();
|
||||
jCheckBox1 = new javax.swing.JCheckBox();
|
||||
jTextField2 = new javax.swing.JTextField();
|
||||
jCheckBox2 = new javax.swing.JCheckBox();
|
||||
jTextField3 = new javax.swing.JTextField();
|
||||
jTextField4 = new javax.swing.JTextField();
|
||||
jTextField5 = new javax.swing.JTextField();
|
||||
jCheckBox3 = new javax.swing.JCheckBox();
|
||||
jCheckBox4 = new javax.swing.JCheckBox();
|
||||
jCheckBox5 = new javax.swing.JCheckBox();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
|
||||
setLayout(null);
|
||||
|
||||
jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jButton1.setText("*X Report");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jButton1);
|
||||
jButton1.setBounds(30, 10, 130, 23);
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("*Receipt Title"));
|
||||
jPanel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jPanel1.setLayout(null);
|
||||
|
||||
jTextField1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jTextField1.setText("jTextField1");
|
||||
jPanel1.add(jTextField1);
|
||||
jTextField1.setBounds(20, 30, 260, 25);
|
||||
|
||||
jCheckBox1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jCheckBox1.setText("jCheckBox1");
|
||||
jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||
jPanel1.add(jCheckBox1);
|
||||
jCheckBox1.setBounds(290, 30, 110, 25);
|
||||
|
||||
jTextField2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jTextField2.setText("jTextField2");
|
||||
jPanel1.add(jTextField2);
|
||||
jTextField2.setBounds(20, 60, 260, 25);
|
||||
|
||||
jCheckBox2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jCheckBox2.setText("jCheckBox2");
|
||||
jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||
jPanel1.add(jCheckBox2);
|
||||
jCheckBox2.setBounds(290, 60, 110, 25);
|
||||
|
||||
jTextField3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jTextField3.setText("jTextField3");
|
||||
jPanel1.add(jTextField3);
|
||||
jTextField3.setBounds(20, 90, 260, 25);
|
||||
|
||||
jTextField4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jTextField4.setText("jTextField4");
|
||||
jPanel1.add(jTextField4);
|
||||
jTextField4.setBounds(20, 120, 260, 25);
|
||||
|
||||
jTextField5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jTextField5.setText("jTextField5");
|
||||
jPanel1.add(jTextField5);
|
||||
jTextField5.setBounds(20, 150, 260, 25);
|
||||
|
||||
jCheckBox3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jCheckBox3.setText("jCheckBox3");
|
||||
jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||
jPanel1.add(jCheckBox3);
|
||||
jCheckBox3.setBounds(290, 90, 110, 25);
|
||||
|
||||
jCheckBox4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jCheckBox4.setText("jCheckBox4");
|
||||
jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||
jPanel1.add(jCheckBox4);
|
||||
jCheckBox4.setBounds(290, 120, 110, 25);
|
||||
|
||||
jCheckBox5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jCheckBox5.setText("jCheckBox5");
|
||||
jCheckBox5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
jCheckBox5.setMargin(new java.awt.Insets(0, 0, 0, 0));
|
||||
jPanel1.add(jCheckBox5);
|
||||
jCheckBox5.setBounds(290, 150, 110, 25);
|
||||
|
||||
jButton2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jButton2.setText("*Z Report");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel1.add(jButton2);
|
||||
jButton2.setBounds(20, 220, 130, 23);
|
||||
|
||||
add(jPanel1);
|
||||
jPanel1.setBounds(10, 60, 470, 260);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
|
||||
printZReport();
|
||||
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
|
||||
printXReport();
|
||||
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JCheckBox jCheckBox1;
|
||||
private javax.swing.JCheckBox jCheckBox2;
|
||||
private javax.swing.JCheckBox jCheckBox3;
|
||||
private javax.swing.JCheckBox jCheckBox4;
|
||||
private javax.swing.JCheckBox jCheckBox5;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JTextField jTextField1;
|
||||
private javax.swing.JTextField jTextField2;
|
||||
private javax.swing.JTextField jTextField3;
|
||||
private javax.swing.JTextField jTextField4;
|
||||
private javax.swing.JTextField jTextField5;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.javapos;
|
||||
|
||||
import com.unicenta.data.loader.ImageUtils;
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.TicketPrinterException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import javax.swing.JComponent;
|
||||
import jpos.CashDrawer;
|
||||
import jpos.JposException;
|
||||
import jpos.POSPrinter;
|
||||
import jpos.POSPrinterConst;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DevicePrinterJavaPOS implements DevicePrinter {
|
||||
|
||||
private static final String JPOS_SIZE0 = "\u001b|1C";
|
||||
private static final String JPOS_SIZE1 = "\u001b|2C";
|
||||
private static final String JPOS_SIZE2 = "\u001b|3C";
|
||||
private static final String JPOS_SIZE3 = "\u001b|4C";
|
||||
private static final String JPOS_LF = "\n";
|
||||
private static final String JPOS_BOLD = "\u001b|bC";
|
||||
private static final String JPOS_UNDERLINE = "\u001b|uC";
|
||||
private static final String JPOS_CUT = "\u001b|100fP";
|
||||
|
||||
private String m_sName;
|
||||
|
||||
private POSPrinter m_printer = null;
|
||||
private CashDrawer m_drawer = null;
|
||||
|
||||
private StringBuilder m_sline;
|
||||
|
||||
/** Creates a new instance of DevicePrinterJavaPOS
|
||||
* @param sDevicePrinterName
|
||||
* @param sDeviceDrawerName
|
||||
* @throws com.unicenta.pos.printer.TicketPrinterException */
|
||||
public DevicePrinterJavaPOS(String sDevicePrinterName, String sDeviceDrawerName) throws TicketPrinterException {
|
||||
|
||||
m_sName = sDevicePrinterName;
|
||||
if (sDeviceDrawerName != null && !sDeviceDrawerName.equals("")) {
|
||||
m_sName += " - " + sDeviceDrawerName;
|
||||
}
|
||||
|
||||
try {
|
||||
m_printer = new POSPrinter();
|
||||
m_printer.open(sDevicePrinterName);
|
||||
m_printer.claim(10000);
|
||||
m_printer.setDeviceEnabled(true);
|
||||
m_printer.setMapMode(POSPrinterConst.PTR_MM_METRIC); // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units
|
||||
} catch (JposException e) {
|
||||
// cannot live without the printer.
|
||||
throw new TicketPrinterException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
m_drawer = new CashDrawer();
|
||||
m_drawer.open(sDeviceDrawerName);
|
||||
m_drawer.claim(10000);
|
||||
m_drawer.setDeviceEnabled(true);
|
||||
} catch (JposException e) {
|
||||
// can live without the drawer;
|
||||
m_drawer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getPrinterComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
try {
|
||||
m_printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_TRANSACTION);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void printImage(BufferedImage image) {
|
||||
try {
|
||||
if (m_printer.getCapRecBitmap()) { // si podemos imprimir bitmaps.
|
||||
|
||||
File f = File.createTempFile("jposimg", ".png");
|
||||
try (OutputStream out = new FileOutputStream(f)) {
|
||||
out.write(ImageUtils.writeImage(image));
|
||||
}
|
||||
|
||||
m_printer.printBitmap(POSPrinterConst.PTR_S_RECEIPT, f.getAbsolutePath(), POSPrinterConst.PTR_BM_ASIS, POSPrinterConst.PTR_BM_CENTER);
|
||||
}
|
||||
// JG 16 May 12 use multicatch
|
||||
} catch (IOException | JposException eIO) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printLogo(){
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarCode(String type, String position, String code) {
|
||||
try {
|
||||
if (m_printer.getCapRecBarCode()) { // si podemos imprimir codigos de barras
|
||||
if (DevicePrinter.POSITION_NONE.equals(position)) {
|
||||
m_printer.printBarCode(POSPrinterConst.PTR_S_RECEIPT, code, POSPrinterConst.PTR_BCS_EAN13, 10 * 100, 60 * 100, POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_NONE);
|
||||
} else {
|
||||
m_printer.printBarCode(POSPrinterConst.PTR_S_RECEIPT, code, POSPrinterConst.PTR_BCS_EAN13, 10 * 100, 60 * 100, POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_BELOW);
|
||||
}
|
||||
}
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iTextSize
|
||||
*/
|
||||
@Override
|
||||
public void beginLine(int iTextSize) {
|
||||
m_sline = new StringBuilder();
|
||||
if (iTextSize == DevicePrinter.SIZE_0) {
|
||||
m_sline.append(JPOS_SIZE0);
|
||||
} else if (iTextSize == DevicePrinter.SIZE_1) {
|
||||
m_sline.append(JPOS_SIZE1);
|
||||
} else if (iTextSize == DevicePrinter.SIZE_2) {
|
||||
m_sline.append(JPOS_SIZE2);
|
||||
} else if (iTextSize == DevicePrinter.SIZE_3) {
|
||||
m_sline.append(JPOS_SIZE3);
|
||||
} else {
|
||||
m_sline.append(JPOS_SIZE0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iStyle
|
||||
* @param sText
|
||||
*/
|
||||
@Override
|
||||
public void printText(int iStyle, String sText) {
|
||||
|
||||
if ((iStyle & DevicePrinter.STYLE_BOLD) != 0) {
|
||||
m_sline.append(JPOS_BOLD);
|
||||
}
|
||||
if ((iStyle & DevicePrinter.STYLE_UNDERLINE) != 0) {
|
||||
m_sline.append(JPOS_UNDERLINE);
|
||||
}
|
||||
m_sline.append(sText);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endLine() {
|
||||
|
||||
m_sline.append(JPOS_LF);
|
||||
try {
|
||||
m_printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, m_sline.toString());
|
||||
} catch (JposException e) {
|
||||
}
|
||||
m_sline = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
try {
|
||||
// cut the receipt
|
||||
m_printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, JPOS_CUT);
|
||||
|
||||
// end of the transaction
|
||||
m_printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_NORMAL);
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void openDrawer() {
|
||||
|
||||
if (m_drawer != null) {
|
||||
try {
|
||||
m_drawer.openDrawer();
|
||||
} catch (JposException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize() throws Throwable {
|
||||
|
||||
m_printer.setDeviceEnabled(false);
|
||||
m_printer.release();
|
||||
m_printer.close();
|
||||
|
||||
if (m_drawer != null) {
|
||||
m_drawer.setDeviceEnabled(false);
|
||||
m_drawer.release();
|
||||
m_drawer.close();
|
||||
}
|
||||
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.printer;
|
||||
|
||||
import com.unicenta.data.gui.JMessageDialog;
|
||||
import com.unicenta.data.gui.MessageInf;
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.ticket.BasicTicket;
|
||||
import com.unicenta.pos.printer.ticket.BasicTicketForPrinter;
|
||||
import com.unicenta.pos.util.ReportUtils;
|
||||
import com.unicenta.pos.util.SelectPrinter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.print.*;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.standard.JobName;
|
||||
import javax.print.attribute.standard.Media;
|
||||
import javax.print.attribute.standard.MediaSizeName;
|
||||
import javax.print.attribute.standard.OrientationRequested;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Class DevicePrinterPrinter is responsible for printing tickets using system <br>
|
||||
* printers. It takes into consideration if a user set a printer as a receipt <br>
|
||||
* printer or not.
|
||||
* <p>For receipt printers lenght of a receipt must be calculated in this class.</p>
|
||||
* <p>For normal printers number of pages must be calculated dynamically in the <br>
|
||||
* class PrintableTicket @see com.unicenta.pos.printer.printer.PrintableTicket
|
||||
*
|
||||
* @author jaroslawwozniak
|
||||
*/
|
||||
@Slf4j
|
||||
public class DevicePrinterPrinter implements DevicePrinter {
|
||||
|
||||
private Component parent;
|
||||
/*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;
|
||||
|
||||
// // For Page Size 72mm x 200mm && MediaSizeName A4.
|
||||
// private static final int imageable_width = 190;
|
||||
// private static final int imageable_height = 546;
|
||||
// private static final int imageable_x = 10;
|
||||
// private static final int imageable_y = 287;
|
||||
// private static final Media media = MediaSizeName.ISO_A4;
|
||||
|
||||
// // For Page Size A4 && MediaSizeName A4.
|
||||
// private static final int imageable_width = 451;
|
||||
// private static final int imageable_height = 698;
|
||||
// private static final int imageable_x = 72;
|
||||
// private static final int imageable_y = 72;
|
||||
// private static final Media media = MediaSizeName.ISO_A4;
|
||||
|
||||
private int imageable_width;
|
||||
private int imageable_height;
|
||||
private int imageable_x;
|
||||
private int imageable_y;
|
||||
private Media media;
|
||||
|
||||
// JG 16 May 12 use multicatch
|
||||
private static final HashMap<String, MediaSizeName> mediasizenamemap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance of DevicePrinterPrinter
|
||||
*
|
||||
* @param parent
|
||||
* @param printername - name of printer that will be called in the system
|
||||
* @param imageable_x
|
||||
* @param imageable_y
|
||||
* @param imageable_height
|
||||
* @param imageable_width
|
||||
* @param mediasizename
|
||||
*/
|
||||
public DevicePrinterPrinter(Component parent, String printername, int imageable_x, int imageable_y, int imageable_width, int imageable_height, String mediasizename) {
|
||||
|
||||
this.parent = parent;
|
||||
m_sName = "Printer"; // "AppLocal.getIntString("printer.screen");
|
||||
m_ticketcurrent = null;
|
||||
printservice = ReportUtils.getPrintService(printername);
|
||||
|
||||
this.imageable_x = imageable_x;
|
||||
this.imageable_y = imageable_y;
|
||||
this.imageable_width = imageable_width;
|
||||
this.imageable_height = imageable_height;
|
||||
this.media = getMedia(mediasizename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter that returns the name of a printer
|
||||
*
|
||||
* @return m_sName a name of a printer
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter that returns the description of a printer
|
||||
*
|
||||
* @return description of a printer
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter that returns the printer's component
|
||||
*
|
||||
* @return printer's component
|
||||
*/
|
||||
@Override
|
||||
public JComponent getPrinterComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that sets the current ticket as a null
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
m_ticketcurrent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for start a new ticket
|
||||
*/
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
m_ticketcurrent = new BasicTicketForPrinter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for printing an image
|
||||
*
|
||||
* @param image a buffered image object
|
||||
*/
|
||||
@Override
|
||||
public void printImage(BufferedImage image) {
|
||||
m_ticketcurrent.printImage(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printLogo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarCode(String type, String position, String code) {
|
||||
m_ticketcurrent.printBarCode(type, position, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for starting a new line on a receipt
|
||||
*
|
||||
* @param iTextSize a size of text in the line
|
||||
*/
|
||||
@Override
|
||||
public void beginLine(int iTextSize) {
|
||||
m_ticketcurrent.beginLine(iTextSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for printing text
|
||||
*
|
||||
* @param iStyle style of text
|
||||
* @param sText text to print
|
||||
*/
|
||||
@Override
|
||||
public void printText(int iStyle, String sText) {
|
||||
m_ticketcurrent.printText(iStyle, sText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for ending a line
|
||||
*/
|
||||
@Override
|
||||
public void endLine() {
|
||||
m_ticketcurrent.endLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for ending and printing a ticket<br>
|
||||
* It manages to get a printerJob, set the name of the job, get a Book object<br>
|
||||
* and print the receipt
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
|
||||
try {
|
||||
|
||||
PrintService ps;
|
||||
|
||||
if (printservice == null) {
|
||||
String[] printers = ReportUtils.getPrintNames();
|
||||
if (printers.length == 0) {
|
||||
log.error(AppLocal.getIntString("message.noprinters"));
|
||||
ps = null;
|
||||
} else {
|
||||
SelectPrinter selectprinter = SelectPrinter.getSelectPrinter(parent, printers);
|
||||
selectprinter.setVisible(true);
|
||||
if (selectprinter.isOK()) {
|
||||
ps = ReportUtils.getPrintService(selectprinter.getPrintService());
|
||||
} else {
|
||||
ps = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ps = printservice;
|
||||
}
|
||||
|
||||
if (ps != null) {
|
||||
|
||||
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
|
||||
aset.add(OrientationRequested.PORTRAIT);
|
||||
aset.add(new JobName(AppLocal.APP_NAME + " - Document", null));
|
||||
aset.add(media);
|
||||
|
||||
DocPrintJob printjob = ps.createPrintJob();
|
||||
Doc doc = new SimpleDoc(new PrintableBasicTicket(m_ticketcurrent, imageable_x, imageable_y, imageable_width, imageable_height), DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
|
||||
|
||||
printjob.print(doc, aset);
|
||||
}
|
||||
|
||||
} catch (PrintException ex) {
|
||||
log.error(ex.getMessage());
|
||||
JMessageDialog.showMessage(parent, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.printererror"), ex));
|
||||
}
|
||||
|
||||
//ticket is not needed any more
|
||||
m_ticketcurrent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is responsible for opening a drawer
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void openDrawer() {
|
||||
// Una simulacion
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
private static MediaSizeName getMedia(String mediasizename) {
|
||||
return mediasizenamemap.get(mediasizename);
|
||||
}
|
||||
|
||||
static {
|
||||
mediasizenamemap.put("Postcard", MediaSizeName.JAPANESE_POSTCARD);
|
||||
mediasizenamemap.put("Statement", MediaSizeName.INVOICE);
|
||||
|
||||
mediasizenamemap.put("Letter", MediaSizeName.NA_LETTER);
|
||||
mediasizenamemap.put("Executive", MediaSizeName.EXECUTIVE);
|
||||
mediasizenamemap.put("Legal", MediaSizeName.NA_LEGAL);
|
||||
|
||||
mediasizenamemap.put("A0", MediaSizeName.ISO_A0);
|
||||
mediasizenamemap.put("A1", MediaSizeName.ISO_A1);
|
||||
mediasizenamemap.put("A2", MediaSizeName.ISO_A2);
|
||||
mediasizenamemap.put("A3", MediaSizeName.ISO_A3);
|
||||
mediasizenamemap.put("A4", MediaSizeName.ISO_A4);
|
||||
mediasizenamemap.put("A5", MediaSizeName.ISO_A5);
|
||||
mediasizenamemap.put("A6", MediaSizeName.ISO_A6);
|
||||
mediasizenamemap.put("A7", MediaSizeName.ISO_A7);
|
||||
mediasizenamemap.put("A8", MediaSizeName.ISO_A8);
|
||||
mediasizenamemap.put("A9", MediaSizeName.ISO_A9);
|
||||
mediasizenamemap.put("A10", MediaSizeName.ISO_A10);
|
||||
|
||||
mediasizenamemap.put("B0", MediaSizeName.JIS_B0);
|
||||
mediasizenamemap.put("B1", MediaSizeName.JIS_B1);
|
||||
mediasizenamemap.put("B2", MediaSizeName.JIS_B2);
|
||||
mediasizenamemap.put("B3", MediaSizeName.JIS_B3);
|
||||
mediasizenamemap.put("B4", MediaSizeName.JIS_B4);
|
||||
mediasizenamemap.put("B5", MediaSizeName.JIS_B5);
|
||||
mediasizenamemap.put("B6", MediaSizeName.JIS_B6);
|
||||
mediasizenamemap.put("B7", MediaSizeName.JIS_B7);
|
||||
mediasizenamemap.put("B8", MediaSizeName.JIS_B8);
|
||||
mediasizenamemap.put("B9", MediaSizeName.JIS_B9);
|
||||
mediasizenamemap.put("B10", MediaSizeName.JIS_B10);
|
||||
|
||||
mediasizenamemap.put("ISOB0", MediaSizeName.ISO_B0);
|
||||
mediasizenamemap.put("ISOB1", MediaSizeName.ISO_B1);
|
||||
mediasizenamemap.put("ISOB2", MediaSizeName.ISO_B2);
|
||||
mediasizenamemap.put("ISOB3", MediaSizeName.ISO_B3);
|
||||
mediasizenamemap.put("ISOB4", MediaSizeName.ISO_B4);
|
||||
mediasizenamemap.put("ISOB5", MediaSizeName.ISO_B5);
|
||||
mediasizenamemap.put("ISOB6", MediaSizeName.ISO_B6);
|
||||
mediasizenamemap.put("ISOB7", MediaSizeName.ISO_B7);
|
||||
mediasizenamemap.put("ISOB8", MediaSizeName.ISO_B8);
|
||||
mediasizenamemap.put("ISOB9", MediaSizeName.ISO_B9);
|
||||
mediasizenamemap.put("ISOB10", MediaSizeName.ISO_B10);
|
||||
mediasizenamemap.put("EnvISOB0", MediaSizeName.ISO_B0);
|
||||
mediasizenamemap.put("EnvISOB1", MediaSizeName.ISO_B1);
|
||||
mediasizenamemap.put("EnvISOB2", MediaSizeName.ISO_B2);
|
||||
mediasizenamemap.put("EnvISOB3", MediaSizeName.ISO_B3);
|
||||
mediasizenamemap.put("EnvISOB4", MediaSizeName.ISO_B4);
|
||||
mediasizenamemap.put("EnvISOB5", MediaSizeName.ISO_B5);
|
||||
mediasizenamemap.put("EnvISOB6", MediaSizeName.ISO_B6);
|
||||
mediasizenamemap.put("EnvISOB7", MediaSizeName.ISO_B7);
|
||||
mediasizenamemap.put("EnvISOB8", MediaSizeName.ISO_B8);
|
||||
mediasizenamemap.put("EnvISOB9", MediaSizeName.ISO_B9);
|
||||
mediasizenamemap.put("EnvISOB10", MediaSizeName.ISO_B10);
|
||||
|
||||
mediasizenamemap.put("C0", MediaSizeName.ISO_C0);
|
||||
mediasizenamemap.put("C1", MediaSizeName.ISO_C1);
|
||||
mediasizenamemap.put("C2", MediaSizeName.ISO_C2);
|
||||
mediasizenamemap.put("C3", MediaSizeName.ISO_C3);
|
||||
mediasizenamemap.put("C4", MediaSizeName.ISO_C4);
|
||||
mediasizenamemap.put("C5", MediaSizeName.ISO_C5);
|
||||
mediasizenamemap.put("C6", MediaSizeName.ISO_C6);
|
||||
|
||||
mediasizenamemap.put("EnvPersonal", MediaSizeName.PERSONAL_ENVELOPE);
|
||||
mediasizenamemap.put("EnvMonarch", MediaSizeName.MONARCH_ENVELOPE);
|
||||
mediasizenamemap.put("Monarch", MediaSizeName.MONARCH_ENVELOPE);
|
||||
mediasizenamemap.put("Env9", MediaSizeName.NA_NUMBER_9_ENVELOPE);
|
||||
mediasizenamemap.put("Env10", MediaSizeName.NA_NUMBER_10_ENVELOPE);
|
||||
mediasizenamemap.put("Env11", MediaSizeName.NA_NUMBER_11_ENVELOPE);
|
||||
mediasizenamemap.put("Env12", MediaSizeName.NA_NUMBER_12_ENVELOPE);
|
||||
mediasizenamemap.put("Env14", MediaSizeName.NA_NUMBER_14_ENVELOPE);
|
||||
mediasizenamemap.put("c8x10", MediaSizeName.NA_8X10);
|
||||
|
||||
mediasizenamemap.put("EnvDL", MediaSizeName.ISO_DESIGNATED_LONG);
|
||||
mediasizenamemap.put("DL", MediaSizeName.ISO_DESIGNATED_LONG);
|
||||
mediasizenamemap.put("EnvC0", MediaSizeName.ISO_C0);
|
||||
mediasizenamemap.put("EnvC1", MediaSizeName.ISO_C1);
|
||||
mediasizenamemap.put("EnvC2", MediaSizeName.ISO_C2);
|
||||
mediasizenamemap.put("EnvC3", MediaSizeName.ISO_C3);
|
||||
mediasizenamemap.put("EnvC4", MediaSizeName.ISO_C4);
|
||||
mediasizenamemap.put("EnvC5", MediaSizeName.ISO_C5);
|
||||
mediasizenamemap.put("EnvC6", MediaSizeName.ISO_C6);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-20162009 Openbravo, S.L.
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.printer;
|
||||
|
||||
import com.unicenta.pos.printer.ticket.BasicTicket;
|
||||
import com.unicenta.pos.printer.ticket.PrintItem;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.print.PageFormat;
|
||||
import java.awt.print.Printable;
|
||||
import java.awt.print.PrinterException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class PrintableBasicTicket implements Printable {
|
||||
|
||||
private int imageable_width;
|
||||
private int imageable_height;
|
||||
private int imageable_x;
|
||||
private int imageable_y;
|
||||
|
||||
private BasicTicket ticket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ticket
|
||||
* @param imageable_x
|
||||
* @param imageable_y
|
||||
* @param imageable_width
|
||||
* @param imageable_height
|
||||
*/
|
||||
public PrintableBasicTicket(BasicTicket ticket, int imageable_x, int imageable_y, int imageable_width, int imageable_height) {
|
||||
this.ticket = ticket;
|
||||
this.imageable_x = imageable_x;
|
||||
this.imageable_y = imageable_y;
|
||||
this.imageable_width = imageable_width;
|
||||
this.imageable_height = imageable_height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
|
||||
|
||||
Graphics2D g2d = (Graphics2D) graphics;
|
||||
|
||||
int line = 0;
|
||||
int currentpage = 0;
|
||||
int currentpagey = 0;
|
||||
boolean printed = false;
|
||||
|
||||
g2d.translate(imageable_x, imageable_y);
|
||||
|
||||
java.util.List<PrintItem> commands = ticket.getCommands();
|
||||
|
||||
while (line < commands.size()) {
|
||||
|
||||
int itemheight = commands.get(line).getHeight();
|
||||
|
||||
if (currentpagey + itemheight <= imageable_height) {
|
||||
currentpagey += itemheight;
|
||||
} else {
|
||||
currentpage ++;
|
||||
currentpagey = itemheight;
|
||||
}
|
||||
|
||||
if (currentpage < pageIndex) {
|
||||
line ++;
|
||||
} else if (currentpage == pageIndex) {
|
||||
printed = true;
|
||||
commands.get(line).draw(g2d, 0, currentpagey - itemheight, imageable_width);
|
||||
|
||||
line ++;
|
||||
} else if (currentpage > pageIndex) {
|
||||
line ++;
|
||||
}
|
||||
}
|
||||
|
||||
return printed
|
||||
? Printable.PAGE_EXISTS
|
||||
: Printable.NO_SUCH_PAGE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" id="window" palette="3" red="ff" type="palette"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-127,0,0,1,126"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="16" left="16" right="16" top="16"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jline1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jline1"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jline2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jline2"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,200 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.screen;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.printer.DeviceDisplay;
|
||||
import com.unicenta.pos.printer.DeviceDisplayBase;
|
||||
import com.unicenta.pos.printer.DeviceDisplayImpl;
|
||||
import java.awt.*;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class DeviceDisplayPanel extends JPanel implements DeviceDisplay, DeviceDisplayImpl {
|
||||
|
||||
private String m_sName;
|
||||
|
||||
private DeviceDisplayBase m_displaylines;
|
||||
|
||||
/** Creates new form JVisor */
|
||||
public DeviceDisplayPanel() {
|
||||
this(1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dZoom
|
||||
*/
|
||||
public DeviceDisplayPanel(double dZoom) {
|
||||
|
||||
initComponents();
|
||||
|
||||
m_sName = AppLocal.getIntString("display.screen");
|
||||
|
||||
jline1.setFont(new Font("Monospaced", Font.BOLD, (int)(16 * dZoom)));
|
||||
jline2.setFont(new Font("Monospaced", Font.BOLD, (int)(16 * dZoom)));
|
||||
// JG Feb' 16 - Revert
|
||||
// Consolas intro'd in v4.1 but causes issue in RightToLeft languages i.e.: Arabic
|
||||
// jline1.setFont(new Font("Consolas", Font.BOLD, (int)(16 * dZoom)));
|
||||
// jline2.setFont(new Font("Consolas", Font.BOLD, (int)(16 * dZoom)));
|
||||
|
||||
m_displaylines = new DeviceDisplayBase(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getDisplayComponent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(int animation, String sLine1, String sLine2) {
|
||||
|
||||
m_displaylines.writeVisor(animation, sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(String sLine1, String sLine2) {
|
||||
|
||||
m_displaylines.writeVisor(sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void clearVisor() {
|
||||
m_displaylines.clearVisor();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void repaintLines() {
|
||||
jline1.setText(m_displaylines.getLine1());
|
||||
jline2.setText(m_displaylines.getLine2());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
|
||||
paintBorder(g);
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
Insets i = getInsets();
|
||||
|
||||
//g.setColor(getBackground());
|
||||
g2d.setPaint(new GradientPaint(getWidth() - i.left - i.right - 50,
|
||||
getHeight() - i.top - i.bottom - 50,
|
||||
getBackground(),
|
||||
getWidth() - i.left - i.right,
|
||||
getHeight() - i.top - i.bottom,
|
||||
new Color(0xf0f0f0), true));
|
||||
g2d.fillRect(i.left, i.top,
|
||||
getWidth() - i.left - i.right,
|
||||
getHeight() - i.top - i.bottom);
|
||||
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
java.awt.GridBagConstraints gridBagConstraints;
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jline1 = new javax.swing.JLabel();
|
||||
jline2 = new javax.swing.JLabel();
|
||||
|
||||
setBackground(javax.swing.UIManager.getDefaults().getColor("window"));
|
||||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(16, 16, 16, 16));
|
||||
jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jPanel1.setOpaque(false);
|
||||
jPanel1.setLayout(new java.awt.GridBagLayout());
|
||||
|
||||
jline1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jline1.setText("jline1");
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 0;
|
||||
jPanel1.add(jline1, gridBagConstraints);
|
||||
|
||||
jline2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jline2.setText("jline2");
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 1;
|
||||
jPanel1.add(jline2, gridBagConstraints);
|
||||
|
||||
add(jPanel1, java.awt.BorderLayout.CENTER);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JLabel jline1;
|
||||
private javax.swing.JLabel jline2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="Display.Window" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-11,0,0,2,-1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||
<SyntheticProperty name="generatePosition" type="boolean" value="false"/>
|
||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="m_jContainer">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="11" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,134 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.screen;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.printer.DeviceDisplay;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class DeviceDisplayWindow extends javax.swing.JFrame implements DeviceDisplay {
|
||||
|
||||
private final String m_sName;
|
||||
private final DeviceDisplayPanel m_display;
|
||||
|
||||
/** Creates new form DeviceDisplayWindow */
|
||||
public DeviceDisplayWindow() {
|
||||
initComponents();
|
||||
|
||||
m_sName = AppLocal.getIntString("display.window");
|
||||
m_display = new DeviceDisplayPanel(3.0);
|
||||
|
||||
m_jContainer.add(m_display.getDisplayComponent());
|
||||
try {
|
||||
this.setIconImage(ImageIO.read(DeviceDisplayWindow.class.getResourceAsStream("/com/unicenta/images/favicon.png")));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getDisplayComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param animation
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(int animation, String sLine1, String sLine2) {
|
||||
m_display.writeVisor(animation, sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sLine1
|
||||
* @param sLine2
|
||||
*/
|
||||
@Override
|
||||
public void writeVisor(String sLine1, String sLine2) {
|
||||
m_display.writeVisor(sLine1, sLine2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void clearVisor() {
|
||||
m_display.clearVisor();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
m_jContainer = new javax.swing.JPanel();
|
||||
|
||||
setTitle(AppLocal.getIntString("display.window")); // NOI18N
|
||||
|
||||
m_jContainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
m_jContainer.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
|
||||
m_jContainer.setLayout(new java.awt.BorderLayout());
|
||||
getContentPane().add(m_jContainer, java.awt.BorderLayout.CENTER);
|
||||
|
||||
setSize(new java.awt.Dimension(767, 245));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel m_jContainer;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="m_jScrollView">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,188 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.screen;
|
||||
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import com.unicenta.pos.printer.ticket.BasicTicket;
|
||||
import com.unicenta.pos.printer.ticket.BasicTicketForScreen;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DevicePrinterPanel extends javax.swing.JPanel implements DevicePrinter {
|
||||
|
||||
private final String m_sName;
|
||||
|
||||
private final JTicketContainer m_jTicketContainer;
|
||||
private BasicTicket m_ticketcurrent;
|
||||
|
||||
/** Creates new form JPrinterScreen2 */
|
||||
public DevicePrinterPanel() {
|
||||
initComponents();
|
||||
|
||||
m_sName = AppLocal.getIntString("printer.screen");
|
||||
|
||||
m_ticketcurrent = null;
|
||||
|
||||
m_jTicketContainer = new JTicketContainer();
|
||||
m_jScrollView.setViewportView(m_jTicketContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterName() {
|
||||
return m_sName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printLogo(){
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getPrinterDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JComponent getPrinterComponent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void reset() {
|
||||
m_ticketcurrent = null;
|
||||
m_jTicketContainer.removeAllTickets();
|
||||
m_jTicketContainer.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginReceipt() {
|
||||
m_ticketcurrent = new BasicTicketForScreen();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void printImage(BufferedImage image) {
|
||||
m_ticketcurrent.printImage(image);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
@Override
|
||||
public void printBarCode(String type, String position, String code) {
|
||||
m_ticketcurrent.printBarCode(type, position, code);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iTextSize
|
||||
*/
|
||||
@Override
|
||||
public void beginLine(int iTextSize) {
|
||||
m_ticketcurrent.beginLine(iTextSize);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iStyle
|
||||
* @param sText
|
||||
*/
|
||||
@Override
|
||||
public void printText(int iStyle, String sText) {
|
||||
m_ticketcurrent.printText(iStyle, sText);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endLine() {
|
||||
m_ticketcurrent.endLine();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void endReceipt() {
|
||||
m_jTicketContainer.addTicket(new JTicket(m_ticketcurrent));
|
||||
m_ticketcurrent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void openDrawer() {
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
m_jScrollView = new javax.swing.JScrollPane();
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
m_jScrollView.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
add(m_jScrollView, java.awt.BorderLayout.CENTER);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane m_jScrollView;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-93,0,0,0,-103"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Form>
|
||||
@@ -0,0 +1,107 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.screen;
|
||||
|
||||
import com.unicenta.pos.printer.ticket.BasicTicket;
|
||||
import java.awt.*;
|
||||
import java.util.Map;
|
||||
|
||||
class JTicket extends javax.swing.JPanel {
|
||||
|
||||
private static final int H_GAP = 8;
|
||||
private static final int V_GAP = 8;
|
||||
private static final int COLUMNS = 42;
|
||||
private static final int LINEWIDTH = COLUMNS * 7;
|
||||
|
||||
private final BasicTicket basict;
|
||||
private final Map desktophints;
|
||||
|
||||
/** Creates new form JTicket */
|
||||
public JTicket(BasicTicket t) {
|
||||
|
||||
basict = t;
|
||||
desktophints = (Map) Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints");
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
paintBorder(g);
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
if (desktophints != null) {
|
||||
g2d.addRenderingHints(desktophints);
|
||||
}
|
||||
|
||||
Insets i = getInsets();
|
||||
g2d.setPaint(new GradientPaint(
|
||||
getWidth() - i.left - i.right - 100,
|
||||
getHeight() - i.top - i.bottom - 100,
|
||||
getBackground(),
|
||||
getWidth() - i.left - i.right,
|
||||
getHeight() - i.top - i.bottom,
|
||||
new Color(0xf0f0f0), true));
|
||||
g2d.fillRect(i.left, i.top,
|
||||
getWidth() - i.left - i.right,
|
||||
getHeight() - i.top - i.bottom);
|
||||
|
||||
g.setColor(getForeground());
|
||||
basict.draw(g2d, i.left + H_GAP, i.top + V_GAP, LINEWIDTH);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Insets ins = getInsets();
|
||||
return new Dimension((int) (
|
||||
LINEWIDTH + 2 * H_GAP) + ins.left + ins.right
|
||||
, (int) (basict.getHeight() + 2 * V_GAP) + ins.top + ins.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
setBackground(new java.awt.Color(255, 255, 255));
|
||||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[700, 600]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-114,0,0,2,122"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Form>
|
||||
@@ -0,0 +1,133 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.screen;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
// JG 16 May 12 replace
|
||||
// import java.awt.*;
|
||||
// import java.awt.event.*;
|
||||
// import java.awt.image.*;
|
||||
// import java.util.*;
|
||||
// import java.awt.print.*;
|
||||
|
||||
// import javax.swing.*;
|
||||
// import javax.swing.border.*;
|
||||
// import javax.swing.event.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
class JTicketContainer extends javax.swing.JPanel {
|
||||
|
||||
protected int H_GAP = 8;
|
||||
protected int V_GAP = 8;
|
||||
|
||||
/** Creates new form JTicketContainer */
|
||||
public JTicketContainer() {
|
||||
initComponents();
|
||||
setLayout(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
|
||||
Insets ins = getInsets();
|
||||
int iMaxx = 0;
|
||||
int iMaxy = ins.top + V_GAP;
|
||||
int n = getComponentCount();
|
||||
for(int i = 0; i < n; i++) {
|
||||
Component comp = getComponent(i);
|
||||
Dimension dc = comp.getPreferredSize();
|
||||
if (dc.width > iMaxx) {
|
||||
iMaxx = dc.width;
|
||||
}
|
||||
iMaxy += V_GAP + dc.height;
|
||||
}
|
||||
|
||||
return new Dimension(iMaxx + 2 * H_GAP + ins.left + ins.right, iMaxy + ins.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
Insets ins = getInsets();
|
||||
int x = ins.left + H_GAP;
|
||||
int y = ins.top + V_GAP;
|
||||
|
||||
int n = getComponentCount();
|
||||
for(int i = 0; i < n; i++) {
|
||||
Component comp = getComponent(i);
|
||||
Dimension dc = comp.getPreferredSize();
|
||||
|
||||
comp.setBounds(x, y, dc.width, dc.height);
|
||||
y += V_GAP + dc.height;
|
||||
}
|
||||
}
|
||||
|
||||
public void addTicket(JTicket ticket) {
|
||||
|
||||
add(ticket);
|
||||
|
||||
doLayout();
|
||||
revalidate();
|
||||
scrollRectToVisible(new Rectangle(0, getPreferredSize().height - 1, 1, 1));
|
||||
}
|
||||
|
||||
public void removeAllTickets() {
|
||||
|
||||
removeAll();
|
||||
|
||||
doLayout();
|
||||
revalidate();
|
||||
scrollRectToVisible(new Rectangle(0, 0, 1, 1));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
setPreferredSize(new java.awt.Dimension(700, 600));
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
Copyright (c) 2009-2016 uniCenta & previous Openbravo POS works
|
||||
http://sourceforge.net/projects/unicentaopos
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
-->
|
||||
|
||||
<!ELEMENT output (ticket | display | opendrawer | play | )*>
|
||||
|
||||
<!ELEMENT ticket (line | image | barcode | cut)*>
|
||||
<!ATTLIST ticket printer CDATA "0">
|
||||
|
||||
<!ELEMENT line (text)*>
|
||||
<!ATTLIST line size (0 | 1 | 2 | 3) "0">
|
||||
|
||||
<!ELEMENT text (#PCDATA)>
|
||||
<!ATTLIST text align (left | right | center) "left">
|
||||
<!ATTLIST text length CDATA #IMPLIED>
|
||||
<!ATTLIST text bold (true | false) "false">
|
||||
<!ATTLIST text underline (true | false) "false">
|
||||
|
||||
<!ELEMENT image (#PCDATA)>
|
||||
|
||||
<!ELEMENT barcode (#PCDATA)>
|
||||
<!ATTLIST barcode type (EAN13 | CODE128) "EAN13">
|
||||
|
||||
<!ELEMENT display (line)*>
|
||||
<!ATTLIST display animation (scroll | flyer | blink | curtain | none) "none">
|
||||
|
||||
<!ELEMENT play (#PCDATA)>
|
||||
|
||||
<!ELEMENT opendrawer EMPTY>
|
||||
<!ATTLIST opendrawer printer CDATA "0">
|
||||
@@ -0,0 +1,169 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
@Slf4j
|
||||
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() {
|
||||
// JG 16 May 12 use diamond inference
|
||||
m_aCommands = new ArrayList<>();
|
||||
pil = null;
|
||||
m_iBodyHeight = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract Font getBaseFont();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract int getFontHeight();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract double getImageScale();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return m_iBodyHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g2d
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
*/
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public java.util.List<PrintItem> getCommands() {
|
||||
return m_aCommands;
|
||||
}
|
||||
|
||||
// INTERFAZ PRINTER 2
|
||||
|
||||
/**
|
||||
*
|
||||
* @param image
|
||||
*/
|
||||
public void printImage(BufferedImage image) {
|
||||
|
||||
PrintItem pi = new PrintItemImage(image, getImageScale());
|
||||
m_aCommands.add(pi);
|
||||
m_iBodyHeight += pi.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iTextSize
|
||||
*/
|
||||
public void beginLine(int iTextSize) {
|
||||
pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iStyle
|
||||
* @param sText
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jaroslawwozniak
|
||||
* @author adrianromero
|
||||
|
||||
*/
|
||||
public class BasicTicketForPrinter extends BasicTicket {
|
||||
|
||||
// private static final Font BASEFONT = new Font("Monospaced",
|
||||
private static final Font BASEFONT = new Font("Courier New",
|
||||
Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.50));
|
||||
private static final int FONTHEIGHT = 12;
|
||||
|
||||
// private static Font BASEFONT = new Font("Monospaced",
|
||||
// Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
|
||||
|
||||
// JG Feb' 16 - Revert
|
||||
// Consolas intro'd in v4.1 but causes issue in RightToLeft languages i.e.: Arabic
|
||||
// private static Font BASEFONT = new Font("Consolas", Font.PLAIN,8).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
|
||||
// private static int FONTHEIGHT = 12;
|
||||
|
||||
private static final double IMAGE_SCALE = 0.65;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected Font getBaseFont() {
|
||||
return BASEFONT;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected int getFontHeight() {
|
||||
return FONTHEIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override protected double getImageScale() {
|
||||
return IMAGE_SCALE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class BasicTicketForScreen extends BasicTicket {
|
||||
|
||||
// private static Font BASEFONT = new Font("Monospaced",
|
||||
private static Font BASEFONT = new Font("Courier New",
|
||||
Font.PLAIN, 12).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
|
||||
// JG Feb' 16 - Revert
|
||||
// Consolas intro'd in v4.1 but causes issue in RightToLeft languages i.e.: Arabic
|
||||
// private static Font BASEFONT = new Font("Consolas", Font.PLAIN, 12).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40));
|
||||
|
||||
private static int FONTHEIGHT = 20;
|
||||
private static double IMAGE_SCALE = 1.0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected Font getBaseFont() {
|
||||
return BASEFONT;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected int getFontHeight() {
|
||||
return FONTHEIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected double getImageScale() {
|
||||
return IMAGE_SCALE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import java.awt.Font;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class MyPrinterState {
|
||||
|
||||
private int m_iSize;
|
||||
|
||||
/** Creates a new instance of PrinterState
|
||||
* @param iSize */
|
||||
public MyPrinterState(int iSize) {
|
||||
m_iSize = iSize;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getLineMult() {
|
||||
return getLineMult(m_iSize);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iSize
|
||||
* @return
|
||||
*/
|
||||
public static int getLineMult(int iSize) {
|
||||
switch (iSize) {
|
||||
case 0:
|
||||
case 2:
|
||||
return 1;
|
||||
case 1:
|
||||
case 3:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param baseFont
|
||||
* @param iStyle
|
||||
* @return
|
||||
*/
|
||||
public Font getFont(Font baseFont, int iStyle) {
|
||||
|
||||
Font f;
|
||||
AffineTransform a;
|
||||
switch (m_iSize) {
|
||||
case 0:
|
||||
f = baseFont;
|
||||
break;
|
||||
case 2:
|
||||
a = AffineTransform.getScaleInstance(2.0, 1.0);
|
||||
a.preConcatenate(baseFont.getTransform());
|
||||
f = baseFont.deriveFont(a);
|
||||
break;
|
||||
case 1:
|
||||
a = AffineTransform.getScaleInstance(1.0, 2.0);
|
||||
a.preConcatenate(baseFont.getTransform());
|
||||
f = baseFont.deriveFont(a);
|
||||
break;
|
||||
case 3:
|
||||
a = AffineTransform.getScaleInstance(2.0, 2.0);
|
||||
a.preConcatenate(baseFont.getTransform());
|
||||
f = baseFont.deriveFont(a);
|
||||
break;
|
||||
default:
|
||||
f = baseFont;
|
||||
break;
|
||||
}
|
||||
f = f.deriveFont((iStyle & DevicePrinter.STYLE_BOLD) != 0 ? Font.BOLD : baseFont.getStyle());
|
||||
// Falta aplicar el subrayado
|
||||
return f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface PrintItem {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
*/
|
||||
public void draw(Graphics2D g, int x, int y, int width);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import com.unicenta.pos.printer.DevicePrinter;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import org.krysalis.barcode4j.BarcodeDimension;
|
||||
import org.krysalis.barcode4j.HumanReadablePlacement;
|
||||
import org.krysalis.barcode4j.impl.AbstractBarcodeBean;
|
||||
import org.krysalis.barcode4j.impl.code128.Code128Bean;
|
||||
import org.krysalis.barcode4j.impl.upcean.*;
|
||||
import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class PrintItemBarcode implements PrintItem {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected AbstractBarcodeBean m_barcode;
|
||||
protected String m_sCode;
|
||||
protected int m_iWidth;
|
||||
protected int m_iHeight;
|
||||
protected double scale;
|
||||
|
||||
/** Creates a new instance of PrinterItemBarcode
|
||||
* @param type
|
||||
* @param position
|
||||
* @param code
|
||||
* @param scale */
|
||||
public PrintItemBarcode(String type, String position, String code, double scale) {
|
||||
|
||||
m_sCode = code;
|
||||
this.scale = scale;
|
||||
|
||||
if (DevicePrinter.BARCODE_CODE128.equals(type)) {
|
||||
m_barcode = new Code128Bean();
|
||||
} else {
|
||||
m_barcode = new EAN13Bean();
|
||||
}
|
||||
|
||||
if (m_barcode != null) {
|
||||
m_barcode.setModuleWidth(1.0);
|
||||
m_barcode.setBarHeight(40.0);
|
||||
m_barcode.setFontSize(10.0);
|
||||
m_barcode.setQuietZone(10.0);
|
||||
m_barcode.doQuietZone(true);
|
||||
if (DevicePrinter.POSITION_NONE.equals(position)) {
|
||||
m_barcode.setMsgPosition(HumanReadablePlacement.HRP_NONE);
|
||||
} else {
|
||||
m_barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
|
||||
}
|
||||
BarcodeDimension dim = m_barcode.calcDimensions(m_sCode);
|
||||
m_iWidth = (int) dim.getWidth(0);
|
||||
m_iHeight = (int) dim.getHeight(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
*/
|
||||
@Override
|
||||
public void draw(Graphics2D g, int x, int y, int width) {
|
||||
|
||||
if (m_barcode != null) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
AffineTransform oldt = g2d.getTransform();
|
||||
|
||||
g2d.translate(x - 10 + (width - (int)(m_iWidth * scale)) / 2, y + 10);
|
||||
g2d.scale(scale, scale);
|
||||
|
||||
try {
|
||||
m_barcode.generateBarcode(new Java2DCanvasProvider(g2d, 0), m_sCode);
|
||||
} catch (IllegalArgumentException e) {
|
||||
g2d.drawRect(0, 0, m_iWidth, m_iHeight);
|
||||
g2d.drawLine(0, 0, m_iWidth, m_iHeight);
|
||||
g2d.drawLine(m_iWidth, 0, 0, m_iHeight);
|
||||
}
|
||||
|
||||
g2d.setTransform(oldt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return (int) (m_iHeight * scale) + 20;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class PrintItemImage implements PrintItem {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected BufferedImage image;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected double scale;
|
||||
|
||||
/** Creates a new instance of PrintItemImage
|
||||
* @param image
|
||||
* @param scale
|
||||
*/
|
||||
public PrintItemImage(BufferedImage image, double scale) {
|
||||
this.image = image;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
*/
|
||||
@Override
|
||||
public void draw(Graphics2D g, int x, int y, int width) {
|
||||
g.drawImage(image, x + (width - (int)(image.getWidth() * scale)) / 2, y,
|
||||
(int)(image.getWidth() * scale),
|
||||
(int)(image.getHeight() * scale)
|
||||
, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return (int) (image.getHeight() * scale);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS 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.
|
||||
//
|
||||
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.printer.ticket;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class PrintItemLine implements PrintItem {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected Font font;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected int fontheight;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected int textsize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected List<StyledText> m_atext;
|
||||
|
||||
/** Creates a new instance of PrinterItemLine
|
||||
* @param textsize
|
||||
* @param font
|
||||
* @param fontheight */
|
||||
public PrintItemLine(int textsize, Font font, int fontheight) {
|
||||
this.textsize = textsize;
|
||||
this.font = font;
|
||||
this.fontheight = fontheight;
|
||||
|
||||
// JG 16 May 12 use diamond inference
|
||||
m_atext = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param style
|
||||
* @param text
|
||||
*/
|
||||
public void addText(int style, String text) {
|
||||
m_atext.add(new StyledText(style, text));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param g
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
*/
|
||||
@Override
|
||||
public void draw(Graphics2D g, int x, int y, int width) {
|
||||
|
||||
MyPrinterState ps = new MyPrinterState(textsize);
|
||||
float left = x;
|
||||
for (int i = 0; i < m_atext.size(); i++) {
|
||||
StyledText t = m_atext.get(i);
|
||||
g.setFont(ps.getFont(font, t.style));
|
||||
g.drawString(t.text, left, (float) y);
|
||||
left += g.getFontMetrics().getStringBounds(t.text, g).getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return fontheight * MyPrinterState.getLineMult(textsize);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static class StyledText {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param style
|
||||
* @param text
|
||||
*/
|
||||
public StyledText(int style, String text) {
|
||||
this.style = style;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public int style;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user