public void showTotalStatistics(
      List<CutPlanSenquence> plan, List<ProductCutTargetDTO> cutDataInfo) {
    this.removeAll();
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel row = new JPanel(new FlowLayout(FlowLayout.LEADING));
    row.add(GUIFactory.createLabel("Numar busteni", 150));
    row.add(createValueLabel(plan.size()));
    this.add(row);

    double volumeLumber = 0, volumeProduct = 0;
    for (CutPlanSenquence cutSequence : plan) {
      volumeLumber +=
          MetricTools.toMeterCubs(cutSequence.getLumberLog().getVolume(), METRIC.MILIMETER);
      volumeProduct +=
          MetricTools.toMeterCubs(cutSequence.getCutDiagram().cutInfo.cutVolume, METRIC.MILIMETER);
    }

    row = new JPanel(new FlowLayout(FlowLayout.LEADING));
    row.add(GUIFactory.createLabel("Volum lemn", 150));
    row.add(createValueLabel(formatter.format(volumeLumber) + " m .cub"));
    this.add(row);

    row = new JPanel(new FlowLayout(FlowLayout.LEADING));
    row.add(GUIFactory.createLabel("Volum produs", 150));
    row.add(createValueLabel(formatter.format(volumeProduct) + " m .cub"));
    this.add(row);

    row = new JPanel(new FlowLayout(FlowLayout.LEADING));
    row.add(GUIFactory.createLabel("Eficenta total", 150));
    row.add(createValueLabel(formatter.format(100 * volumeProduct / volumeLumber) + " %"));
    this.add(row);

    for (ProductCutTargetDTO productInfo : cutDataInfo) {
      row = new JPanel(new FlowLayout(FlowLayout.LEADING));
      row.add(GUIFactory.createLabel("Volum " + productInfo.getProduct(), 150));
      row.add(
          createValueLabel(
              MetricFormatter.formatVolume(
                  productInfo.getCutPieces()
                      * MetricTools.toMeterCubs(productInfo.getProductVolume()))));
      this.add(row);
    }
  }
Beispiel #2
0
  /** 公開スタンプブラウズペインを生成する。 */
  private JPanel createBrowsePane() {

    JPanel browsePane = new JPanel();

    tableModel = new ListTableModel<PublishedTreeModel>(COLUMN_NAMES, 10, METHOD_NAMES, CLASSES);
    browseTable = new JTable(tableModel);
    for (int i = 0; i < COLUMN_WIDTH.length; i++) {
      browseTable.getColumnModel().getColumn(i).setPreferredWidth(COLUMN_WIDTH[i]);
    }
    browseTable.setDefaultRenderer(Object.class, new OddEvenRowRenderer());

    importBtn = new JButton("インポート");
    importBtn.setEnabled(false);
    cancelBtn = new JButton("閉じる");
    deleteBtn = new JButton("削除");
    deleteBtn.setEnabled(false);
    publicLabel = new JLabel("グローバル", WEB_ICON, SwingConstants.CENTER);
    localLabel = new JLabel("院内", HOME_ICON, SwingConstants.CENTER);
    importedLabel = new JLabel("インポート済", FLAG_ICON, SwingConstants.CENTER);

    JScrollPane tableScroller = new JScrollPane(browseTable);
    tableScroller.getViewport().setPreferredSize(new Dimension(730, 380));

    // レイアウトする
    browsePane.setLayout(new BorderLayout(0, 17));
    JPanel flagPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 7, 5));
    flagPanel.add(localLabel);
    flagPanel.add(publicLabel);
    flagPanel.add(importedLabel);
    JPanel cmdPanel =
        GUIFactory.createCommandButtonPanel(new JButton[] {cancelBtn, deleteBtn, importBtn});
    browsePane.add(flagPanel, BorderLayout.NORTH);
    browsePane.add(tableScroller, BorderLayout.CENTER);
    browsePane.add(cmdPanel, BorderLayout.SOUTH);

    // レンダラを設定する
    PublishTypeRenderer pubTypeRenderer = new PublishTypeRenderer();
    browseTable.getColumnModel().getColumn(4).setCellRenderer(pubTypeRenderer);
    ImportedRenderer importedRenderer = new ImportedRenderer();
    browseTable.getColumnModel().getColumn(5).setCellRenderer(importedRenderer);

    // BrowseTableをシングルセレクションにする
    browseTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel sleModel = browseTable.getSelectionModel();
    sleModel.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
              int row = browseTable.getSelectedRow();
              PublishedTreeModel model = tableModel.getObject(row);
              if (model != null) {
                if (model.isImported()) {
                  importBtn.setEnabled(false);
                  deleteBtn.setEnabled(true);
                } else {
                  importBtn.setEnabled(true);
                  deleteBtn.setEnabled(false);
                }
              } else {
                importBtn.setEnabled(false);
                deleteBtn.setEnabled(false);
              }
            }
          }
        });

    // import
    importBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            importPublishedTree();
          }
        });

    // remove
    deleteBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removeImportedTree();
          }
        });

    // キャンセル
    cancelBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            stop();
          }
        });

    return browsePane;
  }