本文整理汇总了Java中prefuse.data.tuple.TupleSet.tuples方法的典型用法代码示例。如果您正苦于以下问题:Java TupleSet.tuples方法的具体用法?Java TupleSet.tuples怎么用?Java TupleSet.tuples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.data.tuple.TupleSet
的用法示例。
在下文中一共展示了TupleSet.tuples方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
@Override
public void run(double frac) {
// TODO Auto-generated method stub
Rectangle2D b = getLayoutBounds();
double bx = b.getMinX(), by = b.getMinY();
double w = b.getWidth(), h = b.getHeight();
TupleSet ts = m_vis.getGroup(m_group);
Iterator<?> iter = ts.tuples();
// layout grid contents
while ( iter.hasNext() ) {
VisualItem item = (VisualItem)iter.next();
item.setVisible(true);
int i = getIndex(item);
double radius = Math.sqrt((double)i) * 25.0;
double angle = Math.sqrt((double)i) * Math.PI;
double x = bx + w/2 + (radius * Math.sin(angle));
double y = by + h/2 + (radius * Math.cos(angle));
setX(item,null,x);
setY(item,null,y);
}
}
示例2: tuples
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
/**
* Get a filtered iterator over the tuples in the given set,
* filtered by the given predicate.
* @param ts the TupleSet to iterate over
* @param p the filter predicate
* @return a filtered iterator over the tuples
*/
public static Iterator<Tuple> tuples(TupleSet ts, Predicate p) {
// no predicate means no filtering
if ( p == null )
return ts.tuples();
// attempt to generate an optimized query plan
Iterator<Tuple> iter = null;
if ( ts instanceof Table ) {
Table t = (Table)ts;
IntIterator ii = getOptimizedIterator(t,p);
if ( ii != null )
iter = t.tuples(ii);
}
// optimization fails, scan the entire table
if ( iter == null ) {
iter = new FilterIterator(ts.tuples(), p);
}
return iter;
}
示例3: inferType
import prefuse.data.tuple.TupleSet; //导入方法依赖的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;
}
}
示例4: getDataType
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
/**
* Retrieve the data type.
*/
protected int getDataType(TupleSet ts) {
if ( m_type == Constants.UNKNOWN ) {
boolean numbers = true;
if ( ts instanceof Table ) {
numbers = ((Table)ts).canGetDouble(m_field);
} else {
for ( Iterator it = ts.tuples(); it.hasNext(); ) {
if ( !((Tuple)it.next()).canGetDouble(m_field) ) {
numbers = false;
break;
}
}
}
if ( numbers ) {
return Constants.NUMERICAL;
} else {
return Constants.ORDINAL;
}
} else {
return m_type;
}
}
示例5: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
public void run(double frac) {
TupleSet focus = m_vis.getGroup(Visualization.FOCUS_ITEMS);
if (focus == null || focus.getTupleCount() == 0)
return;
Graph g = (Graph) m_vis.getGroup(m_group);
Node f = null;
Iterator tuples = focus.tuples();
while (tuples.hasNext()
&& !g.containsTuple(f = (Node) tuples.next())) {
f = null;
}
if (f == null)
return;
g.getSpanningTree(f);
}
示例6: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
public void run(double frac) {
TupleSet focus = m_vis.getGroup(Visualization.FOCUS_ITEMS);
if ( focus==null || focus.getTupleCount() == 0 ) return;
Graph g = (Graph)m_vis.getGroup(m_group);
Node f = null;
Iterator tuples = focus.tuples();
while (tuples.hasNext() && !g.containsTuple(f=(Node)tuples.next()))
{
f = null;
}
if ( f == null ) return;
g.getSpanningTree(f);
}
示例7: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
@Override
public void run(double frac) {
// TODO Auto-generated method stub
initialize();
TupleSet ts = m_vis.getGroup(m_group);
Iterator<?> iter;
if (m_filter != null)
iter = ts.tuples();
else
iter = ts.tuples(m_filter);
// layout grid contents
while ( iter.hasNext() ) {
VisualItem item = (VisualItem)iter.next();
// layout items only once
if(layedOutObjects.add(item) == false)
continue;
item.setVisible(true);
// TODO: find the ip address somewhere in the linked tuples
InetAddress ip_address = (InetAddress)item.get(Data.ADDRESS);
//System.out.println(ip_address);
//int ip_hash = ip_address.hashCode();
//double distance = (double) ip_hash / (double)Integer.MAX_VALUE * total_length;
double distance = hashIP(ip_address.getHostAddress());
double y = getY(distance);
double x = getX(distance,y);
//System.out.println("Distance, X, Y: "+distance+", "+x+", "+y);
setX(item,null,x);
setY(item,null,y);
}
}
示例8: initHierarchyTree
import prefuse.data.tuple.TupleSet; //导入方法依赖的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);
}
}
示例9: items
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
/**
* Get an iterator over all items in the given group which match the given
* Predicate filter.
* @param group the visual data group to iterate over
* @param filter a Predicate indicating which items should be included in
* the iteration.
* @return a filtered iterator over VisualItems
*/
@SuppressWarnings("unchecked")
public Iterator<VisualItem> items(String group, Predicate filter) {
if ( ALL_ITEMS.equals(group) )
return items(filter);
TupleSet t = getGroup(group);
return (Iterator<VisualItem>) ( t==null ? Collections.<VisualItem>emptyList().iterator()
: t.tuples(filter) );
}
示例10: search
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
/**
* @see prefuse.data.search.SearchTupleSet#search(java.lang.String)
*/
public void search(String query) {
if ( query == null )
query = "";
if ( !m_caseSensitive )
query = query.toLowerCase();
if ( query.equals(m_query) )
return;
Pattern pattern = null;
try {
pattern = Pattern.compile(query);
} catch ( Exception e ) {
Logger logger = Logger.getLogger(this.getClass().getName());
logger.warning("Pattern compile failed."
+ "\n" + StringLib.getStackTrace(e));
return;
}
Tuple[] rem = clearInternal();
m_query = query;
Iterator fields = m_source.keySet().iterator();
while ( fields.hasNext() ) {
String field = (String)fields.next();
TupleSet ts = (TupleSet)m_source.get(field);
Iterator tuples = ts.tuples();
while ( tuples.hasNext() ) {
Tuple t = (Tuple)tuples.next();
String text = t.getString(field);
if ( !m_caseSensitive )
text = text.toLowerCase();
if ( pattern.matcher(text).matches() )
addInternal(t);
}
}
Tuple[] add = getTupleCount() > 0 ? toArray() : null;
fireTupleEvent(add, rem);
}
示例11: analyzeGraphGrid
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
/**
* Analyzes a set of nodes to try and determine grid dimensions. Currently
* looks for the edge count on a node to drop to 2 to determine the end of
* a row.
* @param ts TupleSet ts a set of nodes to analyze. Contained tuples
* <b>must</b> implement be Node instances.
* @return a two-element int array with the row and column lengths
*/
public static int[] analyzeGraphGrid(TupleSet ts) {
// TODO: more robust grid analysis?
int m, n;
Iterator iter = ts.tuples(); iter.next();
for ( n=2; iter.hasNext(); n++ ) {
Node nd = (Node)iter.next();
if ( nd.getDegree() == 2 )
break;
}
m = ts.getTupleCount() / n;
return new int[] {m,n};
}
示例12: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
/**
* @see prefuse.action.Action#run(double)
*/
public void run(double frac) {
TupleSet ts = m_vis.getGroup(m_group);
int nn = ts.getTupleCount();
Rectangle2D r = getLayoutBounds();
double height = r.getHeight();
double width = r.getWidth();
double cx = r.getCenterX();
double cy = r.getCenterY();
double radius = m_radius;
if (radius <= 0) {
radius = 0.45 * (height < width ? height : width);
}
Iterator items = ts.tuples();
for (int i=0; items.hasNext(); i++) {
VisualItem n = (VisualItem)items.next();
double angle = (2*Math.PI*i) / nn;
double x = Math.cos(angle)*radius + cx;
double y = Math.sin(angle)*radius + cy;
setX(n, null, x);
setY(n, null, y);
}
}
示例13: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
public void run(double frac) {
TupleSet focus = m_vis.getGroup(Visualization.FOCUS_ITEMS);
if ( focus==null || focus.getTupleCount() == 0 ) return;
Graph g = (Graph)m_vis.getGroup(m_group);
Node f = null;
Iterator tuples = focus.tuples();
while (tuples.hasNext() && !g.containsTuple(f=(Node)tuples.next()))
{
f = null;
}
if ( f == null ) return;
g.getSpanningTree(f);
}
示例14: run
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes" })
@Override
public void run(double frac) {
if (timeScale == null) {
// setMinMax(); TODO get layout bounds
// get Inf / Sup of TemporalDataset (only temporal objects)
log.debug("cannot layout without timescale");
return;
}
TupleSet items = m_vis.getGroup(m_group);
if (items == null) {
log.debug("nothing to layout");
return;
}
// consider only nodes = temporal objects
if (items instanceof VisualGraph) {
items = ((VisualGraph) items).getNodes();
}
// TODO consider only: anchored (visible) objects --> index
Iterator tuples = items.tuples(m_filter);
while (tuples.hasNext()) {
VisualItem item = (VisualItem) tuples.next();
layoutItem(item);
}
}
示例15: updateNodePositions
import prefuse.data.tuple.TupleSet; //导入方法依赖的package包/类
private void updateNodePositions() {
Rectangle2D bounds = getLayoutBounds();
double x1=0, x2=0, y1=0, y2=0;
if ( bounds != null ) {
x1 = bounds.getMinX(); y1 = bounds.getMinY();
x2 = bounds.getMaxX(); y2 = bounds.getMaxY();
}
// update positions
TupleSet ts = m_vis.getGroup(m_nodeGroup);
Iterator<?> iter;
if (m_filter == null)
iter = ts.tuples();
else
iter = ts.tuples(m_filter);
while ( iter.hasNext() ) {
VisualItem item = (VisualItem)iter.next();
ForceItem fitem = (ForceItem)item.get(FORCEITEM);
if ( item.isFixed() ) {
// clear any force computations
fitem.force[0] = 0.0f;
fitem.force[1] = 0.0f;
fitem.velocity[0] = 0.0f;
fitem.velocity[1] = 0.0f;
if ( Double.isNaN(item.getX()) ) {
setX(item, referrer, 0.0);
setY(item, referrer, 0.0);
}
continue;
}
double x = fitem.location[0];
double y = fitem.location[1];
if ( m_enforceBounds && bounds != null) {
Rectangle2D b = item.getBounds();
double hw = b.getWidth()/2;
double hh = b.getHeight()/2;
if ( x+hw > x2 ) x = x2-hw;
if ( x-hw < x1 ) x = x1+hw;
if ( y+hh > y2 ) y = y2-hh;
if ( y-hh < y1 ) y = y1+hh;
}
// set the actual position
setX(item, referrer, x);
setY(item, referrer, y);
}
}