/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package etomica.virial;


/**
 * @author andrew
 *
 * cluster weight wrapper (absolute value of wrapped cluster)
 */
public class ClusterWeightAbs implements ClusterWeight, java.io.Serializable {
	
    private static final long serialVersionUID = 1L;
    protected final ClusterAbstract weightCluster;
	
	public ClusterWeightAbs(ClusterAbstract cluster) {
		weightCluster = cluster;
	}
	
	public static ClusterWeight makeWeightCluster(ClusterAbstract cluster) {
		if (cluster instanceof ClusterWeight) {
			return (ClusterWeight)cluster;
		}
		return new ClusterWeightAbs(cluster);
	}

	public static ClusterWeight[] makeWeightClusters(ClusterAbstract[] clusters) {
		ClusterWeight[] weightClusters = new ClusterWeight[clusters.length];
		for (int i=0; i<clusters.length; i++) {
			weightClusters[i] = makeWeightCluster(clusters[i]);
		}
		return weightClusters;
	}
    
    public ClusterAbstract getSubCluster() {
        return weightCluster;
    }
    
    public ClusterAbstract makeCopy() {
        return new ClusterWeightAbs(weightCluster.makeCopy());
    }
	
	public int pointCount() {
		return weightCluster.pointCount();
	}
	
	public double value(BoxCluster box) {
		return Math.abs(weightCluster.value(box));
	}
    
    public void setTemperature(double temp) {
        weightCluster.setTemperature(temp);
    }
}

@@ -407,188 +407,347 @@
   pr
-ivate static final long serialVersionUID = 1L;%0A    protected final ClusterAbstract weightCluster;%0A%09%0A%09public ClusterWeightAbs(ClusterAbstract cluster) %7B%0A%09%09weightCluster = cluster;%0A%09
+otected final ClusterAbstract weightCluster;%0A    protected boolean doAbs = true;%0A%09%0A%09public ClusterWeightAbs(ClusterAbstract cluster) %7B%0A%09%09weightCluster = cluster;%0A%09%7D%0A%0A    /**%0A     * Sets the cluster to actually return the %7Cvalue%7C (as default) or just value.%0A     */%0A    public void setDoAbs(boolean doAbs) %7B%0A        this.doAbs = doAbs;%0A    
 %7D%0A%09%0A

allow class to turn into a thin wrapper after construction