Cleaned up many warnings
authorBill Kuker <bkuker@billkuker.com>
Fri, 7 Aug 2009 01:27:26 +0000 (01:27 +0000)
committerBill Kuker <bkuker@billkuker.com>
Fri, 7 Aug 2009 01:27:26 +0000 (01:27 +0000)
src/QuadTest.java [deleted file]
src/TriTest.java [deleted file]
src/com/billkuker/rocketry/motorsim/Burn.java
src/com/billkuker/rocketry/motorsim/QuantityChecking.aj
src/com/billkuker/rocketry/motorsim/test/MotorIOTest.java
src/com/billkuker/rocketry/motorsim/visual/BurnPanel.java
src/com/billkuker/rocketry/motorsim/visual/CrappyEditor.java
src/com/billkuker/rocketry/motorsim/visual/Editor.java
src/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java
src/com/billkuker/rocketry/motorsim/visual/workbench/WorkbenchTreeModel.java

diff --git a/src/QuadTest.java b/src/QuadTest.java
deleted file mode 100644 (file)
index 76a000c..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-import java.awt.BasicStroke;\r
-import java.awt.Color;\r
-import java.awt.Graphics;\r
-import java.awt.Graphics2D;\r
-import java.awt.Shape;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Area;\r
-import java.awt.geom.FlatteningPathIterator;\r
-import java.awt.geom.GeneralPath;\r
-import java.awt.geom.PathIterator;\r
-\r
-import javax.swing.JFrame;\r
-import javax.swing.JPanel;\r
-\r
-\r
-public class QuadTest extends JPanel {\r
-\r
-\r
-       public void paint(Graphics g){\r
-               super.paint(g);\r
-               Graphics2D g2d = (Graphics2D)g;\r
-\r
-               g2d.scale(30, 30);\r
-\r
-               Area a;\r
-               GeneralPath p;\r
-\r
-               g2d.setStroke(new BasicStroke(.02f));\r
-               \r
-               \r
-               /*\r
-                a = new Area(new Rectangle2D.Double(0,0,1,1));\r
-               //a.transform(AffineTransform.getRotateInstance(Math.PI/4.0));\r
-               g2d.setColor(Color.black);\r
-               g2d.draw(a);\r
-               g2d.setColor(Color.red);\r
-               \r
-               g2d.draw(square( a ));\r
-               System.out.println(\r
-                               yRotatedVolume(a) + ", " +\r
-                               yRotatedSurfaceArea(a) + "\n"\r
-                               );\r
-\r
-               \r
-               a = new Area( new Ellipse2D.Double(2, 5, 4, 4));\r
-               g2d.setColor(Color.black);\r
-               g2d.draw(a);\r
-               g2d.setColor(Color.red);\r
-               \r
-               g2d.draw(square( a ));\r
-               System.out.println(\r
-                               yRotatedVolume(a) + ", " +\r
-                               yRotatedSurfaceArea(a) + "\n"\r
-                               );\r
-               \r
-       \r
-               */\r
-               p = new GeneralPath();\r
-               p.moveTo(0,0);\r
-               p.lineTo(1, 1);\r
-               p.lineTo(0,1);\r
-               p.closePath();\r
-               a = new Area(p);\r
-               g2d.translate(0, 8);\r
-               g2d.setColor(Color.black);\r
-               g2d.draw(a);\r
-               g2d.setColor(Color.red);\r
-               \r
-               g2d.draw(square( a ));\r
-               System.out.println(\r
-                               yRotatedVolume(a) + ", " +\r
-                               yRotatedSurfaceArea(a) + "\n"\r
-                               );\r
-               \r
-               p = new GeneralPath();\r
-               p.moveTo(0,0);\r
-               p.lineTo(2, 2);\r
-               p.lineTo(0,2);\r
-               p.closePath();\r
-               a = new Area(p);\r
-               g2d.translate(0, 2);\r
-               g2d.setColor(Color.black);\r
-               g2d.draw(a);\r
-               g2d.setColor(Color.red);\r
-               \r
-               g2d.draw(square( a ));\r
-               System.out.println(\r
-                               yRotatedVolume(a) + ", " +\r
-                               yRotatedSurfaceArea(a) + "\n"\r
-                               );\r
-\r
-               p = new GeneralPath();\r
-               p.moveTo(0,1);\r
-               p.lineTo(1,1);\r
-               p.lineTo(2, 2);\r
-               p.lineTo(0,2);\r
-               p.closePath();\r
-               a = new Area(p);\r
-               g2d.translate(0, 2);\r
-               g2d.setColor(Color.black);\r
-               g2d.draw(a);\r
-               g2d.setColor(Color.red);\r
-               \r
-               g2d.draw(square( a ));\r
-               System.out.println(\r
-                               yRotatedVolume(a) + ", " +\r
-                               yRotatedSurfaceArea(a) + "\n"\r
-                               );\r
-                \r
-\r
-       }\r
-       \r
-       \r
-       private double yRotatedVolume(Area a){\r
-               return Math.PI * area(new Area(square(a)));\r
-       }\r
-       \r
-       private Shape square(java.awt.geom.Area a) {\r
-               PathIterator i = a.getPathIterator(new AffineTransform(), 0.0001);\r
-               GeneralPath cur = new GeneralPath();\r
-\r
-               double last[] = {0,0};\r
-               while (!i.isDone()) {\r
-                       double coords[] = new double[6];\r
-                       int type = i.currentSegment(coords);\r
-                       switch (type) {\r
-                       case PathIterator.SEG_CLOSE:\r
-                               cur.closePath();\r
-                               break;\r
-                       case PathIterator.SEG_MOVETO:\r
-                               cur.moveTo(Math.pow(coords[0],2), coords[1]);\r
-                               last[0] = coords[0];\r
-                               last[1] = coords[1];\r
-                               break;\r
-                       case PathIterator.SEG_CUBICTO:\r
-                               throw new Error("Non-flattened geometry!");\r
-                       case PathIterator.SEG_LINETO:\r
-                               double x = last[0];\r
-                               double y = last[1];\r
-                               double len = Math.sqrt(Math.pow(last[0]-coords[0], 2) + Math.pow(last[1]-coords[1], 2));\r
-                               int steps = (int)(len / .01) + 5;\r
-                               for (int s = 0; s < steps; s++) {\r
-                                       x += (coords[0] - last[0]) / steps;\r
-                                       y += (coords[1] - last[1]) / steps;\r
-                                       cur.lineTo(Math.pow(x, 2), y);\r
-                               }\r
-                               last[0] = coords[0];\r
-                               last[1] = coords[1];\r
-                               break;\r
-                       case PathIterator.SEG_QUADTO:\r
-                               throw new Error("Non-flattened geometry!");\r
-\r
-                       }\r
-                       i.next();\r
-               }\r
-               return cur;\r
-       }\r
-       \r
-       private double yRotatedSurfaceArea(java.awt.geom.Area a) {\r
-               //TODO: I think I need to handle seg_close!!\r
-               PathIterator i = a.getPathIterator(new AffineTransform(), .001);\r
-               double x = 0, y = 0;\r
-               double mx = 0, my = 0;\r
-               double len = 0;\r
-               while (!i.isDone()) {\r
-                       double coords[] = new double[6];\r
-                       int type = i.currentSegment(coords);\r
-                       if (type == PathIterator.SEG_LINETO || type == PathIterator.SEG_CLOSE) {\r
-\r
-\r
-                               double nx = coords[0];\r
-                               double ny = coords[1];\r
-                               \r
-                               if ( type == PathIterator.SEG_CLOSE ){\r
-                                       nx = mx;\r
-                                       ny = my;\r
-                               }\r
-                               \r
-                               double dy = Math.abs(y-ny);\r
-                               double dx = Math.abs(x-nx);\r
-                               double xl = x>nx?x:nx;\r
-                               double xs = x<nx?x:nx;  \r
-                               \r
-                               double add = 0;\r
-                               if ( dx == 0 ){\r
-                                       add = 2 * Math.PI * xl * dy;\r
-                               } else if ( dy == 0 ){\r
-                                        add = Math.PI * xl * xl - Math.PI * xs * xs;\r
-                               }else{\r
-                                       double h = xl/dx * dy;\r
-                                       double s1 = Math.sqrt(xl*xl + h*h);\r
-                                       double s2 = Math.sqrt(xs*xs + (h-dy)*(h-dy));\r
-                                       add = Math.PI * (xl*s1 - xs*s2);\r
-                               }\r
-                               \r
-                               len += add;\r
-\r
-                               x = nx;\r
-                               y = ny;\r
-                       } else if (type == PathIterator.SEG_MOVETO) {\r
-                               mx = x = coords[0];\r
-                               my = y = coords[1];\r
-                       } else {\r
-                               throw new Error("Non-flattened geometry!");\r
-                       }\r
-                       i.next();\r
-               }\r
-               return len;\r
-       }\r
-       \r
-\r
-       \r
-       private double area(java.awt.geom.Area a) {\r
-               if ( !a.isSingular() )\r
-                       throw new IllegalArgumentException("Can not calculate area of non-singular shape!");\r
-               PathIterator i = a.getPathIterator(new AffineTransform(), .001);\r
-               \r
-               \r
-               double x = 0, y = 0, sx = 0, sy = 0;\r
-               double nx, ny;\r
-               double area = 0;\r
-               while (!i.isDone()) {\r
-                       double coords[] = new double[6];\r
-                       int type = i.currentSegment(coords);\r
-                       switch( type ){\r
-                       case PathIterator.SEG_CLOSE:\r
-                               //Go back to the start\r
-                               nx = sx;\r
-                               ny = sy;\r
-                               area += x * ny;\r
-                               area -= y * nx;\r
-                               break;\r
-                       case PathIterator.SEG_LINETO:\r
-                               nx = coords[0];\r
-                               ny = coords[1];\r
-                               area += x * ny;\r
-                               area -= y * nx;\r
-\r
-                               //Remember the last points\r
-                               x = nx;\r
-                               y = ny;\r
-                               \r
-                               break;\r
-                       case PathIterator.SEG_MOVETO:\r
-                               //Remember the starting point\r
-                               x = sx = coords[0];\r
-                               y = sy = coords[1];\r
-                               break;\r
-                       default:\r
-                               throw new Error("Bad segment type from Flattening Path Iterator");\r
-                       }\r
-                       i.next();\r
-               }\r
-               \r
-               area = area / 2.0; // Result so far is double the signed area\r
-               \r
-               if ( area < 0 ) //Depending on winding it could be negative\r
-                       area = area * -1.0;\r
-               \r
-               \r
-               return area;\r
-       }\r
-\r
-       \r
-       public class FancyPathIterator extends FlatteningPathIterator{\r
-\r
-               public FancyPathIterator(PathIterator path, double error) {\r
-                       super(path, error);\r
-               }\r
-               \r
-               \r
-               \r
-       }\r
-       \r
-       public static void main(String args[]){\r
-               JFrame f = new JFrame();\r
-               f.setContentPane(new QuadTest());\r
-               f.setDefaultCloseOperation(f.DISPOSE_ON_CLOSE);\r
-               f.setSize(1500,800);\r
-               f.setLocation(1600, 100);\r
-               f.show();\r
-       }\r
-}\r
diff --git a/src/TriTest.java b/src/TriTest.java
deleted file mode 100644 (file)
index 11716cf..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-import java.awt.BorderLayout;\r
-import java.awt.Color;\r
-import java.awt.Graphics;\r
-import java.awt.Graphics2D;\r
-import java.awt.Shape;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Area;\r
-import java.awt.geom.Ellipse2D;\r
-import java.awt.geom.GeneralPath;\r
-import java.awt.geom.PathIterator;\r
-\r
-import javax.swing.JFrame;\r
-import javax.swing.JPanel;\r
-import javax.swing.JSlider;\r
-import javax.swing.event.ChangeEvent;\r
-import javax.swing.event.ChangeListener;\r
-\r
-\r
-public class TriTest extends JPanel {\r
-       \r
-       private class RegressableShape {\r
-               private Area a;\r
-               public RegressableShape( Shape s ){\r
-                       if ( s instanceof Area )\r
-                               a = (Area)s;\r
-                       a = new Area(s);\r
-               }\r
-               \r
-               public Area getRegressedShape(double regression){\r
-                       if ( regression == 0 )\r
-                               return a;\r
-                       \r
-                       //Build these separatly because intersecting the line\r
-                       //with the circle creates a small amount of error which\r
-                       //shows up when the resulting edge is no longer exactly\r
-                       //colinear with the original edge.\r
-                       Area rRect = new Area();        \r
-                       Area rCirc = new Area();\r
-                       \r
-                       PathIterator i = a.getPathIterator(new AffineTransform(), .001);\r
-                       double last[] = {0,0};\r
-                       double first[] = {0,0};\r
-\r
-                       while (!i.isDone()) {\r
-                               double coords[] = new double[6];\r
-                               int type = i.currentSegment(coords);\r
-                               switch (type){\r
-                                       case PathIterator.SEG_MOVETO:\r
-                                               first[0] = last[0] = coords[0];\r
-                                               first[1] = last[1] = coords[1];\r
-                                               break;\r
-                                       case PathIterator.SEG_CLOSE:\r
-                                               coords[0] = first[0];\r
-                                               coords[1] = first[1];\r
-                                       case PathIterator.SEG_LINETO:\r
-                                               //Calculate the normal to this edge\r
-                                               double dx = coords[0]-last[0];\r
-                                               double dy = coords[1]-last[1];\r
-                                               double len = Math.sqrt(dx*dx + dy*dy);                                          \r
-                                               double normal[] = {-dy/len,dx/len};\r
-                                               \r
-                                               //Calculate the displacement of the endpoints\r
-                                               //to create a rect\r
-                                               double displacement[] = {regression*normal[0], regression*normal[1]};\r
-\r
-                                               //Create that rect. Winding does not seem to matter...\r
-                                               GeneralPath p = new GeneralPath();\r
-                                               p.moveTo(last[0], last[1]);\r
-                                               p.lineTo(last[0]+displacement[0], last[1]+displacement[1]);\r
-                                               p.lineTo(coords[0]+displacement[0], coords[1]+displacement[1]);\r
-                                               p.lineTo(coords[0], coords[1]);\r
-                                               p.closePath();\r
-                                               rRect.add( new Area(p));\r
-\r
-                                               double er = Math.abs(regression);\r
-                                               rCirc.add(new Area(new Ellipse2D.Double(coords[0]-er, coords[1]-er, 2*er, 2*er)));\r
-                                               \r
-                                               last[0] = coords[0];\r
-                                               last[1] = coords[1];\r
-                                               break;\r
-                                       case PathIterator.SEG_CUBICTO:\r
-                                       case PathIterator.SEG_QUADTO:\r
-                                               throw new Error("Unflattend Geometry!");\r
-                               }\r
-                               i.next();\r
-                       }\r
-                       \r
-\r
-                       if ( regression > 0 ){\r
-                               //Combine all together\r
-                               rRect.add(a);\r
-                               rRect.add(rCirc);\r
-                       }else{\r
-                               Area acp = (Area)a.clone();\r
-                               acp.subtract(rRect);\r
-                               acp.subtract(rCirc);\r
-                               rRect = acp;\r
-                       }\r
-                       return rRect;\r
-               }\r
-       }\r
-       \r
-       double r = 0;\r
-       \r
-       RegressableShape shape;\r
-       {\r
-               GeneralPath p = new GeneralPath();\r
-               p.moveTo(100,100);\r
-               p.lineTo(200, 200);\r
-               p.lineTo(100, 300);\r
-               p.closePath();\r
-               shape = new RegressableShape(p);\r
-       }\r
-       \r
-       @Override\r
-       public void paint(Graphics gg){\r
-               Graphics2D g = (Graphics2D)gg;\r
-               \r
-               g.clearRect(0, 0, 600, 600);\r
-\r
-\r
-               g.setColor(Color.black);\r
-               g.fill(shape.getRegressedShape(r));\r
-               g.setColor(Color.yellow);               \r
-               g.draw(shape.getRegressedShape(0));\r
-               g.setColor(Color.red);\r
-               g.draw(shape.getRegressedShape(r));\r
-\r
-               \r
-       }\r
-       \r
-       \r
-       public static void main( String args[] ){\r
-               JFrame f = new JFrame();\r
-               f.setDefaultCloseOperation(f.DISPOSE_ON_CLOSE);\r
-               final TriTest t = new TriTest();\r
-               f.getContentPane().setLayout(new BorderLayout());\r
-               f.getContentPane().add(t, BorderLayout.CENTER);\r
-               f.getContentPane().add(new JSlider(){{\r
-                               setMinimum(-100);\r
-                               setMaximum(100);\r
-                               addChangeListener(new ChangeListener(){\r
-                                       { setValue(0); }\r
-                                       public void stateChanged(ChangeEvent arg0) {\r
-                                               t.r = getValue();\r
-                                               t.repaint();\r
-                                       }\r
-                               });\r
-                       }}, BorderLayout.SOUTH);\r
-\r
-               f.setSize(400,400);\r
-               f.setLocation(600,600);\r
-               f.show();\r
-               \r
-       }\r
-}\r
index 046dca2f5c66ae1e40b6055df492eb9557d86ce2..ef2474b39d0291e82e9d47f7553c2716a66671ab 100644 (file)
@@ -146,7 +146,7 @@ public class Burn {
                        //log.debug("Mass Gen Rate: " + mGenRate);\r
                        \r
                        //Calculate specific gas constant\r
-                       Amount specificGasConstant = Constants.R.divide(motor.getFuel().getCombustionProduct().getEffectiveMolarWeight());\r
+                       Amount<?> specificGasConstant = Constants.R.divide(motor.getFuel().getCombustionProduct().getEffectiveMolarWeight());\r
                        //This unit conversion helps JScience to convert nozzle flow rate to\r
                        //kg/s a little later on I verified the conversion by hand and\r
                        //JScience checks it too.\r
@@ -162,7 +162,7 @@ public class Burn {
                                Amount<Area> aStar = motor.getNozzle().throatArea();\r
                                double k = motor.getFuel().getCombustionProduct().getRatioOfSpecificHeats();\r
                                double kSide = Math.sqrt(k) * Math.pow((2/(k+1)) , (((k+1)/2)/(k-1)));\r
-                               Amount sqrtPart = specificGasConstant.times(chamberTemp).sqrt();\r
+                               Amount<?> sqrtPart = specificGasConstant.times(chamberTemp).sqrt();\r
                                mNozzle = pDiff.times(aStar).times(kSide).divide(sqrtPart).to(MassFlowRate.UNIT);\r
                                //log.debug("Mass Exit Rate: " + mNozzle.to(MassFlowRate.UNIT));                \r
                        }\r
index a17c5d1a6f55762874922eb6c0bdc9a4e246fa31..50f674b348e7edb70bf659771f3069d2417b2871 100644 (file)
@@ -18,6 +18,7 @@ public aspect QuantityChecking {
 
        declare parents: Motor || Grain || Chamber || Nozzle || Fuel extends Checked;
 
+       @SuppressWarnings("unchecked")
        void around(Checked c, Amount amt):
                execution(void Checked+.set*(Amount)) && target(c) && args(amt) {
                System.out.println(thisJoinPointStaticPart.getSignature().getName()
index d367913c74dbbd1e72e1e0299630346af2438f97..b401bc506ed6d4857ca70b1c268031ab1f1393ea 100644 (file)
@@ -50,7 +50,7 @@ public class MotorIOTest {
 \r
                MotorIO.writeMotor(m, f);\r
 \r
-               Motor r = MotorIO.readMotor(f);\r
+               MotorIO.readMotor(f);\r
 \r
        }\r
 }\r
index 4715257d194c033bb33cc71ee6d9cf1bb5dcd8b4..9f95aeb3ca258e0a3f993aed04231d118e0f6e9e 100644 (file)
@@ -72,6 +72,7 @@ public class BurnPanel extends JPanel {
                        tp.setResizeWeight(.5);\r
                        \r
                        grain = new GrainPanel(burn.getMotor().getGrain()){\r
+                               private static final long serialVersionUID = 1L;\r
                                @Override protected void addComponents(java.awt.Component crossSection, java.awt.Component slider, java.awt.Component label, java.awt.Component area, java.awt.Component volume) {\r
                                        JSplitPane h = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, crossSection, area); \r
                                        add(h, BorderLayout.CENTER);\r
index 1e3038b69edb64bdf5cd9a49093e58027acc139f..c83977cf8fd01374a8159edc0044b0dda241a185 100644 (file)
@@ -33,6 +33,7 @@ import com.billkuker.rocketry.motorsim.motors.example.CSlot;
 import com.billkuker.rocketry.motorsim.motors.example.EndBurner;\r
 \r
 public class CrappyEditor extends JFrame {\r
+       private static final long serialVersionUID = 1L;\r
        JTabbedPane tabs;\r
 \r
        public CrappyEditor() {\r
@@ -52,6 +53,7 @@ public class CrappyEditor extends JFrame {
        }\r
 \r
        private class Editor extends JPanel {\r
+               private static final long serialVersionUID = 1L;\r
                RSyntaxTextArea text = new RSyntaxTextArea();\r
 \r
                Editor(Motor m) {\r
@@ -60,6 +62,7 @@ public class CrappyEditor extends JFrame {
                        JPanel buttons = new JPanel(new FlowLayout());\r
 \r
                        buttons.add(new JButton("Burn!") {\r
+                               private static final long serialVersionUID = 1L;\r
                                {\r
                                        addActionListener(new ActionListener() {\r
                                                public void actionPerformed(ActionEvent arg0) {\r
@@ -89,6 +92,7 @@ public class CrappyEditor extends JFrame {
                        });\r
                        \r
                        buttons.add(new JButton("End Burner Example") {\r
+                               private static final long serialVersionUID = 1L;\r
                                {\r
                                        addActionListener(new ActionListener() {\r
                                                public void actionPerformed(ActionEvent arg0) {\r
@@ -99,6 +103,7 @@ public class CrappyEditor extends JFrame {
                        });\r
                        \r
                        buttons.add(new JButton("C-Slot Example") {\r
+                               private static final long serialVersionUID = 1L;\r
                                {\r
                                        addActionListener(new ActionListener() {\r
                                                public void actionPerformed(ActionEvent arg0) {\r
@@ -163,6 +168,6 @@ public class CrappyEditor extends JFrame {
        \r
 \r
        public static void main(String args[]) {\r
-               new CrappyEditor().show();\r
+               new CrappyEditor().setVisible(true);\r
        }\r
 }\r
index 8de080605944a4747991e4b33a66c5605a9c4faa..9fa90caf2641319bdb3fcac934565e2036aec0b0 100644 (file)
@@ -83,7 +83,7 @@ public class Editor extends PropertySheetPanel {
 \r
        public static class AmountPropertyEditor extends PropertyEditorSupport {\r
                JTextField editor = new JTextField();\r
-               Unit oldUnit;\r
+               Unit<?> oldUnit;\r
 \r
                @Override\r
                public boolean supportsCustomEditor() {\r
index 30614e1261fe72f216b4808b00609a872ef5f46b..f6443545ca034059210535da6c05c641666c1a8f 100644 (file)
@@ -204,6 +204,7 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener {
                        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));\r
 \r
                        p.add(new Chooser<Fuel>(fuelTypes) {\r
+                               private static final long serialVersionUID = 1L;\r
                                @Override\r
                                protected void choiceMade(Fuel o) {\r
                                        motor.setFuel(o);\r
@@ -242,6 +243,7 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener {
                        setRightComponent(new NozzlePanel(n));\r
 \r
                        parts.add(new JTextField(motor.getName()){\r
+                               private static final long serialVersionUID = 1L;\r
                                {\r
                                        final JTextField t = this;\r
                                        addFocusListener(new FocusListener() {\r
index f269f79d9ff96dbd2bf16ca56e1f30e87c3fccd7..b24b0aab0e17e1e486be38987c18f4705efea57d 100644 (file)
@@ -108,6 +108,7 @@ public class WorkbenchTreeModel extends DefaultTreeModel {
                
        }
        
+       @SuppressWarnings("unchecked")
        public void removeMotor(Motor m){
                Enumeration<TreeNode> e = getRoot().children();
                while ( e.hasMoreElements() ){