Android Open Source - clusterkraf Cluster Transitions






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;
/*from  w  w w  . java2 s. c  o  m*/
import java.lang.ref.WeakReference;
import java.util.ArrayList;

import com.google.android.gms.maps.Projection;

class ClusterTransitions {

  final ArrayList<AnimatedTransition> animated;
  final ArrayList<ClusterPoint> stationary;

  private ClusterTransitions(Builder builder) {
    this.animated = builder.animatedTransitions;
    this.stationary = builder.stationaryTransitions;
  }

  static class Builder {

    private final WeakReference<Projection> projectionRef;
    private final ArrayList<ClusterPoint> previousClusterPoints;

    private final ArrayList<AnimatedTransition> animatedTransitions = new ArrayList<AnimatedTransition>();
    private final ArrayList<ClusterPoint> stationaryTransitions = new ArrayList<ClusterPoint>();

    Builder(Projection projection, ArrayList<ClusterPoint> previousClusterPoints) {
      this.projectionRef = new WeakReference<Projection>(projection);
      this.previousClusterPoints = previousClusterPoints;
    }

    void add(ClusterPoint currentClusterPoint) {
      Projection projection = projectionRef != null ? projectionRef.get() : null;
      if (currentClusterPoint != null && projection != null) {
        boolean animated = false;
        if (previousClusterPoints != null) {
          for (ClusterPoint previousClusterPoint : previousClusterPoints) {
            for (InputPoint previousInputPoint : previousClusterPoint.getPointsInCluster()) {
              if (currentClusterPoint.containsInputPoint(previousInputPoint)) {
                AnimatedTransition transition = getTransition(previousInputPoint);
                if (transition != null) {
                  transition.addOriginClusterRelevantInputPoint(previousInputPoint);
                } else {
                  transition = new AnimatedTransition(projection, previousClusterPoint, previousInputPoint, currentClusterPoint);
                  animatedTransitions.add(transition);
                  animated = true;
                }
              }
            }
          }
        }
        if (animated == false) {
          stationaryTransitions.add(currentClusterPoint);
        }
      }
    }

    private AnimatedTransition getTransition(InputPoint relevantInputPoint) {
      for (AnimatedTransition at : animatedTransitions) {
        if (at.destinationContains(relevantInputPoint) && at.originContains(relevantInputPoint)) {
          return at;
        }
      }
      return null;
    }

    ClusterTransitions build() {
      return new ClusterTransitions(this);
    }
  }

}




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