raimund@3028: package de.intevation.flys.artifacts.model.fixings;
raimund@3028:
raimund@3028: import org.apache.log4j.Logger;
raimund@3028:
raimund@3028: import de.intevation.artifacts.Artifact;
raimund@3028: import de.intevation.artifacts.CallContext;
raimund@3028:
raimund@3035: import de.intevation.flys.utils.KMIndex;
raimund@3035:
raimund@3028: import de.intevation.flys.artifacts.FLYSArtifact;
raimund@3035: import de.intevation.flys.artifacts.FixationArtifactAccess;
raimund@3035:
raimund@3028: import de.intevation.flys.artifacts.model.FacetTypes;
raimund@3028: import de.intevation.flys.artifacts.model.DataFacet;
raimund@3035: import de.intevation.flys.artifacts.model.CalculationResult;
raimund@3028:
raimund@3028: import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
raimund@3028:
raimund@3028:
raimund@3028: /**
raimund@3028: * Facet to show the outliers in a fix calculation.
raimund@3028: *
raimund@3028: * @author Raimund Renkert
raimund@3028: */
raimund@3028: public class FixOutlierFacet
raimund@3028: extends DataFacet
raimund@3028: implements FacetTypes {
raimund@3028:
raimund@3028: /** House logger. */
raimund@3028: private static Logger logger = Logger.getLogger(FixOutlierFacet.class);
raimund@3028:
raimund@3028: /** Trivial Constructor. */
raimund@3028: public FixOutlierFacet() {
raimund@3028: }
raimund@3028:
raimund@3028:
raimund@3028: /**
raimund@3028: * @param name
raimund@3028: */
raimund@3028: public FixOutlierFacet(String description) {
raimund@3028: super(0, FIX_OUTLIER, description, ComputeType.ADVANCE, null, null);
raimund@3028: }
raimund@3028:
raimund@3028:
raimund@3028: /**
raimund@3028: * Returns the data this facet requires.
raimund@3028: *
raimund@3028: * @param artifact the owner artifact.
raimund@3028: * @param context the CallContext (ignored).
raimund@3028: *
raimund@3028: * @return the data.
raimund@3028: */
raimund@3028: @Override
raimund@3028: public Object getData(Artifact artifact, CallContext context) {
raimund@3028: logger.debug("FixOutlierFacet.getData");
raimund@3035:
raimund@3035: if (artifact instanceof FLYSArtifact) {
raimund@3035: FLYSArtifact flys = (FLYSArtifact)artifact;
raimund@3035: FixationArtifactAccess access = new FixationArtifactAccess(flys);
raimund@3035:
raimund@3035: CalculationResult res =
raimund@3035: (CalculationResult) flys.compute(context,
raimund@3035: ComputeType.ADVANCE,
raimund@3035: false);
raimund@3035:
raimund@3035: FixResult result = (FixResult) res.getData();
raimund@3035:
raimund@3035: double km = access.getCurrentKm();
raimund@3035: KMIndex kmQWs = result.getOutliers();
raimund@3035:
raimund@3035: QW[] qws = kmQWs.binarySearch(km).getValue();
raimund@3035: if (qws == null) {
raimund@3035: return null;
raimund@3035: }
raimund@3035: return qws;
raimund@3035: }
raimund@3035: else {
raimund@3035: logger.debug("Not an instance of FixationArtifact.");
raimund@3035: return null;
raimund@3035: }
raimund@3028: }
raimund@3028:
raimund@3028:
raimund@3028: /**
raimund@3028: * Create a deep copy of this Facet.
raimund@3028: * @return a deep copy.
raimund@3028: */
raimund@3028: @Override
raimund@3028: public FixOutlierFacet deepCopy() {
raimund@3028: FixOutlierFacet copy = new FixOutlierFacet();
raimund@3028: copy.set(this);
raimund@3028: return copy;
raimund@3028: }
raimund@3028: }
raimund@3028: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :