|
|
@@ -26,6 +26,22 @@
|
|
|
|
|
|
package net.sourceforge.barbecue;
|
|
|
|
|
|
+import java.awt.Color;
|
|
|
+import java.awt.Dimension;
|
|
|
+import java.awt.Font;
|
|
|
+import java.awt.FontMetrics;
|
|
|
+import java.awt.Graphics;
|
|
|
+import java.awt.Graphics2D;
|
|
|
+import java.awt.Insets;
|
|
|
+import java.awt.Rectangle;
|
|
|
+import java.awt.print.PageFormat;
|
|
|
+import java.awt.print.Printable;
|
|
|
+import java.awt.print.PrinterException;
|
|
|
+import java.text.CharacterIterator;
|
|
|
+import java.text.StringCharacterIterator;
|
|
|
+
|
|
|
+import javax.swing.JComponent;
|
|
|
+
|
|
|
import net.sourceforge.barbecue.env.EnvironmentFactory;
|
|
|
import net.sourceforge.barbecue.env.HeadlessEnvironment;
|
|
|
import net.sourceforge.barbecue.output.GraphicsOutput;
|
|
|
@@ -33,21 +49,6 @@ import net.sourceforge.barbecue.output.Output;
|
|
|
import net.sourceforge.barbecue.output.OutputException;
|
|
|
import net.sourceforge.barbecue.output.SizingOutput;
|
|
|
|
|
|
-import javax.swing.*;
|
|
|
-
|
|
|
-import java.awt.*;
|
|
|
-import java.awt.event.ActionEvent;
|
|
|
-import java.awt.event.ActionListener;
|
|
|
-import java.awt.event.MouseAdapter;
|
|
|
-import java.awt.event.MouseListener;
|
|
|
-import java.awt.event.MouseEvent;
|
|
|
-import java.awt.print.PageFormat;
|
|
|
-import java.awt.print.Printable;
|
|
|
-import java.awt.print.PrinterException;
|
|
|
-import java.awt.print.PrinterJob;
|
|
|
-import java.text.CharacterIterator;
|
|
|
-import java.text.StringCharacterIterator;
|
|
|
-
|
|
|
/**
|
|
|
* Abstract barcode class that provides functionality that is common to
|
|
|
* all barcodes. Specific barcode implementations must subclass
|
|
|
@@ -58,7 +59,9 @@ import java.text.StringCharacterIterator;
|
|
|
public abstract class Barcode extends JComponent
|
|
|
implements Printable {
|
|
|
|
|
|
- private static final int DEFAULT_BAR_HEIGHT = 50;
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
+ private static final int DEFAULT_BAR_HEIGHT = 50;
|
|
|
|
|
|
protected String data;
|
|
|
protected String label;
|
|
|
@@ -83,7 +86,7 @@ public abstract class Barcode extends JComponent
|
|
|
} else {
|
|
|
this.barHeight = Barcode.DEFAULT_BAR_HEIGHT;
|
|
|
}
|
|
|
- this.font = EnvironmentFactory.getEnvironment().getDefaultFont();
|
|
|
+ this.font=new Font("Microsoft YaHei UI",Font.PLAIN,12);
|
|
|
this.drawingText = true;
|
|
|
setBackground(Color.white);
|
|
|
setForeground(Color.black);
|
|
|
@@ -424,8 +427,16 @@ public abstract class Barcode extends JComponent
|
|
|
Dimension d = new Dimension();
|
|
|
if (EnvironmentFactory.getEnvironment() instanceof HeadlessEnvironment) {
|
|
|
try {
|
|
|
- d = draw(new SizingOutput(font, getForeground(), getBackground()), 0, 0, barWidth, barHeight);
|
|
|
+ if(font == null)
|
|
|
+ {
|
|
|
+ d = draw(new SizingOutput(font, getForeground(), getBackground()), 0, 0, barWidth, barHeight);
|
|
|
+ } else
|
|
|
+ {
|
|
|
+ java.awt.FontMetrics fontMetrics = getFontMetrics(font);
|
|
|
+ d = draw(new SizingOutput(font, fontMetrics, getForeground(), getBackground()), 0, 0, barWidth, barHeight);
|
|
|
+ }
|
|
|
} catch (OutputException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
try {
|