Coverage Report - com.buckosoft.PicMan.business.contact.engine.Ribbon
 
Classes in this File Line Coverage Branch Coverage Complexity
Ribbon
0%
0/46
0%
0/10
9
 
 1  
 /******************************************************************************
 2  
  * Ribbon.java - Make the original contact sheet
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2005 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.business.contact.engine;
 9  
 
 10  
 import java.awt.Graphics2D;
 11  
 import java.awt.image.BufferedImage;
 12  
 import java.util.Date;
 13  
 import java.util.LinkedList;
 14  
 import java.util.List;
 15  
 
 16  
 import com.buckosoft.PicMan.business.contact.ContactEngine;
 17  
 import com.buckosoft.PicMan.domain.Contact;
 18  
 
 19  
 /** Make one of the original contact sheets.
 20  
  * @author Dick Balaska
 21  
  * @since 2011/12/17
 22  
  * @since 2005/08/06
 23  
  * @version $Revision: 1.2 $ <br> $Date: 2014/02/13 07:24:02 $
 24  
  * @see <a href="http://cvs.buckosoft.com/Projects/PicMan/PicMan/src/main/java/com/buckosoft/PicMan/business/contact/engine/Ribbon.java">Ribbon.java</a>
 25  
  */
 26  0
 public class Ribbon extends ContactEngine {
 27  
 
 28  
         /** Make a contact sheet based on the setup.
 29  
          * @return Success
 30  
          */
 31  
         protected        boolean        _makeContact() {
 32  
 
 33  0
                 boolean        success = true;
 34  
                 
 35  0
                 logger.info("makeContact '" + cName + "'");
 36  
 
 37  
                 
 38  
 //                List<String> picNames = pmf.getDB().getPicNamesBySet(contactParams.getSetName(), contactParams.getSize());
 39  
 //                picNames = setupPicsList(contactParams, picNames);
 40  0
                 List<String> picNames = this.contactManager.getPicNames(contactParams); 
 41  0
                 List<String> f = randomize(picNames);
 42  0
                 logger.info("select from " + f.size() + " filters");
 43  0
                 if (f.size() == 0) {
 44  0
                         RuntimeException e = new RuntimeException("No pics to make contact " + contactParams.getUuid());
 45  0
                         pmf.addError(e);
 46  0
                         return(false);
 47  
                 }
 48  0
                 LinkedList<String> ll = new LinkedList<String>();
 49  0
                 BufferedImage bi = new BufferedImage(cWidth, cHeight, BufferedImage.TYPE_3BYTE_BGR);
 50  0
                 Graphics2D         g = bi.createGraphics();
 51  
                 String                tName;
 52  0
                 Contact                c = new Contact();
 53  0
                 c.setName(cUuid);
 54  0
                 c.setStartTime(new Date());
 55  0
                 c.setCid(chain.getCid());
 56  
                 try {
 57  0
                         int irow = 0;
 58  0
                         int row = 0;
 59  0
                         while (row < cHeight) {
 60  0
                                 int icol = 0;
 61  0
                                 int col = 0;
 62  0
                                 while (col < cWidth) {
 63  0
                                         if (ll.isEmpty())
 64  0
                                                 ll = new LinkedList<String>(f);
 65  0
                                         tName = (String)ll.removeFirst();
 66  0
                                         int widthDrawn = drawThumb(g, tName, tHeight, col, row);
 67  
 
 68  
                                         
 69  0
                                         c.setPic(tName, irow, icol);
 70  0
                                         col += widthDrawn;
 71  0
                                         icol++;
 72  0
                                 }
 73  0
                                 row += contactParams.getSize();
 74  0
                                 irow++;
 75  0
                                 if (isAbort())
 76  0
                                         break;
 77  0
                         }
 78  0
                         drawContactLabel(g);
 79  0
                 } catch (Exception e) {
 80  0
                         logger.error("Error drawing contact", e);
 81  0
                         pmf.addError(e);
 82  0
                         return(false);
 83  
                         
 84  0
                 }
 85  0
                 success = writePic(bi, false);
 86  0
                 c.setEndTime(new Date());
 87  0
                 pmf.getDB().addContact(c);
 88  0
                 return(success);
 89  
         }
 90  
         
 91  
 }