import java.beans.PropertyChangeSupport;
import java.lang.reflect.Method;
+import org.apache.log4j.Logger;
+
public aspect ChangeListening {
+ private static Logger log = Logger.getLogger(ChangeListening.class);
public interface Subject {
// public void addPropertyChangeListener(PropertyChangeListener l);
}
private PropertyChangeSupport Subject.pcs;
public void Subject.addPropertyChangeListener(PropertyChangeListener l) {
- //System.out.println("PCS Added");
pcs.addPropertyChangeListener(l);
}
public void Subject.removePropertyChangeListener(PropertyChangeListener l) {
- //System.out.println("PCS Removed");
pcs.addPropertyChangeListener(l);
}
void around(Subject s, Object newVal):
execution(void Subject+.set*(..)) && target(s) && args(newVal) {
- System.out.println(s);
String name = thisJoinPointStaticPart.getSignature().getName();
name = name.replaceFirst("set", "");
Object old = null;
old = m.invoke(s);
} catch (Throwable t) {
- System.err.print("Error getting old value for " + name);
+ log.warn("Error getting old value for " + name);
}
proceed(s, newVal);
if (old != newVal) {
- System.out.println(name + " changed from " + old + " to "
- + newVal);
s.pcs.firePropertyChange(name, old, newVal);
}
}
import javax.measure.unit.SI;\r
\r
import org.jscience.physics.amount.Amount;\r
-import com.billkuker.rocketry.motorsim.Validating.ValidationException;\r
\r
public class Motor implements Validating{\r
private Chamber chamber;\r
import javax.measure.unit.Unit;
+import org.apache.log4j.Logger;
import org.jscience.physics.amount.Amount;
public aspect QuantityChecking {
+ private static Logger log = Logger.getLogger(QuantityChecking.class);
public interface Checked {
};
@SuppressWarnings("unchecked")
void around(Checked c, Amount amt):
execution(void Checked+.set*(Amount)) && target(c) && args(amt) {
- System.out.println(thisJoinPointStaticPart.getSignature().getName()
- + " set to " + amt);
try {
BeanInfo b = Introspector.getBeanInfo(c.getClass());
PropertyDescriptor ps[] = b.getPropertyDescriptors();
Amount a = amt;
if (!a.getUnit().isCompatible(u)) {
- System.err.println("Aspect Expected " + expected
+ log.warn("Aspect Expected " + expected
+ " got " + u);
throw new Error(ps[i].getShortDescription()
public interface Validating {
public class ValidationException extends Exception{
+ private static final long serialVersionUID = 1L;
+
public ValidationException(Validating part, String error){
super(error);
}
\r
import javax.measure.quantity.Pressure;\r
\r
+import org.apache.log4j.Logger;\r
import org.jscience.physics.amount.Amount;\r
\r
public abstract class PiecewiseSaintRobertFuel extends SaintRobertFuel {\r
+ \r
+ private static final Logger log = Logger.getLogger(PiecewiseSaintRobertFuel.class);\r
\r
private class Entry{\r
double a;\r
Entry e = entries.get(samplePressure);\r
return e.a;\r
} catch ( NoSuchElementException e ){\r
- System.err.println("Pressure " + pressure + " is outside of expiermental range for " + this.getClass().getSimpleName());\r
+ log.warn("Pressure " + pressure + " is outside of expiermental range for " + this.getClass().getSimpleName());\r
return entries.get(entries.lastKey()).a;\r
}\r
}\r
Entry e = entries.get(samplePressure);\r
return e.n;\r
} catch ( NoSuchElementException e ){\r
- System.err.println("Pressure " + pressure + " is outside of expiermental range for " + this.getClass().getSimpleName());\r
+ log.warn("Pressure " + pressure + " is outside of expiermental range for " + this.getClass().getSimpleName());\r
return entries.get(entries.lastKey()).n;\r
}\r
}\r
import org.jscience.physics.amount.Amount;\r
\r
import com.billkuker.rocketry.motorsim.Validating;\r
-import com.billkuker.rocketry.motorsim.Validating.ValidationException;\r
import com.billkuker.rocketry.motorsim.grain.util.BurningShape;\r
import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;\r
import com.billkuker.rocketry.motorsim.visual.Editor;\r
import org.jscience.physics.amount.Amount;\r
\r
import com.billkuker.rocketry.motorsim.Validating;\r
-import com.billkuker.rocketry.motorsim.Validating.ValidationException;\r
import com.billkuker.rocketry.motorsim.grain.util.BurningShape;\r
import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;\r
import com.billkuker.rocketry.motorsim.visual.Editor;\r
import javax.measure.quantity.Length;\r
import javax.measure.unit.SI;\r
\r
+import org.apache.log4j.Logger;\r
import org.jscience.physics.amount.Amount;\r
\r
public class BurningShape {\r
\r
+ private static final Logger log = Logger.getLogger(BurningShape.class);\r
+ \r
private static class RegressableShape {\r
private Area a;\r
public RegressableShape( Shape s ){\r
\r
} else {\r
RegressableShape r = new RegressableShape(s);\r
- System.err.println("Warning: Complex (non circle / square) geometry slows me down.");\r
+ log.warn("Warning: Complex (non circle / square) geometry slows me down.");\r
return r.getRegressedShape(mm * (plus?-1:1));\r
}\r
\r
double guess;\r
while (true) {\r
guess = min + (max - min) / 2; // Guess halfway through\r
- //System.out.println("Min: " + min + " Guess: " + guess + " Max: "\r
- //+ max);\r
+\r
a = getCrossSection(Amount.valueOf(guess, SI.MILLIMETER));\r
if (a.isEmpty()) {\r
// guess is too big\r
double coords[] = new double[6];\r
int type = i.currentSegment(coords);\r
if (type == PathIterator.SEG_LINETO) {\r
- // System.out.println("Line");\r
double nx = coords[0];\r
double ny = coords[1];\r
- // System.out.println(x+","+y+ " to " + nx+"," + ny);\r
len += Math.sqrt(Math.pow(x - nx, 2) + Math.pow(y - ny, 2));\r
x = nx;\r
y = ny;\r
} else if (type == PathIterator.SEG_MOVETO) {\r
- // System.out.println("Move");\r
x = coords[0];\r
y = coords[1];\r
} else {\r
- // System.err.println("Got " + type);\r
+ \r
}\r
i.next();\r
}\r
Amount<Force> expected = Amount.valueOf(87.2, .1, SI.NEWTON);\r
\r
assertApproximate(t, expected);\r
- \r
- System.out.println(t);\r
}\r
\r
@Test\r
\r
NumberFormat nf = NumberFormat.getInstance();\r
nf.setMaximumFractionDigits(2);\r
- //System.out.println("Time: " + nf.format(displayedTime.doubleValue(SI.SECOND)) + "s");\r
\r
pressure.mark(displayedTime);\r
thrust.mark(displayedTime);\r
import javax.swing.JTextField;\r
import javax.swing.WindowConstants;\r
import javax.swing.table.TableCellRenderer;\r
-import javax.swing.text.TableView.TableCell;\r
\r
import org.apache.log4j.Logger;\r
import org.jscience.physics.amount.Amount;\r
\r
@Override\r
public void setAsText(String text) throws IllegalArgumentException {\r
- System.out.println("Setting text " + text);\r
editor.setText(text);\r
};\r
\r
package com.billkuker.rocketry.motorsim.visual.workbench;\r
\r
import java.awt.BorderLayout;\r
-import java.awt.Dimension;\r
import java.awt.event.ActionEvent;\r
import java.awt.event.ActionListener;\r
import java.awt.event.FocusEvent;\r
import javax.swing.UIManager;\r
import javax.swing.WindowConstants;\r
\r
+import org.apache.log4j.Logger;\r
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;\r
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;\r
import org.jscience.physics.amount.Amount;\r
\r
public class MotorEditor extends JTabbedPane implements PropertyChangeListener {\r
private static final long serialVersionUID = 1L;\r
+ private static Logger log = Logger.getLogger(MotorEditor.class);\r
RSyntaxTextArea text = new RSyntaxTextArea();\r
Motor motor;\r
GrainEditor grainEditor;\r
}\r
});\r
} catch (BurnCanceled c){\r
- System.err.println("Burn Canceled!");\r
+ log.info("Burn Canceled!");\r
} catch (Exception e) {\r
remove(bar);\r
JTextArea t = new JTextArea(e.getMessage());\r
p.add(new Editor(ng), grainEditorIndex);\r
p.remove(0);\r
p.add(new Editor(g), 0);\r
- // System.out.println("Chose new grain");\r
}\r
}\r
});\r
public void focusLost(FocusEvent e) {\r
String n = t.getText();\r
if (!"".equals(n) && !n.equals(motor.getName())) {\r
- System.out.println("Name Changed");\r
motor.setName(n);\r
} else {\r
t.setText(motor.getName());\r
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
-import javax.swing.plaf.multi.MultiButtonUI;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import com.billkuker.rocketry.motorsim.ConvergentDivergentNozzle;
import com.billkuker.rocketry.motorsim.Motor;
import com.billkuker.rocketry.motorsim.RocketScience;
-import com.billkuker.rocketry.motorsim.grain.MultiGrain;
public class MultiBurnChart extends JPanel implements BurnWatcher {
+ private static final long serialVersionUID = 1L;
private XYSeriesCollection dataset = new XYSeriesCollection();
private XYSeries createSeries(Burn b) {
XYSeries s = new XYSeries(b.getMotor().getName());
- Amount<Force> low = Amount.valueOf(1, SI.NEWTON);
for( Burn.Interval i : b.getData().values() ){
s.add(i.time.doubleValue(time), i.thrust.doubleValue(force));
}