Java tutorial
/** * Copyright (c) 2008, 2009 Hugo Corbucci and others.<br> * All rights reserved. This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html<br> * <br> * Contributors:<br> * Hugo Corbucci - initial API and implementation<br> * <br> * This file was created on 2008/06/23, 10:01:23, by Hugo Corbucci.<br> * It is part of package br.org.archimedes.io.pdf.elements on the br.org.archimedes.io.pdf project.<br> */ package br.org.archimedes.io.pdf.elements; import java.io.IOException; import br.org.archimedes.exceptions.NotSupportedException; import br.org.archimedes.interfaces.ElementExporter; import br.org.archimedes.io.pdf.PDFWriterHelper; import br.org.archimedes.line.Line; import br.org.archimedes.model.Point; import br.org.archimedes.model.Rectangle; import com.lowagie.text.pdf.PdfContentByte; /** * Belongs to package br.org.archimedes.io.pdf. * * @author night */ public class LineExporter implements ElementExporter<Line> { /* * (non-Javadoc) * @see br.org.archimedes.interfaces.ElementExporter#exportElement(br.org.archimedes * .model.Element, java.io.OutputStream) */ public void exportElement(Line line, Object outputObject) throws IOException { PDFWriterHelper helper = (PDFWriterHelper) outputObject; PdfContentByte cb = helper.getPdfContentByte(); Point initial = helper.modelToDocument(line.getInitialPoint()); Point ending = helper.modelToDocument(line.getEndingPoint()); float x = (float) initial.getX(); float y = (float) initial.getY(); cb.moveTo(x, y); x = (float) ending.getX(); y = (float) ending.getY(); cb.lineTo(x, y); cb.stroke(); } public void exportElement(Line element, Object outputObject, Rectangle boundingBox) throws IOException, NotSupportedException { throw new NotSupportedException(); } }