Menu

#36 not fill a rect,but draw a line, will make barcode read ok

open
nobody
None
5
2012-02-01
2012-02-01
Anonymous
No

with same printer, the barcode can not be read.and I found the reason.
Java2DCanvasProvider.java

public void deviceFillRect(double x, double y, double w, double h) {
g2d.fill(new Rectangle2D.Double(x, y, w, h));
}

fill a rect is the reason.
when I modify it with draw a line (not fill a rect),the barcode will be read ok.
my code is following:

public void deviceFillRect(double x, double y, double w, double h) {
Stroke objSave = g2d.getStroke();
try{
int cap = BasicStroke.CAP_BUTT;
int join = BasicStroke.JOIN_BEVEL;
float dash_phase = 0.0f;
float miterlimit = 1.0f;
BasicStroke stroke = new BasicStroke(new Double(w).floatValue(), cap, join, miterlimit, null, dash_phase);
g2d.setStroke(stroke);
Line2D line = new Line2D.Double();
line.setLine(x+(w/2), y, x+(w/2), y+h);
g2d.draw(line);
}finally{
g2d.setStroke(objSave);
}
}

Discussion


Log in to post a comment.