Atavism Version 2018.1AGIS API

atavism.server.engine
Class QuadTree<ElementType extends QuadTreeElement<ElementType>>

java.lang.Object
  extended by atavism.server.engine.QuadTree<ElementType>

public class QuadTree<ElementType extends QuadTreeElement<ElementType>>
extends java.lang.Object


Nested Class Summary
 class QuadTree.NewsAndFrees
          Instances of this class are used to accumulate news and frees of objects, from the point of view of perceivers, so that we can perform the new and free operations, which generate messages, without holding the top-level quad tree lock.
 
Field Summary
protected  java.util.Set<FixedPerceiver<ElementType>> fixedPerceivers
           
protected static Logger log
           
 QuadTree.NewsAndFrees spawningNewsAndFrees
           
 
Constructor Summary
QuadTree(Geometry g)
           
QuadTree(Geometry g, boolean supportsExtentBasedPerceiver)
           
QuadTree(Geometry g, int hysteresis)
           
 
Method Summary
 QuadTreeNode<ElementType> addElement(ElementType elem)
           
protected  QuadTreeNode<ElementType> addElementInternal(ElementType elem, QuadTree.NewsAndFrees newsAndFrees)
           
 java.lang.Integer addElementReturnCountForPerceiver(ElementType elem, OID mobilePerceiverOid)
          If the perceiverOid is non-null, the count returned is the count of the number of news plus number of frees for the perceiver as a result of adding elem to the quadtree; else null
 void addFixedPerceiver(FixedPerceiver<ElementType> perceiver)
           
protected  QuadTreeNode<ElementType> addHelper(QuadTreeNode<ElementType> node, ElementType elem, Point loc, QuadTree.NewsAndFrees newsAndFrees)
           
 void addRegion(Region region)
           
protected  void createQuadTree(Geometry g, int hysteresis)
           
 java.util.Collection<ElementType> getElementPerceivables(ElementType elem)
           
 java.util.Set<ElementType> getElements(ElementType elem, int radius)
           
 java.util.Set<ElementType> getElements(Point loc, int radius)
           
 java.util.Set<ElementType> getElementsBetween(Point loc1, Point loc2)
           
 int getHysteresis()
           
 Geometry getLocalGeometry()
           
 java.util.concurrent.locks.Lock getLock()
           
 int getMaxDepth()
           
 int getMaxObjects()
           
 java.util.List<Region> getRegionsContainingPoint(Point loc)
          Entrypoint to get the regions containing the point - - needed now that we've done away with the RegionManager
 boolean getSupportsExtentBasedPerceiver()
           
 void printTree()
           
 boolean removeElement(ElementType elem)
           
protected  boolean removeElementInternal(ElementType elem, QuadTree.NewsAndFrees newsAndFrees)
           
 java.lang.Integer removeElementReturnCountForPerceiver(ElementType elem, OID mobilePerceiverOid)
          If the perceiverOid is non-null, the count returned is the count of the number of news plus number of frees for the perceiver as a result of adding elem to the quadtree; else null
 void removeFixedPerceiver(FixedPerceiver<ElementType> perceiver)
           
 void setHysteresis(int hysteresis)
           
 void setLocalGeometry(Geometry g)
           
protected  void setLocalGeometryHelper(QuadTreeNode<ElementType> node, Geometry g, QuadTree.NewsAndFrees newsAndFrees)
           
 void setMaxDepth(int max)
           
 void setMaxObjects(int max)
           
 void updateElement(ElementType elem, Point loc)
          Moves elem to the right place in the quadtree if its position has changed.
protected  void updateElementInternal(ElementType elem, Point loc, QuadTree.NewsAndFrees newsAndFrees)
           
protected  void updateElementPerceiversInternal(ElementType elem, QuadTreeNode<ElementType> oldNode, QuadTreeNode<ElementType> newNode, QuadTree.NewsAndFrees newsAndFrees)
          Notify all perceivers that can now see, or can no longer see the specified object (elem)
protected  void updatePerceiver(Perceiver<ElementType> perceiver)
           
protected  void updatePerceiverHelper(java.util.Set<QuadTreeNode<ElementType>> nodeSet, QuadTreeNode<ElementType> node, Perceiver<ElementType> perceiver)
          Adds all nodes to nodeSet in or under 'node' that the passed in perceiver overlaps with.
protected  void updatePerceiverInternal(Perceiver<ElementType> perceiver, QuadTree.NewsAndFrees newsAndFrees)
          Notify the object's perceiver about what they can see/not see.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spawningNewsAndFrees

public QuadTree.NewsAndFrees spawningNewsAndFrees

fixedPerceivers

protected java.util.Set<FixedPerceiver<ElementType extends QuadTreeElement<ElementType>>> fixedPerceivers

log

protected static final Logger log
Constructor Detail

QuadTree

public QuadTree(Geometry g)

QuadTree

public QuadTree(Geometry g,
                int hysteresis)

QuadTree

public QuadTree(Geometry g,
                boolean supportsExtentBasedPerceiver)
Method Detail

createQuadTree

protected void createQuadTree(Geometry g,
                              int hysteresis)

printTree

public void printTree()

getElements

public java.util.Set<ElementType> getElements(Point loc,
                                              int radius)

getElementsBetween

public java.util.Set<ElementType> getElementsBetween(Point loc1,
                                                     Point loc2)

getElements

public java.util.Set<ElementType> getElements(ElementType elem,
                                              int radius)

getLocalGeometry

public Geometry getLocalGeometry()

addRegion

public void addRegion(Region region)

getRegionsContainingPoint

public java.util.List<Region> getRegionsContainingPoint(Point loc)
Entrypoint to get the regions containing the point - - needed now that we've done away with the RegionManager


setMaxObjects

public void setMaxObjects(int max)

getMaxObjects

public int getMaxObjects()

setMaxDepth

public void setMaxDepth(int max)

getMaxDepth

public int getMaxDepth()

getSupportsExtentBasedPerceiver

public boolean getSupportsExtentBasedPerceiver()

getLock

public java.util.concurrent.locks.Lock getLock()

getHysteresis

public int getHysteresis()

setHysteresis

public void setHysteresis(int hysteresis)

addElement

public QuadTreeNode<ElementType> addElement(ElementType elem)

addElementReturnCountForPerceiver

public java.lang.Integer addElementReturnCountForPerceiver(ElementType elem,
                                                           OID mobilePerceiverOid)
If the perceiverOid is non-null, the count returned is the count of the number of news plus number of frees for the perceiver as a result of adding elem to the quadtree; else null


removeElement

public boolean removeElement(ElementType elem)

removeElementReturnCountForPerceiver

public java.lang.Integer removeElementReturnCountForPerceiver(ElementType elem,
                                                              OID mobilePerceiverOid)
If the perceiverOid is non-null, the count returned is the count of the number of news plus number of frees for the perceiver as a result of adding elem to the quadtree; else null


updateElement

public void updateElement(ElementType elem,
                          Point loc)
Moves elem to the right place in the quadtree if its position has changed.

Parameters:
elem -
loc -

updatePerceiver

protected void updatePerceiver(Perceiver<ElementType> perceiver)

addFixedPerceiver

public void addFixedPerceiver(FixedPerceiver<ElementType> perceiver)

removeFixedPerceiver

public void removeFixedPerceiver(FixedPerceiver<ElementType> perceiver)

setLocalGeometry

public void setLocalGeometry(Geometry g)

getElementPerceivables

public java.util.Collection<ElementType> getElementPerceivables(ElementType elem)

addElementInternal

protected QuadTreeNode<ElementType> addElementInternal(ElementType elem,
                                                       QuadTree.NewsAndFrees newsAndFrees)

addHelper

protected QuadTreeNode<ElementType> addHelper(QuadTreeNode<ElementType> node,
                                              ElementType elem,
                                              Point loc,
                                              QuadTree.NewsAndFrees newsAndFrees)

removeElementInternal

protected boolean removeElementInternal(ElementType elem,
                                        QuadTree.NewsAndFrees newsAndFrees)

updateElementInternal

protected void updateElementInternal(ElementType elem,
                                     Point loc,
                                     QuadTree.NewsAndFrees newsAndFrees)

updateElementPerceiversInternal

protected void updateElementPerceiversInternal(ElementType elem,
                                               QuadTreeNode<ElementType> oldNode,
                                               QuadTreeNode<ElementType> newNode,
                                               QuadTree.NewsAndFrees newsAndFrees)
Notify all perceivers that can now see, or can no longer see the specified object (elem)

Parameters:
elem: - the element that is moving
oldNode: - the node the element has left
newNode: - the node the element has entered
newsAndFrees -

updatePerceiverInternal

protected void updatePerceiverInternal(Perceiver<ElementType> perceiver,
                                       QuadTree.NewsAndFrees newsAndFrees)
Notify the object's perceiver about what they can see/not see. If you change your set of perceivers, you should be told about all objects you can see and you should not have to wait for the other objects to 'move' before you see it.

Parameters:
perceiver -
newsAndFrees -

updatePerceiverHelper

protected void updatePerceiverHelper(java.util.Set<QuadTreeNode<ElementType>> nodeSet,
                                     QuadTreeNode<ElementType> node,
                                     Perceiver<ElementType> perceiver)
Adds all nodes to nodeSet in or under 'node' that the passed in perceiver overlaps with. Recursive function that calls itself for the children of the specified node.

Parameters:
nodeSet -
node -
perceiver -

setLocalGeometryHelper

protected void setLocalGeometryHelper(QuadTreeNode<ElementType> node,
                                      Geometry g,
                                      QuadTree.NewsAndFrees newsAndFrees)


Copyright © 2018 Dragonsan Studios Sp. z o.o.