VectorPlot renders a vector field in a drawing panel using arrows centered on each grid point in the GridPointData. The default representation of the vector field uses fixed length arrows to show direction and color to show magnitude. @author Wolfgang Christian @version 1.0
| 29 | * @version 1.0 |
| 30 | */ |
| 31 | public class VectorPlot implements Plot2D { |
| 32 | public static final int STROKEDARROW = 0; |
| 33 | public static final int FILLEDARROW = 1; |
| 34 | private GeneralPath vectorpath; |
| 35 | private int arrowType = STROKEDARROW; // draw the arrow with a solid arrowhead |
| 36 | private boolean visible = true; |
| 37 | private GridData griddata; |
| 38 | private boolean autoscaleZ = true; |
| 39 | private boolean scaleArrowToGrid = true; |
| 40 | private VectorColorMapper colorMap; |
| 41 | private int ampIndex = 0; // amplitude index |
| 42 | private int aIndex = 1; // x componnet index |
| 43 | private int bIndex = 2; // y component index |
| 44 | private double xmin, xmax, ymin, ymax; |
| 45 | Grid grid; |
| 46 | |
| 47 | /** |
| 48 | * Constructs a VectorPlot without data. |
| 49 | */ |
| 50 | public VectorPlot() { |
| 51 | this(null); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Constructs a VectorPlot that renders the given grid data. |
| 56 | * |
| 57 | * @param _griddata the data |
| 58 | */ |
| 59 | public VectorPlot(GridData _griddata) { |
| 60 | griddata = _griddata; |
| 61 | colorMap = new VectorColorMapper(256, 1.0); |
| 62 | if(griddata==null) { |
| 63 | return; |
| 64 | } |
| 65 | grid = (griddata.isCellData()) ? new Grid(griddata.getNx(), griddata.getNy()) : new Grid(griddata.getNx()-1, griddata.getNy()-1); |
| 66 | grid.setColor(Color.lightGray); |
| 67 | grid.setVisible(false); |
| 68 | update(); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets closest index from the given x world coordinate. |
| 73 | * |
| 74 | * @param x double the coordinate |
| 75 | * @return int the index |
| 76 | */ |
| 77 | @Override |
| 78 | public int xToIndex(double x) { |
| 79 | return griddata.xToIndex(x); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Gets closest index from the given y world coordinate. |
| 84 | * |
| 85 | * @param y double the coordinate |
| 86 | * @return int the index |
| 87 | */ |
| 88 | @Override |
nothing calls this directly
no outgoing calls
no test coverage detected