Ignore:
Timestamp:
08/29/08 08:17:54 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/io/PdfFramesetWriter.java

    r282 r286  
    11package org.expeditee.io;
    22
     3import java.awt.Color;
    34import java.awt.Dimension;
     5import java.awt.Graphics2D;
    46import java.awt.Image;
    57import java.io.FileOutputStream;
     
    1113import org.expeditee.gui.FrameGraphics;
    1214import org.expeditee.gui.UserSettings;
     15import org.expeditee.items.Circle;
    1316import org.expeditee.items.Item;
     17import org.expeditee.items.Line;
    1418import org.expeditee.items.Picture;
    1519import org.expeditee.items.Text;
     20import org.expeditee.items.widgets.InteractiveWidget;
    1621
    1722import com.lowagie.text.Document;
     
    2631 *
    2732 * @author root
    28  *
     33 * 
    2934 */
    3035public class PdfFramesetWriter extends DefaultFramesetWriter {
     
    3439        private PdfWriter _pdfWriter;
    3540
    36         public PdfFramesetWriter(long firstFrame, long maxFrame) {
     41        private boolean _showFrameNames;
     42
     43        public PdfFramesetWriter(long firstFrame, long maxFrame,
     44                        boolean showFrameNames) {
    3745                super(firstFrame, maxFrame);
    3846                Dimension d = FrameGraphics.getMaxSize();
    3947                _pdfDocument = new Document(new Rectangle(d.width, d.height));
     48                _showFrameNames = showFrameNames;
    4049        }
    41        
     50
    4251        public PdfFramesetWriter() {
    43                 this(1, Long.MAX_VALUE);
     52                this(1, Long.MAX_VALUE, false);
     53        }
     54
     55        @Override
     56        protected String getFileName(Frame start) {
     57                String fileName = start.getFramesetName();
     58                if (_maxFrame < Long.MAX_VALUE) {
     59                        fileName += "_" + _firstFrame + "-" + _maxFrame;
     60                }
     61                return fileName;
    4462        }
    4563
     
    4866                _format = ".pdf";
    4967                super.initialise(start);
     68
    5069                try {
    5170                        _pdfWriter = PdfWriter.getInstance(_pdfDocument,
     
    6887        }
    6988
     89        protected void writeStartFrame(Frame starting) throws IOException {
     90                // TODO color in the frame background color
     91
     92                super.writeStartFrame(starting);
     93        }
     94
    7095        protected void writeEndFrame(Frame ending) throws IOException {
     96                if (_showFrameNames)
     97                        writeText((Text) ending.getNameItem());
    7198                super.writeEndFrame(ending);
    7299                // Move to the next page
     
    108135        protected void writePicture(Picture pic) throws IOException {
    109136                Image image = pic.getCroppedImage();
    110                 if(image == null)
     137                if (image == null)
    111138                        return;
    112139                try {
     
    124151
    125152        @Override
     153        protected void writeLine(Line lineEnd) throws IOException {
     154                PdfContentByte cb = _pdfWriter.getDirectContent();
     155//              Color fill = lineEnd.getFillColor();
     156//              if (fill != null) {
     157//                      cb.setColorFill(fill);
     158//              }
     159                Graphics2D g = cb.createGraphicsShapes(
     160                                FrameGraphics.getMaxSize().width,
     161                                FrameGraphics.getMaxSize().height);
     162                lineEnd.paint(g);
     163//              if (fill != null) {
     164//                      g.setPaint(fill);
     165//              }
     166//              lineEnd.paintFill(g);
     167        }
     168
     169        @Override
    126170        protected Collection<Item> getItemsToWrite(Frame toWrite) {
    127171                return toWrite.getVisibleItems();
    128172        }
     173       
     174        @Override
     175        protected void writeCircle(Circle toWrite) throws IOException {
     176                PdfContentByte cb = _pdfWriter.getDirectContent();
     177                Graphics2D g = cb.createGraphicsShapes(
     178                                FrameGraphics.getMaxSize().width,
     179                                FrameGraphics.getMaxSize().height);
     180                toWrite.paint(g);
     181        }
     182       
     183       
     184        @Override
     185        protected void writeWidget(InteractiveWidget toWrite) throws IOException {
     186                PdfContentByte cb = _pdfWriter.getDirectContent();
     187                Graphics2D g = cb.createGraphicsShapes(
     188                                FrameGraphics.getMaxSize().width,
     189                                FrameGraphics.getMaxSize().height);
     190                toWrite.paint(g);
     191        }
    129192}
Note: See TracChangeset for help on using the changeset viewer.