Merge pull request #13 from soupwizard/fix-build-warnings-add-overrides

fix about 100 build warnings by add @Override, couple other warning fixes
This commit is contained in:
plaa 2012-12-15 13:40:05 -08:00
commit 58183fc2b6
33 changed files with 140 additions and 65 deletions

View File

@ -22,6 +22,7 @@ public abstract class AbstractMotorLoader implements MotorLoader {
* This method delegates the reading to the loaded from the Reader using the charset
* returned by {@link #getDefaultCharset()}.
*/
@Override
public List<Motor> load(InputStream stream, String filename) throws IOException {
return load(new InputStreamReader(stream, getDefaultCharset()), filename);
}

View File

@ -19,6 +19,7 @@ public interface MotorLoader extends Loader<Motor> {
* @return a list of motors contained in the file.
* @throws IOException if an I/O exception occurs of the file format is invalid.
*/
@Override
public List<Motor> load(InputStream stream, String filename) throws IOException;
}

View File

@ -98,6 +98,7 @@ class BodyTubeHandler extends BaseHandler<BodyTube> {
*
* @return BULK
*/
@Override
public Material.Type getMaterialType() {
return Material.Type.BULK;
}

View File

@ -187,6 +187,7 @@ class MassObjectHandler extends PositionDependentHandler<MassObject> {
*
* @param position the OpenRocket position
*/
@Override
public void setRelativePosition(RocketComponent.Position position) {
current.setRelativePosition(position);
}

View File

@ -147,6 +147,7 @@ class NoseConeHandler extends BaseHandler<NoseCone> {
*
* @return BULK
*/
@Override
public Material.Type getMaterialType() {
return Material.Type.BULK;
}

View File

@ -113,6 +113,7 @@ class ParachuteHandler extends RecoveryDeviceHandler<Parachute> {
*
* @return a component
*/
@Override
public Parachute getComponent() {
return chute;
}

View File

@ -61,6 +61,7 @@ public abstract class RecoveryDeviceHandler<C extends RecoveryDevice> extends Po
* @param rawDensity the density as specified in the Rocksim design file
* @return a value in OpenRocket SURFACE density units
*/
@Override
protected double computeDensity(RocksimDensityType type, double rawDensity) {
double result;

View File

@ -151,6 +151,7 @@ class TransitionHandler extends BaseHandler<Transition> {
*
* @return BULK
*/
@Override
public Material.Type getMaterialType() {
return Material.Type.BULK;
}

View File

@ -24,10 +24,15 @@ public abstract class TextFieldListener implements ActionListener, FocusListener
public abstract void setText(String text);
@Override
public void actionPerformed(ActionEvent e) {
setText(field.getText());
}
@Override
public void focusGained(FocusEvent e) { }
@Override
public void focusLost(FocusEvent e) {
setText(field.getText());
}

View File

@ -60,6 +60,7 @@ public class ColorChooser extends JPanel {
final JButton button = new JButton(COLOR_CHOOSER_BUTTON_LABEL);
ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed (ActionEvent actionEvent) {
chooser.updateUI();
@ -71,6 +72,7 @@ public class ColorChooser extends JPanel {
// Wait until current event dispatching completes before showing
// dialog
Runnable showDialog = new Runnable() {
@Override
public void run () {
dialog.show();
}
@ -84,6 +86,7 @@ public class ColorChooser extends JPanel {
// Add listener on model to detect changes to selected color
ColorSelectionModel model = chooser.getSelectionModel();
model.addChangeListener(new ChangeListener() {
@Override
public void stateChanged (ChangeEvent evt) {
ColorSelectionModel model = (ColorSelectionModel) evt.getSource();
// Get the new color value

View File

@ -244,10 +244,12 @@ public class UnitSelector extends StyledLabel implements StateChangeListener, Mo
//////// ItemListener handling ////////
@Override
public void addItemListener(ItemListener listener) {
itemListeners.add(listener);
}
@Override
public void removeItemListener(ItemListener listener) {
itemListeners.remove(listener);
}
@ -301,6 +303,7 @@ public class UnitSelector extends StyledLabel implements StateChangeListener, Mo
unit = u;
}
@Override
public void actionPerformed(ActionEvent e) {
setSelectedUnit(unit);
}
@ -316,23 +319,28 @@ public class UnitSelector extends StyledLabel implements StateChangeListener, Mo
//////// Mouse handling ////////
@Override
public void mouseClicked(MouseEvent e) {
if (unitGroup.getUnitCount() > 1)
popup();
}
@Override
public void mouseEntered(MouseEvent e) {
if (unitGroup.getUnitCount() > 1)
setBorder(withinBorder);
}
@Override
public void mouseExited(MouseEvent e) {
setBorder(normalBorder);
}
@Override
public void mousePressed(MouseEvent e) {
} // Ignore
@Override
public void mouseReleased(MouseEvent e) {
} // Ignore

View File

@ -461,6 +461,7 @@ public class ComponentAnalysisDialog extends JDialog implements ChangeListener {
//Close button
button = new JButton(trans.get("dlg.but.close"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ComponentAnalysisDialog.this.dispose();
}

View File

@ -29,6 +29,7 @@ public abstract class Caret implements FigureElement {
/**
* Paints the caret to the Graphics2D element.
*/
@Override
public void paint(Graphics2D g2, double scale) {
Area caret = getCaret();
AffineTransform t = new AffineTransform(1.0/scale, 0, 0, 1.0/scale, x, y);
@ -39,6 +40,7 @@ public abstract class Caret implements FigureElement {
}
@Override
public void paint(Graphics2D g2, double scale, Rectangle visible) {
throw new UnsupportedOperationException("paint() with rectangle unsupported.");
}

View File

@ -188,6 +188,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
viewport.addChangeListener(new ChangeListener() {
private int oldWidth = -1;
@Override
public void stateChanged(ChangeEvent e) {
Dimension d = ComponentAddButtons.this.viewport.getExtentSize();
if (d.width != oldWidth) {
@ -356,6 +357,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
* Updates the enabled status of the button.
* TODO: LOW: What about updates to the rocket tree?
*/
@Override
public void valueChanged(TreeSelectionEvent e) {
updateEnabled();
}

View File

@ -148,16 +148,22 @@ public class ComponentIcons {
icons[0] = new ImageIcon(bi, desc);
// Create disabled icon
if (false) { // Fade using alpha
boolean useAlphaFade = false; // don't use fade to alpha yet
if (useAlphaFade) { // Fade using alpha
int rgb[] = bi2.getRGB(0, 0, bi2.getWidth(), bi2.getHeight(), null, 0, bi2.getWidth());
for (int i = 0; i < rgb.length; i++) {
final int alpha = (rgb[i] >> 24) & 0xFF;
rgb[i] = (rgb[i] & 0xFFFFFF) | (alpha / 3) << 24;
//rgb[i] = (rgb[i]&0xFFFFFF) | ((rgb[i]>>1)&0x3F000000);
}
bi2.setRGB(0, 0, bi2.getWidth(), bi2.getHeight(), rgb, 0, bi2.getWidth());
/* TODO This code to do fade using alpha had been dead code inside a "if (false) {" block.
* Eclipse would give a build warning about dead code, so this code has been commented out
* but left here for future use; am assuming it was dead code because it wasn't working correctly
* but that it will be useful in the future.
*/
// int rgb[] = bi2.getRGB(0, 0, bi2.getWidth(), bi2.getHeight(), null, 0, bi2.getWidth());
// for (int i = 0; i < rgb.length; i++) {
// final int alpha = (rgb[i] >> 24) & 0xFF;
// rgb[i] = (rgb[i] & 0xFFFFFF) | (alpha / 3) << 24;
//
// //rgb[i] = (rgb[i]&0xFFFFFF) | ((rgb[i]>>1)&0x3F000000);
// }
// bi2.setRGB(0, 0, bi2.getWidth(), bi2.getHeight(), rgb, 0, bi2.getWidth());
} else { // Raster alpha

View File

@ -34,6 +34,7 @@ public final class MRUDesignFileAction extends JMenu {
parent = theParent;
MRUDesignFile opts = MRUDesignFile.getInstance();
opts.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!evt.getPropertyName().equals(MRUDesignFile.MRU_FILE_LIST_PROPERTY)) {
return;
@ -68,6 +69,7 @@ public final class MRUDesignFileAction extends JMenu {
*/
private Action createAction(String file) {
Action action = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (BasicFrame.open(new File(command), parent)) {

View File

@ -276,6 +276,7 @@ public class RocketActions {
/////// Action classes
private abstract class RocketAction extends AbstractAction implements ClipboardListener {
@Override
public abstract void clipboardChanged();
}

View File

@ -70,6 +70,7 @@ public class UndoRedoAction extends AbstractAction implements UndoRedoListener {
// Set all the values correctly (name and enabled/disabled status)
@Override
public void setAllValues() {
String name, desc;
boolean actionEnabled;

View File

@ -145,6 +145,7 @@ public class ButtonColumn extends AbstractCellEditor
//
// Implement TableCellRenderer interface
//
@Override
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
@ -194,6 +195,7 @@ public class ButtonColumn extends AbstractCellEditor
/*
* The button has been pressed. Stop editing and invoke the custom Action
*/
@Override
public void actionPerformed(ActionEvent e)
{
int row = table.convertRowIndexToModel( table.getEditingRow() );
@ -216,6 +218,7 @@ public class ButtonColumn extends AbstractCellEditor
* the mouse to another cell before releasing it, the editor is still
* active. Make sure editing is stopped when the mouse is released.
*/
@Override
public void mousePressed(MouseEvent e)
{
if (table.isEditing()
@ -223,6 +226,7 @@ public class ButtonColumn extends AbstractCellEditor
isButtonColumnEditor = true;
}
@Override
public void mouseReleased(MouseEvent e)
{
if (isButtonColumnEditor
@ -232,7 +236,12 @@ public class ButtonColumn extends AbstractCellEditor
isButtonColumnEditor = false;
}
@Override
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
}

View File

@ -107,6 +107,7 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
add(scrollPane, "cell 0 0 6 1,grow");
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JTable target = (JTable) e.getSource();
int selectedColumn = table.getColumnModel().getColumnIndexAtX(target.getSelectedColumn());
@ -200,6 +201,7 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
JMenuItem mntmExit = new JMenuItem("Close");
mnFile.add(mntmExit);
mntmExit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
Window w = SwingUtilities.getWindowAncestor(ComponentPresetEditor.this);
w.dispose();
@ -303,6 +305,7 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
associated.clear();
}
@Override
public void removeRow(int row) {
super.removeRow(row);
associated.remove(row);
@ -312,6 +315,7 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
return associated.get(row);
}
@Override
public boolean isCellEditable(int rowIndex, int mColIndex) {
return false;
}
@ -375,8 +379,9 @@ public class ComponentPresetEditor extends JPanel implements PresetResultListene
}
}
catch (Exception e) {
String fileName = (file == null) ? "(file is null, can't get name)" : file.getName();
JOptionPane.showMessageDialog(ComponentPresetEditor.this, "Unable to open OpenRocket component file: " +
file.getName() + " Invalid format. " + e.getMessage());
fileName + " Invalid format. " + e.getMessage());
editContext.setOpenedFile(null);
editContext.setEditingSelected(false);
return false;

View File

@ -25,6 +25,7 @@ public class ImagePreviewPanel extends JPanel
bg = getBackground();
}
@Override
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
@ -42,15 +43,18 @@ public class ImagePreviewPanel extends JPanel
* Make reasonably sure we have an image format that AWT can
* handle so we don't try to draw something silly.
*/
if ((name != null) &&
name.toLowerCase().endsWith(".jpg") ||
name.toLowerCase().endsWith(".jpeg") ||
name.toLowerCase().endsWith(".gif") ||
name.toLowerCase().endsWith(".png")) {
icon = new ImageIcon(name);
image = icon.getImage();
scaleImage();
repaint();
if (name != null) {
String nameLower = name.toLowerCase();
if (nameLower.endsWith(".jpg") ||
nameLower.endsWith(".jpeg") ||
nameLower.endsWith(".gif") ||
nameLower.endsWith(".png")) {
icon = new ImageIcon(name);
image = icon.getImage();
scaleImage();
repaint();
}
}
}
}
@ -86,6 +90,7 @@ public class ImagePreviewPanel extends JPanel
image = image.getScaledInstance(width, height, Image.SCALE_DEFAULT);
}
@Override
public void paintComponent(Graphics g) {
g.setColor(bg);

View File

@ -8,52 +8,52 @@ package net.sf.openrocket.gui.print;
*/
public enum PrintUnit {
FOOT {
public double toInches(double d) { return d*12; }
public double toMillis(double d) { return d/FEET_PER_MM; }
public double toCentis(double d) { return d/(FEET_PER_MM*TEN); }
public double toMeters(double d) { return d/(FEET_PER_MM*TEN*TEN*TEN); }
public double toPoints(double d) { return (d * POINTS_PER_INCH * 12); }
public double convert(double d, PrintUnit u) { return u.toInches(d)/12; }
@Override public double toInches(double d) { return d*12; }
@Override public double toMillis(double d) { return d/FEET_PER_MM; }
@Override public double toCentis(double d) { return d/(FEET_PER_MM*TEN); }
@Override public double toMeters(double d) { return d/(FEET_PER_MM*TEN*TEN*TEN); }
@Override public double toPoints(double d) { return (d * POINTS_PER_INCH * 12); }
@Override public double convert(double d, PrintUnit u) { return u.toInches(d)/12; }
},
INCHES {
public double toInches(double d) { return d; }
public double toMillis(double d) { return d/INCHES_PER_MM; }
public double toCentis(double d) { return d/(INCHES_PER_MM*TEN); }
public double toMeters(double d) { return d/(INCHES_PER_MM*TEN*TEN*TEN); }
public double toPoints(double d) { return (d * POINTS_PER_INCH); }
public double convert(double d, PrintUnit u) { return u.toInches(d); }
@Override public double toInches(double d) { return d; }
@Override public double toMillis(double d) { return d/INCHES_PER_MM; }
@Override public double toCentis(double d) { return d/(INCHES_PER_MM*TEN); }
@Override public double toMeters(double d) { return d/(INCHES_PER_MM*TEN*TEN*TEN); }
@Override public double toPoints(double d) { return (d * POINTS_PER_INCH); }
@Override public double convert(double d, PrintUnit u) { return u.toInches(d); }
},
MILLIMETERS {
public double toInches(double d) { return d * INCHES_PER_MM; }
public double toMillis(double d) { return d; }
public double toCentis(double d) { return d/TEN; }
public double toMeters(double d) { return d/(TEN*TEN*TEN); }
public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
public double convert(double d, PrintUnit u) { return u.toMillis(d); }
@Override public double toInches(double d) { return d * INCHES_PER_MM; }
@Override public double toMillis(double d) { return d; }
@Override public double toCentis(double d) { return d/TEN; }
@Override public double toMeters(double d) { return d/(TEN*TEN*TEN); }
@Override public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
@Override public double convert(double d, PrintUnit u) { return u.toMillis(d); }
},
CENTIMETERS {
public double toInches(double d) { return d * INCHES_PER_MM * TEN; }
public double toMillis(double d) { return d * TEN; }
public double toCentis(double d) { return d; }
public double toMeters(double d) { return d/(TEN*TEN); }
public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
public double convert(double d, PrintUnit u) { return u.toCentis(d); }
@Override public double toInches(double d) { return d * INCHES_PER_MM * TEN; }
@Override public double toMillis(double d) { return d * TEN; }
@Override public double toCentis(double d) { return d; }
@Override public double toMeters(double d) { return d/(TEN*TEN); }
@Override public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
@Override public double convert(double d, PrintUnit u) { return u.toCentis(d); }
},
METERS {
public double toInches(double d) { return d * INCHES_PER_MM * TEN * TEN * TEN; }
public double toMillis(double d) { return d * TEN * TEN * TEN; }
public double toCentis(double d) { return d * TEN * TEN; }
public double toMeters(double d) { return d; }
public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
public double convert(double d, PrintUnit u) { return u.toMeters(d); }
@Override public double toInches(double d) { return d * INCHES_PER_MM * TEN * TEN * TEN; }
@Override public double toMillis(double d) { return d * TEN * TEN * TEN; }
@Override public double toCentis(double d) { return d * TEN * TEN; }
@Override public double toMeters(double d) { return d; }
@Override public double toPoints(double d) { return INCHES.toPoints(toInches(d)); }
@Override public double convert(double d, PrintUnit u) { return u.toMeters(d); }
},
POINTS {
public double toInches(double d) { return d/POINTS_PER_INCH; }
public double toMillis(double d) { return d/(POINTS_PER_INCH * INCHES_PER_MM); }
public double toCentis(double d) { return toMillis(d)/TEN; }
public double toMeters(double d) { return toMillis(d)/(TEN*TEN*TEN); }
public double toPoints(double d) { return d; }
public double convert(double d, PrintUnit u) { return u.toPoints(d); }
@Override public double toInches(double d) { return d/POINTS_PER_INCH; }
@Override public double toMillis(double d) { return d/(POINTS_PER_INCH * INCHES_PER_MM); }
@Override public double toCentis(double d) { return toMillis(d)/TEN; }
@Override public double toMeters(double d) { return toMillis(d)/(TEN*TEN*TEN); }
@Override public double toPoints(double d) { return d; }
@Override public double convert(double d, PrintUnit u) { return u.toPoints(d); }
};
// Handy constants for conversion methods

View File

@ -71,6 +71,7 @@ public class CheckBoxNode {
*
* @return the text label
*/
@Override
public String toString () {
return text;
}

View File

@ -103,6 +103,7 @@ public class CheckTreeSelectionModel extends DefaultTreeSelectionModel {
*
* @param pPaths an array of paths
*/
@Override
public void setSelectionPaths (TreePath[] pPaths) {
TreePath selected[] = getSelectionPaths();
for (TreePath aSelected : selected) {
@ -118,6 +119,7 @@ public class CheckTreeSelectionModel extends DefaultTreeSelectionModel {
*
* @param paths an array of tree path nodes
*/
@Override
public void addSelectionPaths (TreePath[] paths) {
// deselect all descendants of paths[]
for (TreePath path : paths) {
@ -195,6 +197,7 @@ public class CheckTreeSelectionModel extends DefaultTreeSelectionModel {
*
* @param paths the array of path nodes
*/
@Override
public void removeSelectionPaths (TreePath[] paths) {
for (TreePath path : paths) {
if (path.getPathCount() == 1) {

View File

@ -43,6 +43,7 @@ public class Rule extends PrintableComponent {
*
* @param g the opaque graphics context
*/
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;

View File

@ -13,6 +13,7 @@ public abstract class InterpolatingAtmosphericModel implements AtmosphericModel
private AtmosphericConditions[] levels = null;
@Override
public AtmosphericConditions getConditions(double altitude) {
if (levels == null)
computeLayers();

View File

@ -106,5 +106,6 @@ public interface SimulationModifier extends ChangeSource {
* another rocket instance (e.g. the same modification on another rocket component that
* has the same component ID).
*/
@Override
public boolean equals(Object obj);
}

View File

@ -395,6 +395,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
}
@Deprecated
@Override
public int getMotorCount() {
return 1;

View File

@ -52,6 +52,7 @@ public class EventQueue extends PriorityQueue<FlightEvent> implements Monitorabl
return super.remove(o);
}
@Override
public int getModID() {
return modID;
}

View File

@ -67,5 +67,6 @@ public interface SimulationComputationListener extends SimulationListener {
public double postSimpleThrustCalculation(SimulationStatus status, double thrust) throws SimulationException;
@Override
public FlightDataType[] getFlightDataTypes();
}

View File

@ -26,6 +26,7 @@ public class DampingMoment extends AbstractSimulationListener {
private static final FlightDataType type = FlightDataType.getType("Damping moment coefficient", "Cdm", UnitGroup.UNITS_COEFFICIENT);
private static final FlightDataType[] typeList = {type};
@Override
public String getName(){
return "Damping moment listener";
}
@ -33,6 +34,7 @@ public class DampingMoment extends AbstractSimulationListener {
/**
* Return a list of any flight data types this listener creates.
*/
@Override
public FlightDataType[] getFlightDataTypes(){
return typeList;
}

View File

@ -42,15 +42,16 @@ public class SerializeMotors {
if (iterator == null) {
System.out.println("Can't find resources-src/thrustcurves directory");
System.exit(1);
}
while (iterator.hasNext()) {
Pair<String, InputStream> f = iterator.next();
String fileName = f.getU();
InputStream is = f.getV();
List<Motor> motors = loader.load(is, fileName);
allMotors.addAll(motors);
} else {
while (iterator.hasNext()) {
Pair<String, InputStream> f = iterator.next();
String fileName = f.getU();
InputStream is = f.getV();
List<Motor> motors = loader.load(is, fileName);
allMotors.addAll(motors);
}
}
oos.writeObject(allMotors);

View File

@ -16,18 +16,22 @@ public class FixedUnitGroup extends UnitGroup {
this.unitString = unitString;
}
@Override
public int getUnitCount(){
return 1;
}
@Override
public Unit getDefaultUnit(){
return new GeneralUnit(1, unitString);
}
@Override
public Unit getSIUnit(){
return new GeneralUnit(1, unitString);
}
@Override
public boolean contains(Unit u){
return true;
}