UOCL-244: receipts added to main code base
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.unicenta</groupId>
|
<groupId>com.unicenta</groupId>
|
||||||
<artifactId>unicentaopos</artifactId>
|
<artifactId>unicentaopos</artifactId>
|
||||||
<version>5.0.1</version>
|
<version>5.0.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author JG uniCenta
|
* @author JG uniCenta
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -51,7 +50,9 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
*/
|
*/
|
||||||
protected int m_iBodyHeight;
|
protected int m_iBodyHeight;
|
||||||
|
|
||||||
/** Creates a new instance of AbstractTicket */
|
/**
|
||||||
|
* Creates a new instance of AbstractTicket
|
||||||
|
*/
|
||||||
public BasicTicket() {
|
public BasicTicket() {
|
||||||
// JG 16 May 12 use diamond inference
|
// JG 16 May 12 use diamond inference
|
||||||
m_aCommands = new ArrayList<>();
|
m_aCommands = new ArrayList<>();
|
||||||
@@ -60,25 +61,21 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract Font getBaseFont();
|
protected abstract Font getBaseFont();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract int getFontHeight();
|
protected abstract int getFontHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected abstract double getImageScale();
|
protected abstract double getImageScale();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -87,7 +84,6 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param g2d
|
* @param g2d
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
@@ -96,19 +92,39 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, int x, int y, int width) {
|
public void draw(Graphics2D g2d, int x, int y, int width) {
|
||||||
|
|
||||||
BufferedImage image = new BufferedImage(width + 10, 10, 1);
|
|
||||||
g2d = image.createGraphics();
|
|
||||||
|
|
||||||
int currenty = y;
|
int currenty = y;
|
||||||
for (PrintItem pi : m_aCommands) {
|
for (PrintItem pi : m_aCommands) {
|
||||||
pi.draw(g2d, x, currenty, width);
|
pi.draw(g2d, x, currenty, width);
|
||||||
currenty += pi.getHeight();
|
currenty += pi.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveTicket(g2d, x, y, width);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveTicket(Graphics2D g2d, int x, int y, int width) {
|
||||||
|
|
||||||
|
int receiptHeight = 5;
|
||||||
|
|
||||||
|
PrintItem pi;
|
||||||
|
for(Iterator i$ = m_aCommands.iterator(); i$.hasNext(); receiptHeight += pi.getHeight()) {
|
||||||
|
pi = (PrintItem)i$.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedImage image = new BufferedImage(width + 10, receiptHeight, 1);
|
||||||
|
g2d = image.createGraphics();
|
||||||
|
int currenty = y;
|
||||||
|
|
||||||
|
for(Iterator i$ = this.m_aCommands.iterator(); i$.hasNext(); currenty += pi.getHeight()) {
|
||||||
|
pi = (PrintItem)i$.next();
|
||||||
|
pi.draw(g2d, x, currenty, width);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ImageIO.write(this.negative(image), "png", new File(System.getProperty("user.home") + "/test.png"));
|
ImageIO.write(this.negative(image), "png", new File(System.getProperty("user.home") + "/test.png"));
|
||||||
} catch (Exception var10) {
|
}
|
||||||
System.out.println("Error serialising receipt image !!! : " + var10);
|
catch (Exception e) {
|
||||||
|
System.out.println("Error serialising receipt image !!! : " + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -127,7 +143,6 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public java.util.List<PrintItem> getCommands() {
|
public java.util.List<PrintItem> getCommands() {
|
||||||
@@ -137,7 +152,6 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
// INTERFAZ PRINTER 2
|
// INTERFAZ PRINTER 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param image
|
* @param image
|
||||||
*/
|
*/
|
||||||
public void printImage(BufferedImage image) {
|
public void printImage(BufferedImage image) {
|
||||||
@@ -148,7 +162,6 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param type
|
* @param type
|
||||||
* @param position
|
* @param position
|
||||||
* @param code
|
* @param code
|
||||||
@@ -161,7 +174,6 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param iTextSize
|
* @param iTextSize
|
||||||
*/
|
*/
|
||||||
public void beginLine(int iTextSize) {
|
public void beginLine(int iTextSize) {
|
||||||
@@ -169,7 +181,6 @@ public abstract class BasicTicket implements PrintItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param iStyle
|
* @param iStyle
|
||||||
* @param sText
|
* @param sText
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user