当前位置: 首页>>代码示例>>Java>>正文


Java Entry类代码示例

本文整理汇总了Java中com.github.davidmoten.rtree.Entry的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Entry类属于com.github.davidmoten.rtree包,在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: find

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
/**
 * Finds the closest node or edges within the specified maximum radius.
 *
 * @param x          the x position of the query point
 * @param y          the y position of the query point
 * @param nodeAction the action that needs to be executed when a node is found
 * @param edgeAction the action that needs to be executed when an edge is found
 */
@SuppressWarnings("squid:S1166") // No need to log the exception itself, a message is enough.
public void find(final double x, final double y,
                 final Consumer<Integer> nodeAction, final BiConsumer<Integer, Integer> edgeAction) {
    try {
        final Entry<Integer[], Geometry> result = tree.nearest(point(x, y), MAX_NEARNESS_DISTANCE, 1)
                .toBlocking()
                .first();

        if (result.geometry() instanceof Rectangle) {
            nodeAction.accept(result.value()[0]);
        } else if (result.geometry() instanceof Line) {
            edgeAction.accept(result.value()[0], result.value()[1]);
        }
    } catch (final NoSuchElementException e) {
        // There is no need to log the exception itself.
        LOGGER.debug("No node or edge found at position (" + x + ", " + y + ").");
    }
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:27,代码来源:RTree.java

示例2: entries1000

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
static List<Entry<Object, Rectangle>> entries1000() {
    List<Entry<Object, Rectangle>> list = new ArrayList<Entry<Object, Rectangle>>();
    BufferedReader br = new BufferedReader(
            new InputStreamReader(RTreeBenchmark.class.getResourceAsStream("/1000.txt")));
    String line;
    try {
        while ((line = br.readLine()) != null) {
            String[] items = line.split(" ");
            double x = Double.parseDouble(items[0]);
            double y = Double.parseDouble(items[1]);
            list.add(Entries.entry(new Object(), Geometries.rectangle(x, y, x + 1, y + 1)));
        }
        br.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return list;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:19,代码来源:RTreeBenchmark.java

示例3: place

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@Override
public boolean place(final Word word) {
    final Rectangle wordRectangle = Geometries.rectangle(
            word.getPosition().getX(),
            word.getPosition().getY(),
            word.getPosition().getX() + word.getDimension().getWidth(),
            word.getPosition().getY() + word.getDimension().getHeight());

    final Observable<Entry<String, Rectangle>> results = placedWordRTree.search(
            wordRectangle);

    final int matches = results.count().toBlocking().single();
    if (matches > 0) {
        return false;
    }
    placedWordRTree = placedWordRTree.add(word.getWord(), wordRectangle);
    return true;
}
 
开发者ID:kennycason,项目名称:kumo,代码行数:19,代码来源:RTreeWordPlacer.java

示例4: find

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
/**
 * Find.
 *
 * @param longitude the longitude
 * @param latitude the latitude
 * @return the city
 */
public City find(Double longitude, Double latitude){
	if(longitude == null || latitude == null){
		return null;
	}
	Observable<Entry<City, Geometry>> result =  this.rtree.nearest(Geometries.pointGeographic(longitude, latitude), 10000, 1);
	if(result==null){
		return null;
	}
	try{
		return result.toBlocking().single().value();
	}catch(NoSuchElementException e){
		return null;
	}
}
 
开发者ID:mmarmol,项目名称:geolite2,代码行数:22,代码来源:CityFinder.java

示例5: findTilesInBox

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
/**
 * @return all tiles that intersect the specified bounding box.
 */
public List<TileBounds> findTilesInBox(final double minX,
                                       final double minY,
                                       final double maxX,
                                       final double maxY) {

    final Rectangle rectangle = Geometries.rectangle(minX, minY, maxX, maxY);
    final Observable<Entry<TileBounds, Geometry>> searchResults = tree.search(rectangle);
    return convertResultsToList(searchResults);
}
 
开发者ID:saalfeldlab,项目名称:render,代码行数:13,代码来源:TileBoundsRTree.java

示例6: testRTree

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@Test
public void testRTree() {
    RTree<String> rtree = RTree.create();
    rtree = rtree.add("foo", closed(10, 20));
    rtree = rtree.add("bar", closedOpen(14, 28));
    rtree = rtree.add("baz", open(18, 36));

    int count = 0;
    for (Entry<String> result : rtree.search(singleton(20)).toBlocking().toIterable()) {
        count++;
    }
    assertEquals(3, count);
}
 
开发者ID:nmdp-bioinformatics,项目名称:ngs,代码行数:14,代码来源:RangeGeometriesTest.java

示例7: entriesList

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
static List<Entry<Object, Point>> entriesList() {
    List<Entry<Object, Point>> result = entries().toList().toBlocking().single();
    System.out.println("loaded greek earthquakes into list");
    return result;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:6,代码来源:GreekEarthquakes.java

示例8: insertBatchGreek

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Point> insertBatchGreek() {
    RTree<Object, Point> tree = rtreeGreek;
    for (Entry<Object, Point> entry: entriesGreek04) tree = tree.add(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java

示例9: insertBatch1k

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Rectangle> insertBatch1k() {
    RTree<Object, Rectangle> tree = rtree1k;
    for (Entry<Object, Rectangle> entry: entries1k04) tree = tree.add(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java

示例10: deleteBatchGreek

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Point> deleteBatchGreek() {
    RTree<Object, Point> tree = rtreeGreek;
    for (Entry<Object, Point> entry: entriesGreek06) tree = tree.delete(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java

示例11: deleteBatch1k

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
@GenerateMicroBenchmark
public RTree<Object, Rectangle> deleteBatch1k() {
    RTree<Object, Rectangle> tree = rtree1k;
    for (Entry<Object, Rectangle> entry: entries1k06) tree = tree.delete(entry);
    return tree;
}
 
开发者ID:ambling,项目名称:rtree-benchmark,代码行数:7,代码来源:RTreeBenchmark.java

示例12: joinGroupedShapes

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void joinGroupedShapes() {
	
	// find groups of shapes that are visually together
	// - Must overlap
	// - Must be same type
	// - Must not contain each other
	// - Only one must have text
	
	// we can't actually make a group here, as that makes things like
	// bounding rectangles annoying. Instead, just link them together
	// with an edge 
	
	// insert naive implementation here
	for (final ShapeData shapeData: shapes) {
		
		if (shapeData.is1d())
			continue;
		
		final String symbolName = shapeData.vertex.getProperty("symbolName");
		if (symbolName.equals(""))
			continue;
		
		Observable<Entry<ShapeData, Rectangle>> entries = rtree.search(shapeData.rtreeBounds);
		
		entries.forEach(new Rx.RTreeAction() {

			@Override
			public void call(Entry<ShapeData, Rectangle> entry) {
				ShapeData other = entry.value();
				
				if (other == shapeData || other.is1d())
					return;
				
				// if the intersection is equal to the area of the smallest, then
				// we can assume one of them contains the other
				// .. don't want those to be joined
				
				if (!other.vertex.getProperty("symbolName").equals(symbolName) || 
					ShapeData.eitherEncloses(shapeData, other)) {
					return;
				}
				
				// but if it doesn't contain, then link them together
				createEdge(shapeData, other, "linked", null, null);
			}
		});
	}
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:49,代码来源:VisioPageParser.java

示例13: infer1dConnections

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void infer1dConnections(final ShapeData shapeData) {
	
	// create a list of things that I'm attached to
	final Set<Vertex> attached = Sets.newHashSet(shapeData.vertex.getVertices(Direction.BOTH));
	
	// identify any shapes that it overlaps with
	// add that shape to the list of connections
	Observable<Entry<ShapeData, Rectangle>> entries = rtree.search(shapeData.rtreeBounds);
	
	entries.subscribe(new Rx.RTreeSubscriber() {
		
		@Override
		public void onNext(Entry<ShapeData, Rectangle> e) {
			
			ShapeData other = e.value();
			
			if (other == shapeData || other.removed || !other.is1d() || attached.contains(other.vertex))
				return;
			
			// don't infer connections between lines of different colors
			// or different line patterns
			if (!shapeData.lineColor.equals(other.lineColor) || shapeData.linePattern != other.linePattern) {
				return;
			}
			
			// compute if they intersect
			List<Point2D> intersections = new ArrayList<>();
			
			if (!GeomUtils.findIntersections(shapeData.path1D, other.path1D, intersections, null)) {
				return;
			}
			
			// TODO
			// if they are both dynamic connectors, don't create connections
			// unless their intersection is at the end of a line?
			// alternatively, try to check if the intersection happens at an
			// 'arcto' point. if so, discard, as that's a 'clear' visual indicator
			// that it should not be connected
			
			// ok, we've gotten here, create a connection between the two lines
			// -> connection point is first point.. not sure what to do with other points
			Point2D intersection = intersections.get(0);
			createEdge(shapeData, other, "inferred-1d", intersection.getX(), intersection.getY());
		}
	});
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:47,代码来源:VisioPageParser.java

示例14: associateTextboxWithShape

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
/**
 * this takes a shape that is a 'textbox'
 */
protected void associateTextboxWithShape(final ShapeData textBox) {
	
	// limit the search to some reasonable number/distance (TODO: what is reasonable)
	
	Observable<Entry<ShapeData, Rectangle>> entries = SpatialTools.nearest(rtree, textBox.rtreeBounds, helper.textInferenceDistance(textBox), rtree.size());
	
	final List<ShapeData> maybe = new ArrayList<>();
	
	entries.subscribe(new Rx.RTreeSubscriber() {
		
		@Override
		public void onNext(Entry<ShapeData, Rectangle> e) {
			
			ShapeData other = e.value();
			
			if (other == textBox || other.hasText || other.removed || !helper.onTextInference(textBox, other))
				return;
			
			// if it encloses it, only associate if there's nothing else closer
			if (other.encloses(textBox)) {
				if (maybe.isEmpty())
					maybe.add(other);
				
				return;
			}
			
			doAssociateTextboxWithShape(textBox, other);
			maybe.clear();
			
			// TODO: probably want to be more intelligent, and assign the text to
			//       things that are nearer in a particular direction, taking 
			//       advantage of how a human might naturally align the text..
			
			// done with this
			unsubscribe();
		}
	});
	
	// if we didn't find any alternatives, associate the first one that enclosed
	if (!maybe.isEmpty())
		doAssociateTextboxWithShape(textBox, maybe.get(0));
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:46,代码来源:VisioPageParser.java

示例15: inferDisconnectedGroupConnections

import com.github.davidmoten.rtree.Entry; //导入依赖的package包/类
protected void inferDisconnectedGroupConnections(final GroupData groupData, final List<ShapeData> connections, final boolean ignore1d) {
	// identify any shapes that the group overlaps with
	// add that shape to the list of connections
	Observable<Entry<ShapeData, Rectangle>> entries = rtree.search(groupData.group.rtreeBounds);
	
	final Path2D groupPath = groupData.group.getPath();
	
	entries.subscribe(new Rx.RTreeSubscriber() {

		@Override
		public void onNext(Entry<ShapeData, Rectangle> e) {
			
			ShapeData other = e.value();
			if (other == groupData.group)
				return;
			
			if (other.is1d()) {
				
				// TODO: what we probably want is a function that checks all segments of the path 
				//       -- but only matches on the end segments matching
				
				if (ignore1d)
					return;
				
				// check to see if one of the endpoints of the 1d shape intersects
				// with the group
				if (!GeomUtils.pathIntersects(groupPath, other.path1Dstart) &&
				    !GeomUtils.pathIntersects(groupPath, other.path1Dend)) {
					return;
				}
				
			} else {
				
				if (!other.vertex.getVertices(Direction.BOTH).iterator().hasNext() ||  
					!GeomUtils.pathIntersects(groupPath, other.path2D)) {
					return;
				}
			}
			
			connections.add(other);
		}
	});
}
 
开发者ID:BBN-D,项目名称:poi-visio-graph,代码行数:44,代码来源:VisioPageParser.java


注:本文中的com.github.davidmoten.rtree.Entry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。