Skip to content

Add clusterEnabled to Options #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions library/src/com/twotoasters/clusterkraf/ClustersBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@ ArrayList<ClusterPoint> build() {
clusteredPoints = new ArrayList<ClusterPoint>(relevantInputPointsList.size());
for (InputPoint point : relevantInputPointsList) {
boolean addedToExistingCluster = false;
for (ClusterPoint clusterPoint : clusteredPoints) {
if (clusterPoint.getPixelDistanceFrom(point) <= options.getPixelDistanceToJoinCluster()) {
clusterPoint.add(point);
addedToExistingCluster = true;
break;

if (options.isClusterEnabled()) {
for (ClusterPoint clusterPoint : clusteredPoints) {
if (clusterPoint.getPixelDistanceFrom(point) <= options.getPixelDistanceToJoinCluster()) {
clusterPoint.add(point);
addedToExistingCluster = true;
break;
}
}
}

if (addedToExistingCluster == false) {
clusteredPoints.add(new ClusterPoint(point, projection, false));
}
Expand Down
21 changes: 20 additions & 1 deletion library/src/com/twotoasters/clusterkraf/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class Options {
*/
private double expandBoundsFactor = DEFAULT_EXPAND_BOUNDS_FACTOR;

/**
* Enable or disable clustering
*/
private boolean clusterEnabled = true;

/**
* The MarkerOptionsChooser to use for customizing MarkerOptions objects.
*/
Expand Down Expand Up @@ -116,7 +121,21 @@ public class Options {
/**
*
*/
private ProcessingListener processingListener;
private ProcessingListener processingListener;

/**
* @return clusterEnabled
*/
public boolean isClusterEnabled() {
return clusterEnabled;
}

/**
* @param clusterEnabled
*/
public void setClusterEnabled(boolean clusterEnabled) {
this.clusterEnabled = clusterEnabled;
}

/**
* @return the transitionDuration
Expand Down