Example #1
0
  /**
   * Returns the hash code for this ScalarMap. If <code>scalarMap1.equals(
   * scalarMap2)</code> is true, then <code>scalarMap1.hashCode() ==
   * scalarMap2.hashCode()</code>.
   *
   * @return The hash code for this ScalarMap.
   */
  public int hashCode() {
    ScalarType s = getScalar();
    DisplayRealType ds = getDisplayScalar();

    int hash = 0;
    if (s != null) {
      if (ds != null) {
        hash = s.hashCode() ^ ds.hashCode();
      } else {
        hash = s.hashCode();
      }
    } else if (ds != null) {
      hash = ds.hashCode();
    }

    return hash;
  }
Example #2
0
 /**
  * Change underscore characters (_) in the Scalar name to blanks. Can be used to change the
  * displayed scalar name on the axis.
  *
  * @param u2b true to change, false to change back
  * @see #setScalarName as an alternative
  */
 public void setUnderscoreToBlank(boolean u2b) {
   underscore_to_blank = u2b;
   if (Scalar != null) {
     scalarName = Scalar.getName();
     if (underscore_to_blank) {
       scalarName = scalarName.replace('_', ' ');
     }
     // set the label on the scale as well.  DRM 17-Nov-2000
     if (axisScale != null) axisScale.setTitle(scalarName);
   }
 }
Example #3
0
 ScalarMap(ScalarType scalar, DisplayRealType display_scalar, boolean needNonNullScalar)
     throws VisADException {
   if (scalar == null && needNonNullScalar) {
     throw new DisplayException("ScalarMap: scalar is null");
   }
   if (display_scalar == null) {
     throw new DisplayException("ScalarMap: display_scalar is null");
   }
   if (display_scalar.equals(Display.List)) {
     throw new DisplayException("ScalarMap: display_scalar may not be List");
   }
   boolean text = display_scalar.getText();
   if (scalar != null) {
     /* WLH 15 June 2000
           if (text && !(scalar instanceof TextType)) {
             throw new DisplayException("ScalarMap: RealType scalar cannot be " +
                                        "used with TextType display_scalar");
           }
     */
     if (!text && !(scalar instanceof RealType)) {
       throw new DisplayException(
           "ScalarMap: TextType scalar cannot be " + "used with RealType display_scalar");
     }
   }
   control = null;
   Scalar = scalar;
   DisplayScalar = display_scalar;
   display = null;
   ScalarIndex = -1;
   DisplayScalarIndex = -1;
   isScaled = DisplayScalar.getRange(displayRange);
   isManual = false;
   dataRange[0] = Double.NaN;
   dataRange[1] = Double.NaN;
   defaultUnitRange[0] = dataRange[0];
   defaultUnitRange[1] = dataRange[1];
   OldTick = Long.MIN_VALUE;
   NewTick = Long.MIN_VALUE + 1;
   tickFlag = false;
   if (Scalar != null) scalarName = Scalar.getName();
   if (DisplayScalar.equals(Display.XAxis)
       || DisplayScalar.equals(Display.YAxis)
       || DisplayScalar.equals(Display.ZAxis)) {
     axisScale = new AxisScale(this);
   }
 }
Example #4
0
 /**
  * Returns a string representation of the ScalarMap with the specified prefix prepended.
  *
  * @param pre prefix to prepend to the representation
  * @return a string that "textually represents" this ScalarMap with <CODE>pre</CODE> prepended.
  */
 public String toString(String pre) {
   return pre + "ScalarMap: " + Scalar.toString() + " -> " + DisplayScalar.toString() + "\n";
 }