/** * Constructor. * @param inst a Weka Instances instance */ @SuppressWarnings("unchecked") public WekaObviousTable(Instances inst) { this.instances = inst; this.schema = new SchemaImpl(); Enumeration attributes = instances.enumerateAttributes(); while (attributes.hasMoreElements()) { Attribute att = (Attribute) attributes.nextElement(); Class<?> c = checkClass(att); schema.addColumn(att.name(), c, null); } }
/** * Constructor * @param instance wrapped weka Instance */ @SuppressWarnings("unchecked") public WekaObviousTuple(Instance instance) { this.instance = instance; this.schema = new SchemaImpl(); Enumeration attributes = instance.enumerateAttributes(); while (attributes.hasMoreElements()) { Attribute att = (Attribute) attributes.nextElement(); Class<?> c = checkClass(att); schema.addColumn(att.name(), c, null); } }
c = int.class; currentSchema.addColumn(columnName, format.getFormattedClass(), value); idToName.put(id, columnName); } catch (Exception e) {
@Override public void addColumn(Column c) { table.getSchema().addColumn(c.getName(), c.getValueClass(), null); }
/** * Constructor. * @param inNodeSchema original schema for nodes * @param inEdgeSchema original schema for edges */ public IvtkObviousTree(Schema inNodeSchema, Schema inEdgeSchema) { this.nodeSchema = inNodeSchema; this.edgeSchema = inEdgeSchema; if (!edgeSchema.hasColumn("parent")) { edgeSchema.addColumn("parent", Integer.class, 0); } if (!edgeSchema.hasColumn("child")) { edgeSchema.addColumn("child", Integer.class, 0); } edgeTable = new IvtkObviousTable(edgeSchema); tree = new DefaultTree(); ColumnFactory factory = ColumnFactory.getInstance(); for (int i = 0; i < nodeSchema.getColumnCount(); i++) { Column col = factory.create(nodeSchema.getColumnType(i).getSimpleName(), nodeSchema.getColumnName(i)); tree.addColumn(col); } if (this.forest == null) { this.forest = new ArrayList<Tree<Node, Edge>>(); } if (!this.forest.contains(this)) { this.forest.add(this); } }
@SuppressWarnings("unchecked") @Override public void addColumn(String arg0, Class arg1, Object arg2) { if (!m_names.contains(arg0)) { if (!table.getSchema().hasColumn(arg0)) { table.getSchema().addColumn(arg0, arg1, arg2); } Column col = ColumnFactory.getColumn(arg1, getRowCount(), arg2); int colIndex = table.getSchema().getColumnIndex(arg0); this.m_lastCol = colIndex; this.m_columns.add(col); this.m_names.add(arg0); ColumnEntry entry = new ColumnEntry(colIndex, col, new ColumnMetadata(this, arg0)); ColumnEntry oldEntry = (ColumnEntry) this.m_entries.put(arg0, entry); if (oldEntry != null) { oldEntry.dispose(); } invalidateSchema(); // listen to what the column has to say col.addColumnListener(this); fireTableEvent(0, getRowCount(), m_lastCol, TableModelEvent.INSERT); } }