Ejemplo n.º 1
0
  @Override
  public void initUi() {
    try {
      MigLayout layout = new MigLayout("insets 1", "[fill,grow]", "[top][fill,grow]");
      setLayout(layout);
      setOpaque(false);

      // date
      StrandDateLabel lbDate = new StrandDateLabel(strand, date);
      add(lbDate, "wrap");

      // scenes by strand and date
      BookModel model = mainFrame.getBookModel();
      Session session = model.beginTransaction();
      SceneDAOImpl sceneDao = new SceneDAOImpl(session);
      List<Scene> sceneList = sceneDao.findByStrandAndDate(strand, date);
      model.commit();
      if (sceneList.isEmpty()) {
        SpacePanel spacePanel = new SpacePanel(mainFrame, strand, date);
        add(spacePanel, "grow");
      } else {
        MigLayout layout2 = new MigLayout("insets 0", "[]", "[top]");
        JPanel colPanel = new JPanel(layout2);
        colPanel.setOpaque(false);
        for (Scene scene : sceneList) {
          ChronoScenePanel csp = new ChronoScenePanel(mainFrame, scene);
          colPanel.add(csp, "grow");
        }
        add(colPanel, "grow");
      }
    } catch (Exception e) {
    }
  }
Ejemplo n.º 2
0
 private JFreeChart createChart(CategoryDataset setCategory) {
   JFreeChart chart =
       ChartFactory.createBarChart(
           this.chartTitle, "", "", setCategory, PlotOrientation.VERTICAL, true, true, false);
   CategoryPlot plot = (CategoryPlot) chart.getPlot();
   plot.addRangeMarker(ChartUtil.getAverageMarker(this.average), Layer.FOREGROUND);
   BookModel model = this.mainFrame.getBookModel();
   Session session = model.beginTransaction();
   StrandDAOImpl daoStrand = new StrandDAOImpl(session);
   List strands = daoStrand.findAll();
   model.commit();
   Color[] colors = new Color[strands.size()];
   int i = 0;
   Object iObject = strands.iterator();
   while (((Iterator) iObject).hasNext()) {
     Strand strand = (Strand) ((Iterator) iObject).next();
     colors[i] = ColorUtil.darker(strand.getJColor(), 0.25D);
     i++;
   }
   iObject = (BarRenderer) plot.getRenderer();
   for (int j = 0; j < setCategory.getRowCount(); j++) {
     Color color = colors[(j % colors.length)];
     ((BarRenderer) iObject).setSeriesPaint(j, color);
   }
   return chart;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
  @Override
  public void refresh() {
    Part currentPart = mainFrame.getCurrentPart();
    BookModel model = mainFrame.getBookModel();
    Session session = model.beginTransaction();
    ChapterDAOImpl dao = new ChapterDAOImpl(session);
    List<Chapter> chapters = dao.findAll(currentPart);
    model.commit();

    removeAll();

    // "chapter" for unassigned scenes
    JScrollPane scrollerUnassigend = new JScrollPane(new ChapterPanel(mainFrame));
    scrollerUnassigend.setMinimumSize(new Dimension(200, 180));
    add(scrollerUnassigend, "growx");
    add(scroller, "grow");

    // chapters
    MigLayout layout =
        new MigLayout(
            "wrap " + cols,
            "", // columns
            "[top]" // rows
            );
    panel.setLayout(layout);
    panel.removeAll();
    for (Chapter chapter : chapters) {
      panel.add(new ChapterPanel(mainFrame, chapter), "grow");
    }
    if (panel.getComponentCount() == 0) {
      panel.add(new JLabel(I18N.getMsg("msg.warning.no.chapters")));
    }
    revalidate();
    repaint();
  }
Ejemplo n.º 5
0
  /**
   * Gets the timestamp for the scene and creates a label on the panel that displays the timestamp
   *
   * @return
   */
  private JLabel addSceneTimeTextToPanel() {
    JLabel label = new JLabel();
    if (scene.hasSceneTs()) {
      DateFormat formatter = I18N.getDateTimeFormatter();
      label.setText(formatter.format(scene.getSceneTs()));
    } else {
      // Add the date of scenes with relative dates to the panel
      if (scene.hasRelativeScene()) {
        BookModel model = mainFrame.getBookModel();
        Session session = model.beginTransaction();
        SceneDAOImpl dao = new SceneDAOImpl(session);
        // Get all scenes from the book
        Scene relative = dao.findRealtiveScene(scene.getRelativeSceneId());
        session.close();
        // Create the timestamp for the relative date
        Timestamp ts = relative.getSceneTs();
        Calendar cal = Calendar.getInstance();
        cal.setTime(ts);
        cal.add(Calendar.DAY_OF_WEEK, scene.getRelativeDateDifference());
        ts.setTime(cal.getTime().getTime());
        DateFormat formatter = I18N.getDateTimeFormatter();
        label.setText("[" + formatter.format(ts) + "]");
      }
    }

    return label;
  }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
 @Override
 protected AbstractEntity getEntity(Long id) {
   BookModel model = mainFrame.getBookModel();
   Session session = model.beginTransaction();
   ItemDAOImpl dao = new ItemDAOImpl(session);
   Item item = dao.find(id);
   model.commit();
   return item;
 }
Ejemplo n.º 8
0
 @SuppressWarnings("unchecked")
 private JTable createTable() {
   Part part = mainFrame.getCurrentPart();
   BookModel model = mainFrame.getBookModel();
   Session session = model.beginTransaction();
   PersonDAOImpl personDAO = new PersonDAOImpl(session);
   List persons = personDAO.findByCategories(selectedCategories);
   SceneDAOImpl sceneDAO = new SceneDAOImpl(session);
   List scenes = sceneDAO.findByPart(part);
   model.commit();
   String[] string1 = new String[scenes.size() + 1];
   string1[0] = "";
   int i = 1;
   Object scenesIterator = scenes.iterator();
   while (((Iterator) scenesIterator).hasNext()) {
     Scene scene = (Scene) ((Iterator) scenesIterator).next();
     string1[i] = ((Scene) scene).getChapterSceneNo(false);
     i++;
   }
   scenesIterator = new ArrayList();
   String[] string2 = new String[scenes.size() + 1];
   Iterator personsIterator = persons.iterator();
   Object localObject6;
   while (personsIterator.hasNext()) {
     Person person = (Person) personsIterator.next();
     int j = 0;
     Object[] string3 = new Object[scenes.size() + 1];
     string3[(j++)] = person.getAbbreviation();
     int n = 0;
     localObject6 = scenes.iterator();
     while (((Iterator) localObject6).hasNext()) {
       Scene localScene = (Scene) ((Iterator) localObject6).next();
       if (localScene.getPersons().contains(person)) {
         n = 1;
         string3[j] = ColorUtil.darker(localScene.getStrand().getJColor(), 0.05D);
       } else {
         string3[j] = null;
       }
       string2[j] = HtmlUtil.wrapIntoTable(localScene.getTitleText(true, 500));
       j++;
     }
     if ((cbShowUnusedPersons == null) || (cbShowUnusedPersons.isSelected()) || (n != 0)) {
       ((List) scenesIterator).add(string3);
     }
   }
   Object[][] localObject31 = new Object[((List) scenesIterator).size()][];
   i = 0;
   Iterator localObject4 = ((List) scenesIterator).iterator();
   while (((Iterator) localObject4).hasNext()) {
     Object[] arrayOfObject1 = (Object[]) ((Iterator) localObject4).next();
     localObject31[(i++)] = arrayOfObject1;
   }
   JTable ntable = new ReadOnlyTable((Object[][]) localObject31, string1);
   if (ntable.getModel().getRowCount() == 0) {
     return ntable;
   }
   ntable.getColumnModel().getColumn(0).setPreferredWidth(200);
   ntable.getColumnModel().getColumn(0).setCellRenderer(new HeaderTableCellRenderer());
   for (int k = 1; k < ntable.getColumnCount(); k++) {
     int m = ntable.getColumnModel().getColumn(k).getModelIndex();
     Object localObject5 = ntable.getModel().getValueAt(0, m);
     localObject6 = ntable.getColumnModel().getColumn(k);
     if ((localObject5 == null) || ((localObject5 instanceof Color))) {
       ((TableColumn) localObject6).setPreferredWidth(colWidth);
       ((TableColumn) localObject6).setCellRenderer(new ColorTableCellRenderer(false));
     }
   }
   ntable.setAutoResizeMode(0);
   ntable.getTableHeader().setReorderingAllowed(false);
   ToolTipHeader localToolTipHeader = new ToolTipHeader(ntable.getColumnModel());
   localToolTipHeader.setToolTipStrings((String[]) string2);
   localToolTipHeader.setToolTipText("Default ToolTip TEXT");
   ntable.setTableHeader(localToolTipHeader);
   return ntable;
 }