Draws this vector field in the given drawing panel. @param panel @param g
(DrawingPanel panel, Graphics g)
| 289 | * @param g |
| 290 | */ |
| 291 | @Override |
| 292 | public void draw(DrawingPanel panel, Graphics g) { |
| 293 | if(!visible||(griddata==null)) { |
| 294 | return; |
| 295 | } |
| 296 | if(grid.isVisible()) { |
| 297 | // grid.setMinMax(xmin, xmax, ymin, ymax); |
| 298 | grid.draw(panel, g); |
| 299 | } |
| 300 | colorMap.checkPallet(panel.getBackground()); |
| 301 | GridData griddata = this.griddata; |
| 302 | double[][][] data = griddata.getData(); |
| 303 | double dx = griddata.getDx(); |
| 304 | double dy = griddata.getDy(); |
| 305 | double left = griddata.getLeft(); |
| 306 | double top = griddata.getTop(); |
| 307 | double aspectRatio = panel.getAspectRatio(); |
| 308 | float arrowLength = (float) Math.abs(panel.getYPixPerUnit()); // arrows will use panel scale |
| 309 | if(scaleArrowToGrid) { // arrows will adjust size to fit grid |
| 310 | arrowLength = Math.max(1, panel.getSize().width/(float) data.length/(float) aspectRatio-1); |
| 311 | arrowLength = Math.min(18, arrowLength*0.72f); |
| 312 | } |
| 313 | switch(arrowType) { |
| 314 | case STROKEDARROW : |
| 315 | vectorpath = createVectorPath(arrowLength); |
| 316 | break; |
| 317 | case FILLEDARROW : |
| 318 | vectorpath = createFilledVectorPath(arrowLength); |
| 319 | break; |
| 320 | default : |
| 321 | vectorpath = createVectorPath(arrowLength); |
| 322 | } |
| 323 | int sgnx = (panel.getXPixPerUnit()<0) ? sgnx = -1 : 1; |
| 324 | int sgny = (panel.getYPixPerUnit()<0) ? sgny = -1 : 1; |
| 325 | double amp = 0, a = 0, b = 0, x = 0, y = 0; |
| 326 | Color background = panel.getBackground(); |
| 327 | for(int i = 0, nx = griddata.getNx(); i<nx; i++) { |
| 328 | for(int j = 0, ny = griddata.getNy(); j<ny; j++) { |
| 329 | if(griddata instanceof GridPointData) { |
| 330 | x = data[i][j][0]; |
| 331 | y = data[i][j][1]; |
| 332 | amp = data[i][j][ampIndex+2]; |
| 333 | a = data[i][j][aIndex+2]; |
| 334 | b = data[i][j][bIndex+2]; |
| 335 | } else if(griddata instanceof ArrayData) { |
| 336 | x = left+i*dx; |
| 337 | y = top+j*dy; |
| 338 | amp = data[ampIndex][i][j]; |
| 339 | a = data[aIndex][i][j]; |
| 340 | b = data[bIndex][i][j]; |
| 341 | } |
| 342 | // start in-line code for speed |
| 343 | Graphics2D g2 = (Graphics2D) g; |
| 344 | Color c = colorMap.doubleToColor(amp); |
| 345 | if(background==c) { |
| 346 | continue; |
| 347 | } |
| 348 | g2.setColor(colorMap.doubleToColor(amp)); |
nothing calls this directly
no test coverage detected