From: Bill Kuker Date: Mon, 13 Apr 2009 13:42:57 +0000 (+0000) Subject: Cleaned up warnings X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=ef436e7bf837454619b56e9fdd9537a55e643e84;p=sw%2Fmotorsim Cleaned up warnings --- diff --git a/src/com/billkuker/rocketry/motorsim/MotorPart.java b/src/com/billkuker/rocketry/motorsim/MotorPart.java index 1bd054e..861145a 100644 --- a/src/com/billkuker/rocketry/motorsim/MotorPart.java +++ b/src/com/billkuker/rocketry/motorsim/MotorPart.java @@ -13,7 +13,6 @@ import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import javax.measure.quantity.Quantity; import javax.measure.unit.Unit; import org.jscience.physics.amount.Amount; @@ -38,54 +37,40 @@ public class MotorPart { vcs = new VetoableChangeSupport(this); vcs.addVetoableChangeListener(new VetoableChangeListener(){ + @SuppressWarnings("unchecked") @Override public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { if ( evt.getNewValue() instanceof Amount ){ - try { - BeanInfo b = Introspector.getBeanInfo(evt.getSource().getClass()); - PropertyDescriptor ps[] = b.getPropertyDescriptors(); - for ( int i = 0; i < ps.length; i++ ){ - if (ps[i].getName().equals(evt.getPropertyName())){ - Type t = ps[i].getReadMethod().getGenericReturnType(); - ParameterizedType p = (ParameterizedType) t; - Class expected = (Class)p.getActualTypeArguments()[0]; - Field f = expected.getDeclaredField("UNIT"); - Unit u = (Unit) f.get(null); - - Amount a = (Amount)evt.getNewValue(); - if (!a.getUnit().isCompatible(u)) - throw new PropertyVetoException(ps[i].getShortDescription() - + " must be in units of " - + expected.getSimpleName(), evt); - - System.out.println("Expected " + expected + " got " + u); + try { + BeanInfo b = Introspector.getBeanInfo(evt.getSource().getClass()); + PropertyDescriptor ps[] = b.getPropertyDescriptors(); + for ( int i = 0; i < ps.length; i++ ){ + if (ps[i].getName().equals(evt.getPropertyName())){ + Type t = ps[i].getReadMethod().getGenericReturnType(); + ParameterizedType p = (ParameterizedType) t; + Class expected = (Class)p.getActualTypeArguments()[0]; + Field f = expected.getDeclaredField("UNIT"); + Unit u = (Unit) f.get(null); + + Amount a = (Amount)evt.getNewValue(); + if (!a.getUnit().isCompatible(u)) + throw new PropertyVetoException(ps[i].getShortDescription() + + " must be in units of " + + expected.getSimpleName(), evt); + + System.out.println("Expected " + expected + " got " + u); + } } + } catch ( PropertyVetoException e ){ + throw e; + } catch (Exception e) { + e.printStackTrace(); } - } catch ( PropertyVetoException e ){ - throw e; - } catch (Exception e) { - e.printStackTrace(); - } } } }); } - public void checkAmount(Amount a, Class q) - throws IllegalArgumentException { - try { - Field f = q.getDeclaredField("UNIT"); - Unit u = (Unit)f.get(null); - - if (!a.getUnit().isCompatible(u)) { - throw new IllegalArgumentException("Value " - + " must be in units of " + q.getSimpleName()); - } - } catch (Exception e) { - throw new Error(e); - } - } - public void addPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(listener); } diff --git a/src/com/billkuker/rocketry/motorsim/visual/Chart.java b/src/com/billkuker/rocketry/motorsim/visual/Chart.java index 0b36d96..09637ba 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/Chart.java +++ b/src/com/billkuker/rocketry/motorsim/visual/Chart.java @@ -122,6 +122,7 @@ public class Chart extends JPanel { } } + @SuppressWarnings("unchecked") public void setDomain(Iterable> d) { //double low = d.low.doubleValue(xUnit); diff --git a/src/com/billkuker/rocketry/motorsim/visual/Editor.java b/src/com/billkuker/rocketry/motorsim/visual/Editor.java index 2c195e0..85b8fd6 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/Editor.java +++ b/src/com/billkuker/rocketry/motorsim/visual/Editor.java @@ -11,19 +11,14 @@ import java.beans.PropertyEditorSupport; import java.lang.reflect.InvocationTargetException; import java.util.Vector; -import javax.measure.unit.NonSI; import javax.measure.unit.Unit; import javax.swing.JFrame; -import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.WindowConstants; import org.apache.log4j.Logger; import org.jscience.physics.amount.Amount; -import com.billkuker.rocketry.motorsim.Grain; -import com.billkuker.rocketry.motorsim.grain.CoredCylindricalGrain; -import com.billkuker.rocketry.motorsim.grain.RodAndTubeGrain; import com.l2fprod.common.propertysheet.PropertySheetPanel; public class Editor extends PropertySheetPanel { @@ -98,6 +93,7 @@ public class Editor extends PropertySheetPanel { return editor.getText(); } + @SuppressWarnings("unchecked") @Override public Object getValue() { String text = editor.getText().trim(); @@ -124,6 +120,7 @@ public class Editor extends PropertySheetPanel { } + @SuppressWarnings("unchecked") @Override public void setValue(Object o) { Amount a = (Amount) o; diff --git a/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java b/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java index cbb48f5..7089ab2 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java +++ b/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java @@ -36,7 +36,6 @@ public class GrainPanel extends JPanel { private Chart area; Chart volume; private XC xc; - private SL sl; private Grain grain; public GrainPanel(Grain g){ @@ -95,7 +94,7 @@ public class GrainPanel extends JPanel { left.add(xc); left.add(l, BorderLayout.NORTH); - left.add( sl = new SL(), BorderLayout.SOUTH); + left.add( new SL(), BorderLayout.SOUTH); add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, charts));