if (PiecewiseUtilities.compare(previousMax, q) != 0) { Range valueRange = RangeFactory.create(previousMax, true, q, false);
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof LinearColorMap)) return false; final LinearColorMap that = (LinearColorMap) o; if (!PiecewiseUtilities.equals(name, that.name)) return false; if (!PiecewiseUtilities.equals(defaultColor, that.defaultColor)) return false; if (preFilteringColor != that.preFilteringColor) return false; if (!PiecewiseUtilities.equals(preFilteringElements, that.preFilteringElements)) return false; if (!PiecewiseUtilities.equals(standardElements, that.standardElements)) return false; return piecewise.equals(that.piecewise); }
@Override public int hashCode() { if (hashCode >= 0) return hashCode; hashCode = 37; hashCode = PiecewiseUtilities.hash(name, hashCode); hashCode = PiecewiseUtilities.hash(defaultColor, hashCode); hashCode = PiecewiseUtilities.hash(preFilteringColor, hashCode); hashCode = PiecewiseUtilities.hash(preFilteringElements, hashCode); hashCode = PiecewiseUtilities.hash(standardElements, hashCode); hashCode = PiecewiseUtilities.hash(piecewise, hashCode); return hashCode; } }
@Override public int hashCode() { if (hashCode < 0) { int result = PiecewiseUtilities.deepHashCode(elements); result = PiecewiseUtilities.deepHashCode(minimums); result = PiecewiseUtilities.hash(getName(), result); hashCode = PiecewiseUtilities.hash(getApproximateDomainRange(), hashCode); } return hashCode; } }
final double minSource = doubleValue(sType, sourceRange.getMin(), sMinInc); final double maxSource = doubleValue(sType, sourceRange.getMax(), sMaxInc); final double minDestination = doubleValue(dType, destinationRange.getMin(), dMinInc); final double maxDestination = doubleValue(dType, destinationRange.getMax(), dMaxInc); if (PiecewiseUtilities.compare(minDestination, maxDestination) == 0) return SingleDimensionTransformation.create(0, minDestination); if (PiecewiseUtilities.compare(minSource, maxSource) == 0) throw new IllegalArgumentException("Impossible to map a single value to a range."); scale = 0; final double offset = minDestination - scale * minSource; return createLinearTransform1D(scale, offset);
PiecewiseUtilities.ensureNonNull("DomainElement1D[]", inDomainElements); if (PiecewiseUtilities.compare(inMinimum, previous.getInputMaximum()) <= 0) { PiecewiseUtilities.domainElementsOverlap(elements, i); assert PiecewiseUtilities.isSorted(elements);
"t0", RangeFactory.create(0.0, true, 1.0, true), PiecewiseUtilities.createLinearTransform1D( RangeFactory.create(0.0, true, 1.0, true), RangeFactory.create(200, 201)));
/** * Public constructor for building a {@link DomainElement1D} which applies the specified transformation on the values that fall into its * definition range. * * @param name for this {@link DomainElement1D}. * @param valueRange for this {@link DomainElement1D}. * @param transform for this {@link DomainElement1D}. * @throws IllegalArgumentException */ public DefaultPiecewiseTransform1DElement(CharSequence name, Range valueRange, final MathTransformation transform) throws IllegalArgumentException { super(name, valueRange); // ///////////////////////////////////////////////////////////////////// // // Initial checks // // ///////////////////////////////////////////////////////////////////// PiecewiseUtilities.ensureNonNull("transform", transform); this.transform = transform; }
PiecewiseUtilities.ensureNonNull("name", name); PiecewiseUtilities.ensureNonNull("range", inputRange); inputMinimumInf = true; } else this.inputMinimum = PiecewiseUtilities.doubleValue(type, inputRange.getMin() .doubleValue(), minInc ? 0 : +1); if (Double.isInfinite(tempMax)) { inputMaximumInf = true; } else this.inputMaximum = PiecewiseUtilities.doubleValue(type, inputRange.getMax() .doubleValue(), maxInc ? 0 : -1);
/** * @param sample * @return */ private int getDomainElementIndex(final double sample) { int i = -1; // Special 'binarySearch' for NaN i = PiecewiseUtilities.binarySearch(minimums, sample); if (i >= 0) { // The value is exactly equals to one of minimum, // or is one of NaN values. There is nothing else to do. assert Double.doubleToRawLongBits(sample) == Double.doubleToRawLongBits(minimums[i]); return i; } assert i == Arrays.binarySearch(minimums, sample) : i; // 'binarySearch' found the index of "insertion point" (-(insertion // point) - 1). The // insertion point is defined as the point at which the key would be // inserted into the list: the index of the first element greater than // the key, or list.size(), if all elements in the list are less than // the specified key. Note that this guarantees that the return value // will be >= 0 if and only if the key is found. i = -i - 1; return i; }
final double minSource = doubleValue(sType, sourceRange.getMin(), sMinInc); final double maxSource = doubleValue(sType, sourceRange.getMax(), sMaxInc); final double minDestination = doubleValue(dType, destinationRange.getMin(), dMinInc); final double maxDestination = doubleValue(dType, destinationRange.getMax(), dMaxInc); if (PiecewiseUtilities.compare(minDestination, maxDestination) == 0) return SingleDimensionTransformation.create(0, minDestination); if (PiecewiseUtilities.compare(minSource, maxSource) == 0) throw new IllegalArgumentException("Impossible to map a single value to a range."); scale = 0; final double offset = minDestination - scale * minSource; return createLinearTransform1D(scale, offset);
PiecewiseUtilities.ensureNonNull("DomainElement1D[]", inDomainElements); if (PiecewiseUtilities.compare(inMinimum, previous.getInputMaximum()) <= 0) { PiecewiseUtilities.domainElementsOverlap(elements, i); assert PiecewiseUtilities.isSorted(elements);
PiecewiseUtilities.createLinearTransform1D( RangeFactory.create(0.0, true, 1.0, true, false), RangeFactory.create(200, true, 201, true)));
@Override public int hashCode() { if (hashCode < 0) { int result = PiecewiseUtilities.deepHashCode(elements); result = PiecewiseUtilities.deepHashCode(minimums); result = PiecewiseUtilities.hash(getName(), result); hashCode = PiecewiseUtilities.hash(getApproximateDomainRange(), hashCode); } return hashCode; } }
/** * Public constructor for building a {@link DomainElement1D} which applies the specified transformation on the values that fall into its * definition range. * * @param name for this {@link DomainElement1D}. * @param valueRange for this {@link DomainElement1D}. * @param transform for this {@link DomainElement1D}. * @throws IllegalArgumentException */ public DefaultPiecewiseTransform1DElement(CharSequence name, Range valueRange, final MathTransformation transform) throws IllegalArgumentException { super(name, valueRange); // ///////////////////////////////////////////////////////////////////// // // Initial checks // // ///////////////////////////////////////////////////////////////////// PiecewiseUtilities.ensureNonNull("transform", transform); this.transform = transform; }
PiecewiseUtilities.ensureNonNull("name", name); PiecewiseUtilities.ensureNonNull("range", inputRange); inputMinimumInf = true; } else this.inputMinimum = PiecewiseUtilities.doubleValue(type, inputRange.getMin() .doubleValue(), minInc ? 0 : +1); if (Double.isInfinite(tempMax)) { inputMaximumInf = true; } else this.inputMaximum = PiecewiseUtilities.doubleValue(type, inputRange.getMax() .doubleValue(), maxInc ? 0 : -1);
/** * @param sample * @return */ private int getDomainElementIndex(final double sample) { int i = -1; // Special 'binarySearch' for NaN i = PiecewiseUtilities.binarySearch(minimums, sample); if (i >= 0) { // The value is exactly equals to one of minimum, // or is one of NaN values. There is nothing else to do. assert Double.doubleToRawLongBits(sample) == Double.doubleToRawLongBits(minimums[i]); return i; } assert i == Arrays.binarySearch(minimums, sample) : i; // 'binarySearch' found the index of "insertion point" (-(insertion // point) - 1). The // insertion point is defined as the point at which the key would be // inserted into the list: the index of the first element greater than // the key, or list.size(), if all elements in the list are less than // the specified key. Note that this guarantees that the return value // will be >= 0 if and only if the key is found. i = -i - 1; return i; }
boolean minInc = outRange.isMinIncluded(); boolean maxInc = outRange.isMaxIncluded(); outputMinimum = PiecewiseUtilities.doubleValue(type, outRange.getMin(), minInc ? 0 : +1); outputMaximum = PiecewiseUtilities.doubleValue(type, outRange.getMax(), maxInc ? 0 : -1); outputMinimumNaN = Double.isNaN(outputMinimum); outputMaximumNaN = Double.isNaN(outputMaximum); final int compareOutBounds = PiecewiseUtilities.compare(outputMinimum, outputMaximum); setTransform(PiecewiseUtilities.createLinearTransform1D(0, outputMinimum)); setInverse(null); return; throw new IllegalArgumentException("Bad range defined"); final MathTransformation transform = PiecewiseUtilities.createLinearTransform1D(inRange, RangeFactory.create(outputMinimum, true, outputMaximum, true, true)); setTransform(transform); final double scale = tempTransform.getScale(); if (Math.abs(scale) < 1E-6) if (PiecewiseUtilities.compare(getInputMaximum(), getInputMinimum()) == 0) setInverse(SingleDimensionTransformation.create(0, getInputMinimum())); else
/** * Returns a hash value for this domain element. This value need not remain consistent between different implementations of the same class. * */ public int hashCode() { if (hashCode >= 0) return hashCode; hashCode = 37; hashCode = PiecewiseUtilities.hash(name, hashCode); hashCode = PiecewiseUtilities.hash(range, hashCode); hashCode = PiecewiseUtilities.hash(inputMaximum, hashCode); hashCode = PiecewiseUtilities.hash(inputMinimum, hashCode); return hashCode; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof LinearColorMap)) return false; final LinearColorMap that = (LinearColorMap) o; if (!PiecewiseUtilities.equals(name, that.name)) return false; if (!PiecewiseUtilities.equals(defaultColor, that.defaultColor)) return false; if (preFilteringColor != that.preFilteringColor) return false; if (!PiecewiseUtilities.equals(preFilteringElements, that.preFilteringElements)) return false; if (!PiecewiseUtilities.equals(standardElements, that.standardElements)) return false; return piecewise.equals(that.piecewise); }