root/trunk/matml/src/sphlow/PlotSpecial.java

Revision 148, 2.9 kB (checked in by powell, 7 years ago)

New Sphlow Java applet.

  • Property svn:keywords set to Author Date Id Revision
Line 
1// This is the thing that makes the big plots on the left side.
2
3import java.awt.*;
4
5public class PlotSpecial extends Panel {
6  private Plot dRhoPlot; public PlotPanel pp;
7  public double deltarho, dmax, curvelocities[]={0,0,0,0,0,0,0,0,0,0};
8  private int points[]={0,0,0,0,0,0,0,0,0,0};
9  boolean curveExists[]={true,false,false,false,false,false,false,false,false,
10                         false};
11
12public void init() {
13  setLayout(new BorderLayout());
14
15  dRhoPlot=new Plot(); add("Center",dRhoPlot); dRhoPlot.init();
16  dRhoPlot.setTitle("Velocity Contours"); dRhoPlot.setGrid(true);
17  dRhoPlot.setNumSets(10); dRhoPlot.setMarksStyle("none");
18  dRhoPlot.setXLabel("Sphere Density"); dRhoPlot.setYLabel("Diameter");
19
20  dRhoPlot.addPoint(0,pp.rho,0,false); dRhoPlot.addPoint(0,pp.rho,dmax,true);
21  /* drawPlot(1,pp.u); */ }
22
23private void _drawPlot(int curvenum, double u) {
24  if(curvenum<1||curvenum>9) return;
25  if(curveExists[curvenum]) {                   // Erase old curve if it exists
26    for(int i=0;i<points[curvenum];i++)
27      dRhoPlot.erasePoint(curvenum,0);
28    points[curvenum]=0; }
29
30  curvelocities[curvenum]=u;                            // Draw new right curve
31  double rhomin=pp.rho+u*u*u*pp.rho*pp.rho/800000/pp.mu/pp.g;
32  double rhomax=pp.rho+deltarho;
33  if(rhomin-pp.rho<=deltarho) {
34    if(rhomax-pp.rho>deltarho) rhomax=pp.rho+deltarho;
35    boolean first=false; for(int i=0; i<=100; i++) {
36      double newrho=rhomin+i*Math.abs(rhomax-rhomin)/100.;
37      double Re=pp.dc.rerat(pp.dc.free(newrho,u));
38      if(Re>0&&(Re*=pp.mu/pp.rho/u)<=dmax) {
39        dRhoPlot.addPoint(curvenum,newrho,Re,first);
40        points[curvenum]++; first=true; }}}
41
42  rhomax=pp.rho-u*u*u*pp.rho*pp.rho/800000/pp.mu/pp.g;
43  rhomin=Math.max(pp.rho-deltarho,0);
44  if(pp.rho-rhomax<=deltarho && rhomax>0) {
45    boolean first=false; for(int i=0; i<=100; i++) {     // Draw new left curve
46      double newrho=rhomin+i*Math.abs(rhomax-rhomin)/100.;
47      double Re=pp.dc.rerat(pp.dc.free(newrho,u));
48      if(Re>0&&(Re*=pp.mu/pp.rho/u)<=dmax) {
49        dRhoPlot.addPoint(curvenum,newrho,Re,first);
50        points[curvenum]++; first=true; }}}
51
52  dRhoPlot.setXRange(Math.max(pp.rho-deltarho,0), pp.rho+deltarho);
53  dRhoPlot.setYRange(0,dmax);
54  curveExists[curvenum]=true; }
55
56public void drawPlot(int curvenum, double u) {
57  _drawPlot(curvenum, u); dRhoPlot.drawPlot(true); }
58
59public void redoAllPlots() {
60  dRhoPlot.erasePoint(0,0); dRhoPlot.erasePoint(0,0);
61  dRhoPlot.addPoint(0,pp.rho,0,false); dRhoPlot.addPoint(0,pp.rho,dmax,true);
62  for(int i=1; i<10; i++)
63    if(curveExists[i]) _drawPlot(i, curvelocities[i]);
64  dRhoPlot.drawPlot(true); }
65
66public void changedRho(double newdRho) {
67  deltarho=newdRho; redoAllPlots(); }
68
69public void changeDmax(double newDmax) {
70  dmax=newDmax; redoAllPlots(); }
71
72public PlotSpecial(PlotPanel fff) {
73  pp=fff; deltarho=Math.abs(pp.rho_p-pp.rho);
74  dmax=100000*pp.mu/pp.rho/pp.u; }
75
76public void paint(Graphics g) { dRhoPlot.paint(g); }}
Note: See TracBrowser for help on using the browser.