private CategoryDataset createDataset() {
   DefaultCategoryDataset setCategory = new DefaultCategoryDataset();
   try {
     Part part = this.mainFrame.getCurrentPart();
     BookModel model = this.mainFrame.getBookModel();
     Session session = model.beginTransaction();
     StrandDAOImpl daoStrand = new StrandDAOImpl(session);
     List strands = daoStrand.findAll();
     SceneDAOImpl daoScene = new SceneDAOImpl(session);
     List scenes = daoScene.findDistinctDates(part);
     double d = 0.0D;
     Iterator iStrand = strands.iterator();
     while (iStrand.hasNext()) {
       Strand strand = (Strand) iStrand.next();
       Iterator iScene = scenes.iterator();
       while (iScene.hasNext()) {
         Date date = (Date) iScene.next();
         long l = daoStrand.countByDate(date, strand);
         setCategory.addValue(l, strand, date);
         d += l;
       }
     }
     model.commit();
     this.average = (d / (strands.size() + scenes.size()));
   } catch (Exception exc) {
     System.err.println("StrandsByDateChart.createDataset() Exception : " + exc.getMessage());
   }
   return setCategory;
 }
Exemple #2
0
 @SuppressWarnings("unchecked")
 private JTable createTable() {
   Part part = this.mainFrame.getCurrentPart();
   BookModel documentModel = this.mainFrame.getBookModel();
   Session session = documentModel.beginTransaction();
   PersonDAOImpl personDAO = new PersonDAOImpl(session);
   List<Person> persons = personDAO.findByCategories(this.selectedCategories);
   SceneDAOImpl sceneDAO = new SceneDAOImpl(session);
   List<Date> dates = sceneDAO.findDistinctDates(part);
   LocationDAOImpl locationDAO = new LocationDAOImpl(session);
   List<Location> locations = locationDAO.findAll();
   documentModel.commit();
   Object[] arrayOfObject1 =
       ArrayUtils.addAll(new Object[] {I18N.getMsg("msg.common.location"), ""}, dates.toArray());
   this.foundCharacters.clear();
   ArrayList localArrayList = new ArrayList();
   Iterator<Location> locationsIterator = locations.iterator();
   while (locationsIterator.hasNext()) {
     Location location = locationsIterator.next();
     Object[] localObject2 = new Object[arrayOfObject1.length];
     int j = 0;
     localObject2[(j++)] = location.getName();
     localObject2[(j++)] = location.getCountryCity();
     int m = 0;
     Iterator<Date> datesIterator = dates.iterator();
     while (datesIterator.hasNext()) {
       Date localDate = datesIterator.next();
       WiWWContainer localWiWWContainer =
           new WiWWContainer(this.mainFrame, localDate, location, persons);
       localObject2[j] = localWiWWContainer;
       if (localWiWWContainer.isFound()) {
         this.foundCharacters.addAll(localWiWWContainer.getCharacterList());
         m = 1;
       }
       j++;
     }
     if (m != 0) {
       localArrayList.add(localObject2);
     }
   }
   //	Object[] localObject1 = new Object[localArrayList.size()][];
   //	int i = 0;
   /* Obfuscator ?
   Object localObject2 = localArrayList.iterator();
   while (((Iterator) localObject2).hasNext()) {
   	Object[] arrayOfObject2 = (Object[]) ((Iterator) localObject2).next();
   	localObject1[(i++)] = arrayOfObject2;
   }*/
   ReadOnlyTable jTable =
       new ReadOnlyTable((Object[][]) localArrayList.toArray(new Object[0][]), arrayOfObject1);
   for (int k = 2; k < jTable.getColumnCount(); k++) {
     TableColumn localTableColumn = jTable.getColumnModel().getColumn(k);
     localTableColumn.setPreferredWidth(120);
     localTableColumn.setCellRenderer(new WiWWTableCellRenderer());
   }
   jTable.setAutoResizeMode(0);
   jTable.getTableHeader().setReorderingAllowed(false);
   return jTable;
 }