All Downloads are FREE. Search and download functionalities are using the official Maven repository.

timeBench.data.expression.GranularityContextPredicate Maven / Gradle / Ivy

Go to download

TimeBench, a flexible, easy-to-use, and reusable software library written in Java that provides foundational data structures and algorithms for time- oriented data in Visual Analytics.

The newest version!
package timeBench.data.expression;

import prefuse.data.Tuple;
import prefuse.data.expression.ColumnExpression;
import prefuse.data.expression.ComparisonPredicate;
import prefuse.data.expression.Expression;
import prefuse.data.expression.NumericLiteral;
import timeBench.calendar.Granularity;
import timeBench.data.TemporalElement;

/**
 * Predicate that indicates if a {@link TemporalElement} is of a certain context
 * granularity. Ignores checks granularity id.
 * 
 * @author Rind
 */
public class GranularityContextPredicate extends ComparisonPredicate {

    private Granularity granularity;

    public GranularityContextPredicate(Granularity granularity) {
        super(ComparisonPredicate.EQ, new ColumnExpression(
                TemporalElement.GRANULARITY_CONTEXT_ID), new NumericLiteral(
                granularity.getGranularityContextIdentifier()));

        this.granularity = granularity;
    }

    @Override
    public boolean getBoolean(Tuple t) {
        int tupleGCid = t.getInt(TemporalElement.GRANULARITY_CONTEXT_ID);
        return (granularity.getGranularityContextIdentifier() == tupleGCid);
    }

    @Override
    public void setLeftExpression(Expression e) {
        throw new UnsupportedOperationException("readonly");
    }

    @Override
    public void setRightExpression(Expression e) {
        throw new UnsupportedOperationException("readonly");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy