Package gov.nasa.arc.mct.table.view

Examples of gov.nasa.arc.mct.table.view.BorderState


          label.setBackground(table.getTableHeader().getBackground());
          label.setForeground(table.getTableHeader().getForeground());
        }
        label.setForeground(getColumnHeaderFontColor(column));
        label.setBackground(LabeledTable.this.getColumnHeaderBackgroundColor(column));
        BorderState b = getColumnHeaderBorderState(column);
        if (b != null) {
          boolean hasNorth = b.hasNorthBorder();
          boolean hasWest = b.hasWestBorder();
          boolean hasSouth = b.hasSouthBorder();
          boolean hasEast = b.hasEastBorder();
          int w = TableCellFormatter.getBorderWidth();
 
          Border outside = BorderFactory.createMatteBorder(hasNorth ? w : 0, hasWest ? w : 0, hasSouth ? w : 0, hasEast ? w : 0,
              getColumnHeaderBorderColor(column));
          Border inside = BorderFactory.createEmptyBorder(hasNorth ? 0 : w, hasWest ? 0 : w, hasSouth ? 0 : w, hasEast ? 0 : w);
          label.setBorder(BorderFactory.createCompoundBorder(outside,inside));
        }
        return label;
      }
    };
    table.getTableHeader().setDefaultRenderer(headerRenderer);
   
    rowHeaders = new JList(model.getRowLabelModel());
    rowHeaders.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   
    rowHeaders.setCellRenderer(new ListCellRenderer() {

      @Override
      public Component getListCellRendererComponent(JList list,
          Object value, int index, boolean isSelected,
          boolean hasFocus) {
        JLabel label = (JLabel) defaultHeaderRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, 0, index);
        ContentAlignment alignment = LabeledTable.this.getRowHeaderAlignment(index);
        label.setHorizontalAlignment(alignment.getComponentAlignment());
        Border padding = BorderFactory.createEmptyBorder(0, 5, 0, 5);
        if (headerBorder != null) label.setBorder(headerBorder);
        label.setBorder(BorderFactory.createCompoundBorder(label.getBorder(), padding));
        Font headerFont = new Font(LabeledTable.this.getRowHeaderFontName(index).name(),
            getRowHeaderFontStyle(index).intValue(),
            getRowHeaderFontSize(index).intValue());
        if (LabeledTable.this.getRowHeaderTextAttribute(index).equals(TextAttribute.UNDERLINE_ON)) {
          headerFont = headerFont.deriveFont(TableFormattingConstants.underlineMap);
        }
        label.setFont(headerFont);
       
       
        // Set the row header height to match the table row.
        int rowHeight = table.getRowHeight(index);
        Dimension d = label.getMinimumSize();
        d.setSize(d.getWidth() + 2*ROW_HEADER_MARGIN, rowHeight);
        label.setPreferredSize(d);
       
        int r = index - table.getSelectedRow();
       
        if (r >= 0 && r < table.getSelectedRowCount() &&
          table.getSelectedColumnCount() == table.getColumnCount()) {
          label.setBackground(table.getSelectionBackground());
          label.setForeground(table.getSelectionForeground());
        } else {
          label.setBackground(LabeledTable.this.getRowHeaderBackgroundColor(index));
          label.setForeground(table.getTableHeader().getForeground());
        }
        label.setForeground(getRowHeaderFontColor(index));
        label.setBackground(LabeledTable.this.getRowHeaderBackgroundColor(index));
       
        BorderState b = getRowHeaderBorderState(index);
        if (b != null) {
          boolean hasNorth = b.hasNorthBorder();
          boolean hasWest = b.hasWestBorder();
          boolean hasSouth = b.hasSouthBorder();
          boolean hasEast = b.hasEastBorder();
          int w = TableCellFormatter.getBorderWidth();
 
          Border outside = BorderFactory.createMatteBorder(hasNorth ? w : 0, hasWest ? w : 0, hasSouth ? w : 0, hasEast ? w : 0,
              getRowHeaderBorderColor(index));
          Border inside = BorderFactory.createEmptyBorder(hasNorth ? 0 : w, hasWest ? 0 : w, hasSouth ? 0 : w, hasEast ? 0 : w);
View Full Code Here


   * @param newBorderState the new Border State for the for header
   */
  public void setRowHeaderBorderState(int rowIndex, BorderState newBorderState) {
    if (rowIndex < table.getRowCount()) {
      while (rowHeaderBorderStates.size() < rowIndex-1) {
        rowHeaderBorderStates.add(new BorderState(BorderEdge.NONE.value()));
      }
      rowHeaderBorderStates.set(rowIndex, newBorderState);
    }
  }
View Full Code Here

   *
   * @param rowIndex the index of the row header
   * @return the border states of the row header
   */
  public BorderState getRowHeaderBorderState(int rowIndex) {
    BorderState borderState = rowHeaderBorderStates.get(rowIndex);
    return (borderState !=null ? borderState : new BorderState(BorderEdge.NONE.value()));
  }
View Full Code Here

   * @param newBorderState the new Border State for the col header
   */
  public void setColumnHeaderBorderState(int colIndex, BorderState newBorderState) {
    if (colIndex < table.getColumnCount()) {
      while (columnHeaderBorderStates.size() < colIndex-1) {
        columnHeaderBorderStates.add(new BorderState(BorderEdge.NONE.value()));
      }
      columnHeaderBorderStates.set(colIndex, newBorderState);
    }
  }
View Full Code Here

   *
   * @param colIndex the index of the col header
   * @return the border states of the col header
   */
  public BorderState getColumnHeaderBorderState(int colIndex) {
    BorderState borderState = columnHeaderBorderStates.get(colIndex);
    return (borderState !=null ? borderState : new BorderState(BorderEdge.NONE.value()));
  }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.table.view.BorderState

Copyright © 2018 www.massapicom. 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.