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

Revision 148, 2.0 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 PlotPanel extends Panel {
6  public DiamCalculator dc; public double mu, rho, g, rho_p, u;
7  private double oRe=0;
8  private Plot fRePlot; // , dRhoPlot;
9
10public void init() {
11  setLayout(new BorderLayout());
12
13  fRePlot=new Plot(); add("Center",fRePlot); fRePlot.init();
14  fRePlot.setTitle("Friction Factor Graph"); fRePlot.setGrid(true);
15  fRePlot.setNumSets(2); fRePlot.setMarksStyle("none");
16  fRePlot.setXLabel("Reynolds Number"); fRePlot.setYLabel("Friction Factor");
17  fRePlot.setXLog(true);                fRePlot.setYLog(true);
18
19  fRePlot.addPoint(0,.2,120,false);   fRePlot.addPoint(0,.5,50,true);
20  fRePlot.addPoint(0,1,26,true);      fRePlot.addPoint(0,2,14,true);
21  fRePlot.addPoint(0,5,7.1,true);     fRePlot.addPoint(0,10,4.3,true);
22  fRePlot.addPoint(0,20,2.5,true);    fRePlot.addPoint(0,50,1.5,true);
23  fRePlot.addPoint(0,100,1.05,true);  fRePlot.addPoint(0,200,.8,true);
24  fRePlot.addPoint(0,500,.56,true);   fRePlot.addPoint(0,1000,.45,true);
25  fRePlot.addPoint(0,2000,.42,true);  fRePlot.addPoint(0,5000,.4,true);
26  fRePlot.addPoint(0,10000,.42,true); fRePlot.addPoint(0,20000,.46,true);
27  fRePlot.addPoint(0,50000,.49,true); fRePlot.addPoint(0,100000,.5,true); }
28
29public PlotPanel(double imu, double irho, double ig, double irp, double iu) {
30  mu=imu; rho=irho; g=ig; rho_p=irp; u=iu; dc=new DiamCalculator(mu,rho,g); }
31
32public void drawLines() {
33  if(oRe>0) {
34    for(int i=0; i<5; i++) fRePlot.erasePoint(1,0); }
35  double orat=dc.free(rho_p,u);
36  if(orat>=5e-6&&orat<600) {
37    oRe=dc.rerat(orat);
38    fRePlot.addPoint(1,oRe,.3,false);
39    fRePlot.addPoint(1,oRe,oRe*orat,true);
40    fRePlot.addPoint(1,.2,oRe*orat,true);
41    fRePlot.addPoint(1,oRe,oRe*orat,false);
42    if(orat>1.5) fRePlot.addPoint(1,.2,.2*orat,true);
43    else fRePlot.addPoint(1,.3/orat,.3,true); }
44  else { oRe=0; if(orat<5e-6) {
45    throw new Error("Reynolds number too large."); }}
46 
47  fRePlot.fillPlot(); }
48
49public void paint(Graphics g) { fRePlot.paint(g); }}
Note: See TracBrowser for help on using the browser.