Android Open Source - clusterkraf Cluster Point






From Project

Back to project page clusterkraf.

License

The source code is released under:

Apache License

If you think the Android project clusterkraf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.twotoasters.clusterkraf;
/* w ww  .j a  va2 s  . c om*/
import java.util.ArrayList;
import java.util.HashSet;

import com.google.android.gms.maps.Projection;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;

/**
 * Represents one or more InputPoint objects that have been clustered together
 * due to pixel proximity
 */
public class ClusterPoint extends BasePoint {

  private final ArrayList<InputPoint> pointsInClusterList = new ArrayList<InputPoint>();
  private final HashSet<InputPoint> pointsInClusterSet = new HashSet<InputPoint>();

  private final boolean transition;

  private LatLngBounds boundsOfInputPoints;

  ClusterPoint(InputPoint initialPoint, Projection projection, boolean transition) {
    this.mapPosition = initialPoint.getMapPosition();
    this.transition = transition;
    add(initialPoint);
    buildScreenPosition(projection);
  }

  ClusterPoint(InputPoint initialPoint, Projection projection, boolean transition, LatLng overridePosition) {
    this(initialPoint, projection, transition);
    this.mapPosition = overridePosition;
  }

  void add(InputPoint point) {
    pointsInClusterList.add(point);
    pointsInClusterSet.add(point);

    boundsOfInputPoints = null;
  }

  ArrayList<InputPoint> getPointsInCluster() {
    return pointsInClusterList;
  }

  /**
   * @param index
   * @return the InputPoint at the given index
   */
  public InputPoint getPointAtOffset(int index) {
    return pointsInClusterList.get(index);
  }

  /**
   * @return the number of InputPoint objects in this ClusterPoint
   */
  public int size() {
    return pointsInClusterList.size();
  }

  /**
   * @param point
   * @return true if the InputPoint is in this ClusterPoint, otherwise false
   */
  public boolean containsInputPoint(InputPoint point) {
    return pointsInClusterSet.contains(point);
  }

  @Override
  void clearScreenPosition() {
    super.clearScreenPosition();
    for (InputPoint inputPoint : pointsInClusterList) {
      inputPoint.clearScreenPosition();
    }
  }

  /**
   * @return true if this object is part of a transition, otherwise false
   */
  public boolean isTransition() {
    return transition;
  }

  LatLngBounds getBoundsOfInputPoints() {
    if (boundsOfInputPoints == null) {
      LatLngBounds.Builder builder = LatLngBounds.builder();
      for (InputPoint inputPoint : pointsInClusterList) {
        builder.include(inputPoint.getMapPosition());
      }
      boundsOfInputPoints = builder.build();
    }
    return boundsOfInputPoints;
  }

}




Java Source Code List

android.UnusedStub.java
com.twotoasters.clusterkraf.AnimatedTransition.java
com.twotoasters.clusterkraf.BasePoint.java
com.twotoasters.clusterkraf.ClusterPoint.java
com.twotoasters.clusterkraf.ClusterTransitionsAnimation.java
com.twotoasters.clusterkraf.ClusterTransitionsBuildingTask.java
com.twotoasters.clusterkraf.ClusterTransitions.java
com.twotoasters.clusterkraf.ClusteringOnCameraChangeListener.java
com.twotoasters.clusterkraf.ClusteringTask.java
com.twotoasters.clusterkraf.Clusterkraf.java
com.twotoasters.clusterkraf.ClustersBuilder.java
com.twotoasters.clusterkraf.InfoWindowDownstreamAdapter.java
com.twotoasters.clusterkraf.InputPoint.java
com.twotoasters.clusterkraf.MarkerOptionsChooser.java
com.twotoasters.clusterkraf.OnInfoWindowClickDownstreamListener.java
com.twotoasters.clusterkraf.OnMarkerClickDownstreamListener.java
com.twotoasters.clusterkraf.Options.java
com.twotoasters.clusterkraf.sample.AdvancedModeFragment.java
com.twotoasters.clusterkraf.sample.DelayedIndeterminateProgressBarRunnable.java
com.twotoasters.clusterkraf.sample.MainActivity.java
com.twotoasters.clusterkraf.sample.MarkerData.java
com.twotoasters.clusterkraf.sample.NormalModeFragment.java
com.twotoasters.clusterkraf.sample.RandomPointsProvider.java
com.twotoasters.clusterkraf.sample.SampleActivity.java
com.twotoasters.clusterkraf.sample.SingleChoiceDialogFragment.java
com.twotoasters.clusterkraf.sample.ToastedMarkerOptionsChooser.java
com.twotoasters.clusterkraf.sample.ToastedOnMarkerClickDownstreamListener.java
com.twotoasters.clusterkraf.sample.TwoToastersActivity.java
com.twotoasters.clusterkraf.util.Distance.java