Examples of LabeledTableModel


Examples of gov.nasa.arc.mct.table.model.LabeledTableModel

    AbbreviatingTableLabelingAlgorithm algorithm = new AbbreviatingTableLabelingAlgorithm();
    algorithm.setOrientation(TableOrientation.COLUMN_MAJOR);
    algorithm.setContextLabels("Ku_VBSP");

    LabeledTableModel model = new LabeledTableModel(algorithm, TableOrientation.COLUMN_MAJOR) {

      @Override
      public int getObjectCount() {
        return data.length;
      }

      @Override
      public int getAttributeCount() {
        return data[0].length;
      }

      @Override
      public Object getObjectAt(int rowIndex, int columnIndex) {
        return data[rowIndex][columnIndex];
      }

      @Override
      public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
      }

      @Override
      public String getObjectIdentifierAt(int rowIndex, int columnIndex) {
        // TODO Auto-generated method stub
        return identifiers[rowIndex][columnIndex];
      }

      @Override
      protected boolean canSetObjectAt(int rowIndex, int columnIndex,
          boolean isInsertRow, boolean isInsertColumn) {
        // TODO Auto-generated method stub
        return false;
      }

      @Override
      protected void setObjectAt(Object value, int rowIndex,
          int columnIndex, boolean isInsertRow, boolean isInsertColumn) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public Object getStoredObjectAt(int objectIndex, int attributeIndex) {
        return data[objectIndex][attributeIndex];
      }

      @Override
      public boolean isSkeleton() {
        // TODO Auto-generated method stub
        return false;
      }

    };
    model.updateLabels();

    //Create and set up the window.
    JFrame frame = new JFrame("SimpleTableDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
View Full Code Here

Examples of gov.nasa.arc.mct.table.model.LabeledTableModel

        if (flavors.length < 1 || flavors[0].getRepresentationClass() != View.class) {
          return false;
        }

        // Ask the model whether a value can be dropped at the location.
        LabeledTableModel model = LabeledTableModel.class.cast(table.getTable().getModel());
        return model.canSetValueAt(row, column, isInsertRow, isInsertColumn);
  }
View Full Code Here

Examples of gov.nasa.arc.mct.table.model.LabeledTableModel

   * of the columns will get a default width.
   *
   * @param columnWidths an array of new column widths, or null to preserve existing widths
   */
  public void updateColumnsFromModel(int[] columnWidths) {
    LabeledTableModel model = LabeledTableModel.class.cast(table.getModel());
    TableColumnModel columnModel = table.getColumnModel();

    if (columnWidths == null) {
      columnWidths = new int[columnModel.getColumnCount()];
      for (int i=0; i < columnWidths.length; ++i) {
        columnWidths[i] = columnModel.getColumn(i).getPreferredWidth();
      }
    }
    if (columnModel.getColumnCount() == model.getColumnCount()) {
      for (int i=0; i < model.getColumnCount(); ++i) {
        if (!columnModel.getColumn(i).getHeaderValue().toString().equals(model.getColumnName(i))) {
          columnModel.getColumn(i).setHeaderValue(model.getColumnName(i));
        }
        if (i > (columnWidths.length - 1)) {
          columnModel.getColumn(i).setPreferredWidth(DEFAULT_COLUMN_WIDTH);
        } else {
          if (columnModel.getColumn(i).getPreferredWidth() != columnWidths[i]) {
            columnModel.getColumn(i).setPreferredWidth(columnWidths[i]);
          }
        }
      }
      return;
    }
   
    while (columnModel.getColumnCount() > 0) {
      columnModel.removeColumn(columnModel.getColumn(0));
    }
   
    for (int i=0; i < model.getColumnCount(); ++i) {
      TableColumn column = new TableColumn(i, (columnWidths.length > i ? columnWidths[i] : DEFAULT_COLUMN_WIDTH));
      column.setHeaderValue(model.getColumnName(i));
      columnModel.addColumn(column);
    }
  }
View Full Code Here

Examples of gov.nasa.arc.mct.table.model.LabeledTableModel

 
  /**
   * Update the header values of all columns.
   */
  public void updateColumnsHeaderValuesOnly() {
    LabeledTableModel model = LabeledTableModel.class.cast(table.getModel());
    TableColumnModel columnModel = table.getColumnModel();
    // Note: cannot iterate over model.getColumnCount() because it is sometimes zero
    Enumeration<TableColumn>  allCols = columnModel.getColumns();
    int i = 0;
    while (allCols.hasMoreElements()) {
      TableColumn tc = allCols.nextElement();
      tc.setHeaderValue(model.getColumnName(i++));
    }
  }
View Full Code Here

Examples of gov.nasa.arc.mct.table.model.LabeledTableModel

   * In a one dimensional table we only allow insertion in one direction, depending
   * on the table orientation, while  in a two dimensional table we allow
   * insertions in both directions.
   */
  public void updateDropMode() {
    LabeledTableModel model = LabeledTableModel.class.cast(table.getModel());
    if (model.getTableType() == TableType.TWO_DIMENSIONAL) {
      table.setDropMode(DropMode.ON_OR_INSERT);
    } else if (model.getOrientation() == TableOrientation.ROW_MAJOR) {
      table.setDropMode(DropMode.ON_OR_INSERT_ROWS);
    } else {
      table.setDropMode(DropMode.ON_OR_INSERT_COLS);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.