Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code smells clean up #132

Open
wants to merge 4 commits into
base: sf-auto-merge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/net/sf/freecol/client/control/ConnectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ public boolean logout(LogoutReason reason) {
switch (reason) {
case DEFEATED: case QUIT:
fcc.logout(false);
SwingUtilities.invokeLater(() -> {
mainTitle();
});
SwingUtilities.invokeLater(this::mainTitle);
break;
case LOGIN: // Occurs when you Open a new game during a current one
fcc.logout(false);
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/control/InGameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public final class InGameController extends FreeColClientHolder {
* Selecting next unit depends on mode--- either from the active list,
* from the going-to list, or flush going-to and end the turn.
*/
private static enum MoveMode {
private enum MoveMode {
NEXT_ACTIVE_UNIT,
EXECUTE_GOTO_ORDERS,
END_TURN;
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/FontLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class FontLibrary {
* <li>HEADER -- a stylized old-fashioned typeface for headers</li>
* </ul>
*/
public static enum FontType {
public enum FontType {
NORMAL,
SIMPLE,
HEADER
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public enum ViewMode {
};

/** Levels (danger, finance) for confirmEuropeanTribute(). */
private static final String levels[] = { "low", "normal", "high" };
private static final String[] levels = { "low", "normal", "high" };


/**
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/SwingGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
public class SwingGUI extends GUI {

/** A rough position to place dialogs and panels on the canvas. */
public static enum PopupPosition {
public enum PopupPosition {
ORIGIN,
CENTERED,
CENTERED_LEFT,
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/action/ColopediaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ColopediaAction extends FreeColAction {
public static final String id = "colopediaAction.";

// Order of elements will influence ingame order of menu items.
public static enum PanelType {
public enum PanelType {
TERRAIN, RESOURCES, GOODS, UNITS,
BUILDINGS, FATHERS, NATIONS,
NATION_TYPES, CONCEPTS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class DisplayTileTextAction extends SelectableAction {
public static final String id = "displayTileTextAction.";

// FIXME: make ClientOptions use enum
public static enum DisplayText {
public enum DisplayText {
EMPTY, NAMES, OWNERS, REGIONS;

public String getKey() {
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/animation/Animations.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class Animations {
* used as a callback for an animation to trigger painting.
*/
public interface Procedure {
public void execute();
};
void execute();
}

/**
* Collect animations for a unit move.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void setMirrored(boolean mirror) {
* @param direction The preferred {@code Direction}.
* @return A list of {@code Direction}s.
*/
private synchronized static List<Direction> trialDirections(Direction direction) {
private static synchronized List<Direction> trialDirections(Direction direction) {
if (alternatives.isEmpty()) { // Populate first time
// Favour the closest E-W cases
for (Direction d : Direction.allDirections) {
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/dialog/Flag.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public UnionShape getUnionShape() {
public Set<UnionPosition> getUnionPositions() {
return this.unionPositions;
}
};
}

/**
* The shape of the "union", which generally depends on the
Expand All @@ -135,7 +135,7 @@ public enum UnionShape {
CHEVRON,
BEND,
RHOMBUS
};
}

/**
* The position of the "union", which depends on the alignment of
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/dialog/FreeColDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public class FreeColDialog<T> extends JDialog implements PropertyChangeListener

private static final Logger logger = Logger.getLogger(FreeColDialog.class.getName());

public static enum DialogType {
public enum DialogType {
PLAIN,
QUESTION,
};
}

/** The enclosing client. */
protected final FreeColClient freeColClient;
Expand Down
8 changes: 4 additions & 4 deletions src/net/sf/freecol/client/gui/dialog/NegotiationDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public GoodsTradeItemPanel(Player source, List<Goods> allGoods) {
super(new MigLayout("wrap 1", "", ""));

this.source = source;
this.goodsBox = new JComboBox<>(new DefaultComboBoxModel<Goods>());
this.goodsBox = new JComboBox<>(new DefaultComboBoxModel<>());
this.goodsBox.setRenderer(new GoodsBoxRenderer());
this.clearButton = Utility.localizedButton("negotiationDialog.clear");
this.clearButton.addActionListener(this);
Expand Down Expand Up @@ -494,7 +494,7 @@ public InciteTradeItemPanel(Player source, Player other) {

this.source = source;
this.other = other;
this.victimBox = new JComboBox<>(new DefaultComboBoxModel<Player>());
this.victimBox = new JComboBox<>(new DefaultComboBoxModel<>());
this.victimBox.setRenderer(new InciteBoxRenderer());
this.clearButton = Utility.localizedButton("negotiationDialog.clear");
this.clearButton.addActionListener(this);
Expand Down Expand Up @@ -615,7 +615,7 @@ public StanceTradeItemPanel(Player source, Player target) {

this.source = source;
this.target = target;
this.stanceBox = new JComboBox<>(new DefaultComboBoxModel<Stance>());
this.stanceBox = new JComboBox<>(new DefaultComboBoxModel<>());
this.stanceBox.setRenderer(new StanceBoxRenderer());
this.clearButton = Utility.localizedButton("negotiationDialog.clear");
this.clearButton.addActionListener(this);
Expand Down Expand Up @@ -733,7 +733,7 @@ public UnitTradeItemPanel(Player source, List<Unit> allUnits) {
super(new MigLayout("wrap 1", "", ""));

this.source = source;
this.unitBox = new JComboBox<>(new DefaultComboBoxModel<Unit>());
this.unitBox = new JComboBox<>(new DefaultComboBoxModel<>());
this.unitBox.setRenderer(new UnitBoxRenderer());
this.clearButton = Utility.localizedButton("negotiationDialog.clear");
this.clearButton.addActionListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private ImageResource getTerrainOrBeachImageResource(Tile tile, final Tile borde
return null;
}
final ImageResource terrainImageResource;
final boolean notABeachTransition = borderingTile.isLand() || !borderingTile.isLand() && !tile.isLand();;
final boolean notABeachTransition = borderingTile.isLand() || !borderingTile.isLand() && !tile.isLand();
if (notABeachTransition) {
terrainImageResource = ImageCache.getImageResource(ImageLibrary.getTerrainImageKey(borderingTile.getType()));
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/label/CargoLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface CargoLabel {
* @param cargoPanel The CargoPanel to affect.
* @return True if the component was added.
*/
public boolean addCargo(Component comp, Unit carrier, CargoPanel cargoPanel);
boolean addCargo(Component comp, Unit carrier, CargoPanel cargoPanel);


/**
Expand All @@ -47,7 +47,7 @@ public interface CargoLabel {
* @param comp The Component to remove.
* @param cargoPanel The {@link CargoPanel} to affect.
*/
public default void removeCargo(Component comp, CargoPanel cargoPanel) {
default void removeCargo(Component comp, CargoPanel cargoPanel) {
cargoPanel.update();
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/label/Draggable.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public interface Draggable {
*
* @return True if the object is on a carrier.
*/
public boolean isOnCarrier();
boolean isOnCarrier();
}
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/mapviewer/MapViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final class MapViewer extends FreeColClientHolder {

private static final Logger logger = Logger.getLogger(MapViewer.class.getName());

private static enum BorderType { COUNTRY, REGION }
private enum BorderType { COUNTRY, REGION }

/**
* Calculates what part of the {@link Map} is visible on screen. This includes handling
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/menu/InGameMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void paintComponent(Graphics g) {
final FontMetrics fm = g2d.getFontMetrics();
final Rectangle2D d = fm.getStringBounds(text, g2d);
final int textWidth = (int) d.getWidth();
final int textHeight = (int) d.getHeight();;
final int textHeight = (int) d.getHeight();

final int rightSidePaddingInPx = 10;
final int centerHeight = getHeight() - getInsets().bottom;
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/option/OptionGroupUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String convertValueToText(Object value, boolean selected,
Option option = (Option)node.getUserObject();
return Messages.getName(option.getId());
}
};
}

private final List<OptionUpdater> optionUpdaters = new ArrayList<>();

Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/option/OptionUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public interface OptionUpdater {
* Updates the value of the {@link net.sf.freecol.common.option.Option}
* this object keeps.
*/
public void updateOption();
void updateOption();

/**
* Reset with the value from the option.
*/
public void reset();
void reset();

}
3 changes: 1 addition & 2 deletions src/net/sf/freecol/client/gui/panel/ColonyPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,7 @@ public void update() {
*/
@Override
public JToolTip createToolTip() {
JToolTip toolTip = new RebelToolTip(getFreeColClient(), getColony());
return toolTip;
return new RebelToolTip(getFreeColClient(), getColony());
}


Expand Down
10 changes: 5 additions & 5 deletions src/net/sf/freecol/client/gui/panel/DropTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface DropTarget {
* @param goods The {@code Goods} to check.
* @return True if the goods are acceptable.
*/
public default boolean accepts(Goods goods) {
default boolean accepts(Goods goods) {
return false;
}

Expand All @@ -44,7 +44,7 @@ public default boolean accepts(Goods goods) {
* @param goodsType The {@code GoodsType} to check.
* @return True if the goods type is acceptable.
*/
public default boolean accepts(GoodsType goodsType) {
default boolean accepts(GoodsType goodsType) {
return false;
}

Expand All @@ -54,7 +54,7 @@ public default boolean accepts(GoodsType goodsType) {
* @param unit The {@code Unit} to check.
* @return True if the unit is acceptable.
*/
public default boolean accepts(Unit unit) {
default boolean accepts(Unit unit) {
return false;
}

Expand All @@ -71,7 +71,7 @@ public default boolean accepts(Unit unit) {
* currently selected carrier.
* @return The component argument on success, null on failure.
*/
public Component add(Component comp, boolean editState);
Component add(Component comp, boolean editState);

/**
* Get a suggested amount of goods to add, used when partial
Expand All @@ -80,7 +80,7 @@ public default boolean accepts(Unit unit) {
* @param goodsType The {@code GoodsType} proposed to add.
* @return A good amount of goods to add.
*/
public default int suggested(GoodsType goodsType) {
default int suggested(GoodsType goodsType) {
return -1; // Not applicable
}
}
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/panel/EuropePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public void logSale(GoodsType goodsType, int amount,
}


public static enum EuropeAction {
public enum EuropeAction {
EXIT,
RECRUIT,
PURCHASE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void setLabelValues(JLabel label, Settlement value) {
}
}

private static enum DisplayListOption {
private enum DisplayListOption {
ALL,
ONLY_NATIVES,
ONLY_EUROPEAN
Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/panel/FreeColImageBorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ private BufferedImage getImage(String key) {
return image;
}
final Dimension scaledDimensions = new Dimension(
(int) Math.round(image.getWidth() * scaleFactor),
(int) Math.round(image.getHeight() * scaleFactor)
Math.round(image.getWidth() * scaleFactor),
Math.round(image.getHeight() * scaleFactor)
);
return ir.getImage(scaledDimensions, false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/panel/InfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class InfoPanel extends FreeColPanel
private static final Logger logger = Logger.getLogger(InfoPanel.class.getName());


private static enum InfoPanelMode {
private enum InfoPanelMode {
NONE, END, MAP, TILE, UNIT;
}

Expand Down
3 changes: 1 addition & 2 deletions src/net/sf/freecol/client/gui/panel/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public MainPanel(FreeColClient freeColClient) {
}

private JButton createImportantButton(Action action) {
final FreeColButton button = new FreeColButton(ButtonStyle.IMPORTANT, action);
return button;
return new FreeColButton(ButtonStyle.IMPORTANT, action);
}


Expand Down
4 changes: 2 additions & 2 deletions src/net/sf/freecol/client/gui/panel/NewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public final class NewPanel extends FreeColPanel implements ItemListener {
private static final Logger logger = Logger.getLogger(NewPanel.class.getName());

/** The actions for this panel. */
private static enum NewPanelAction {
private enum NewPanelAction {
OK,
CANCEL,
SINGLE,
JOIN,
START,
META_SERVER,
SHOW_DIFFICULTY
};
}

/**
* A particular specification to use for the new game. If not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public interface ColopediaDetailPanel<T> {
*
* @param root a {@code DefaultMutableTreeNode}
*/
public void addSubTrees(DefaultMutableTreeNode root);
void addSubTrees(DefaultMutableTreeNode root);

/**
* Builds the details panel for the given identifier.
*
* @param id The object identifier to display.
* @param panel the detail panel to build
*/
public void buildDetail(String id, JPanel panel);
void buildDetail(String id, JPanel panel);

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public final class ReportCompactColonyPanel extends ReportPanel {
private static class ColonySummary {

/** Types of production for a given goods type. */
public static enum ProductionStatus {
public enum ProductionStatus {
FAIL, // Negative production and below low alarm level
BAD, // Negative production
NONE, // No production at all
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/plaf/FreeColLookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ColorUIResource getMenuDisabledForeground() {
private static final String transparentPanelUI
= "net.sf.freecol.client.gui.plaf.FreeColTransparentPanelUI";

private static final Class uiClasses[] = {
private static final Class[] uiClasses = {
FreeColButtonUI.class,
FreeColCheckBoxUI.class,
FreeColComboBoxUI.class,
Expand Down
2 changes: 1 addition & 1 deletion src/net/sf/freecol/client/gui/video/VideoListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public interface VideoListener {
/**
* Called when a playback has stopped.
*/
public void stopped();
void stopped();
}
2 changes: 1 addition & 1 deletion src/net/sf/freecol/common/ObjectWithId.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public interface ObjectWithId {
*
* @return The object identifier.
*/
public String getId();
String getId();
}
Loading