Commit b558586d authored by Nico Mack's avatar Nico Mack

Fixed cloning issue with ModalMarker

Changes to API of ClusterManager
parent 92de8d13
......@@ -93,7 +93,7 @@ public class ClusterManager<P extends Positionable> {
List<P> coalescing = kdTree.findNearest(candidate, radius);
// If there were items within that zone, than we the candidate will be
// If there were items within that zone, than the candidate will be
// a cluster, representing the matching items.
boolean isClustered = (!coalescing.isEmpty());
......@@ -170,7 +170,7 @@ public class ClusterManager<P extends Positionable> {
*/
// ---------------------------------------------------------------------------
public void refresh() {
public void clusterize() {
if (kdTree == null)
return;
......
......@@ -89,12 +89,11 @@ public class ModalMarker extends TetherableMarker {
clusteredBundle = original.clusteredBundle;
coronaBundles = TreeMultimap.create();
coronaBundles.putAll(original.coronaBundles);
coronaBundles.putAll(original.cloneBundles());
activeBundles = new ArrayList<>();
activeBundles.addAll(original.activeBundles);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s) *
......@@ -231,6 +230,18 @@ public class ModalMarker extends TetherableMarker {
}
}
// ---------------------------------------------------------------------------
protected Multimap<String, CoronaBundle> cloneBundles() {
Multimap<String, CoronaBundle> clonedBundles = TreeMultimap.create();
for (Entry<String, CoronaBundle> entry : coronaBundles.entries()) {
CoronaBundle cloned = entry.getValue().clone();
clonedBundles.put(entry.getKey(), cloned);
}
return clonedBundles;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
......
......@@ -28,12 +28,14 @@ import lu.list.itis.dkd.tui.widget.corona.Corona;
import com.google.common.base.Strings;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
import org.jdom2.Element;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
/**
* Provides a way to logically organize and label a set of coronas. Bundles can also be altered
......@@ -47,7 +49,7 @@ import java.util.List;
// * Class Definition and Members *
// ***************************************************************************
public class CoronaBundle implements Comparable<CoronaBundle> {
public class CoronaBundle implements Comparable<CoronaBundle>, Cloneable {
private String name;
private boolean isExclusive;
private boolean isDefault;
......@@ -70,6 +72,19 @@ public class CoronaBundle implements Comparable<CoronaBundle> {
this.coronas = ArrayListMultimap.create();
}
// ---------------------------------------------------------------------------
/**
* @param original
*/
// ---------------------------------------------------------------------------
public CoronaBundle(CoronaBundle original) {
this.name = original.name;
this.isExclusive = original.isExclusive;
this.isDefault = original.isDefault;
this.coronas = original.cloneCoronas();
}
// ---------------------------------------------------------------------------
/**
* @param rootElement
......@@ -119,6 +134,22 @@ public class CoronaBundle implements Comparable<CoronaBundle> {
coronas = CoronaBootstrapper.getCoronas(rootElement.getChild(Externalization.CORONAS_NODE), context, callback);
}
// ---------------------------------------------------------------------------
/**
* @return
*/
// ---------------------------------------------------------------------------
protected Multimap<Integer, Corona> cloneCoronas() {
Multimap<Integer, Corona> clonedCoronas = TreeMultimap.create();
for (Entry<Integer, Corona> entry : coronas.entries()) {
Corona cloned = entry.getValue().clone();
clonedCoronas.put(entry.getKey(), cloned);
}
return clonedCoronas;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
......@@ -281,6 +312,13 @@ public class CoronaBundle implements Comparable<CoronaBundle> {
return name.compareTo(bundle.name);
}
// ---------------------------------------------------------------------------
@Override
public CoronaBundle clone() {
return new CoronaBundle(this);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment