checkstyle

This commit is contained in:
jendave
2011-11-01 19:12:06 +00:00
parent 0000443ccf
commit f562d07256
26 changed files with 2623 additions and 1506 deletions

View File

@@ -566,10 +566,10 @@ public final class CardRules {
case NAME:
return op(card.getName(), operand);
case SUBTYPE:
shouldConatin = operator == StringOp.CONTAINS || operator == StringOp.EQUALS;
shouldConatin = getOperator() == StringOp.CONTAINS || getOperator() == StringOp.EQUALS;
return shouldConatin == card.getType().subTypeContains(operand);
case RULES:
shouldConatin = operator == StringOp.CONTAINS || operator == StringOp.EQUALS;
shouldConatin = getOperator() == StringOp.CONTAINS || getOperator() == StringOp.EQUALS;
return shouldConatin == card.rulesContain(operand);
case JOINED_TYPE:
return op(card.getType().toString(), operand);

View File

@@ -117,18 +117,18 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
*/
@Override
public final boolean populateCustomPanel() {
this.view.btnRestart.setVisible(false);
this.getView().btnRestart.setVisible(false);
this.model.qData.getCards().resetNewList();
if (!this.model.qMatchState.isMatchOver()) {
this.view.btnQuit.setText("Quit (15 Credits)");
this.getView().btnQuit.setText("Quit (15 Credits)");
return false;
} else {
this.view.btnContinue.setVisible(false);
this.getView().btnContinue.setVisible(false);
if (this.wonMatch) {
this.view.btnQuit.setText("Great!");
this.getView().btnQuit.setText("Great!");
} else {
this.view.btnQuit.setText("OK");
this.getView().btnQuit.setText("OK");
}
}
@@ -371,8 +371,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
this.lblTemp2.setIcon(this.icoTemp);
this.lblTemp2.setIconTextGap(50);
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!");
this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, gaptop 10");
this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!");
this.getView().pnlCustom.add(this.lblTemp2, "align center, width 95%!, gaptop 10");
}
/**
@@ -392,9 +392,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
+ ", gapbottom 10");
this.view.pnlCustom.add(cv, "align center, width 95%!");
this.getView().pnlCustom.add(cv, "align center, width 95%!");
}
/**
@@ -411,9 +411,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
this.lblTemp1 = new TitleLabel("You just won 10 random rares!");
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
+ ", gapbottom 10");
this.view.pnlCustom.add(cv, "align center, width 95%!");
this.getView().pnlCustom.add(cv, "align center, width 95%!");
}
/**
@@ -436,9 +436,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
this.lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!");
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
+ ", gapbottom 10");
this.view.pnlCustom.add(cv, "align center, width 95%!");
this.getView().pnlCustom.add(cv, "align center, width 95%!");
}
/**
@@ -478,12 +478,12 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
this.lblTemp2.setIconTextGap(50);
this.lblTemp2.setIcon(this.icoTemp);
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer);
this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!, gapbottom 10");
this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer);
this.getView().pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!, gapbottom 10");
if (cardsWon != null) {
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
this.view.pnlCustom.add(cv, "align center, width 95%!");
this.getView().pnlCustom.add(cv, "align center, width 95%!");
this.model.qData.getCards().addAllCards(cardsWon);
}
}
@@ -500,8 +500,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
this.lblTemp2.setIconTextGap(50);
this.lblTemp2.setIcon(this.icoTemp);
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!");
this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!");
this.getView().pnlCustom.add(this.lblTemp1, "align center, width 95%!");
this.getView().pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!");
}
/**

View File

@@ -17,40 +17,40 @@ import forge.item.CardPrinted;
public class QuestChallenge extends QuestEvent {
// ID (default -1, should be explicitly set at later time.)
/** The id. */
public int id = -1;
private int id = -1;
// Default vals if none provided for this ID
/** The ai life. */
public int aiLife = 25;
private int aiLife = 25;
/** The credits reward. */
public int creditsReward = 100;
private int creditsReward = 100;
/** The card reward. */
public String cardReward = "1 colorless rare";
private String cardReward = "1 colorless rare";
/** The repeatable. */
public boolean repeatable = false;
private boolean repeatable = false;
/** The wins reqd. */
public int winsReqd = 20;
private int winsReqd = 20;
// Other cards used in assignment: starting, and reward.
/** The human extra cards. */
public List<String> humanExtraCards = new ArrayList<String>();
private List<String> humanExtraCards = new ArrayList<String>();
/** The ai extra cards. */
public List<String> aiExtraCards = new ArrayList<String>();
private List<String> aiExtraCards = new ArrayList<String>();
/** The card reward list. */
public List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
private List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
/**
* Instantiates a new quest challenge.
*/
public QuestChallenge() {
super();
this.eventType = "challenge";
this.setEventType("challenge");
}
/**
@@ -61,7 +61,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Integer}.
*/
public final int getAILife() {
return this.aiLife;
return this.getAiLife();
}
/**
@@ -105,7 +105,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Boolean}.
*/
public final boolean getRepeatable() {
return this.repeatable;
return this.isRepeatable();
}
/**
@@ -128,7 +128,7 @@ public class QuestChallenge extends QuestEvent {
* @return the aI extra cards
*/
public final List<String> getAIExtraCards() {
return this.aiExtraCards;
return this.getAiExtraCards();
}
/**
@@ -153,4 +153,88 @@ public class QuestChallenge extends QuestEvent {
public final List<CardPrinted> getCardRewardList() {
return this.cardRewardList;
}
/**
* @return the aiExtraCards
*/
public List<String> getAiExtraCards() {
return aiExtraCards;
}
/**
* @param aiExtraCards the aiExtraCards to set
*/
public void setAiExtraCards(List<String> aiExtraCards) {
this.aiExtraCards = aiExtraCards; // TODO: Add 0 to parameter's name.
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id; // TODO: Add 0 to parameter's name.
}
/**
* @return the repeatable
*/
public boolean isRepeatable() {
return repeatable;
}
/**
* @param repeatable the repeatable to set
*/
public void setRepeatable(boolean repeatable) {
this.repeatable = repeatable; // TODO: Add 0 to parameter's name.
}
/**
* @return the aiLife
*/
public int getAiLife() {
return aiLife;
}
/**
* @param aiLife the aiLife to set
*/
public void setAiLife(int aiLife) {
this.aiLife = aiLife; // TODO: Add 0 to parameter's name.
}
/**
* @param winsReqd the winsReqd to set
*/
public void setWinsReqd(int winsReqd) {
this.winsReqd = winsReqd; // TODO: Add 0 to parameter's name.
}
/**
* @param creditsReward the creditsReward to set
*/
public void setCreditsReward(int creditsReward) {
this.creditsReward = creditsReward; // TODO: Add 0 to parameter's name.
}
/**
* @param cardReward the cardReward to set
*/
public void setCardReward(String cardReward) {
this.cardReward = cardReward; // TODO: Add 0 to parameter's name.
}
/**
* @param cardRewardList the cardRewardList to set
*/
public void setCardRewardList(List<CardPrinted> cardRewardList) {
this.cardRewardList = cardRewardList; // TODO: Add 0 to parameter's name.
}
/**
* @param humanExtraCards the humanExtraCards to set
*/
public void setHumanExtraCards(List<String> humanExtraCards) {
this.humanExtraCards = humanExtraCards; // TODO: Add 0 to parameter's name.
}
}

View File

@@ -28,7 +28,7 @@ public class QuestChallengePanel extends QuestSelectablePanel {
public QuestChallengePanel(final QuestChallenge q) {
super(q);
GuiUtils.addGap(super.rootPanel, 7);
GuiUtils.addGap(super.getRootPanel(), 7);
if (q.getRepeatable()) {
this.repeatabilityLabel = new JLabel("This challenge is repeatable");
@@ -36,7 +36,7 @@ public class QuestChallengePanel extends QuestSelectablePanel {
this.repeatabilityLabel = new JLabel("This challenge is not repeatable");
}
super.rootPanel.add(this.repeatabilityLabel);
super.getRootPanel().add(this.repeatabilityLabel);
}
}

View File

@@ -14,7 +14,7 @@ public class QuestDuel extends QuestEvent {
*/
public QuestDuel() {
super();
this.eventType = "duel";
this.setEventType("duel");
}
}

View File

@@ -13,25 +13,25 @@ import forge.deck.Deck;
public class QuestEvent {
// Default vals if none provided in the event file.
/** The event deck. */
public Deck eventDeck = null;
private Deck eventDeck = null;
/** The title. */
public String title = "Mystery Event";
private String title = "Mystery Event";
/** The description. */
public String description = "";
private String description = "";
/** The difficulty. */
public String difficulty = "Medium";
private String difficulty = "Medium";
/** The icon. */
public String icon = "Unknown.jpg";
private String icon = "Unknown.jpg";
/** The name. */
public String name = "Noname";
private String name = "Noname";
/** The event type. */
public String eventType = null;
private String eventType = null;
/**
* <p>
@@ -109,4 +109,53 @@ public class QuestEvent {
public final String getName() {
return this.name;
}
/**
* @param eventType the eventType to set
*/
public void setEventType(String eventType) {
this.eventType = eventType; // TODO: Add 0 to parameter's name.
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name; // TODO: Add 0 to parameter's name.
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title; // TODO: Add 0 to parameter's name.
}
/**
* @param difficulty the difficulty to set
*/
public void setDifficulty(String difficulty) {
this.difficulty = difficulty; // TODO: Add 0 to parameter's name.
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description; // TODO: Add 0 to parameter's name.
}
/**
* @param eventDeck the eventDeck to set
*/
public void setEventDeck(Deck eventDeck) {
this.eventDeck = eventDeck; // TODO: Add 0 to parameter's name.
}
/**
* @param icon the icon to set
*/
public void setIcon(String icon) {
this.icon = icon; // TODO: Add 0 to parameter's name.
}
}

View File

@@ -26,22 +26,22 @@ import forge.quest.data.QuestUtil;
public class QuestEventManager {
/** The easy a iduels. */
public List<QuestDuel> easyAIduels = null;
private List<QuestDuel> easyAIduels = null;
/** The medium a iduels. */
public List<QuestDuel> mediumAIduels = null;
private List<QuestDuel> mediumAIduels = null;
/** The hard a iduels. */
public List<QuestDuel> hardAIduels = null;
private List<QuestDuel> hardAIduels = null;
/** The very hard a iduels. */
public List<QuestDuel> veryHardAIduels = null;
private List<QuestDuel> veryHardAIduels = null;
/** The all duels. */
public List<QuestDuel> allDuels = null;
private List<QuestDuel> allDuels = null;
/** The all challenges. */
public List<QuestChallenge> allChallenges = null;
private List<QuestChallenge> allChallenges = null;
/**
* <p>
@@ -79,7 +79,7 @@ public class QuestEventManager {
// Assemble metadata (may not be necessary later) and deck object.
this.assembleEventMetadata(contents, tempEvent);
tempEvent.eventDeck = manager.getDeck(tempEvent.getName());
tempEvent.setEventDeck(manager.getDeck(tempEvent.getName()));
} // End for(allFiles)
this.assembleDuelDifficultyLists();
@@ -118,7 +118,7 @@ public class QuestEventManager {
value = s.substring(eqpos + 1);
if (key.equalsIgnoreCase("Name")) {
qd.name = value;
qd.setName(value);
}
}
}
@@ -153,18 +153,18 @@ public class QuestEventManager {
value = s.substring(eqpos + 1).trim();
if (key.equalsIgnoreCase("ID")) {
qc.id = Integer.parseInt(value);
qc.setId(Integer.parseInt(value));
} else if (key.equalsIgnoreCase("Repeat")) {
qc.repeatable = Boolean.parseBoolean(value);
qc.setRepeatable(Boolean.parseBoolean(value));
} else if (key.equalsIgnoreCase("AILife")) {
qc.aiLife = Integer.parseInt(value);
qc.setAiLife(Integer.parseInt(value));
} else if (key.equalsIgnoreCase("Wins")) {
qc.winsReqd = Integer.parseInt(value);
qc.setWinsReqd(Integer.parseInt(value));
} else if (key.equalsIgnoreCase("Credit Reward")) {
qc.creditsReward = Integer.parseInt(value);
qc.setCreditsReward(Integer.parseInt(value));
} else if (key.equalsIgnoreCase("Card Reward")) {
qc.cardReward = value;
qc.cardRewardList = QuestUtil.generateCardRewardList(value);
qc.setCardReward(value);
qc.setCardRewardList(QuestUtil.generateCardRewardList(value));
}
// Human extra card list assembled here.
else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
@@ -175,7 +175,7 @@ public class QuestEventManager {
templist.add(n);
}
qc.humanExtraCards = templist;
qc.setHumanExtraCards(templist);
}
// AI extra card list assembled here.
else if (key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
@@ -186,12 +186,12 @@ public class QuestEventManager {
templist.add(n);
}
qc.aiExtraCards = templist;
qc.setAiExtraCards(templist);
}
// Card reward list assembled here.
else if (key.equalsIgnoreCase("Card Reward")) {
qc.cardReward = value;
qc.cardRewardList = QuestUtil.generateCardRewardList(value);
qc.setCardReward(value);
qc.setCardRewardList(QuestUtil.generateCardRewardList(value));
}
}
}
@@ -230,15 +230,15 @@ public class QuestEventManager {
value = s.substring(eqpos + 1);
if (key.equalsIgnoreCase("Name")) {
qe.name = value;
qe.setName(value);
} else if (key.equalsIgnoreCase("Title")) {
qe.title = value;
qe.setTitle(value);
} else if (key.equalsIgnoreCase("Difficulty")) {
qe.difficulty = value;
qe.setDifficulty(value);
} else if (key.equalsIgnoreCase("Description")) {
qe.description = value;
qe.setDescription(value);
} else if (key.equalsIgnoreCase("Icon")) {
qe.icon = value;
qe.setIcon(value);
}
}
}

View File

@@ -32,13 +32,13 @@ public class QuestSelectablePanel extends JPanel {
private static final long serialVersionUID = -1502285997894190742L;
/** The background color. */
protected Color backgroundColor;
private Color backgroundColor;
private boolean selected;
private final QuestEvent event;
private String iconfilename;
/** The root panel. */
public JPanel rootPanel = new JPanel();
private JPanel rootPanel = new JPanel();
/**
* <p>
@@ -51,7 +51,7 @@ public class QuestSelectablePanel extends JPanel {
*/
public QuestSelectablePanel(final QuestEvent qe) {
this.event = qe;
this.iconfilename = qe.icon;
this.iconfilename = qe.getIcon();
final File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
File file = new File(base, this.iconfilename);
@@ -81,9 +81,9 @@ public class QuestSelectablePanel extends JPanel {
iconPanel.add(iconLabel, BorderLayout.NORTH);
this.add(iconPanel, BorderLayout.WEST);
this.rootPanel.setOpaque(false);
this.rootPanel.setLayout(new BoxLayout(this.rootPanel, BoxLayout.Y_AXIS));
this.add(this.rootPanel, BorderLayout.CENTER);
this.getRootPanel().setOpaque(false);
this.getRootPanel().setLayout(new BoxLayout(this.getRootPanel(), BoxLayout.Y_AXIS));
this.add(this.getRootPanel(), BorderLayout.CENTER);
final JPanel centerTopPanel = new JPanel();
centerTopPanel.setOpaque(false);
@@ -100,13 +100,13 @@ public class QuestSelectablePanel extends JPanel {
final JLabel difficultyLabel = new JLabel(qe.getDifficulty());
difficultyLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
centerTopPanel.add(difficultyLabel);
this.rootPanel.add(centerTopPanel);
this.getRootPanel().add(centerTopPanel);
GuiUtils.addGap(this.rootPanel);
GuiUtils.addGap(this.getRootPanel());
final JLabel descriptionLabel = new JLabel(qe.getDescription());
descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
this.rootPanel.add(descriptionLabel);
this.getRootPanel().add(descriptionLabel);
this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80));
this.setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5, 5, 5, 5)));
@@ -162,4 +162,18 @@ public class QuestSelectablePanel extends JPanel {
public final QuestEvent getEvent() {
return this.event;
}
/**
* @return the rootPanel
*/
public JPanel getRootPanel() {
return rootPanel;
}
/**
* @param rootPanel the rootPanel to set
*/
public void setRootPanel(JPanel rootPanel) {
this.rootPanel = rootPanel; // TODO: Add 0 to parameter's name.
}
}

View File

@@ -9,10 +9,11 @@ import forge.model.FModel;
public interface FView {
/**
* Tell the view that the model has been bootstrapped, and its data is
* ready for initial display.
*
* @param model the model that has finished bootstrapping
* Tell the view that the model has been bootstrapped, and its data is ready
* for initial display.
*
* @param model
* the model that has finished bootstrapping
*/
void setModel(FModel model);

View File

@@ -50,15 +50,17 @@ public class ApplicationView implements FView {
// 8/18/11
// 11:37
// PM
@Override
public void run() {
splashFrame = new SplashFrame(skin);
ApplicationView.this.splashFrame = new SplashFrame(skin);
}
});
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on
// 8/18/11 11:37 PM
@Override
public void run() {
splashFrame.setVisible(true);
ApplicationView.this.splashFrame.setVisible(true);
}
});
@@ -73,10 +75,10 @@ public class ApplicationView implements FView {
public final BraidsProgressMonitor getCardLoadingProgressMonitor() {
BraidsProgressMonitor result;
if (splashFrame == null) {
if (this.splashFrame == null) {
result = null;
} else {
result = splashFrame.getMonitorModel();
result = this.splashFrame.getMonitorModel();
}
return result;
@@ -112,13 +114,14 @@ public class ApplicationView implements FView {
AllZone.setSkin(new FSkin(preferences.getSkin()));
} catch (Exception exn) {
} catch (final Exception exn) {
Log.error("Error loading preferences: " + exn);
}
SwingUtilities.invokeLater(new Runnable() { // NOPMD by Braids on 8/7/11
// 1:07 PM: this isn't a web
// app
@Override
public void run() {
final ForgePreferences finalPreferences = model.getPreferences();
@@ -128,7 +131,7 @@ public class ApplicationView implements FView {
} else {
UIManager.setLookAndFeel(finalPreferences.getLaf());
}
} catch (Exception ex) {
} catch (final Exception ex) {
ErrorViewer.showError(ex);
}
}
@@ -137,11 +140,11 @@ public class ApplicationView implements FView {
// For the following two blocks, check if user has cancelled
// SplashFrame.
// Note: Error thrown sometimes because log file cannot be accessed
if (!splashFrame.getSplashHasBeenClosed()) {
if (!this.splashFrame.getSplashHasBeenClosed()) {
AllZone.getCardFactory(); // forces preloading of all cards
}
if (!splashFrame.getSplashHasBeenClosed()) {
if (!this.splashFrame.getSplashHasBeenClosed()) {
try {
ManaSymbols.loadImages();
@@ -150,6 +153,7 @@ public class ApplicationView implements FView {
// on 8/7/11 1:07
// PM: this isn't a
// web app
@Override
public void run() {
AllZone.getInputControl().setComputer(new ComputerAI_Input(new ComputerAI_General()));
@@ -157,14 +161,14 @@ public class ApplicationView implements FView {
// The second
// is useful for debugging.
splashFrame.dispose();
ApplicationView.this.splashFrame.dispose();
// splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
splashFrame = null;
ApplicationView.this.splashFrame = null;
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String[] argz = {};
final String[] argz = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
@@ -174,7 +178,7 @@ public class ApplicationView implements FView {
}
}
});
} catch (Exception ex) {
} catch (final Exception ex) {
ErrorViewer.showError(ex);
}
} // End if(splashHasBeenClosed)

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,7 @@ public final class Main {
final FModel model = new FModel(null);
Singletons.setModel(model);
FSkin skin = new FSkin(model.getPreferences().getSkin());
final FSkin skin = new FSkin(model.getPreferences().getSkin());
final FView view = new ApplicationView(skin);
Singletons.setView(view);
@@ -47,8 +47,9 @@ public final class Main {
view.setModel(model);
} catch (Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM: must
// catch all throwables here.
} catch (final Throwable exn) { // NOPMD by Braids on 8/7/11 1:07 PM:
// must
// catch all throwables here.
ErrorViewer.showError(exn);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,7 @@ public class SplashFrame extends JFrame {
private SplashProgressModel monitorModel = null;
private SplashProgressComponent monitorView = null;
private boolean SplashHasBeenClosed = false;
private boolean splashHasBeenClosed = false;
/**
* <p>
@@ -53,11 +53,10 @@ public class SplashFrame extends JFrame {
* </p>
*
* <!-- CheckStyle won't let me use at-throws. --> Throws
* {@link IllegalStateException} if not called from an event dispatch
* thread.
*
* @param skin
* the skin
* the skin {@link IllegalStateException} if not called from an
* event dispatch thread.
*/
public SplashFrame(final FSkin skin) {
super();
@@ -66,40 +65,41 @@ public class SplashFrame extends JFrame {
throw new IllegalStateException("SplashFrame() must be called from an event dispatch thread.");
}
setUndecorated(true);
this.setUndecorated(true);
// Set preferred JFrame properties.
final ImageIcon bgIcon = skin.getSplash();
final int splashWidthPx = bgIcon.getIconWidth();
final int splashHeightPx = bgIcon.getIconHeight();
setMinimumSize(new Dimension(splashWidthPx, splashHeightPx));
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setMinimumSize(new Dimension(splashWidthPx, splashHeightPx));
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Insert JPanel to hold content above background
final JPanel contentPane = new JPanel();
setContentPane(contentPane);
this.setContentPane(contentPane);
contentPane.setLayout(null);
// Add disclaimer
final JLabel lblDisclaimer = new JLabel(
"<html><center>Forge is not affiliated in any way with Wizards of the Coast.<br>Forge is open source software, released under the GNU Public License.</center></html>");
"<html><center>Forge is not affiliated in any way with Wizards of the Coast."
+ "<br>Forge is open source software, released under the GNU Public License.</center></html>");
lblDisclaimer.setBounds(0, DISCLAIMER_TOP, splashWidthPx, DISCLAIMER_HEIGHT);
lblDisclaimer.setBounds(0, SplashFrame.DISCLAIMER_TOP, splashWidthPx, SplashFrame.DISCLAIMER_HEIGHT);
lblDisclaimer.setFont(new Font("Tahoma", Font.PLAIN, DISCLAIMER_FONT_SIZE));
lblDisclaimer.setFont(new Font("Tahoma", Font.PLAIN, SplashFrame.DISCLAIMER_FONT_SIZE));
lblDisclaimer.setHorizontalAlignment(SwingConstants.CENTER);
lblDisclaimer.setForeground(DISCLAIMER_COLOR);
lblDisclaimer.setForeground(SplashFrame.DISCLAIMER_COLOR);
contentPane.add(lblDisclaimer);
// Add close button
final JButton btnClose = new JButton("X");
btnClose.setBounds(splashWidthPx - (2 * CLOSEBTN_PADDING_Y), CLOSEBTN_PADDING_Y, CLOSEBTN_SIDELENGTH,
CLOSEBTN_SIDELENGTH);
btnClose.setForeground(CLOSEBTN_COLOR);
btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR));
btnClose.setBounds(splashWidthPx - (2 * SplashFrame.CLOSEBTN_PADDING_Y), SplashFrame.CLOSEBTN_PADDING_Y,
SplashFrame.CLOSEBTN_SIDELENGTH, SplashFrame.CLOSEBTN_SIDELENGTH);
btnClose.setForeground(SplashFrame.CLOSEBTN_COLOR);
btnClose.setBorder(BorderFactory.createLineBorder(SplashFrame.CLOSEBTN_COLOR));
btnClose.setOpaque(false);
btnClose.setBackground(new Color(0, 0, 0));
btnClose.setFocusPainted(false);
@@ -107,41 +107,43 @@ public class SplashFrame extends JFrame {
// Action handler: button hover effect
btnClose.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseEntered(final java.awt.event.MouseEvent evt) {
btnClose.setBorder(BorderFactory.createLineBorder(Color.white));
btnClose.setForeground(Color.white);
}
@Override
public void mouseExited(final java.awt.event.MouseEvent evt) {
btnClose.setBorder(BorderFactory.createLineBorder(CLOSEBTN_COLOR));
btnClose.setForeground(CLOSEBTN_COLOR);
btnClose.setBorder(BorderFactory.createLineBorder(SplashFrame.CLOSEBTN_COLOR));
btnClose.setForeground(SplashFrame.CLOSEBTN_COLOR);
}
});
// Action handler: button close
btnClose.addActionListener(new closeAction());
btnClose.addActionListener(new CloseAction());
// Action handler: esc key close
contentPane.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "escAction");
contentPane.getActionMap().put("escAction", new closeAction());
contentPane.getActionMap().put("escAction", new CloseAction());
// Set UI to color splash bar fill with theme colors
UIManager.put("ProgressBar.foreground", skin.getBg1b()); // Filled
UIManager.put("ProgressBar.selectionForeground", skin.getTxt1a()); // Filled
// Instantiate model and view and tie together.
monitorModel = new SplashProgressModel();
monitorView = new SplashProgressComponent();
this.monitorModel = new SplashProgressModel();
this.monitorView = new SplashProgressComponent();
monitorModel.setCurrentView(monitorView);
monitorView.setCurrentModel(monitorModel);
this.monitorModel.setCurrentView(this.monitorView);
this.monitorView.setCurrentModel(this.monitorModel);
// Add prog bar + message, bg image
monitorView.displayUpdate("Assembling file list...");
monitorView.setBounds(BAR_PADDING_X, splashHeightPx - BAR_PADDING_Y - BAR_HEIGHT, splashWidthPx
- (2 * BAR_PADDING_X), BAR_HEIGHT);
contentPane.add(monitorView);
this.monitorView.displayUpdate("Assembling file list...");
this.monitorView.setBounds(SplashFrame.BAR_PADDING_X, splashHeightPx - SplashFrame.BAR_PADDING_Y
- SplashFrame.BAR_HEIGHT, splashWidthPx - (2 * SplashFrame.BAR_PADDING_X), SplashFrame.BAR_HEIGHT);
contentPane.add(this.monitorView);
contentPane.setOpaque(false);
final JLabel bgLabel = new JLabel(bgIcon);
@@ -149,11 +151,11 @@ public class SplashFrame extends JFrame {
// Do not pass Integer.MIN_VALUE directly here; it must be packaged in
// an Integer
// instance. Otherwise, GUI components will not draw unless moused over.
getLayeredPane().add(bgLabel, Integer.valueOf(Integer.MIN_VALUE));
this.getLayeredPane().add(bgLabel, Integer.valueOf(Integer.MIN_VALUE));
bgLabel.setBounds(0, 0, splashWidthPx, splashHeightPx);
pack();
this.pack();
}
/**
@@ -163,7 +165,7 @@ public class SplashFrame extends JFrame {
* frame.
*/
public final SplashProgressComponent getMonitorView() {
return monitorView;
return this.monitorView;
}
/**
@@ -172,7 +174,7 @@ public class SplashFrame extends JFrame {
* @return the BraidsProgressMonitor model used in the splash frame.
*/
public final BraidsProgressMonitor getMonitorModel() {
return monitorModel;
return this.monitorModel;
}
/**
@@ -182,7 +184,7 @@ public class SplashFrame extends JFrame {
* @return SplashHasBeenClosed boolean.
*/
public final boolean getSplashHasBeenClosed() {
return SplashHasBeenClosed;
return this.splashHasBeenClosed;
}
/**
@@ -192,7 +194,7 @@ public class SplashFrame extends JFrame {
* the new splash has been closed
*/
public final void setSplashHasBeenClosed(final boolean neoState) {
SplashHasBeenClosed = neoState;
this.splashHasBeenClosed = neoState;
}
/**
@@ -202,13 +204,14 @@ public class SplashFrame extends JFrame {
* Closes the splash frame by toggling "has been closed" switch (to cancel
* preloading) and dispose() (to discard JFrame).
*
* @param SplashHasBeenClosed
* @param splashHasBeenClosed
* boolean.
*/
private class closeAction extends AbstractAction {
private class CloseAction extends AbstractAction {
@Override
public void actionPerformed(final ActionEvent e) {
setSplashHasBeenClosed(true);
dispose();
SplashFrame.this.setSplashHasBeenClosed(true);
SplashFrame.this.dispose();
}
}

View File

@@ -27,8 +27,8 @@ public class SplashProgressComponent extends JProgressBar {
throw new IllegalStateException("must be called from within an event dispatch thread");
}
setString("");
setStringPainted(true);
this.setString("");
this.setStringPainted(true);
}
/**
@@ -38,8 +38,9 @@ public class SplashProgressComponent extends JProgressBar {
public final void updateProgressBar() {
// Update bar "stripe"
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
stripeUpdate();
SplashProgressComponent.this.stripeUpdate();
}
});
@@ -47,26 +48,26 @@ public class SplashProgressComponent extends JProgressBar {
// Note: shouldUpdateUI() severely retards motion
// of the preloader, so is temporarily disabled.
// if (getCurrentModel().shouldUpdateUI()) {
if ((getCurrentModel().getNumPhases() > 1)) {
displayUpdate("Phase " + getCurrentModel().getCurrentPhase() + ". "
if ((this.getCurrentModel().getNumPhases() > 1)) {
this.displayUpdate("Phase " + this.getCurrentModel().getCurrentPhase() + ". "
// + getUnitsCompletedSoFarThisPhase() + " units processed. "
// + "Overall: " + getTotalPercentCompleteAsString() +
// "% complete, "
+ "Overall ETA in " + getCurrentModel().getRelativeETAAsString(true) + ".");
+ "Overall ETA in " + this.getCurrentModel().getRelativeETAAsString(true) + ".");
} else {
displayUpdate(
this.displayUpdate(
// "Overall: " +
getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
this.getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
// + "(" + getTotalPercentCompleteAsString() + "%); "
+ "ETA in " + getCurrentModel().getRelativeETAAsString(true) + ".");
+ "ETA in " + this.getCurrentModel().getRelativeETAAsString(true) + ".");
}
// getCurrentModel().justUpdatedUI();
// }
if (getCurrentModel().getCurrentPhase() == getCurrentModel().getNumPhases()
&& getCurrentModel().getUnitsCompletedSoFarThisPhase() >= getCurrentModel().getTotalUnitsThisPhase())
{
displayUpdate("Done! Firing up the GUI...");
if ((this.getCurrentModel().getCurrentPhase() == this.getCurrentModel().getNumPhases())
&& (this.getCurrentModel().getUnitsCompletedSoFarThisPhase() >= this.getCurrentModel()
.getTotalUnitsThisPhase())) {
this.displayUpdate("Done! Firing up the GUI...");
}
}
@@ -79,9 +80,10 @@ public class SplashProgressComponent extends JProgressBar {
*/
public final void displayUpdate(final String message) {
final Runnable proc = new Runnable() {
@Override
public void run() {
setString(message);
getCurrentModel().justUpdatedUI();
SplashProgressComponent.this.setString(message);
SplashProgressComponent.this.getCurrentModel().justUpdatedUI();
}
};
@@ -97,10 +99,10 @@ public class SplashProgressComponent extends JProgressBar {
*
*/
public final void stripeUpdate() {
completed = getCurrentModel().getUnitsCompletedSoFarThisPhase();
total = getCurrentModel().getTotalUnitsThisPhase();
this.completed = this.getCurrentModel().getUnitsCompletedSoFarThisPhase();
this.total = this.getCurrentModel().getTotalUnitsThisPhase();
setValue((int) Math.round((int) completed / total * 100));
this.setValue((int) Math.round(((int) this.completed / this.total) * 100));
}
/**
@@ -108,7 +110,7 @@ public class SplashProgressComponent extends JProgressBar {
*
*/
public final void stripeReset() {
setValue(0);
this.setValue(0);
}
/**
@@ -118,7 +120,7 @@ public class SplashProgressComponent extends JProgressBar {
* the new current model
*/
public final void setCurrentModel(final BaseProgressMonitor neoModel) {
currentModel = neoModel;
this.currentModel = neoModel;
}
/**
@@ -127,6 +129,6 @@ public class SplashProgressComponent extends JProgressBar {
* @return the current model
*/
public final BraidsProgressMonitor getCurrentModel() {
return currentModel;
return this.currentModel;
}
}

View File

@@ -29,13 +29,16 @@ public class SplashProgressModel extends BaseProgressMonitor {
*/
/**
* Increment units completed this phase.
*
* @param numUnits
* long
* @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#incrementUnitsCompletedThisPhase(long)
* @param numUnits long
*/
@Override
public final void incrementUnitsCompletedThisPhase(final long numUnits) {
super.incrementUnitsCompletedThisPhase(numUnits);
getCurrentView().updateProgressBar();
this.getCurrentView().updateProgressBar();
}
/**
@@ -44,7 +47,7 @@ public class SplashProgressModel extends BaseProgressMonitor {
* @return the current view
*/
public final SplashProgressComponent getCurrentView() {
return currentView;
return this.currentView;
}
/**
@@ -54,7 +57,7 @@ public class SplashProgressModel extends BaseProgressMonitor {
* the new current view
*/
public final void setCurrentView(final SplashProgressComponent neoView) {
currentView = neoView;
this.currentView = neoView;
}
}

View File

@@ -36,8 +36,8 @@ import forge.quest.data.QuestMatchState;
@SuppressWarnings("serial")
public class WinLoseFrame extends JFrame {
private QuestMatchState matchState;
private WinLoseModeHandler modeHandler;
private final QuestMatchState matchState;
private final WinLoseModeHandler modeHandler;
/** The btn continue. */
public FButton btnContinue;
@@ -76,58 +76,58 @@ public class WinLoseFrame extends JFrame {
* modes (quest, puzzle, etc.)
*
* @param mh
* {@link forge.view.swing.WinLoseModeHandler}
* the mh {@link forge.view.swing.WinLoseModeHandler}
*/
public WinLoseFrame(final WinLoseModeHandler mh) {
super();
// modeHandler handles the unique display for different game modes.
modeHandler = mh;
modeHandler.setView(this);
matchState = AllZone.getMatchState();
this.modeHandler = mh;
this.modeHandler.setView(this);
this.matchState = AllZone.getMatchState();
// Place all content in FPanel
FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10"));
final FPanel contentPanel = new FPanel(new MigLayout("wrap, fill, insets 20 0 10 10"));
contentPanel.setBGImg(AllZone.getSkin().getTexture1());
contentPanel.setBorder(new WinLoseBorder());
getContentPane().add(contentPanel);
this.getContentPane().add(contentPanel);
// Footer should be at least 150 to keep buttons in-pane on Mac OS X
// it needs to be > 175 now that skinning is used
int HEAD_HEIGHT = 150;
int FOOT_HEIGHT = 182;
int FRAME_WIDTH_SMALL = 300;
int FRAME_WIDTH_BIG = 600;
final int HEAD_HEIGHT = 150;
final int FOOT_HEIGHT = 182;
final int FRAME_WIDTH_SMALL = 300;
final int FRAME_WIDTH_BIG = 600;
// Head panel
JPanel pnlHead = new JPanel(new MigLayout("wrap, fill"));
final JPanel pnlHead = new JPanel(new MigLayout("wrap, fill"));
pnlHead.setOpaque(false);
contentPanel.add(pnlHead, "width " + FRAME_WIDTH_SMALL + "!, align center");
lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
lblTitle.setForeground(Color.white);
lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
lblTitle.setFont(AllZone.getSkin().getFont1().deriveFont(Font.PLAIN, 26));
this.lblTitle = new JLabel("WinLoseFrame > lblTitle is broken.");
this.lblTitle.setForeground(Color.white);
this.lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
this.lblTitle.setFont(AllZone.getSkin().getFont1().deriveFont(Font.PLAIN, 26));
lblStats = new JLabel("WinLoseFrame > lblStats is broken.");
lblStats.setForeground(Color.white);
lblStats.setHorizontalAlignment(SwingConstants.CENTER);
lblStats.setFont(AllZone.getSkin().getFont1().deriveFont(Font.PLAIN, 26));
this.lblStats = new JLabel("WinLoseFrame > lblStats is broken.");
this.lblStats.setForeground(Color.white);
this.lblStats.setHorizontalAlignment(SwingConstants.CENTER);
this.lblStats.setFont(AllZone.getSkin().getFont1().deriveFont(Font.PLAIN, 26));
pnlHead.add(lblTitle, "growx");
pnlHead.add(lblStats, "growx");
pnlHead.add(this.lblTitle, "growx");
pnlHead.add(this.lblStats, "growx");
// Custom display panel in center; populated later by mode handler.
JScrollPane scroller = new JScrollPane();
final JScrollPane scroller = new JScrollPane();
scroller.getVerticalScrollBar().setUnitIncrement(16);
pnlCustom = new JPanel(new MigLayout("wrap, fillx"));
pnlCustom.setBackground(new Color(111, 87, 59));
pnlCustom.setForeground(Color.white);
this.pnlCustom = new JPanel(new MigLayout("wrap, fillx"));
this.pnlCustom.setBackground(new Color(111, 87, 59));
this.pnlCustom.setForeground(Color.white);
contentPanel.add(scroller, "w 96%!, align center, gapleft 2%");
scroller.getViewport().add(pnlCustom);
scroller.getViewport().add(this.pnlCustom);
// Foot panel
JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3"));
final JPanel pnlFoot = new JPanel(new MigLayout("wrap, fill, hidemode 3"));
pnlFoot.setOpaque(false);
contentPanel.add(pnlFoot, "width " + FRAME_WIDTH_SMALL + "!, align center");
@@ -135,61 +135,64 @@ public class WinLoseFrame extends JFrame {
this.btnRestart = new FButton("Restart");
this.btnQuit = new FButton("Quit");
pnlFoot.add(btnContinue, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(btnRestart, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(btnQuit, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(this.btnContinue, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(this.btnRestart, "h 36:36, w 200!, gap 0 0 5 5, align center");
pnlFoot.add(this.btnQuit, "h 36:36, w 200!, gap 0 0 5 5, align center");
// Button actions
btnQuit.addActionListener(new java.awt.event.ActionListener() {
this.btnQuit.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
btnQuit_actionPerformed(e);
WinLoseFrame.this.btnQuit_actionPerformed(e);
}
});
btnContinue.addActionListener(new java.awt.event.ActionListener() {
this.btnContinue.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
btnContinue_actionPerformed(e);
WinLoseFrame.this.btnContinue_actionPerformed(e);
}
});
btnRestart.addActionListener(new java.awt.event.ActionListener() {
this.btnRestart.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
btnRestart_actionPerformed(e);
WinLoseFrame.this.btnRestart_actionPerformed(e);
}
});
// End game and set state of "continue" button
Phase.setGameBegins(0);
if (matchState.isMatchOver()) {
btnContinue.setEnabled(false);
btnQuit.grabFocus();
if (this.matchState.isMatchOver()) {
this.btnContinue.setEnabled(false);
this.btnQuit.grabFocus();
}
// Show Wins and Loses
Player human = AllZone.getHumanPlayer();
int humanWins = matchState.countGamesWonBy(human.getName());
int humanLosses = matchState.getGamesPlayedCount() - humanWins;
final Player human = AllZone.getHumanPlayer();
final int humanWins = this.matchState.countGamesWonBy(human.getName());
final int humanLosses = this.matchState.getGamesPlayedCount() - humanWins;
lblStats.setText(ForgeProps.getLocalized(WinLoseText.WON) + humanWins
this.lblStats.setText(ForgeProps.getLocalized(WinLoseText.WON) + humanWins
+ ForgeProps.getLocalized(WinLoseText.LOST) + humanLosses);
// Show "You Won" or "You Lost"
if (matchState.hasWonLastGame(human.getName())) {
lblTitle.setText(ForgeProps.getLocalized(WinLoseText.WIN));
if (this.matchState.hasWonLastGame(human.getName())) {
this.lblTitle.setText(ForgeProps.getLocalized(WinLoseText.WIN));
} else {
lblTitle.setText(ForgeProps.getLocalized(WinLoseText.LOSE));
this.lblTitle.setText(ForgeProps.getLocalized(WinLoseText.LOSE));
}
// Populate custom panel, if necessary.
boolean hasContents = modeHandler.populateCustomPanel();
final boolean hasContents = this.modeHandler.populateCustomPanel();
if (!hasContents) {
scroller.setVisible(false);
}
// Size and show frame
Dimension screen = this.getToolkit().getScreenSize();
Rectangle bounds = this.getBounds();
final Dimension screen = this.getToolkit().getScreenSize();
final Rectangle bounds = this.getBounds();
if (hasContents) {
bounds.height = screen.height - 150;
@@ -206,7 +209,7 @@ public class WinLoseFrame extends JFrame {
this.setBackground(AllZone.getSkin().getBg1a());
this.setBounds(bounds);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setUndecorated(true);
this.setVisible(true);
}
@@ -220,9 +223,9 @@ public class WinLoseFrame extends JFrame {
* a {@link java.awt.event.ActionEvent} object.
*/
final void btnContinue_actionPerformed(final ActionEvent e) {
closeWinLoseFrame();
this.closeWinLoseFrame();
AllZone.getDisplay().setVisible(true);
modeHandler.startNextRound();
this.modeHandler.startNextRound();
}
/**
@@ -234,10 +237,10 @@ public class WinLoseFrame extends JFrame {
* a {@link java.awt.event.ActionEvent} object.
*/
final void btnRestart_actionPerformed(final ActionEvent e) {
closeWinLoseFrame();
this.closeWinLoseFrame();
AllZone.getDisplay().setVisible(true);
matchState.reset();
modeHandler.startNextRound();
this.matchState.reset();
this.modeHandler.startNextRound();
}
/**
@@ -249,9 +252,9 @@ public class WinLoseFrame extends JFrame {
* a {@link java.awt.event.ActionEvent} object.
*/
final void btnQuit_actionPerformed(final ActionEvent e) {
closeWinLoseFrame();
matchState.reset();
modeHandler.actionOnQuit();
this.closeWinLoseFrame();
this.matchState.reset();
this.modeHandler.actionOnQuit();
// clear Image caches, so the program doesn't get slower and slower
// not needed with soft values - will shrink as needed
@@ -269,7 +272,7 @@ public class WinLoseFrame extends JFrame {
*/
final JFrame closeWinLoseFrame() {
// Issue 147 - keep battlefield up following win/loss
JFrame frame = (JFrame) AllZone.getDisplay();
final JFrame frame = (JFrame) AllZone.getDisplay();
frame.dispose();
frame.setEnabled(true);
this.dispose();
@@ -277,6 +280,7 @@ public class WinLoseFrame extends JFrame {
}
private class WinLoseBorder extends AbstractBorder {
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width,
final int height) {
g.setColor(AllZone.getSkin().getTxt1a());

View File

@@ -16,7 +16,7 @@ import forge.Constant;
public class WinLoseModeHandler {
/** The view. */
protected WinLoseFrame view;
private WinLoseFrame view;
/**
* <p>
@@ -40,7 +40,7 @@ public class WinLoseModeHandler {
public void actionOnQuit() {
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String[] argz = {};
final String[] argz = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();
@@ -97,6 +97,13 @@ public class WinLoseModeHandler {
* the new view
*/
public final void setView(final WinLoseFrame wlh) {
view = wlh;
this.view = wlh;
}
/**
* @return the view
*/
public WinLoseFrame getView() {
return view;
}
}

View File

@@ -43,8 +43,7 @@ public final class GeneratorFunctions {
public static <T> long estimateSize(final Generator<T> gen) {
long result = 0;
for (@SuppressWarnings("unused")
T ignored : YieldUtils.toIterable(gen))
{
T ignored : YieldUtils.toIterable(gen)) {
result++;
}
@@ -70,15 +69,14 @@ public final class GeneratorFunctions {
* @return a generator which produces a subset <= the inputGenerator
*/
public static <T> Generator<T> filterGenerator(final Lambda1<Boolean, T> predicate,
final Generator<T> inputGenerator)
{
final Generator<T> inputGenerator) {
Generator<T> result = new Generator<T>() {
@Override
public void generate(final Yieldable<T> outputYield) {
Yieldable<T> inputYield = new Yieldable<T>() {
Boolean pResult;
private Boolean pResult;
@Override
public void yield(final T input) {
@@ -171,11 +169,9 @@ public final class GeneratorFunctions {
* the generator from which to select a random item
* @return an item chosen at random from the generator; this may be null, if
* the generator contains null items.
* @throws NoSuchElementException
* if the generator has no contents
*/
public static <T> T selectRandom(final Generator<T> generator) throws NoSuchElementException
{
public static <T> T selectRandom(final Generator<T> generator) {
/*
* This algorithm requires some explanation. Each time we encounter a
* new item from the generator, we determine via random chance if the

View File

@@ -26,13 +26,13 @@ public class BaseProgressMonitor implements BraidsProgressMonitor {
private float[] phaseWeights;
/** The SECOND s_ pe r_ minute. */
public final int SECONDS_PER_MINUTE = 60;
private final int secondsPerMinute = 60;
/** The SECOND s_ pe r_ hour. */
public final int SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
private final int secondsPerHour = 60 * secondsPerMinute;
/** The SECOND s_ pe r_ day. */
public final int SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
private final int secondsPerDay = 24 * secondsPerHour;
/**
* Convenience for BaseProgressMonitor(1, 1, 2.0f, null).
@@ -306,20 +306,20 @@ public class BaseProgressMonitor implements BraidsProgressMonitor {
}
String result = "";
if (etaSec > SECONDS_PER_DAY) {
result += Integer.toString(etaSec / SECONDS_PER_DAY);
if (etaSec > secondsPerDay) {
result += Integer.toString(etaSec / secondsPerDay);
result += " da, ";
etaSec %= SECONDS_PER_DAY; // Shave off the portion recorded.
etaSec %= secondsPerDay; // Shave off the portion recorded.
}
if (result.length() > 0 || etaSec > SECONDS_PER_HOUR) {
result += Integer.toString(etaSec / SECONDS_PER_HOUR);
if (result.length() > 0 || etaSec > secondsPerHour) {
result += Integer.toString(etaSec / secondsPerHour);
result += " hr, ";
etaSec %= SECONDS_PER_HOUR; // Shave off the portion recorded.
etaSec %= secondsPerHour; // Shave off the portion recorded.
}
if (result.length() > 0 || etaSec > SECONDS_PER_MINUTE) {
result += Integer.toString(etaSec / SECONDS_PER_MINUTE);
if (result.length() > 0 || etaSec > secondsPerMinute) {
result += Integer.toString(etaSec / secondsPerMinute);
result += " min, ";
etaSec %= SECONDS_PER_MINUTE; // Shave off the portion recorded.
etaSec %= secondsPerMinute; // Shave off the portion recorded.
}
result += Integer.toString(etaSec);

View File

@@ -51,8 +51,7 @@ public class StderrProgressMonitor extends BaseProgressMonitor {
* long, float, float[])
*/
public StderrProgressMonitor(final int numPhases, final long totalUnitsFirstPhase,
final float minUpdateIntervalSec, final float[] phaseWeights)
{
final float minUpdateIntervalSec, final float[] phaseWeights) {
super(numPhases, totalUnitsFirstPhase, minUpdateIntervalSec, phaseWeights);
}
@@ -64,6 +63,7 @@ public class StderrProgressMonitor extends BaseProgressMonitor {
*/
/**
* @param numUnits long
* @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#BaseProgressMonitor(int)
*/
@Override

View File

@@ -2,14 +2,38 @@ package net.slightlymagic.maxmtg;
import net.slightlymagic.braids.util.lambda.Lambda1;
/** This class represents an action (lambda) and some arguments to make a call at a later time */
/**
* This class represents an action (lambda) and some arguments to make a call at
* a later time.
*
* @param <R>
* the generic type
* @param <A1>
* the generic type
*/
public class Closure1<R, A1> {
private final Lambda1<R, A1> method;
private final A1 argument;
public Closure1(Lambda1<R, A1> lambda, A1 object) {
method = lambda;
argument = object;
/**
* Instantiates a new closure1.
*
* @param lambda
* the lambda
* @param object
* the object
*/
public Closure1(final Lambda1<R, A1> lambda, final A1 object) {
this.method = lambda;
this.argument = object;
}
/**
* Apply.
*
* @return the r
*/
public R apply() {
return this.method.apply(this.argument);
}
public R apply() { return method.apply(argument); }
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,23 +2,67 @@ package net.slightlymagic.maxmtg;
import org.apache.commons.lang3.StringUtils;
/**
/**
* Special predicate class to perform string operations.
*
* @param <T>
* the generic type
*/
public abstract class PredicateString<T> extends Predicate<T> {
/** Possible operators for string operands. */
public enum StringOp { CONTAINS, NOT_CONTAINS, EQUALS, NOT_EQUALS }
protected final StringOp operator;
public enum StringOp {
/** The CONTAINS. */
CONTAINS,
/** The NO t_ contains. */
NOT_CONTAINS,
/** The EQUALS. */
EQUALS,
/** The NO t_ equals. */
NOT_EQUALS
}
/** The operator. */
private final StringOp operator;
/**
* Op.
*
* @param op1
* the op1
* @param op2
* the op2
* @return true, if successful
*/
protected final boolean op(final String op1, final String op2) {
switch (operator) {
case CONTAINS: return StringUtils.containsIgnoreCase(op1, op2);
case NOT_CONTAINS: return !StringUtils.containsIgnoreCase(op1, op2);
case EQUALS: return op1.equalsIgnoreCase(op2);
case NOT_EQUALS: return op1.equalsIgnoreCase(op2);
default: return false;
switch (this.getOperator()) {
case CONTAINS:
return StringUtils.containsIgnoreCase(op1, op2);
case NOT_CONTAINS:
return !StringUtils.containsIgnoreCase(op1, op2);
case EQUALS:
return op1.equalsIgnoreCase(op2);
case NOT_EQUALS:
return op1.equalsIgnoreCase(op2);
default:
return false;
}
}
public PredicateString(final StringOp operator) {this.operator = operator; }
}
/**
* Instantiates a new predicate string.
*
* @param operator
* the operator
*/
public PredicateString(final StringOp operator) {
this.operator = operator;
}
/**
* @return the operator
*/
public StringOp getOperator() {
return operator;
}
}

View File

@@ -1,2 +1,3 @@
/** Forge Card Game. */
package net.slightlymagic.maxmtg;

View File

@@ -22,7 +22,7 @@ import java.awt.FocusTraversalPolicy;
* @author scheglov_ke
*/
public class FocusTraversalOnArray extends FocusTraversalPolicy {
private final Component m_Components[];
private final Component[] mComponents;
// //////////////////////////////////////////////////////////////////////////
//
@@ -35,7 +35,7 @@ public class FocusTraversalOnArray extends FocusTraversalPolicy {
* @param components a Component
*/
public FocusTraversalOnArray(final Component[] components) {
m_Components = components;
mComponents = components;
}
// //////////////////////////////////////////////////////////////////////////
@@ -44,15 +44,15 @@ public class FocusTraversalOnArray extends FocusTraversalPolicy {
//
// //////////////////////////////////////////////////////////////////////////
private int indexCycle(final int index, final int delta) {
int size = m_Components.length;
int size = mComponents.length;
int next = (index + delta + size) % size;
return next;
}
private Component cycle(final Component currentComponent, final int delta) {
int index = -1;
loop: for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
loop: for (int i = 0; i < mComponents.length; i++) {
Component component = mComponents[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
@@ -69,7 +69,7 @@ public class FocusTraversalOnArray extends FocusTraversalPolicy {
}
index = newIndex;
//
Component component = m_Components[newIndex];
Component component = mComponents[newIndex];
if (component.isEnabled() && component.isVisible() && component.isFocusable()) {
return component;
}
@@ -106,7 +106,7 @@ public class FocusTraversalOnArray extends FocusTraversalPolicy {
* @return Component
*/
public final Component getFirstComponent(final Container container) {
return m_Components[0];
return mComponents[0];
}
/**
@@ -114,7 +114,7 @@ public class FocusTraversalOnArray extends FocusTraversalPolicy {
* @return Component
*/
public final Component getLastComponent(final Container container) {
return m_Components[m_Components.length - 1];
return mComponents[mComponents.length - 1];
}
/**
@@ -124,4 +124,4 @@ public class FocusTraversalOnArray extends FocusTraversalPolicy {
public final Component getDefaultComponent(final Container container) {
return getFirstComponent(container);
}
}
}