/** * Check if we need to show/hide the max data distance box * * @throws RemoteException On badness * @throws VisADException On badness */ public void checkBoxVisibility() throws VisADException, RemoteException { if (maxDistanceBox == null) { return; } if ((maxDataDistance == null) || !super.isVisible()) { maxDistanceBox.setVisible(false); } else { double km = maxDataDistance.getValue(CommonUnit.meter) / 1000.0; if (km > 2000) { maxDistanceBox.setVisible(false); } else { if (control != null) { maxDistanceBox.setVisible(control.shouldBeVisible(this)); } } } }
/** * Set the LineWidth property. * * @param value The new value for LineWidth */ public void setLineWidth(float value) { super.setLineWidth(value); try { if (maxDistanceBox != null) { maxDistanceBox.setLineWidth(value); } } catch (Exception exc) { LogUtil.logException("Setting color", exc); } }
/** * Init at the end * * @return Success * @throws RemoteException On badness * @throws VisADException On badness */ protected boolean initFinalInner() throws VisADException, RemoteException { if (!super.initFinalInner()) { return false; } maxDistanceBox = new LineDrawing("TransectGlyph_" + (typeCnt++)); maxDistanceBox.setLineWidth(getLineWidth()); maxDistanceBox.setColor(getColor()); addDisplayable(maxDistanceBox); if (showText) { startTextType = TextType.getTextType("TransectGlyphText_" + (typeCnt++)); startTextDisplayable = new TextDisplayable("start text_" + (typeCnt++), startTextType); startTextDisplayable.setTextSize(control.getDisplayScale() * 2.0f); endTextType = TextType.getTextType("TransectGlyphText_" + (typeCnt++)); endTextDisplayable = new TextDisplayable("end text_" + (typeCnt++), endTextType); endTextDisplayable.setTextSize(control.getDisplayScale() * 2.0f); addDisplayable(startTextDisplayable); addDisplayable(endTextDisplayable); } return true; }
/** * Invoked when box mouse is released. Subclasses should invoke super.dataChange() to ensure the * the bounds are set. * * @throws RemoteException * @throws VisADException */ protected void dataChange() throws VisADException, RemoteException { bounds = (Gridded2DSet) getData(); /* debug float[] highs = bounds.getHi(); float[] lows = bounds.getLow(); if (highs != null && lows != null) System.out.println("box: X range = " + lows[0] + " to " + highs[0] + "; Y range = " + lows[1] + " to " + highs[1] ); */ super.dataChange(); }
/** * Handle glyph moved * * @throws RemoteException On badness * @throws VisADException On badness */ public void updateLocation() throws VisADException, RemoteException { super.updateLocation(); if (points.size() < 2) { return; } if (showText) { setText(startTextDisplayable, 0, startText, startTextType); setText(endTextDisplayable, 1, endText, endTextType); } checkBoxVisibility(); if ((maxDataDistance == null) || (maxDistanceBox == null)) { return; } double km = maxDataDistance.getValue(CommonUnit.meter) / 1000.0; if (km > 2000) { return; } EarthLocation p1 = (EarthLocation) points.get(0); EarthLocation p2 = (EarthLocation) points.get(1); MathType mathType = RealTupleType.LatitudeLongitudeAltitude; Bearing baseBearing = Bearing.calculateBearing( p1.getLatitude().getValue(), p1.getLongitude().getValue(), p2.getLatitude().getValue(), p2.getLongitude().getValue(), null); double baseAngle = baseBearing.getAngle(); LatLonPointImpl[] llps = new LatLonPointImpl[] { Bearing.findPoint( p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle + 90.0, km, null), Bearing.findPoint( p2.getLatitude().getValue(), p2.getLongitude().getValue(), baseAngle + 90.0, km, null), Bearing.findPoint( p2.getLatitude().getValue(), p2.getLongitude().getValue(), baseAngle - 90, km, null), Bearing.findPoint( p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle - 90, km, null), Bearing.findPoint( p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle + 90.0, km, null) }; float[][] lineVals = getPointValues(); float alt = lineVals[2][0]; lineVals = new float[3][llps.length]; for (int i = 0; i < lineVals[0].length; i++) { lineVals[0][i] = (float) llps[i].getLatitude(); lineVals[1][i] = (float) llps[i].getLongitude(); } float[][] tmp = new float[3][]; for (int i = 0; i < lineVals[0].length - 1; i++) { tmp[0] = Misc.merge( tmp[0], Misc.interpolate( 2 + getNumInterpolationPoints(), lineVals[0][i], lineVals[0][i + 1])); tmp[1] = Misc.merge( tmp[1], Misc.interpolate( 2 + getNumInterpolationPoints(), lineVals[1][i], lineVals[1][i + 1])); } tmp[2] = new float[tmp[0].length]; lineVals = tmp; for (int i = 0; i < lineVals[0].length; i++) { lineVals[2][i] = alt; } Data theData = new Gridded3DSet(mathType, lineVals, lineVals[0].length); maxDistanceBox.setData(theData); }