コード例 #1
0
 /** Refresh the GUI. */
 public void refreshGUI() {
   for (int i = 0; i < statsData.length; i++) {
     String label = ToolsRes.getString("Table.Entry.Count"); // $NON-NLS-1$
     switch (i) {
       case 0:
         label = ToolsRes.getString("Table.Entry.Max");
         break; //$NON-NLS-1$
       case 1:
         label = ToolsRes.getString("Table.Entry.Min");
         break; //$NON-NLS-1$
       case 2:
         label = ToolsRes.getString("Table.Entry.Mean");
         break; //$NON-NLS-1$
       case 3:
         label = ToolsRes.getString("Table.Entry.StandardDev");
         break; //$NON-NLS-1$
       case 4:
         label = ToolsRes.getString("Table.Entry.StandardError"); // $NON-NLS-1$
     }
     statsData[i][0] = label;
   }
   tableChanged(null);
   refreshTable();
 }
コード例 #2
0
  /** Initializes the table. */
  protected void init() {
    dataTable
        .getColumnModel()
        .addColumnModelListener(
            new TableColumnModelListener() {
              public void columnAdded(TableColumnModelEvent e) {
                /** empty block */
              }

              public void columnRemoved(TableColumnModelEvent e) {
                /** empty block */
              }

              public void columnSelectionChanged(ListSelectionEvent e) {
                /** empty block */
              }

              public void columnMarginChanged(ChangeEvent e) {
                refreshTable();
              }

              public void columnMoved(TableColumnModelEvent e) {
                refreshTable();
              }
            });
    // assemble statistics data array
    Dataset workingData = dataTable.getWorkingData();
    double[] xstats = getStatistics(workingData.getXPoints());
    double[] ystats = getStatistics(workingData.getValidYPoints());
    if (statsData == null) {
      statsData = new Object[xstats.length][0];
    }
    for (int i = 0; i < xstats.length; i++) {
      String label = ToolsRes.getString("Table.Entry.Count"); // $NON-NLS-1$
      if (i == 5) {
        statsData[i] =
            new Object[] {label, new Integer((int) xstats[i]), new Integer((int) ystats[i])};
      } else {
        switch (i) {
          case 0:
            label = ToolsRes.getString("Table.Entry.Max");
            break; //$NON-NLS-1$
          case 1:
            label = ToolsRes.getString("Table.Entry.Min");
            break; //$NON-NLS-1$
          case 2:
            label = ToolsRes.getString("Table.Entry.Mean");
            break; //$NON-NLS-1$
          case 3:
            label = ToolsRes.getString("Table.Entry.StandardDev");
            break; //$NON-NLS-1$
          case 4:
            label = ToolsRes.getString("Table.Entry.StandardError"); // $NON-NLS-1$
        }
        statsData[i] = new Object[] {label, new Double(xstats[i]), new Double(ystats[i])};
      }
    }
    // set and configure table model and header
    setModel(tableModel);
    setGridColor(Color.blue);
    setEnabled(false);
    setTableHeader(null); // no table header
    labelRenderer = new LabelRenderer();
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    setDefaultRenderer(Double.class, new ScientificRenderer(3));
    ListSelectionModel selectionModel = dataTable.getSelectionModel();
    selectionModel.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            Dataset workingData = dataTable.getWorkingData();
            double[] xstats = getStatistics(workingData.getXPoints());
            double[] ystats = getStatistics(workingData.getValidYPoints());
            int i = 0;
            for (; i < xstats.length - 1; i++) {
              statsData[i][1] = new Double(xstats[i]);
              statsData[i][2] = new Double(ystats[i]);
            }
            statsData[i][1] = new Integer((int) xstats[i]);
            statsData[i][2] = new Integer((int) ystats[i]);
            refreshTable();
          }
        });
    refreshCellWidths();
  }