//
// ShadowBarbRealTupleTypeJ2D.java
//

/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad.bom;

import visad.*;
import visad.java2d.*;

import java.rmi.*;

/**
   The ShadowBarbRealTupleTypeJ2D class shadows the RealTupleType class
   for BarbManipulationRendererJ2D and BarbRendererJ2D, within a
   DataDisplayLink, under Java2D.

*/ public class ShadowBarbRealTupleTypeJ2D extends ShadowRealTupleTypeJ2D { public ShadowBarbRealTupleTypeJ2D(MathType t, DataDisplayLink link, ShadowType parent) throws VisADException, RemoteException { super(t, link, parent); } public VisADGeometryArray[] makeFlow(int which, float[][] flow_values, float flowScale, float arrowScale, float[][] spatial_values, byte[][] color_values, boolean[][] range_select) throws VisADException { DataRenderer renderer = getLink().getRenderer(); boolean direct = renderer.getIsDirectManipulation(); if (direct && renderer instanceof BarbManipulationRendererJ2D) { return ShadowBarbRealTupleTypeJ2D.staticMakeFlow(getDisplay(), which, flow_values, flowScale, spatial_values, color_values, range_select, renderer, true); } else { return ShadowBarbRealTupleTypeJ2D.staticMakeFlow(getDisplay(), which, flow_values, flowScale, spatial_values, color_values, range_select, renderer, false); } } private static final int NUM = 512; public static VisADGeometryArray[] staticMakeFlow(DisplayImpl display, int which, float[][] flow_values, float flowScale, float[][] spatial_values, byte[][] color_values, boolean[][] range_select, DataRenderer renderer, boolean direct) throws VisADException { if (flow_values[0] == null) return null; if (spatial_values[0] == null) return null; int len = spatial_values[0].length; int flen = flow_values[0].length; int rlen = 0; // number of non-missing values if (range_select[0] == null) { rlen = len; } else { for (int j=0; j vx.length) { float[] cx = vx; float[] cy = vy; int l = 2 * vx.length; vx = new float[l]; vy = new float[l]; System.arraycopy(cx, 0, vx, 0, cx.length); System.arraycopy(cy, 0, vy, 0, cy.length); if (color_values != null) { byte[] cred = vred; byte[] cgreen = vgreen; byte[] cblue = vblue; byte[] calpha = valpha; vred = new byte[l]; vgreen = new byte[l]; vblue = new byte[l]; if (calpha != null) valpha = new byte[l]; System.arraycopy(cred, 0, vred, 0, cred.length); System.arraycopy(cgreen, 0, vgreen, 0, cgreen.length); System.arraycopy(cblue, 0, vblue, 0, cblue.length); if (calpha != null) System.arraycopy(calpha, 0, valpha, 0, calpha.length); } } if (numt[0] + NUM/2 > tx.length) { float[] cx = tx; float[] cy = ty; int l = 2 * tx.length; tx = new float[l]; ty = new float[l]; System.arraycopy(cx, 0, tx, 0, cx.length); System.arraycopy(cy, 0, ty, 0, cy.length); if (color_values != null) { byte[] cred = tred; byte[] cgreen = tgreen; byte[] cblue = tblue; byte[] calpha = talpha; tred = new byte[l]; tgreen = new byte[l]; tblue = new byte[l]; if (calpha != null) talpha = new byte[l]; System.arraycopy(cred, 0, tred, 0, cred.length); System.arraycopy(cgreen, 0, tgreen, 0, cgreen.length); System.arraycopy(cblue, 0, tblue, 0, cblue.length); if (calpha != null) System.arraycopy(calpha, 0, talpha, 0, talpha.length); } } int oldnv = numv[0]; int oldnt = numt[0]; float mbarb[] = makeBarb(south[j], spatial_values[0][j], spatial_values[1][j], scale, pt_size, f0, f1, vx, vy, numv, tx, ty, numt, renderer); if (direct) { ((BarbManipulationRendererJ2D) renderer). setVectorSpatialValues(mbarb, which); } int nv = numv[0]; int nt = numt[0]; if (color_values != null) { if (color_values[0].length > 1) { for (int i=oldnv; i 0) { tarray = new VisADTriangleArray(); tarray.vertexCount = nt; coordinates = new float[3 * nt]; // float[][] normals = new float[3 * nt]; // not used in Java2D m = 0; for (int i=0; i= 2.5) { wsp25 = (float) Math.max(wnd_spd + 2.5, 5.0); slant = 0.15f * scale; barb = 0.4f * scale; // WLH 6 Aug 99 - barbs point the other way (duh) x0 = -f0 / wnd_spd; y0 = -f1 / wnd_spd; //plot the flag pole // lengthen to 'd = 3.0f * barb' // was 'd = barb' in original BOM code d = 3.0f * barb; x1 = (x +x0*d); y1 = (y +y0*d); /* // commented out in original BOM code vx[nv] = x; vy[nv] = y; nv++; vx[nv] = x1; vy[nv] = y1; nv++; // g.drawLine(x,y,x1,y1); */ //determine number of wind barbs needed for 10 and 50 kt winds nbarb50 = (int)(wsp25/50.f); nbarb10 = (int)((wsp25 - (nbarb50 * 50.f))/10.f); nbarb5 = (int)((wsp25 - (nbarb50 * 50.f) - (nbarb10 * 10.f))/5.f); //2.5 to 7.5 kt winds are plotted with the barb part way done the pole if (nbarb5 == 1) { barb = barb * 0.4f; slant = slant * 0.4f; x1 = (x + x0 * d); y1 = (y + y0 * d); if (south) { x2 = (x + x0 * (d + slant) - y0 * barb); y2 = (y + y0 * (d + slant) + x0 * barb); } else { x2 = (x + x0 * (d + slant) + y0 * barb); y2 = (y + y0 * (d + slant) - x0 * barb); } vx[nv] = x1; vy[nv] = y1; nv++; vx[nv] = x2; vy[nv] = y2; nv++; // System.out.println("barb5 " + x1 + " " + y1 + "" + x2 + " " + y2); // g.drawLine(x1, y1, x2, y2); } //add a little more pole if (wsp25 >= 5.0f && wsp25 < 10.0f) { d = d + 0.125f * scale; x1=(x + x0 * d); y1=(y + y0 * d); /* WLH 24 April 99 vx[nv] = x; vy[nv] = y; nv++; vx[nv] = x1; vy[nv] = y1; nv++; */ // System.out.println("wsp25 " + x + " " + y + "" + x1 + " " + y1); // g.drawLine(x, y, x1, y1); } //now plot any 10 kt wind barbs barb = 0.4f * scale; slant = 0.15f * scale; for (int j=0; j 0) { d = d +0.125f * scale; x1 = (x + x0 * d); y1 = (y + y0 * d); /* WLH 24 April 99 vx[nv] = x; vy[nv] = y; nv++; vx[nv] = x1; vy[nv] = y1; nv++; */ // System.out.println("line50 " + x + " " + y + "" + x1 + " " + y1); // g.drawLine(x,y,x1,y1); } //plot the 50 kt wind barbs /* WLH 5 Nov 99 s195 = (float) Math.sin(195 * Data.DEGREES_TO_RADIANS); c195 = (float) Math.cos(195 * Data.DEGREES_TO_RADIANS); */ for (int j=0; j

Ads help maintain this website.