本文整理汇总了Java中prefuse.data.Tuple类的典型用法代码示例。如果您正苦于以下问题:Java Tuple类的具体用法?Java Tuple怎么用?Java Tuple使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tuple类属于prefuse.data包,在下文中一共展示了Tuple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBoolean
import prefuse.data.Tuple; //导入依赖的package包/类
@Override
public boolean getBoolean(Tuple t) {
// TODO Auto-generated method stub
boolean ingroup = super.getBoolean(t);
if (!ingroup) {
return(ingroup);
}
if ( !(t instanceof VisualItem) ) {
return false;
}
VisualItem item = (VisualItem)t;
if (!item.canGet("edgeType", String.class)) {
return(false);
}
String eType = item.getString("edgeType");
if (!edgeType.equals(eType)) {
return(false);
}
return(true);
}
示例2: inferType
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* Infer the data field type across all tuples in a TupleSet.
* @param tuples the TupleSet to analyze
* @param field the data field to type check
* @return the inferred data type
* @throws IllegalArgumentException if incompatible types are used
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Class inferType(TupleSet tuples, String field) {
if ( tuples instanceof Table ) {
return ((Table)tuples).getColumnType(field);
} else {
Class type = null, type2 = null;
Iterator iter = tuples.tuples();
while ( iter.hasNext() ) {
Tuple t = (Tuple)iter.next();
if ( type == null ) {
type = t.getColumnType(field);
} else if ( !type.equals(type2=t.getColumnType(field)) ) {
if ( type2.isAssignableFrom(type) ) {
type = type2;
} else if ( !type.isAssignableFrom(type2) ) {
throw new IllegalArgumentException(
"The data field ["+field+"] does not have " +
"a consistent type across provided Tuples");
}
}
}
return type;
}
}
示例3: getComparator
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* Generates a Comparator to be used for sorting tuples drawn from
* the given tuple set.
* @param ts the TupleSet whose Tuples are to be sorted
* @return a Comparator instance for sorting tuples from the given
* set using the sorting criteria given in this specification
*/
public Comparator<Tuple> getComparator(TupleSet ts) {
// get the schema, so we can lookup column value types
Schema s = null;
if ( ts instanceof Table ) {
// for Tables, we can get this directly
s = ((Table)ts).getSchema();
} else {
// if non-table tuple set is empty, we punt
if ( ts.getTupleCount() == 0 )
return new NullComparator<Tuple>();
// otherwise, use the schema of the first tuple in the set
s = ((Tuple)ts.tuples().next()).getSchema();
}
// create the comparator
CompositeComparator<Tuple> cc = new CompositeComparator<Tuple>(m_fields.length);
for ( int i=0; i<m_fields.length; ++i ) {
cc.add(new TupleComparator(m_fields[i], s.getColumnType(m_fields[i]), m_ascend[i]));
}
return cc;
}
示例4: getInt
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* @see prefuse.data.expression.Expression#getInt(prefuse.data.Tuple)
*/
public int getInt(Tuple t) {
int x = m_left.getInt(t);
int y = m_right.getInt(t);
// compute return value
switch ( m_op ) {
case ADD:
return x+y;
case SUB:
return x-y;
case MUL:
return x*y;
case DIV:
return x/y;
case POW:
return (int)Math.pow(x,y);
case MOD:
return x%y;
}
throw new IllegalStateException("Unknown operation type.");
}
示例5: getLong
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* @see prefuse.data.expression.Expression#getLong(prefuse.data.Tuple)
*/
public long getLong(Tuple t) {
long x = m_left.getLong(t);
long y = m_right.getLong(t);
// compute return value
switch ( m_op ) {
case ADD:
return x+y;
case SUB:
return x-y;
case MUL:
return x*y;
case DIV:
return x/y;
case POW:
return (long)Math.pow(x,y);
case MOD:
return x%y;
}
throw new IllegalStateException("Unknown operation type.");
}
示例6: search
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* Searches the indexed Tuple fields for matching string prefixes,
* adding the Tuple instances for each search match to this TupleSet.
* The query string is first broken up into separate terms, as determined
* by the current delimiter string. A search for each term is conducted,
* and all matching Tuples are included in the results.
* @param query the query string to search for.
* @see #setDelimiterString(String)
*/
public void search(String query) {
if ( query == null )
query = "";
if ( query.equals(m_query) )
return;
Tuple[] rem = clearInternal();
m_query = query;
StringTokenizer st = new StringTokenizer(m_query, m_delim);
if ( !st.hasMoreTokens() )
m_query = "";
while ( st.hasMoreTokens() )
prefixSearch(st.nextToken());
Tuple[] add = getTupleCount() > 0 ? toArray() : null;
fireTupleEvent(add, rem);
}
示例7: get
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* @see prefuse.data.expression.Expression#get(prefuse.data.Tuple)
*/
public Object get(Tuple t) {
Class type = getType(t.getSchema());
if ( int.class == type || byte.class == type ) {
return Integer.valueOf(getInt(t));
} else if ( long.class == type ) {
return Long.valueOf(getInt(t));
} else if ( float.class == type ) {
return Float.valueOf(getFloat(t));
} else if ( double.class == type ) {
return Double.valueOf(getDouble(t));
} else {
throw new IllegalStateException();
}
}
示例8: get
import prefuse.data.Tuple; //导入依赖的package包/类
public Object get(Tuple t) {
String str = param(0).get(t).toString();
int len = param(1).getInt(t);
String pad = param(2).get(t).toString();
int strlen = str.length();
if ( strlen > len ) {
return str.substring(0,len);
} else if ( strlen == len ) {
return str;
} else {
StringBuffer sbuf = getBuffer();
sbuf.append(str);
int padlen = pad.length();
int diff = len-strlen;
for ( int i=0; i<diff; i+=padlen)
sbuf.append(pad);
if ( sbuf.length() > len )
sbuf.delete(len, sbuf.length());
return sbuf.toString();
}
}
示例9: getFloat
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* @see prefuse.data.expression.Expression#getFloat(prefuse.data.Tuple)
*/
public float getFloat(Tuple t) {
float x = m_left.getFloat(t);
float y = m_right.getFloat(t);
// compute return value
switch ( m_op ) {
case ADD:
return x+y;
case SUB:
return x-y;
case MUL:
return x*y;
case DIV:
return x/y;
case POW:
return (float)Math.pow(x,y);
case MOD:
return (float)Math.IEEEremainder(x,y);
}
throw new IllegalStateException("Unknown operation type.");
}
示例10: getDouble
import prefuse.data.Tuple; //导入依赖的package包/类
public double getDouble(Tuple t) {
if ( paramCount() == 1 ) {
return Math.ceil(param(0).getDouble(t));
} else {
missingParams(); return Double.NaN;
}
}
示例11: min
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* Get the Tuple with the minimum data field value.
* @param tuples a TupleSet
* @param field the column / data field name
* @return the Tuple with the minimum data field value
*/
public static Tuple min(TupleSet tuples, String field, Comparator<Object> cmp) {
if ( tuples instanceof Table ) {
Table table = (Table)tuples;
ColumnMetadata md = table.getMetadata(field);
return table.getTuple(md.getMinimumRow());
} else {
return min(tuples.tuples(), field, cmp);
}
}
示例12: getBoolean
import prefuse.data.Tuple; //导入依赖的package包/类
@Override
public boolean getBoolean(Tuple t) {
// TODO Auto-generated method stub
boolean ingroup = super.getBoolean(t);
if (!ingroup) {
return(ingroup);
}
if ( !(t instanceof VisualItem) ) {
return false;
}
VisualItem item = (VisualItem)t;
/*
if (!item.canGet(field, String.class)) {
return(false);
}
*/
Object fieldValue = item.get(field);
if (fieldValue == null) {
return(false);
}
if (!fieldValue.equals(value)) {
return(false);
}
return(true);
}
示例13: initHierarchyTree
import prefuse.data.Tuple; //导入依赖的package包/类
private void initHierarchyTree(Tuple root, Graph g)
{
cluster_hierarchy = new Tree();
cluster_hierarchy.addColumn("tuple_ref", Tuple.class);
root_node = cluster_hierarchy.addRoot();
root_node.set("tuple_ref",root_cluster);
TupleSet graph_nodes = g.getNodes();
Iterator graph_tuples_iter = graph_nodes.tuples();
while(graph_tuples_iter.hasNext())
{
Tuple t = (Tuple)graph_tuples_iter.next();
Node child = cluster_hierarchy.addChild(root_node);
child.set("tuple_ref", t);
}
}
示例14: getFloat
import prefuse.data.Tuple; //导入依赖的package包/类
public float getFloat(Tuple arg0) {
// TODO Auto-generated method stub
if(arg0 instanceof Node)
return (float)arg0.getInt(column)/(float)max_node_value;
else
return (float)arg0.getInt(column)/(float)max_edge_value;
}
示例15: getSourceTuple
import prefuse.data.Tuple; //导入依赖的package包/类
/**
* Get the Tuple from a backing source data set that corresponds most
* closely to the given VisualItem.
* @param item the VisualItem for which to retreive the source tuple
* @return the data source tuple, or null if no such tuple could
* be found
*/
public Tuple getSourceTuple(VisualItem item) {
// get the source group and tuple set, exit if none
String group = item.getGroup();
TupleSet source = getSourceData(group);
if ( source == null ) return null;
// first get the source table and row value
int row = item.getRow();
Table t = item.getTable();
while ( t instanceof VisualTable ) {
VisualTable vt = (VisualTable)t;
row = vt.getParentRow(row);
t = vt.getParentTable();
}
// now get the appropriate source tuple
// graphs maintain their own tuple managers so treat them specially
String cgroup = PrefuseLib.getChildGroup(group);
if ( cgroup != null ) {
String pgroup = PrefuseLib.getParentGroup(group);
Graph g = (Graph)getSourceData(pgroup);
if ( t == g.getNodeTable() ) {
return g.getNode(row);
} else {
return g.getEdge(row);
}
} else {
return t.getTuple(row);
}
}