import java.awt.Point; import java.awt.geom.Point2D; import java.io.IOException; import com.gnostice.pdfone.PDFOne; import com.gnostice.pdfone.PdfDocument; import com.gnostice.pdfone.PdfException; import com.gnostice.pdfone.PdfPoint; import com.gnostice.pdfone.PdfWriter; public class PdfPoint_Examples { // Activates the component PDFOne.jar static { PDFOne.activate("T95VZE:W8HBPVA:74VQ8QV:LO4V8", "9B1HRZAP:X5853ERNE:5EREMEGRQ:TX1R10"); } public static void main(String[] args) throws IOException, PdfException { PdfPoint_Examples obj = new PdfPoint_Examples(); obj.PdfPoint_PdfPoint_Example(); } // This code segment creates several points using overloaded // constructors public void PdfPoint_PdfPoint_Example() throws IOException, PdfException { PdfWriter writer = PdfWriter.fileWriter( "PdfPoint_PdfPoint_Example.pdf"); PdfDocument document = new PdfDocument(writer);
// Creates a PdfPoint object for position (200, 100) PdfPoint point1 = new PdfPoint(200, 100);
// Creates a Point object for position (200, 300) Point jPoint = new Point(300, 200); // Creates a PdfPoint object with the Java point object PdfPoint point2 = new PdfPoint(jPoint);
// Creates a Point2D object for position (400, 300) Point2D jPoint2D = new Point2D.Double(300, 400); // Creates a PdfPoint object using the Java point2D object PdfPoint point3 = new PdfPoint(jPoint2D);
// Creates a PdfPoint object with another PdfPoint object PdfPoint point4 = new PdfPoint(point3);
// Increments coordinates of the PdfPoint by 100 point4.setX(point3.getX() + 100); point4.setY(point3.getY() + 100); // Draws lines and writes text identifying the above // PdfPoint objects document.drawLine(point1, point2); document.drawLine(point2, point3); document.drawLine(point3, point4); document.writeText(". PdfPoint(200, 100)", point1); document.writeText(". PdfPoint(jPoint) [jPoint = new Point(300, 200)]", point2); document.writeText(". PdfPoint(jPoint2D) [jPoint2D = new Point2D.Double(300, 400)]", point3); document.writeText(". PdfPoint(point3) [point4 = new PdfPoint(point3); point4.setX(point3.getX() + 100); point4.setY(point3.getY() + 100);]", point4); // Sets the file to be opened after it is written to document.setOpenAfterSave(true); // Writes the document object to file document.write(); // Closes all I/O streams associated with this writer object writer.dispose(); } }