protected Point randomPointIn(Rectangle r) { double x = r.getMinX() + randomDouble() * r.getWidth(); double y = r.getMinY() + randomDouble() * r.getHeight(); x = normX(x); y = normY(y); Point p = ctx.makePoint(x, y); assertEquals(CONTAINS, r.relate(p)); return p; }
/** * Initializes a new hierarchy of partial discs according to a tree of cluster nodes and other * parameters. * * @param <E> Concrete Type of IHierarchyData * @param tree Tree of hierarchy data objects which is used to build the partial disc tree. * @param idType IDType of the hierarchy data objects. * @param dataEventManager Concrete DataEventManager that is responsible for handling and * triggering data specific events. * @param alColorModes List of drawing strategies that shall be used as color modes. */ public <E extends AHierarchyElement<E>> void initHierarchy( Tree<E> tree, E heRoot, ADataEventManager dataEventManager, ArrayList<EPDDrawingStrategyType> alColorModes) { hashPartialDiscs.clear(); selectionManager = new SelectionManager(tree.getNodeIDType()); partialDiscTree = new Tree<PartialDisc>(); navigationHistory.reset(); drawingController.setDrawingState(EDrawingStateType.DRAWING_STATE_FULL_HIERARCHY); LabelManager.get().clearLabels(); drawingStrategyManager.init(pickingManager, uniqueID, alColorModes); PartialDisc pdRoot = new PartialDisc( partialDiscTree, heRoot, drawingStrategyManager.getDefaultDrawingStrategy()); partialDiscTree.setRootNode(pdRoot); partialDiscTree.setLeafIDType(tree.getLeaveIDType()); partialDiscTree.setNodeIDType(tree.getNodeIDType()); hashPartialDiscs.put(heRoot.getID(), pdRoot); // selectionManager.initialAdd(heRoot.getID()); buildTree(tree, heRoot, pdRoot); pdRoot.calculateLargestChildren(); iMaxDisplayedHierarchyDepth = DISP_HIER_DEPTH_DEFAULT; this.dataEventManager = dataEventManager; this.dataEventManager.registerEventListeners(); pdCurrentRootElement = pdRoot; pdCurrentSelectedElement = pdRoot; pdRealRootElement = pdRoot; navigationHistory.addNewHistoryEntry( drawingController.getCurrentDrawingState(), pdCurrentRootElement, pdCurrentSelectedElement, iMaxDisplayedHierarchyDepth); selectionManager.addToType(SelectionType.SELECTION, pdCurrentRootElement.getElementID()); controlBox = new Rectangle(0, 0, 0.3f, 0.2f); upwardNavigationSlider = new OneWaySlider( new Vec2f(controlBox.getMinX() + 0.1f, controlBox.getMinY() + 0.1f), 0.2f, 1f, pdRealRootElement.getHierarchyLevel(), 1, 0, pdRealRootElement.getDepth() - 1); upwardNavigationSlider.setMinSize(80); }
private void _assertIntersect(String msg, SpatialRelation expected, Shape a, Shape b) { SpatialRelation sect = a.relate(b); if (sect == expected) return; msg = ((msg == null) ? "" : msg + "\r") + a + " intersect " + b; if (expected == WITHIN || expected == CONTAINS) { if (a.getClass().equals(b.getClass())) // they are the same shape type assertEquals(msg, a, b); else { // they are effectively points or lines that are the same location assertTrue(msg, !a.hasArea()); assertTrue(msg, !b.hasArea()); Rectangle aBBox = a.getBoundingBox(); Rectangle bBBox = b.getBoundingBox(); if (aBBox.getHeight() == 0 && bBBox.getHeight() == 0 && (aBBox.getMaxY() == 90 && bBBox.getMaxY() == 90 || aBBox.getMinY() == -90 && bBBox.getMinY() == -90)) ; // == a point at the pole else assertEquals(msg, aBBox, bBBox); } } else { assertEquals(msg, expected, sect); // always fails } }
protected Rectangle computeBoundingBox(Collection<? extends Shape> shapes, SpatialContext ctx) { Range xRange = null; double minY = Double.POSITIVE_INFINITY; double maxY = Double.NEGATIVE_INFINITY; for (Shape geom : shapes) { Rectangle r = geom.getBoundingBox(); Range xRange2 = Range.xRange(r, ctx); if (xRange == null) { xRange = xRange2; } else { xRange = xRange.expandTo(xRange2); } minY = Math.min(minY, r.getMinY()); maxY = Math.max(maxY, r.getMaxY()); } return ctx.makeRectangle(xRange.getMin(), xRange.getMax(), minY, maxY); }
static double boundY(double i, Rectangle bounds) { return bound(i, bounds.getMinY(), bounds.getMaxY()); }