本文整理汇总了Java中net.sourceforge.barbecue.BarcodeFactory类的典型用法代码示例。如果您正苦于以下问题:Java BarcodeFactory类的具体用法?Java BarcodeFactory怎么用?Java BarcodeFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BarcodeFactory类属于net.sourceforge.barbecue包,在下文中一共展示了BarcodeFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DynamicImageController
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public DynamicImageController() {
try {
//Graphic Text
BufferedImage bufferedImg = new BufferedImage(100, 25, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bufferedImg.createGraphics();
g2.drawString("This is a text", 0, 10);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(bufferedImg, "png", os);
graphicText = new DefaultStreamedContent(new ByteArrayInputStream(os.toByteArray()), "image/png");
//Chart
JFreeChart jfreechart = ChartFactory.createPieChart("Turkish Cities", createDataset(), true, true, false);
File chartFile = new File("dynamichart");
ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300);
chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png");
//Barcode
File barcodeFile = new File("dynamicbarcode");
BarcodeImageHandler.saveJPEG(BarcodeFactory.createCode128("PRIMEFACES"), barcodeFile);
barcode = new DefaultStreamedContent(new FileInputStream(barcodeFile), "image/jpeg");
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: drawingBarcodeDirectToGraphics
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void drawingBarcodeDirectToGraphics()
throws BarcodeException, OutputException {
// Always get a Barcode from the BarcodeFactory
Barcode barcode = BarcodeFactory.createCode128A("My Barcode");
// We are created an image from scratch here, but for printing in Java,
// your print renderer should have a Graphics internally anyway
BufferedImage image = new BufferedImage(500, 500,
BufferedImage.TYPE_BYTE_GRAY);
// We need to cast the Graphics from the Image to a Graphics2D:
// this is OK
Graphics2D g = (Graphics2D) image.getGraphics();
// Barcode supports a direct draw method to Graphics2D that lets you
// position the barcode on the canvas
barcode.draw(g, 10, 56);
}
示例3: outputtingBarcodeAsPNG
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void outputtingBarcodeAsPNG() throws BarcodeException,
IOException, OutputException {
// get a Barcode from the BarcodeFactory
Barcode barcode = BarcodeFactory.createCode128A("My Barcode");
File f = new File("mybarcode.png");
// Let the barcode image handler do the hard work
BarcodeImageHandler.savePNG(barcode, f);
}
示例4: createBaseBarcode
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
@Override
protected Barcode createBaseBarcode(BarcodeInfo barcodeInfo)
throws BarcodeException
{
return BarcodeFactory.create3of9(barcodeInfo.getCode(),
barcodeInfo.getRequiresChecksum());
}
示例5: outputtingBarcode128x1
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void outputtingBarcode128x1() throws BarcodeException,
IOException, OutputException {
Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("CODE128x1");
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-1.png"));
}
示例6: outputtingBarcode128x2
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void outputtingBarcode128x2() throws BarcodeException,
IOException, OutputException {
Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("2HgH328355316700000241500100");
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-2.png"));
}
示例7: outputtingBarcode128x3
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void outputtingBarcode128x3() throws BarcodeException,
IOException, OutputException {
Barcode barcode3;
barcode3 = BarcodeFactory.createCode128("Code128-3");
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-3.png"));
}
示例8: outputtingBarcode128x4
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void outputtingBarcode128x4() throws BarcodeException,
IOException, OutputException {
Barcode barcode3;
barcode3 = BarcodeFactory
.createCode128("314159265358979323846264338327950288");
barcode3.setResolution(300);
BarcodeImageHandler.savePNG(barcode3, new File("Code128-4.png"));
}
示例9: usingBarbecueAsSwingComponent
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void usingBarbecueAsSwingComponent() throws BarcodeException {
JPanel panel = new JPanel();
// Always get a Barcode from the BarcodeFactory
Barcode barcode = BarcodeFactory.createCode128A("My Barcode");
/*
* Because Barcode extends Component, you can use it just like any other
* Swing component. In this case, we can add it straight into a panel
* and it will be drawn and layed out according to the layout of the
* panel.
*/
panel.add(barcode);
}
示例10: outputtingBarcodeAsJPEG
import net.sourceforge.barbecue.BarcodeFactory; //导入依赖的package包/类
public static void outputtingBarcodeAsJPEG() throws BarcodeException,
IOException, OutputException {
Barcode barcode3 = BarcodeFactory.createCode128C("123456");
barcode3.setResolution(300);
BarcodeImageHandler.saveJPEG(barcode3, new File("123456.jpg"));
}