protected Table setupDataTable() { Table res_tab = this.getData(); if (res_tab == null) { return res_tab; } res_tab.addColumn("seqno","ROW()"); res_tab = addTimeOffsetCol(res_tab, "start_time", "start_time_millis", START_FIELD_NAME, 0); ColumnMetadata dstcol = res_tab.getMetadata(START_FIELD_NAME); long mintime = ((Timestamp)res_tab.get(dstcol.getMinimumRow(), "start_time")).getTime(); res_tab = addTimeOffsetCol(res_tab, "finish_time", "finish_time_millis", END_FIELD_NAME, mintime); res_tab.addColumn(PolygonRenderer.POLYGON,float[].class); log.debug("After adding seqno: #cols: " + res_tab.getColumnCount() + "; #rows: " + res_tab.getRowCount()); return res_tab; }
/** * Instantiate this schema as a new Table instance. * @param nrows the number of starting rows in the table * @return a new Table with this schema */ public Table instantiate(int nrows) { Table t = new Table(nrows, m_size); for ( int i=0; i<m_size; ++i ) { t.addColumn(m_names[i], m_types[i], m_dflts[i]); } return t; }
public void populateTable_OneLinePerState(Table orig_tab) { IntIterator rownumiter; int newrownum, origrownum; rownumiter = orig_tab.rows(); // iterate over everything while (rownumiter.hasNext()) { origrownum = ((Integer)rownumiter.next()).intValue(); newrownum = this.plot_tab.addRow(); this.plot_tab.set(newrownum, "state_name", orig_tab.getString(origrownum, "state_name")); this.plot_tab.set(newrownum, "ycoord", orig_tab.getInt(origrownum, "seqno")); this.plot_tab.set(newrownum,"hostname",orig_tab.getString(origrownum,"hostname")); this.plot_tab.set(newrownum,"friendly_id",orig_tab.getString(origrownum,"friendly_id")); this.plot_tab.set(newrownum,START_FIELD_NAME, orig_tab.getDouble(origrownum,START_FIELD_NAME)); this.plot_tab.set(newrownum,END_FIELD_NAME, orig_tab.getDouble(origrownum,END_FIELD_NAME)); } }
protected void addHostLabels(HeatmapData hd) { Table legend_labels_table = new Table(); legend_labels_table.addColumn("label",String.class); legend_labels_table.addRows(hd.hostnames.length); for (int i = 0; i < hd.hostnames.length; i++) { legend_labels_table.setString(i,"label",hd.hostnames[i]); } float start_x = LEGEND_X_OFFSET; float start_y = LEGEND_Y_OFFSET + BORDER[1] + (BOXWIDTH/2); float incr = this.BOXWIDTH; VisualTable legend_labels_table_viz = this.viz.addTable(legendgroup, legend_labels_table); for (int i = 0; i < hd.hostnames.length; i++) { legend_labels_table_viz.setFloat(i, VisualItem.X, start_x + LEGEND_TEXT_OFFSET); legend_labels_table_viz.setFloat(i, VisualItem.Y, start_y + (i * incr)); legend_labels_table_viz.setTextColor(i,ColorLib.color(java.awt.Color.BLACK)); legend_labels_table_viz.setFont(i,new Font(Font.SANS_SERIF,Font.PLAIN,LEGEND_FONT_SIZE)); } }
protected void addAxisNames() { Table textlabels_table = new Table(); textlabels_table.addColumn("label",String.class); textlabels_table.addColumn("type",String.class); textlabels_table.addRow(); textlabels_table.setString(0,"label","Time/s"); textlabels_table.setString(0,"type","xaxisname"); VisualTable textlabelsviz = this.viz.addTable(labelgroup, textlabels_table); textlabelsviz.setX(0,SIZE_X/2d); textlabelsviz.setY(0,SIZE_Y - BORDER[2] + (BORDER[2]*0.1)); textlabelsviz.setTextColor(0,ColorLib.color(java.awt.Color.GRAY)); textlabelsviz.setFont(0,new Font(Font.SANS_SERIF,Font.PLAIN,AXIS_NAME_FONT_SIZE)); }
/** * Constructor from a prefuse schema instance. * @param prefuseSchema A prefuse schema to wrap around Obvious schema. */ public PrefuseObviousSchema(prefuse.data.Schema prefuseSchema) { this.schema = prefuseSchema; prefuse.data.Table prefuseSchemaTable = new prefuse.data.Table(this.schema.getColumnCount(), SCHEMA_COL_NUMBER); prefuseSchemaTable.addColumn("Name", String.class); prefuseSchemaTable.addColumn("Type", Class.class); prefuseSchemaTable.addColumn("Default Value", Object.class); for (int i = 0; i < this.schema.getColumnCount(); i++) { prefuseSchemaTable.set(i, "Name", this.schema.getColumnName(i)); prefuseSchemaTable.set(i, "Type", this.schema.getColumnType(i)); prefuseSchemaTable.set(i, "Default Value", this.schema.getDefault(i)); } this.schemaTable = new PrefuseObviousTable(prefuseSchemaTable); }
Table agg_tab = new Table(); agg_tab.addColumn("stat", long.class); min = Long.MAX_VALUE; max = Long.MIN_VALUE; agg_tab.addRows(num_hosts*num_hosts); agg_tab.setLong((i*num_hosts)+j,"stat",stats[i][j]); if (stats[i][j] > max) max = stats[i][j]; if (stats[i][j] > 0 && stats[i][j] < min) min = stats[i][j];
srcMillisecondFieldName, dstFieldName + "_fulltime"); ColumnMetadata dstcol = newtable.getMetadata(dstFieldName + "_fulltime"); long mintime = newtable.getLong(dstcol.getMinimumRow(), dstFieldName + "_fulltime"); newtable.addColumn(dstFieldName, "ROUND((["+dstFieldName+"_fulltime] - " + mintime +"L) / 1000L)"); } else { newtable.addColumn(dstFieldName, "ROUND((["+dstFieldName+"_fulltime] - " + timeOffset +"L) / 1000L)");
/** * Add a column with the given name and data type to this table. * @param name the data field name for the column * @param type the data type, as a Java Class, for the column * @see prefuse.data.tuple.TupleSet#addColumn(java.lang.String, java.lang.Class) */ public void addColumn(String name, Class type) { addColumn(name, type, null); }
/** * @see javax.swing.table.TableModel#getRowCount() */ public int getRowCount() { return m_table.getRowCount(); } /**
/** * Get the data value at the given field as an Object. * @param field the data field to retrieve * @return the data value as an Object. The concrete type of this * Object is dependent on the underlying data column used. * @see #canGet(String, Class) * @see prefuse.data.Table#getColumnType(String) */ public final Object get(String field) { return m_table.get(m_cur, field); }
/** * Get the Tuple with the maximum data field value. * @param tuples a TupleSet * @param field the column / data field name * @return the Tuple with the maximum data field value */ public static Tuple max(TupleSet tuples, String field, Comparator cmp) { if ( tuples instanceof Table ) { Table table = (Table)tuples; ColumnMetadata md = table.getMetadata(field); return table.getTuple(md.getMaximumRow()); } else { return max(tuples.tuples(), field, cmp); } }
@Override public IntIterator rows() { return m_table.rows(); }
/** * Add an item to the aggregation at the given row. * @param row the row index of the aggregate * @param member the item to add to the aggregation */ public void addToAggregate(int row, VisualItem member) { validRowCheck(row, true); if ( !aggregateContains(row, member) ) { int ar = m_aggregated.addRow(); m_aggregated.setInt(ar, AGGREGATE, row); m_aggregated.setInt(ar, MEMBER_HASH, getHashCode(member)); m_aggregated.set(ar, MEMBER, member); fireTableEvent(row, row, EventConstants.ALL_COLUMNS, EventConstants.UPDATE); } }
/** * Internal method for adding a link to an adjacency list * @param field which adjacency list (inlinks or outlinks) to use * @param len the length of the adjacency list * @param n the node id of the adjacency list to use * @param e the edge to add to the list */ protected void addLink(String field, int len, int n, int e) { int[] array = (int[])m_links.get(n, field); if ( array == null ) { array = new int[] {e}; m_links.set(n, field, array); return; } else if ( len == array.length ) { int[] narray = new int[Math.max(3*array.length/2, len+1)]; System.arraycopy(array, 0, narray, 0, array.length); array = narray; m_links.set(n, field, array); } array[len] = e; }
/** * Set the value of a given data field. * @param field the data field to set * @param val the value for the field. If the concrete type of this * Object is not compatible with the underlying data model, an * Exception will be thrown. Use the {@link #canSet(String, Class)} * method to check the type-safety ahead of time. * @see #canSet(String, Class) * @see prefuse.data.Table#getColumnType(String) */ public final void set(String field, Object val) { ++m_modCount; m_table.set(m_cur, field, val); }
/** * Initialize mapping between prefuse table rows and the rows reported * by this model. */ private void initRowMap() { m_rowMap = new int[m_table.getRowCount()]; IntIterator rows = m_table.rows(); for ( int i=0; rows.hasNext(); ++i ) { m_rowMap[i] = rows.nextInt(); } }
/** * Add an edge to the graph. Both multiple edges between two nodes * and edges from a node to itself are allowed. * @param s the source node id * @param t the target node id * @return the edge id (edge table row number) of the added edge */ public int addEdge(int s, int t) { // get keys for the nodes long key1 = getKey(s); long key2 = getKey(t); // add edge row, set source/target fields Table edges = getEdgeTable(); int r = edges.addRow(); if ( m_longKey ) { edges.setLong(r, m_skey, key1); edges.setLong(r, m_tkey, key2); } else { edges.setInt(r, m_skey, (int)key1); edges.setInt(r, m_tkey, (int)key2); } return r; }