/** ensure that non-Manual components of flow_tuple have equal dataRanges symmetric about 0.0 */ public static void equalizeFlow(Vector mapVector, DisplayTupleType flow_tuple) throws VisADException, RemoteException { double[] range = new double[2]; double low = Double.MAX_VALUE; double hi = -Double.MAX_VALUE; boolean anyAuto = false; Enumeration maps = mapVector.elements(); while (maps.hasMoreElements()) { ScalarMap map = ((ScalarMap) maps.nextElement()); DisplayRealType dtype = map.getDisplayScalar(); DisplayTupleType tuple = dtype.getTuple(); if (flow_tuple.equals(tuple) && !map.isManual && !map.badRange()) { anyAuto = true; low = Math.min(low, map.dataRange[0]); hi = Math.max(hi, map.dataRange[1]); } } if (!anyAuto) return; hi = Math.max(hi, -low); low = -hi; maps = mapVector.elements(); while (maps.hasMoreElements()) { ScalarMap map = ((ScalarMap) maps.nextElement()); DisplayRealType dtype = map.getDisplayScalar(); DisplayTupleType tuple = dtype.getTuple(); if (flow_tuple.equals(tuple) && !map.isManual && !map.badRange()) { map.setRange(null, low, hi, false); } } }
/** * Return <CODE>true</CODE> if <CODE>type</CODE> is legal for this <CODE>DisplayRenderer</CODE>; * for example, 2-D <CODE>DisplayRenderer</CODE>s use this to disallow mappings to <I>ZAxis</I> * and <I>Latitude</I>. * * @param type The mapping type to check. * @return <CODE>true</CODE> if <CODE>type</CODE> is legal. */ public boolean legalDisplayScalar(DisplayRealType type) { // First check to see if it is a member of the default list for (int i = 0; i < Display.DisplayRealArray.length; i++) { if (Display.DisplayRealArray[i].equals(type)) return true; } // if we get here, it's not one of the defaults. See if it has // a CS that transforms to a default that we know how to handle if (type.getTuple() != null && type.getTuple().getCoordinateSystem() != null) { RealTupleType ref = type.getTuple().getCoordinateSystem().getReference(); if (ref.equals(Display.DisplaySpatialCartesianTuple) || ref.equals(Display.DisplayRGBTuple) || ref.equals(Display.DisplayFlow1Tuple) || ref.equals(Display.DisplayFlow2Tuple)) return true; } return false; }
/** * Set <CODE>Vector</CODE> of <CODE>String</CODE>s describing the cursor location from the cursor * location; this is invoked when the cursor location changes or the cursor display status changes */ public void setCursorStringVector() { synchronized (cursorStringVector) { cursorStringVector.removeAllElements(); float[][] cursor = new float[3][1]; double[] cur = getCursor(); cursor[0][0] = (float) cur[0]; cursor[1][0] = (float) cur[1]; cursor[2][0] = (float) cur[2]; Enumeration maps = display.getMapVector().elements(); while (maps.hasMoreElements()) { try { ScalarMap map = (ScalarMap) maps.nextElement(); DisplayRealType dreal = map.getDisplayScalar(); DisplayTupleType tuple = dreal.getTuple(); int index = dreal.getTupleIndex(); if (tuple != null && (tuple.equals(Display.DisplaySpatialCartesianTuple) || (tuple.getCoordinateSystem() != null && tuple .getCoordinateSystem() .getReference() .equals(Display.DisplaySpatialCartesianTuple)))) { float[] fval = new float[1]; if (tuple.equals(Display.DisplaySpatialCartesianTuple)) { fval[0] = cursor[index][0]; } else { float[][] new_cursor = tuple.getCoordinateSystem().fromReference(cursor); fval[0] = new_cursor[index][0]; } float[] dval = map.inverseScaleValues(fval); RealType real = (RealType) map.getScalar(); // WLH 31 Aug 2000 Real r = new Real(real, dval[0]); Unit overrideUnit = map.getOverrideUnit(); Unit rtunit = real.getDefaultUnit(); // units not part of Time string // DRM 2003-08-19: don't check for equality since toString // may be different if (overrideUnit != null && // !overrideUnit.equals(rtunit) && (!Unit.canConvert(rtunit, CommonUnit.secondsSinceTheEpoch) || rtunit.getAbsoluteUnit().equals(rtunit))) { dval[0] = (float) overrideUnit.toThis((double) dval[0], rtunit); r = new Real(real, dval[0], overrideUnit); } String valueString = r.toValueString(); // WLH 27 Oct 2000 String s = map.getScalarName() + " = " + valueString; // String s = real.getName() + " = " + valueString; cursorStringVector.addElement(s); } // end if (tuple != null && ...) } catch (VisADException e) { } } // end while(maps.hasMoreElements()) } // end synchronized (cursorStringVector) render_trigger(); }
/** check for flow mappings; does not allow flow mapping through CoordinateSystem */ private String findFlow( ShadowTupleType shadow, DisplayImpl display, DisplayTupleType[] tuples, int[] flowToComponent) { ShadowRealType[] components = shadow.getRealComponents(); for (int i = 0; i < components.length; i++) { int num_flow_per_real = 0; Enumeration maps = components[i].getSelectedMapVector().elements(); while (maps.hasMoreElements()) { ScalarMap map = (ScalarMap) maps.nextElement(); DisplayRealType dreal = map.getDisplayScalar(); DisplayTupleType tuple = dreal.getTuple(); if (Display.DisplayFlow1Tuple.equals(tuple) || Display.DisplayFlow2Tuple.equals(tuple)) { if (tuples[0] != null) { if (!tuples[0].equals(tuple)) { return multipleFlowTuples; } } else { tuples[0] = tuple; } num_flow_per_real++; if (num_flow_per_real > 1) { return multipleFlowMapping; } int index = dreal.getTupleIndex(); flowToComponent[index] = i; directMap[index] = map; } else if (Display.DisplayFlow1SphericalTuple.equals(tuple) || Display.DisplayFlow2SphericalTuple.equals(tuple)) { if (tuples[0] != null) { if (!tuples[0].equals(tuple)) { return multipleFlowTuples; } } else { tuples[0] = tuple; coord = tuple.getCoordinateSystem(); } num_flow_per_real++; if (num_flow_per_real > 1) { return multipleFlowMapping; } int index = dreal.getTupleIndex(); flowToComponent[index] = i; directMap[index] = map; } } // while (maps.hasMoreElements()) } return null; }