本文整理匯總了Java中com.lowagie.text.pdf.PdfContentByte.circle方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfContentByte.circle方法的具體用法?Java PdfContentByte.circle怎麽用?Java PdfContentByte.circle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.lowagie.text.pdf.PdfContentByte
的用法示例。
在下文中一共展示了PdfContentByte.circle方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Draws some shapes.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "shapes.pdf"));
// step 3: we open the document
document.open();
// step 4: we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
// an example of a rectangle with a diagonal in very thick lines
cb.setLineWidth(10f);
// draw a rectangle
cb.rectangle(100, 700, 100, 100);
// add the diagonal
cb.moveTo(100, 700);
cb.lineTo(200, 800);
// stroke the lines
cb.stroke();
// an example of some circles
cb.setLineDash(3, 3, 0);
cb.setRGBColorStrokeF(0f, 255f, 0f);
cb.circle(150f, 500f, 100f);
cb.stroke();
cb.setLineWidth(5f);
cb.resetRGBColorStroke();
cb.circle(150f, 500f, 50f);
cb.stroke();
// example with colorfill
cb.setRGBColorFillF(0f, 255f, 0f);
cb.moveTo(100f, 200f);
cb.lineTo(200f, 250f);
cb.lineTo(400f, 150f);
// because we change the fill color BEFORE we stroke the triangle
// the color of the triangle will be red instead of green
cb.setRGBColorFillF(255f, 0f, 0f);
cb.closePathFillStroke();
cb.sanityCheck();
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
示例2: pictureCircles
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Prints 3 circles in different colors that intersect with eachother.
* @param x
* @param y
* @param cb
* @throws Exception
*/
public static void pictureCircles(float x, float y, PdfContentByte cb) throws Exception {
PdfGState gs = new PdfGState();
gs.setBlendMode(PdfGState.BM_SOFTLIGHT);
gs.setFillOpacity(0.7f);
cb.setGState(gs);
cb.setColorFill(Color.gray);
cb.circle(x + 70, y + 70, 50);
cb.fill();
cb.circle(x + 100, y + 130, 50);
cb.fill();
cb.circle(x + 130, y + 70, 50);
cb.fill();
}
示例3: pictureCircles
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Prints 3 circles in different colors that intersect with eachother.
*
* @param x
* @param y
* @param cb
* @throws Exception
*/
private static void pictureCircles(float x, float y, PdfContentByte cb)
throws Exception {
cb.setColorFill(Color.red);
cb.circle(x + 70, y + 70, 50);
cb.fill();
cb.setColorFill(Color.yellow);
cb.circle(x + 100, y + 130, 50);
cb.fill();
cb.setColorFill(Color.blue);
cb.circle(x + 130, y + 70, 50);
cb.fill();
}
示例4: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Draws some concentric circles.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "circles.pdf"));
// step 3: we open the document
document.open();
// step 4: we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
cb.circle(250.0f, 500.0f, 200.0f);
cb.circle(250.0f, 500.0f, 150.0f);
cb.stroke();
cb.setRGBColorFill(0xFF, 0x00, 0x00);
cb.circle(250.0f, 500.0f, 100.0f);
cb.fillStroke();
cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
cb.circle(250.0f, 500.0f, 50.0f);
cb.fill();
cb.sanityCheck();
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
示例5: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Changing the Graphics State with saveState() and restoreState().
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document,
PdfTestBase.getOutputStream( "state.pdf"));
// step 3: we open the document
document.open();
// step 4: we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
cb.circle(260.0f, 500.0f, 250.0f);
cb.fill();
cb.saveState();
cb.setColorFill(Color.red);
cb.circle(260.0f, 500.0f, 200.0f);
cb.fill();
cb.saveState();
cb.setColorFill(Color.blue);
cb.circle(260.0f, 500.0f, 150.0f);
cb.fill();
cb.restoreState();
cb.circle(260.0f, 500.0f, 100.0f);
cb.fill();
cb.restoreState();
cb.circle(260.0f, 500.0f, 50.0f);
cb.fill();
cb.sanityCheck();
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
示例6: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Changing the Graphics State with PdfGState.
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document,
PdfTestBase.getOutputStream( "gstate.pdf"));
// step 3: we open the document
document.open();
// step 4: we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
PdfGState gs = new PdfGState();
gs.setFillOpacity(0.5f);
cb.setGState(gs);
cb.setColorFill(Color.red);
cb.circle(260.0f, 500.0f, 250.0f);
cb.fill();
cb.circle(260.0f, 500.0f, 200.0f);
cb.fill();
cb.circle(260.0f, 500.0f, 150.0f);
cb.fill();
gs.setFillOpacity(0.2f);
cb.setGState(gs);
cb.setColorFill(Color.blue);
cb.circle(260.0f, 500.0f, 100.0f);
cb.fill();
cb.circle(260.0f, 500.0f, 50.0f);
cb.fill();
cb.sanityCheck();
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
示例7: main
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
/**
* Draws different things into different layers.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("layers.pdf"));
// step 3: we open the document
document.open();
// step 4:
// high level
Paragraph p = new Paragraph();
for (int i = 0; i < 100; i++)
p.add(new Chunk("Blah blah blah blah blah. "));
document.add(p);
Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR
+ "hitchcock.png");
img.setAbsolutePosition(100, 500);
document.add(img);
// low level
PdfContentByte cb = writer.getDirectContent();
PdfContentByte cbu = writer.getDirectContentUnder();
cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
cb.circle(250.0f, 500.0f, 50.0f);
cb.fill();
cb.sanityCheck();
cbu.setRGBColorFill(0xFF, 0x00, 0x00);
cbu.circle(250.0f, 500.0f, 100.0f);
cbu.fill();
cbu.sanityCheck();
// step 5: we close the document
document.close();
}
示例8: plotProperties
import com.lowagie.text.pdf.PdfContentByte; //導入方法依賴的package包/類
private void plotProperties(Properties tp, Properties props, List<String> xDate, List<String> yHeight, float height, PdfContentByte cb, boolean countEven) {
StringBuilder temp = null;
String tempValue = null;
String className = null;
String[] tempYcoords;
int origX = 0;
int origY = 0;
Properties args = new Properties();
for (Enumeration e = tp.propertyNames(); e.hasMoreElements();) {
temp = new StringBuilder(e.nextElement().toString());
tempValue = tp.getProperty(temp.toString()).trim();
if (temp.toString().equals("__finalEDB"))
args.setProperty(temp.toString(), props.getProperty(tempValue));
else if (temp.toString().equals("__xDateScale"))
args.setProperty(temp.toString(), props.getProperty(tempValue));
else if (temp.toString().equals("__dateFormat"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__nMaxPixX"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__nMaxPixY"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fStartX"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fEndX"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fStartY"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__fEndY"))
args.setProperty(temp.toString(),tempValue);
else if (temp.toString().equals("__origX"))
origX = Integer.parseInt(tempValue);
else if (temp.toString().equals("__origY"))
origY = Integer.parseInt(tempValue);
else if (temp.toString().equals("__className"))
className = tempValue;
else {
MiscUtils.getLogger().debug("Adding xDate " + temp.toString() + " VAL: " + props.getProperty(temp.toString()));
MiscUtils.getLogger().debug("Adding yHeight " + tempValue + " VAL: " + props.getProperty(tempValue));
xDate.add(props.getProperty(temp.toString()));
yHeight.add(props.getProperty(tempValue));
}
} // end for read in from config file
FrmPdfGraphic pdfGraph = FrmGraphicFactory.create(className);
pdfGraph.init(args);
Properties gProp = pdfGraph.getGraphicXYProp(xDate, yHeight);
//draw the pic
cb.setLineWidth(1.5f);
if (countEven) {
cb.setRGBColorStrokeF(0f, 0f, 255f);
} else {
cb.setRGBColorStrokeF(255f, 0f, 0f);
}
for (Enumeration e = gProp.propertyNames(); e.hasMoreElements();) {
temp = new StringBuilder(e.nextElement().toString());
tempValue = gProp.getProperty(temp.toString(), "");
if (tempValue.equals("")) {
continue;
}
tempYcoords = tempValue.split(",");
for( int idx = 0; idx < tempYcoords.length; ++idx ) {
tempValue = tempYcoords[idx];
cb.circle((origX + Float.parseFloat(temp.toString())), (height - origY + Float.parseFloat(tempValue)), 1.5f);
cb.stroke();
}
}
}