Пример #1
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      try {
        // managing colors
        if (isSelected) {
          this.setBackground(table.getSelectionBackground());
          this.setForeground(table.getSelectionForeground());
        } else {
          this.setBackground(table.getSelectionForeground());
          this.setForeground(Color.BLACK);
        }

        OWLDescription desc = (OWLDescription) value;
        desc.accept(myVisitor);
        String str = myVisitor.result();
        myVisitor.reset();

        this.setText(str);
        // System.out.println( this.getText() );
      } catch (Exception e) {
        e.printStackTrace();
      }

      return this;
    }
Пример #2
0
  public ClassExpTable(
      AxiomIndexer indexer,
      ConcisePlainVisitor visitor,
      HashedCounts classExpCounts,
      Hashtable classExpDepths) {
    this.myIndexer = indexer;
    String[] colNames = {"Class Expression", "#Occurences", "Depth", "Score"};

    Object[][] data = new Object[classExpCounts.keySet().size()][4];

    int i = 0;
    for (Iterator it = classExpCounts.keySet().iterator(); it.hasNext(); ) {
      OWLDescription desc = (OWLDescription) it.next();
      if (desc == null) System.out.println("description is null at " + i);
      Integer count = new Integer(classExpCounts.getCount(desc));
      Integer depth = (Integer) classExpDepths.get(desc);
      try {
        if (depth == null) {
          System.out.println(" depth is null at " + i);
          desc.accept(visitor);
          String str = visitor.result();
          System.out.println("        [" + str + "]");
          visitor.reset();
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      data[i][0] = desc;
      data[i][1] = count;
      data[i][2] = depth;
      data[i][3] = new Double(Math.pow(count.intValue(), (depth.intValue() + 1)));
      i++;
    }
    myDataModel = new ClassExpTableModel(colNames, data);
    myManipModel = new TableSorter(myDataModel);
    myTable = new JTable(myManipModel);
    myManipModel.setTableHeader(myTable.getTableHeader());

    /*
    for ( int vColIndex = 0; vColIndex < 3; vColIndex++ )
    {
    	TableColumn col = myTable.getColumnModel().getColumn(vColIndex);
    	col.setHeaderRenderer(new RichHeaderRenderer());
    }
    */

    myTable.setDefaultRenderer(OWLObjectImpl.class, new ClassExpRenderer(visitor));

    setupUI();

    this.addWindowListener(this);
    this.addComponentListener(this);
    myTable.addMouseListener(this);
    this.setSize(300, 600);
    this.setVisible(true);
  }