mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
All 1-character strings converted to primitives
"b" + "r" now changed to 'b' + 'w'. It's more straight-forward, and may cause perfomance improvements - character primitives allocation is faster and less expensive than string creation.
This commit is contained in:
parent
31589778ca
commit
f60ebfbb1f
451 changed files with 989 additions and 978 deletions
|
|
@ -795,7 +795,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
try {
|
||||
LOGGER.debug("connecting (auto): " + currentConnection.getProxyType().toString()
|
||||
+ " " + currentConnection.getProxyHost() + " " + currentConnection.getProxyPort() + " " + currentConnection.getProxyUsername());
|
||||
+ ' ' + currentConnection.getProxyHost() + ' ' + currentConnection.getProxyPort() + ' ' + currentConnection.getProxyUsername());
|
||||
if (MageFrame.connect(currentConnection)) {
|
||||
showGames(false);
|
||||
return true;
|
||||
|
|
@ -1334,7 +1334,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
hideTables();
|
||||
SessionHandler.disconnect(false);
|
||||
if (errorCall) {
|
||||
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + "?");
|
||||
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + '?');
|
||||
message.setButton1("No", null);
|
||||
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
|
||||
showUserRequestDialog(message);
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public class BigCard extends JComponent {
|
|||
|
||||
try {
|
||||
for (String line : strings) {
|
||||
doc.insertString(doc.getLength(), line + "\n", doc.getStyle("regular"));
|
||||
doc.insertString(doc.getLength(), line + '\n', doc.getStyle("regular"));
|
||||
}
|
||||
} catch (BadLocationException ble) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
|
||||
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
gImage.drawString(card.getPower() + "/" + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
gImage.drawString(card.getPower() + '/' + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
}
|
||||
|
|
@ -228,27 +228,27 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
StringBuilder sb = new StringBuilder();
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
for (String rule : getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
} else {
|
||||
sb.append(card.getName());
|
||||
if (card.getManaCost().size() > 0) {
|
||||
sb.append("\n").append(card.getManaCost());
|
||||
sb.append('\n').append(card.getManaCost());
|
||||
}
|
||||
sb.append("\n").append(cardType);
|
||||
sb.append('\n').append(cardType);
|
||||
if (card.getColor().hasColor()) {
|
||||
sb.append("\n").append(card.getColor().toString());
|
||||
sb.append('\n').append(card.getColor().toString());
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(card.getPower()).append("/").append(card.getToughness());
|
||||
sb.append('\n').append(card.getPower()).append('/').append(card.getToughness());
|
||||
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(card.getLoyalty());
|
||||
sb.append('\n').append(card.getLoyalty());
|
||||
}
|
||||
for (String rule : getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(card.getCardNumber()).append(" - ");
|
||||
sb.append('\n').append(card.getCardNumber()).append(" - ");
|
||||
sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
try {
|
||||
for (String rule : getRules()) {
|
||||
doc.insertString(doc.getLength(), rule + "\n", doc.getStyle("small"));
|
||||
doc.insertString(doc.getLength(), rule + '\n', doc.getStyle("small"));
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
}
|
||||
|
|
@ -301,17 +301,17 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
StringBuilder sbType = new StringBuilder();
|
||||
|
||||
for (String superType : card.getSuperTypes()) {
|
||||
sbType.append(superType).append(" ");
|
||||
sbType.append(superType).append(' ');
|
||||
}
|
||||
|
||||
for (CardType cardType : card.getCardTypes()) {
|
||||
sbType.append(cardType.toString()).append(" ");
|
||||
sbType.append(cardType.toString()).append(' ');
|
||||
}
|
||||
|
||||
if (card.getSubTypes().size() > 0) {
|
||||
sbType.append("- ");
|
||||
for (String subType : card.getSubTypes()) {
|
||||
sbType.append(subType).append(" ");
|
||||
sbType.append(subType).append(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -708,7 +708,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + sort.toString() + "," + Boolean.toString(separateCreatures) + "," + Integer.toString(cardSize) + ")";
|
||||
return '(' + sort.toString() + ',' + Boolean.toString(separateCreatures) + ',' + Integer.toString(cardSize) + ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1327,7 +1327,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
if (!s) {
|
||||
String t = "";
|
||||
for (CardType type : card.getCardTypes()) {
|
||||
t += " " + type.toString();
|
||||
t += ' ' + type.toString();
|
||||
}
|
||||
s |= t.toLowerCase().contains(searchStr);
|
||||
}
|
||||
|
|
@ -1385,14 +1385,14 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// Type line
|
||||
String t = "";
|
||||
for (CardType type : card.getCardTypes()) {
|
||||
t += " " + type.toString();
|
||||
t += ' ' + type.toString();
|
||||
}
|
||||
// Sub & Super Types
|
||||
for (String str : card.getSuperTypes()) {
|
||||
t += " " + str.toLowerCase();
|
||||
t += ' ' + str.toLowerCase();
|
||||
}
|
||||
for (String str : card.getSubTypes()) {
|
||||
t += " " + str.toLowerCase();
|
||||
t += ' ' + str.toLowerCase();
|
||||
}
|
||||
|
||||
for (String qty : qtys.keySet()) {
|
||||
|
|
|
|||
|
|
@ -107,24 +107,24 @@ public class Permanent extends Card {
|
|||
sb.append("\n----- Originally -------\n");
|
||||
sb.append(permanent.getOriginal().getName());
|
||||
if (permanent.getOriginal().getManaCost().size() > 0) {
|
||||
sb.append("\n").append(permanent.getOriginal().getManaCost());
|
||||
sb.append('\n').append(permanent.getOriginal().getManaCost());
|
||||
}
|
||||
sb.append("\n").append(getType(permanent.getOriginal()));
|
||||
sb.append('\n').append(getType(permanent.getOriginal()));
|
||||
if (permanent.getOriginal().getColor().hasColor()) {
|
||||
sb.append("\n").append(permanent.getOriginal().getColor().toString());
|
||||
sb.append('\n').append(permanent.getOriginal().getColor().toString());
|
||||
}
|
||||
if (permanent.getOriginal().getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(permanent.getOriginal().getPower()).append("/").append(permanent.getOriginal().getToughness());
|
||||
sb.append('\n').append(permanent.getOriginal().getPower()).append('/').append(permanent.getOriginal().getToughness());
|
||||
}
|
||||
else if (permanent.getOriginal().getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(permanent.getOriginal().getLoyalty());
|
||||
sb.append('\n').append(permanent.getOriginal().getLoyalty());
|
||||
}
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
if (permanent.getOriginal().getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append("\n").append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append('\n').append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append('\n').append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(permanent.getOriginal().getRarity().toString());
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
|
|
|
|||
|
|
@ -802,6 +802,6 @@ public class RelativeLayout implements LayoutManager2, java.io.Serializable {
|
|||
return getClass().getName()
|
||||
+ "[axis=" + axis
|
||||
+ ",gap=" + gap
|
||||
+ "]";
|
||||
+ ']';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
|
|||
|
||||
private static JLabel createChangingPercentageLabel(final JSlider slider) {
|
||||
|
||||
final JLabel label = new JLabel(" " + String.valueOf(slider.getValue()) + "%");
|
||||
final JLabel label = new JLabel(" " + String.valueOf(slider.getValue()) + '%');
|
||||
|
||||
slider.addChangeListener(e -> {
|
||||
String value = String.valueOf(slider.getValue());
|
||||
|
|
@ -178,7 +178,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
|
|||
labelBuilder.append(" ");
|
||||
}
|
||||
labelBuilder.append(value);
|
||||
labelBuilder.append("%");
|
||||
labelBuilder.append('%');
|
||||
label.setText(labelBuilder.toString());
|
||||
});
|
||||
return label;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return maindeckSettings.toString() + "|" + sideboardSetings.toString() + "|" + dividerLocationNormal + "|" + dividerLocationLimited;
|
||||
return maindeckSettings.toString() + '|' + sideboardSetings.toString() + '|' + dividerLocationNormal + '|' + dividerLocationLimited;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -584,12 +584,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
int second = s - (minute * 60);
|
||||
String text;
|
||||
if (minute < 10) {
|
||||
text = "0" + Integer.toString(minute) + ":";
|
||||
text = '0' + Integer.toString(minute) + ':';
|
||||
} else {
|
||||
text = Integer.toString(minute) + ":";
|
||||
text = Integer.toString(minute) + ':';
|
||||
}
|
||||
if (second < 10) {
|
||||
text = text + "0" + Integer.toString(second);
|
||||
text = text + '0' + Integer.toString(second);
|
||||
} else {
|
||||
text = text + Integer.toString(second);
|
||||
}
|
||||
|
|
@ -599,7 +599,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
if (timeToSubmit > 0) {
|
||||
timeToSubmit--;
|
||||
btnSubmitTimer.setText("Submit (" + timeToSubmit + ")");
|
||||
btnSubmitTimer.setText("Submit (" + timeToSubmit + ')');
|
||||
btnSubmitTimer.setToolTipText("Submit your deck in " + timeToSubmit + " seconds!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,17 +56,17 @@ public class CardHelper {
|
|||
StringBuilder type = new StringBuilder();
|
||||
for (String superType : c.getSuperTypes()) {
|
||||
type.append(superType);
|
||||
type.append(" ");
|
||||
type.append(' ');
|
||||
}
|
||||
for (CardType cardType : c.getCardTypes()) {
|
||||
type.append(cardType.toString());
|
||||
type.append(" ");
|
||||
type.append(' ');
|
||||
}
|
||||
if (c.getSubTypes().size() > 0) {
|
||||
type.append("- ");
|
||||
for (String subType : c.getSubTypes()) {
|
||||
type.append(subType);
|
||||
type.append(" ");
|
||||
type.append(' ');
|
||||
}
|
||||
}
|
||||
return type.toString();
|
||||
|
|
|
|||
|
|
@ -86,10 +86,10 @@ public class MageCardComparator implements Comparator<CardView> {
|
|||
aCom = (float) -1;
|
||||
bCom = (float) -1;
|
||||
if (CardHelper.isCreature(a)) {
|
||||
aCom = new Float(a.getPower() + "." + (a.getToughness().startsWith("-") ? "0" : a.getToughness()));
|
||||
aCom = new Float(a.getPower() + '.' + (a.getToughness().startsWith("-") ? "0" : a.getToughness()));
|
||||
}
|
||||
if (CardHelper.isCreature(b)) {
|
||||
bCom = new Float(b.getPower() + "." + (b.getToughness().startsWith("-") ? "0" : b.getToughness()));
|
||||
bCom = new Float(b.getPower() + '.' + (b.getToughness().startsWith("-") ? "0" : b.getToughness()));
|
||||
}
|
||||
break;
|
||||
// Rarity
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
case 4:
|
||||
return CardHelper.getType(c);
|
||||
case 5:
|
||||
return CardHelper.isCreature(c) ? c.getPower() + "/"
|
||||
return CardHelper.isCreature(c) ? c.getPower() + '/'
|
||||
+ c.getToughness() : "-";
|
||||
case 6:
|
||||
return c.getRarity().toString();
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
|||
|
||||
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
||||
boolean changed = cards.loadCards(exile, bigCard, gameId, true);
|
||||
String titel = name + " (" + exile.size() + ")";
|
||||
String titel = name + " (" + exile.size() + ')';
|
||||
setTitle(titel);
|
||||
this.setTitelBarToolTip(titel);
|
||||
if (exile.size() > 0) {
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ public class ConnectDialog extends MageDialog {
|
|||
// pref settings
|
||||
MageFrame.getInstance().setUserPrefsToConnection(connection);
|
||||
|
||||
logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort());
|
||||
logger.debug("connecting: " + connection.getProxyType() + ' ' + connection.getProxyHost() + ' ' + connection.getProxyPort());
|
||||
task = new ConnectTask();
|
||||
task.execute();
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class GameEndDialog extends MageDialog {
|
|||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (PlayerView player : gameEndView.getPlayers()) {
|
||||
sb.append(player.getName()).append(" Life: ").append(player.getLife()).append(" ");
|
||||
sb.append(player.getName()).append(" Life: ").append(player.getLife()).append(' ');
|
||||
}
|
||||
this.txtLife.setText(sb.toString());
|
||||
|
||||
|
|
@ -128,8 +128,8 @@ public class GameEndDialog extends MageDialog {
|
|||
sdf.applyPattern( "yyyyMMdd_HHmmss" );
|
||||
String fileName = new StringBuilder(dir).append(File.separator)
|
||||
.append(sdf.format(gameEndView.getStartTime()))
|
||||
.append("_").append(gameEndView.getMatchView().getGameType())
|
||||
.append("_").append(gameEndView.getMatchView().getGames().size())
|
||||
.append('_').append(gameEndView.getMatchView().getGameType())
|
||||
.append('_').append(gameEndView.getMatchView().getGames().size())
|
||||
.append(".txt").toString();
|
||||
PrintWriter out = new PrintWriter(fileName);
|
||||
out.print(gamePanel.getGameLog());
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ public class NewTableDialog extends MageDialog {
|
|||
StringBuilder playerTypesString = new StringBuilder();
|
||||
for (Object player : players) {
|
||||
if (playerTypesString.length() > 0) {
|
||||
playerTypesString.append(",");
|
||||
playerTypesString.append(',');
|
||||
}
|
||||
TablePlayerPanel tpp = (TablePlayerPanel) player;
|
||||
playerTypesString.append(tpp.getPlayerType());
|
||||
|
|
|
|||
|
|
@ -836,7 +836,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
StringBuilder packList = new StringBuilder();
|
||||
for (ExpansionInfo exp : allExpansions) {
|
||||
packList.append(exp.getCode());
|
||||
packList.append(";");
|
||||
packList.append(';');
|
||||
}
|
||||
txtRandomPacks.setText(packList.toString());
|
||||
}
|
||||
|
|
@ -860,7 +860,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
StringBuilder packList = new StringBuilder();
|
||||
for (String str : randomPackSelector.getSelectedPacks()) {
|
||||
packList.append(str);
|
||||
packList.append(";");
|
||||
packList.append(';');
|
||||
}
|
||||
this.txtRandomPacks.setText(packList.toString());
|
||||
this.pack();
|
||||
|
|
@ -1088,7 +1088,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
StringBuilder packlist = new StringBuilder();
|
||||
for (String pack : this.randomPackSelector.getSelectedPacks()){
|
||||
packlist.append(pack);
|
||||
packlist.append(";");
|
||||
packlist.append(';');
|
||||
}
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, packlist.toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
// If we are logging the draft create a file that will contain
|
||||
// the log.
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
logFilename = "Draft_" + sdf.format(new Date()) + "_" + draftId + ".txt";
|
||||
logFilename = "Draft_" + sdf.format(new Date()) + '_' + draftId + ".txt";
|
||||
try {
|
||||
Files.write(pathToDraftLog(), "".getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
} catch (IOException ex) {
|
||||
|
|
@ -366,12 +366,12 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
int second = s - (minute * 60);
|
||||
String text;
|
||||
if (minute < 10) {
|
||||
text = "0" + Integer.toString(minute) + ":";
|
||||
text = '0' + Integer.toString(minute) + ':';
|
||||
} else {
|
||||
text = Integer.toString(minute) + ":";
|
||||
text = Integer.toString(minute) + ':';
|
||||
}
|
||||
if (second < 10) {
|
||||
text = text + "0" + Integer.toString(second);
|
||||
text = text + '0' + Integer.toString(second);
|
||||
} else {
|
||||
text = text + Integer.toString(second);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
private void saveDividerLocations() {
|
||||
// save panel sizes and divider locations.
|
||||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
String sb = Double.toString(rec.getWidth()) + "x" + Double.toString(rec.getHeight());
|
||||
String sb = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE, sb);
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAMEPANEL_DIVIDER_LOCATION_0, Integer.toString(this.jSplitPane0.getDividerLocation()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_GAMEPANEL_DIVIDER_LOCATION_1, Integer.toString(this.jSplitPane1.getDividerLocation()));
|
||||
|
|
@ -417,7 +417,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
if (rec != null) {
|
||||
String size = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE, null);
|
||||
String sb = Double.toString(rec.getWidth()) + "x" + Double.toString(rec.getHeight());
|
||||
String sb = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||
// use divider positions only if screen size is the same as it was the time the settings were saved
|
||||
if (size != null && size.equals(sb)) {
|
||||
|
||||
|
|
@ -764,7 +764,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
if (game.getSpellsCastCurrentTurn() > 0 && PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_SHOW_STORM_COUNTER, "true").equals("true")) {
|
||||
this.txtSpellsCast.setVisible(true);
|
||||
this.txtSpellsCast.setText(" " + Integer.toString(game.getSpellsCastCurrentTurn()) + " ");
|
||||
this.txtSpellsCast.setText(' ' + Integer.toString(game.getSpellsCastCurrentTurn()) + ' ');
|
||||
} else {
|
||||
this.txtSpellsCast.setVisible(false);
|
||||
}
|
||||
|
|
@ -1279,7 +1279,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
pickChoice.showDialog(choice, objectId, choiceWindowState);
|
||||
if (choice.isKeyChoice()) {
|
||||
if (pickChoice.isAutoSelect()) {
|
||||
SessionHandler.sendPlayerString(gameId, "#" + choice.getChoiceKey());
|
||||
SessionHandler.sendPlayerString(gameId, '#' + choice.getChoiceKey());
|
||||
} else {
|
||||
SessionHandler.sendPlayerString(gameId, choice.getChoiceKey());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,11 +377,11 @@ public class HelperPanel extends JPanel {
|
|||
public void handleAutoAnswerPopupMenuEvent(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case CMD_AUTO_ANSWER_ID_YES:
|
||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_YES, gameId, originalId.toString() + "#" + message);
|
||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_YES, gameId, originalId.toString() + '#' + message);
|
||||
clickButton(btnLeft);
|
||||
break;
|
||||
case CMD_AUTO_ANSWER_ID_NO:
|
||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_NO, gameId, originalId.toString() + "#" + message);
|
||||
SessionHandler.sendPlayerAction(REQUEST_AUTO_ANSWER_ID_NO, gameId, originalId.toString() + '#' + message);
|
||||
clickButton(btnRight);
|
||||
break;
|
||||
case CMD_AUTO_ANSWER_NAME_YES:
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
int h = priorityTimeLeft / 3600;
|
||||
int m = (priorityTimeLeft % 3600) / 60;
|
||||
int s = priorityTimeLeft % 60;
|
||||
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
|
||||
return (h < 10 ? "0" : "") + h + ':' + (m < 10 ? "0" : "") + m + ':' + (s < 10 ? "0" : "") + s;
|
||||
}
|
||||
|
||||
protected void update(ManaPoolView pool) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class MagePreferences {
|
|||
}
|
||||
|
||||
private static String prefixedKey(String prefix, String key) {
|
||||
return prefix + "/" + key;
|
||||
return prefix + '/' + key;
|
||||
}
|
||||
|
||||
public static String getUserName(String serverAddress) {
|
||||
|
|
|
|||
|
|
@ -161,11 +161,11 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
JTableHeader th = jTablePlayers.getTableHeader();
|
||||
TableColumnModel tcm = th.getColumnModel();
|
||||
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(1)).setHeaderValue("Players (" + this.players.length + ")");
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(1)).setHeaderValue("Players (" + this.players.length + ')');
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(8)).setHeaderValue(
|
||||
"Games " + roomUserInfo.getNumberActiveGames()
|
||||
+ (roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads() : " (")
|
||||
+ " limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
||||
+ " limit: " + roomUserInfo.getNumberMaxGames() + ')');
|
||||
th.repaint();
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
String pwdColumn = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_PASSWORD);
|
||||
switch (action) {
|
||||
case "Join":
|
||||
if (owner.equals(SessionHandler.getUserName()) || owner.startsWith(SessionHandler.getUserName() + ",")) {
|
||||
if (owner.equals(SessionHandler.getUserName()) || owner.startsWith(SessionHandler.getUserName() + ',')) {
|
||||
try {
|
||||
JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
|
|
@ -350,7 +350,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
private void saveDividerLocations() {
|
||||
// save panel sizes and divider locations.
|
||||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
String sb = Double.toString(rec.getWidth()) + "x" + Double.toString(rec.getHeight());
|
||||
String sb = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE, sb);
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_1, Integer.toString(this.jSplitPane1.getDividerLocation()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_2, Integer.toString(this.jSplitPaneTables.getDividerLocation()));
|
||||
|
|
@ -387,7 +387,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
if (rec != null) {
|
||||
String size = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE, null);
|
||||
String sb = Double.toString(rec.getWidth()) + "x" + Double.toString(rec.getHeight());
|
||||
String sb = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||
// use divider positions only if screen size is the same as it was the time the settings were saved
|
||||
if (size != null && size.equals(sb)) {
|
||||
String location = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_DIVIDER_LOCATION_1, null);
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
private void saveDividerLocations() {
|
||||
// save panel sizes and divider locations.
|
||||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
String sb = Double.toString(rec.getWidth()) + "x" + Double.toString(rec.getHeight());
|
||||
String sb = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE, sb);
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_1, Integer.toString(this.jSplitPane1.getDividerLocation()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_2, Integer.toString(this.jSplitPane2.getDividerLocation()));
|
||||
|
|
@ -184,7 +184,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
if (rec != null) {
|
||||
String size = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE, null);
|
||||
String sb = Double.toString(rec.getWidth()) + "x" + Double.toString(rec.getHeight());
|
||||
String sb = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
|
||||
// use divider positions only if screen size is the same as it was the time the settings were saved
|
||||
if (size != null && size.equals(sb)) {
|
||||
String location = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TOURNAMENT_DIVIDER_LOCATION_1, null);
|
||||
|
|
@ -244,7 +244,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((TournamentPane) c).setTitle("Tournament [" + tournament.getTournamentName() + "]");
|
||||
((TournamentPane) c).setTitle("Tournament [" + tournament.getTournamentName() + ']');
|
||||
}
|
||||
txtName.setText(tournament.getTournamentName());
|
||||
txtType.setText(tournament.getTournamentType());
|
||||
|
|
@ -260,7 +260,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
if (tournament.getStepStartTime() != null) {
|
||||
timeLeft = Format.getDuration(tournament.getConstructionTime() - (tournament.getServerTime().getTime() - tournament.getStepStartTime().getTime()) / 1000);
|
||||
}
|
||||
txtTournamentState.setText(new StringBuilder(tournament.getTournamentState()).append(" (").append(timeLeft).append(")").toString());
|
||||
txtTournamentState.setText(new StringBuilder(tournament.getTournamentState()).append(" (").append(timeLeft).append(')').toString());
|
||||
break;
|
||||
case "Dueling":
|
||||
case "Drafting":
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class CardsViewUtil {
|
|||
CardsView cards = new CardsView();
|
||||
|
||||
for (SimpleCardView simple: view.values()) {
|
||||
String key = simple.getExpansionSetCode() + "_" + simple.getCardNumber();
|
||||
String key = simple.getExpansionSetCode() + '_' + simple.getCardNumber();
|
||||
Card card = loadedCards.get(key);
|
||||
if(card == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ public class Format {
|
|||
seconds = seconds % 3600;
|
||||
long m = seconds / 60;
|
||||
long s = seconds % 60;
|
||||
sb.append(h).append(":");
|
||||
sb.append(h).append(':');
|
||||
if (m<10) {
|
||||
sb.append("0");
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(m).append(":");
|
||||
sb.append(m).append(':');
|
||||
if (s<10) {
|
||||
sb.append("0");
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(s);
|
||||
return sb.toString();
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class MusicPlayer {
|
|||
volume = (FloatControl) sourceDataLine.getControl(FloatControl.Type.MASTER_GAIN);
|
||||
sourceDataLine.start();
|
||||
} catch (Exception e) {
|
||||
log.error("Couldn't load file: " + file + " " + e);
|
||||
log.error("Couldn't load file: " + file + ' ' + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ public class GuiDisplayUtil {
|
|||
buffer.append("<tr><td valign='top'><b>");
|
||||
buffer.append(card.getDisplayName());
|
||||
if (card.isGameObject()) {
|
||||
buffer.append(" [").append(card.getId().toString().substring(0, 3)).append("]");
|
||||
buffer.append(" [").append(card.getId().toString().substring(0, 3)).append(']');
|
||||
}
|
||||
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||
buffer.append(symbolCount * GUISizeHelper.cardTooltipFontSize);
|
||||
|
|
@ -232,7 +232,7 @@ public class GuiDisplayUtil {
|
|||
}
|
||||
buffer.append("</td></tr></table>");
|
||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td style='margin-left: 1px'>");
|
||||
String imageSize = " width=" + GUISizeHelper.cardTooltipFontSize + " height=" + GUISizeHelper.cardTooltipFontSize + ">";
|
||||
String imageSize = " width=" + GUISizeHelper.cardTooltipFontSize + " height=" + GUISizeHelper.cardTooltipFontSize + '>';
|
||||
if (card.getColor().isWhite()) {
|
||||
buffer.append("<img src='").append(getResourcePath("card/color_ind_white.png")).append("' alt='W' ").append(imageSize);
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ public class GuiDisplayUtil {
|
|||
|
||||
String pt = "";
|
||||
if (CardUtil.isCreature(card)) {
|
||||
pt = card.getPower() + "/" + card.getToughness();
|
||||
pt = card.getPower() + '/' + card.getToughness();
|
||||
} else if (CardUtil.isPlaneswalker(card)) {
|
||||
pt = card.getLoyalty();
|
||||
}
|
||||
|
|
@ -291,7 +291,7 @@ public class GuiDisplayUtil {
|
|||
buffer.append("<td align='right'>");
|
||||
if (!card.isControlledByOwner()) {
|
||||
if (card instanceof PermanentView) {
|
||||
buffer.append("[").append(((PermanentView) card).getNameOwner()).append("] ");
|
||||
buffer.append('[').append(((PermanentView) card).getNameOwner()).append("] ");
|
||||
} else {
|
||||
buffer.append("[only controlled] ");
|
||||
}
|
||||
|
|
@ -361,16 +361,16 @@ public class GuiDisplayUtil {
|
|||
private static String getTypes(CardView card) {
|
||||
String types = "";
|
||||
for (String superType : card.getSuperTypes()) {
|
||||
types += superType + " ";
|
||||
types += superType + ' ';
|
||||
}
|
||||
for (CardType cardType : card.getCardTypes()) {
|
||||
types += cardType.toString() + " ";
|
||||
types += cardType.toString() + ' ';
|
||||
}
|
||||
if (card.getSubTypes().size() > 0) {
|
||||
types += "- ";
|
||||
}
|
||||
for (String subType : card.getSubTypes()) {
|
||||
types += subType + " ";
|
||||
types += subType + ' ';
|
||||
}
|
||||
return types.trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ public class TableUtil {
|
|||
for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
|
||||
TableColumn column = table.getColumnModel().getColumn(table.convertColumnIndexToView(i));
|
||||
if (!firstValue) {
|
||||
columnWidthSettings.append(",");
|
||||
columnOrderSettings.append(",");
|
||||
columnWidthSettings.append(',');
|
||||
columnOrderSettings.append(',');
|
||||
} else {
|
||||
firstValue = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class MyComboBoxEditor extends BasicComboBoxEditor {
|
|||
|
||||
@Override
|
||||
public Object getItem() {
|
||||
return "[" + this.selectedItem.toString() + "]";
|
||||
return '[' + this.selectedItem.toString() + ']';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class SaveObjectUtil {
|
|||
}
|
||||
}
|
||||
String time = now(DATE_PATTERN);
|
||||
File f = new File("income" + File.separator + name + "_" + time + ".save");
|
||||
File f = new File("income" + File.separator + name + '_' + time + ".save");
|
||||
if (!f.exists()) {
|
||||
f.createNewFile();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -681,17 +681,17 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
StringBuilder sbType = new StringBuilder();
|
||||
|
||||
for (String superType : card.getSuperTypes()) {
|
||||
sbType.append(superType).append(" ");
|
||||
sbType.append(superType).append(' ');
|
||||
}
|
||||
|
||||
for (CardType cardType : card.getCardTypes()) {
|
||||
sbType.append(cardType.toString()).append(" ");
|
||||
sbType.append(cardType.toString()).append(' ');
|
||||
}
|
||||
|
||||
if (card.getSubTypes().size() > 0) {
|
||||
sbType.append("- ");
|
||||
for (String subType : card.getSubTypes()) {
|
||||
sbType.append(subType).append(" ");
|
||||
sbType.append(subType).append(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -702,30 +702,30 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
|
|||
StringBuilder sb = new StringBuilder();
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
for (String rule : card.getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
} else {
|
||||
sb.append(card.getName());
|
||||
if (card.getManaCost().size() > 0) {
|
||||
sb.append("\n").append(card.getManaCost());
|
||||
sb.append('\n').append(card.getManaCost());
|
||||
}
|
||||
sb.append("\n").append(cardType);
|
||||
sb.append('\n').append(cardType);
|
||||
if (card.getColor().hasColor()) {
|
||||
sb.append("\n").append(card.getColor().toString());
|
||||
sb.append('\n').append(card.getColor().toString());
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(card.getPower()).append("/").append(card.getToughness());
|
||||
sb.append('\n').append(card.getPower()).append('/').append(card.getToughness());
|
||||
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(card.getLoyalty());
|
||||
sb.append('\n').append(card.getLoyalty());
|
||||
}
|
||||
if (card.getRules() == null) {
|
||||
card.overrideRules(new ArrayList<>());
|
||||
}
|
||||
for (String rule : card.getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
sb.append('\n').append(rule);
|
||||
}
|
||||
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(card.getCardNumber()).append(" - ");
|
||||
sb.append('\n').append(card.getCardNumber()).append(" - ");
|
||||
sb.append(card.getExpansionSetCode()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
// PT Text
|
||||
ptText = new GlowText();
|
||||
if (CardUtil.isCreature(gameCard)) {
|
||||
ptText.setText(gameCard.getPower() + "/" + gameCard.getToughness());
|
||||
ptText.setText(gameCard.getPower() + '/' + gameCard.getToughness());
|
||||
} else if (CardUtil.isPlaneswalker(gameCard)) {
|
||||
ptText.setText(gameCard.getLoyalty());
|
||||
}
|
||||
|
|
@ -580,9 +580,9 @@ public class CardPanelComponentImpl extends CardPanel {
|
|||
|
||||
// Update card text
|
||||
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) {
|
||||
ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")");
|
||||
ptText.setText(card.getPower() + '/' + card.getToughness() + " (" + card.getLoyalty() + ')');
|
||||
} else if (CardUtil.isCreature(card)) {
|
||||
ptText.setText(card.getPower() + "/" + card.getToughness());
|
||||
ptText.setText(card.getPower() + '/' + card.getToughness());
|
||||
} else if (CardUtil.isPlaneswalker(card)) {
|
||||
ptText.setText(card.getLoyalty());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -380,15 +380,15 @@ public abstract class CardRenderer {
|
|||
} else {
|
||||
StringBuilder sbType = new StringBuilder();
|
||||
for (String superType : cardView.getSuperTypes()) {
|
||||
sbType.append(superType).append(" ");
|
||||
sbType.append(superType).append(' ');
|
||||
}
|
||||
for (CardType cardType : cardView.getCardTypes()) {
|
||||
sbType.append(cardType.toString()).append(" ");
|
||||
sbType.append(cardType.toString()).append(' ');
|
||||
}
|
||||
if (cardView.getSubTypes().size() > 0) {
|
||||
sbType.append("- ");
|
||||
for (String subType : cardView.getSubTypes()) {
|
||||
sbType.append(subType).append(" ");
|
||||
sbType.append(subType).append(' ');
|
||||
}
|
||||
}
|
||||
return sbType.toString();
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class ManaSymbols {
|
|||
setImages.put(set, rarityImages);
|
||||
|
||||
for (String rarityCode : codes) {
|
||||
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET + set + "-" + rarityCode + ".jpg");
|
||||
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET + set + '-' + rarityCode + ".jpg");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
int width = image.getWidth(null);
|
||||
|
|
@ -114,11 +114,11 @@ public class ManaSymbols {
|
|||
}
|
||||
|
||||
for (String code : codes) {
|
||||
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET_SMALL + set + "-" + code + ".png");
|
||||
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET_SMALL + set + '-' + code + ".png");
|
||||
if (file.exists()) {
|
||||
continue;
|
||||
}
|
||||
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET + set + "-" + code + ".jpg");
|
||||
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET + set + '-' + code + ".jpg");
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
try {
|
||||
int width = image.getWidth(null);
|
||||
|
|
@ -130,7 +130,7 @@ public class ManaSymbols {
|
|||
}
|
||||
Rectangle r = new Rectangle(15 + dx, (int) (height * (15.0f + dx) / width));
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
File newFile = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET_SMALL + File.separator + set + "-" + code + ".png");
|
||||
File newFile = new File(getSymbolsPath() + Constants.RESOURCE_PATH_SET_SMALL + File.separator + set + '-' + code + ".png");
|
||||
ImageIO.write(resized, "png", newFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -171,7 +171,7 @@ public class ManaSymbols {
|
|||
resourcePath = Constants.RESOURCE_PATH_MANA_MEDIUM;
|
||||
}
|
||||
for (String symbol : symbols) {
|
||||
File file = new File(getSymbolsPath() + resourcePath + "/" + symbol + ".gif");
|
||||
File file = new File(getSymbolsPath() + resourcePath + '/' + symbol + ".gif");
|
||||
try {
|
||||
|
||||
if (size == 15 || size == 25) {
|
||||
|
|
@ -315,7 +315,7 @@ public class ManaSymbols {
|
|||
if (symbolFilesFound) {
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll(
|
||||
"<img src='file:" + getSymbolsPath(true) + "/symbols/" + resourcePath + "/$1$2.gif' alt='$1$2' width=" + symbolSize
|
||||
+ " height=" + symbolSize + ">");
|
||||
+ " height=" + symbolSize + '>');
|
||||
}
|
||||
replaced = replaced.replace("|source|", "{source}");
|
||||
replaced = replaced.replace("|this|", "{this}");
|
||||
|
|
@ -328,7 +328,7 @@ public class ManaSymbols {
|
|||
int factor = size / 15 + 1;
|
||||
Integer width = setImagesExist.get(_set).width * factor;
|
||||
Integer height = setImagesExist.get(_set).height * factor;
|
||||
return "<img src='file:" + getSymbolsPath() + "/sets/small/" + _set + "-" + rarity + ".png' alt='" + rarity + "' height='" + height + "' width='" + width + "' >";
|
||||
return "<img src='file:" + getSymbolsPath() + "/sets/small/" + _set + '-' + rarity + ".png' alt='" + rarity + "' height='" + height + "' width='" + width + "' >";
|
||||
} else {
|
||||
return set;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -638,7 +638,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
}
|
||||
g.setColor(textColor);
|
||||
g.setFont(ptTextFont);
|
||||
String ptText = cardView.getPower() + "/" + cardView.getToughness();
|
||||
String ptText = cardView.getPower() + '/' + cardView.getToughness();
|
||||
int ptTextWidth = g.getFontMetrics().stringWidth(ptText);
|
||||
g.drawString(ptText,
|
||||
x + (partWidth - ptTextWidth) / 2, curY - ptTextOffset - 1);
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ public class Constants {
|
|||
String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||
}
|
||||
|
||||
public static final String CARD_IMAGE_PATH_TEMPLATE = "." + File.separator + "plugins" + File.separator + "images/{set}/{name}.{collector}.full.jpg";
|
||||
public static final String CARD_IMAGE_PATH_TEMPLATE = '.' + File.separator + "plugins" + File.separator + "images/{set}/{name}.{collector}.full.jpg";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return proxy != null ? proxy.type().toString() + " " : "" + url;
|
||||
return proxy != null ? proxy.type().toString() + ' ' : "" + url;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -196,7 +196,7 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return proxy != null ? proxy.type().toString() + " " : "" + url;
|
||||
return proxy != null ? proxy.type().toString() + ' ' : "" + url;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ public class CardFrames implements Iterable<DownloadJob> {
|
|||
|
||||
private DownloadJob generateDownloadJob(String dirName, String name) {
|
||||
File dst = new File(outDir, name + ".png");
|
||||
String url = BASE_DOWNLOAD_URL + dirName + "/" + name + ".png";
|
||||
return new DownloadJob("frames-" + dirName + "-" + name, fromURL(url), toFile(dst));
|
||||
String url = BASE_DOWNLOAD_URL + dirName + '/' + name + ".png";
|
||||
return new DownloadJob("frames-" + dirName + '-' + name, fromURL(url), toFile(dst));
|
||||
}
|
||||
|
||||
private void useDefaultDir() {
|
||||
|
|
|
|||
|
|
@ -163,12 +163,12 @@ public class GathererSets implements Iterable<DownloadJob> {
|
|||
}
|
||||
|
||||
private DownloadJob generateDownloadJob(String set, String rarity, String urlRarity) {
|
||||
File dst = new File(outDir, set + "-" + rarity + ".jpg");
|
||||
File dst = new File(outDir, set + '-' + rarity + ".jpg");
|
||||
if (symbolsReplacements.containsKey(set)) {
|
||||
set = symbolsReplacements.get(set);
|
||||
}
|
||||
String url = "http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + set + "&size=small&rarity=" + urlRarity;
|
||||
return new DownloadJob(set + "-" + rarity, fromURL(url), toFile(dst));
|
||||
return new DownloadJob(set + '-' + rarity, fromURL(url), toFile(dst));
|
||||
}
|
||||
|
||||
private void changeOutDir(String path) {
|
||||
|
|
|
|||
|
|
@ -54,62 +54,64 @@ public class GathererSymbols implements Iterable<DownloadJob> {
|
|||
|
||||
@Override
|
||||
protected DownloadJob computeNext() {
|
||||
String sym;
|
||||
if (symIndex < symbols.length) {
|
||||
sym = symbols[symIndex++];
|
||||
} else if (numeric <= maxNumeric) {
|
||||
sym = "" + (numeric++);
|
||||
} else {
|
||||
sizeIndex++;
|
||||
if (sizeIndex == sizes.length) {
|
||||
return endOfData();
|
||||
while (true) {
|
||||
String sym;
|
||||
if (symIndex < symbols.length) {
|
||||
sym = symbols[symIndex++];
|
||||
} else if (numeric <= maxNumeric) {
|
||||
sym = "" + (numeric++);
|
||||
} else {
|
||||
sizeIndex++;
|
||||
if (sizeIndex == sizes.length) {
|
||||
return endOfData();
|
||||
}
|
||||
|
||||
symIndex = 0;
|
||||
numeric = 0;
|
||||
dir = new File(outDir, sizes[sizeIndex]);
|
||||
continue;
|
||||
}
|
||||
String symbol = sym.replaceAll("/", "");
|
||||
File dst = new File(dir, symbol + ".gif");
|
||||
|
||||
/**
|
||||
* Handle a bug on Gatherer where a few symbols are missing at the large size.
|
||||
* Fall back to using the medium symbol for those cases.
|
||||
*/
|
||||
int modSizeIndex = sizeIndex;
|
||||
if (sizeIndex == 2) {
|
||||
switch (sym) {
|
||||
case "WP":
|
||||
case "UP":
|
||||
case "BP":
|
||||
case "RP":
|
||||
case "GP":
|
||||
case "E":
|
||||
case "C":
|
||||
modSizeIndex = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Nothing to do, symbol is available in the large size
|
||||
}
|
||||
}
|
||||
|
||||
symIndex = 0;
|
||||
numeric = 0;
|
||||
dir = new File(outDir, sizes[sizeIndex]);
|
||||
return computeNext();
|
||||
}
|
||||
String symbol = sym.replaceAll("/", "");
|
||||
File dst = new File(dir, symbol + ".gif");
|
||||
|
||||
/**
|
||||
* Handle a bug on Gatherer where a few symbols are missing at the large size.
|
||||
* Fall back to using the medium symbol for those cases.
|
||||
*/
|
||||
int modSizeIndex = sizeIndex;
|
||||
if (sizeIndex == 2) {
|
||||
switch (sym) {
|
||||
case "WP":
|
||||
case "UP":
|
||||
case "BP":
|
||||
case "RP":
|
||||
case "GP":
|
||||
case "E":
|
||||
case "C":
|
||||
modSizeIndex = 1;
|
||||
switch (symbol) {
|
||||
case "T":
|
||||
symbol = "tap";
|
||||
break;
|
||||
case "Q":
|
||||
symbol = "untap";
|
||||
break;
|
||||
case "S":
|
||||
symbol = "snow";
|
||||
break;
|
||||
|
||||
default:
|
||||
// Nothing to do, symbol is available in the large size
|
||||
}
|
||||
|
||||
String url = format(urlFmt, sizes[modSizeIndex], symbol);
|
||||
|
||||
return new DownloadJob(sym, fromURL(url), toFile(dst));
|
||||
}
|
||||
|
||||
switch (symbol) {
|
||||
case "T":
|
||||
symbol = "tap";
|
||||
break;
|
||||
case "Q":
|
||||
symbol = "untap";
|
||||
break;
|
||||
case "S":
|
||||
symbol = "snow";
|
||||
break;
|
||||
}
|
||||
|
||||
String url = format(urlFmt, sizes[modSizeIndex], symbol);
|
||||
|
||||
return new DownloadJob(sym, fromURL(url), toFile(dst));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,20 +174,20 @@ public class MagicCardsImageSource implements CardImageSource {
|
|||
|
||||
String preferedLanguage = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PREF_LANGUAGE, "en");
|
||||
|
||||
StringBuilder url = new StringBuilder("http://magiccards.info/scans/").append(preferedLanguage).append("/");
|
||||
url.append(set.toLowerCase()).append("/").append(collectorId);
|
||||
StringBuilder url = new StringBuilder("http://magiccards.info/scans/").append(preferedLanguage).append('/');
|
||||
url.append(set.toLowerCase()).append('/').append(collectorId);
|
||||
|
||||
if (card.isTwoFacedCard()) {
|
||||
url.append(card.isSecondSide() ? "b" : "a");
|
||||
}
|
||||
if (card.isSplitCard()) {
|
||||
url.append("a");
|
||||
url.append('a');
|
||||
}
|
||||
if (card.isFlipCard()) {
|
||||
if (card.isFlippedSide()) { // download rotated by 180 degree image
|
||||
url.append("b");
|
||||
url.append('b');
|
||||
} else {
|
||||
url.append("a");
|
||||
url.append('a');
|
||||
}
|
||||
}
|
||||
url.append(".jpg");
|
||||
|
|
@ -200,16 +200,16 @@ public class MagicCardsImageSource implements CardImageSource {
|
|||
String name = card.getName();
|
||||
// add type to name if it's not 0
|
||||
if (card.getType() > 0) {
|
||||
name = name + " " + card.getType();
|
||||
name = name + ' ' + card.getType();
|
||||
}
|
||||
name = name.replaceAll(" ", "-").replace(",", "").toLowerCase();
|
||||
String set = "not-supported-set";
|
||||
if (setNameTokenReplacement.containsKey(card.getSet())) {
|
||||
set = setNameTokenReplacement.get(card.getSet());
|
||||
} else {
|
||||
set += "-" + card.getSet();
|
||||
set += '-' + card.getSet();
|
||||
}
|
||||
return "http://magiccards.info/extras/token/" + set + "/" + name + ".jpg";
|
||||
return "http://magiccards.info/extras/token/" + set + '/' + name + ".jpg";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class MagidexImageSource implements CardImageSource {
|
|||
}
|
||||
|
||||
// This will properly escape the url
|
||||
URI uri = new URI("http", "magidex.com", "/extstatic/card/" + cardSet + "/" + cardDownloadName + ".jpg", null, null);
|
||||
URI uri = new URI("http", "magidex.com", "/extstatic/card/" + cardSet + '/' + cardDownloadName + ".jpg", null, null);
|
||||
return uri.toASCIIString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class MtgImageSource implements CardImageSource {
|
|||
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
|
||||
}
|
||||
StringBuilder url = new StringBuilder("http://mtgimage.com/set/");
|
||||
url.append(cardSet.toUpperCase()).append("/");
|
||||
url.append(cardSet.toUpperCase()).append('/');
|
||||
|
||||
if (card.isSplitCard()) {
|
||||
url.append(card.getDownloadName().replaceAll(" // ", ""));
|
||||
|
|
@ -86,9 +86,9 @@ public class MtgImageSource implements CardImageSource {
|
|||
}
|
||||
if (card.isFlipCard()) {
|
||||
if (card.isFlippedSide()) { // download rotated by 180 degree image
|
||||
url.append("b");
|
||||
url.append('b');
|
||||
} else {
|
||||
url.append("a");
|
||||
url.append('a');
|
||||
}
|
||||
}
|
||||
url.append(".jpg");
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class MythicspoilerComSource implements CardImageSource {
|
|||
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
|
||||
for (String setName : setNames.split("\\^")) {
|
||||
String URLSetName = URLEncoder.encode(setName, "UTF-8");
|
||||
String baseUrl = "http://mythicspoiler.com/" + URLSetName + "/";
|
||||
String baseUrl = "http://mythicspoiler.com/" + URLSetName + '/';
|
||||
|
||||
Map<String, String> pageLinks = getSetLinksFromPage(cardSet, aliasesStart, prefs, proxyType, baseUrl, baseUrl);
|
||||
setLinks.putAll(pageLinks);
|
||||
|
|
@ -166,7 +166,7 @@ public class MythicspoilerComSource implements CardImageSource {
|
|||
Elements cardsImages = doc.select("img[src^=cards/]"); // starts with cards/
|
||||
if (!aliasesStart.isEmpty()) {
|
||||
for (String text : aliasesStart) {
|
||||
cardsImages.addAll(doc.select("img[src^=" + text + "]"));
|
||||
cardsImages.addAll(doc.select("img[src^=" + text + ']'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,8 +179,8 @@ public class MythicspoilerComSource implements CardImageSource {
|
|||
cardName = cardLink.substring(0, cardLink.length() - 4);
|
||||
}
|
||||
if (cardName != null && !cardName.isEmpty()) {
|
||||
if (cardNameAliases.containsKey(cardSet + "-" + cardName)) {
|
||||
cardName = cardNameAliases.get(cardSet + "-" + cardName);
|
||||
if (cardNameAliases.containsKey(cardSet + '-' + cardName)) {
|
||||
cardName = cardNameAliases.get(cardSet + '-' + cardName);
|
||||
} else if (cardName.endsWith("1") || cardName.endsWith("2") || cardName.endsWith("3") || cardName.endsWith("4") || cardName.endsWith("5")) {
|
||||
if (!cardName.startsWith("forest")
|
||||
&& !cardName.startsWith("swamp")
|
||||
|
|
|
|||
|
|
@ -162,19 +162,19 @@ public class TokensMtgImageSource implements CardImageSource {
|
|||
TokenData tokenData;
|
||||
if (type == 0) {
|
||||
if (matchedTokens.size() > 1) {
|
||||
logger.info("Multiple images were found for token " + name + ", set " + set + ".");
|
||||
logger.info("Multiple images were found for token " + name + ", set " + set + '.');
|
||||
}
|
||||
tokenData = matchedTokens.get(0);
|
||||
} else {
|
||||
if (type > matchedTokens.size()) {
|
||||
logger.warn("Not enough images for token with type " + type + ", name " + name + ", set " + set + ".");
|
||||
logger.warn("Not enough images for token with type " + type + ", name " + name + ", set " + set + '.');
|
||||
return null;
|
||||
}
|
||||
tokenData = matchedTokens.get(card.getType() - 1);
|
||||
}
|
||||
|
||||
String url = "http://tokens.mtg.onl/tokens/" + tokenData.getExpansionSetCode().trim() + "_"
|
||||
+ tokenData.getNumber().trim() + "-" + tokenData.getName().trim() + ".jpg";
|
||||
String url = "http://tokens.mtg.onl/tokens/" + tokenData.getExpansionSetCode().trim() + '_'
|
||||
+ tokenData.getNumber().trim() + '-' + tokenData.getName().trim() + ".jpg";
|
||||
url = url.replace(' ', '-');
|
||||
return url;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,11 +410,11 @@ public class WizardCardsImageSource implements CardImageSource {
|
|||
private String normalizeName(String name) {
|
||||
//Split card
|
||||
if(name.contains("//")) {
|
||||
name = name.substring(0, name.indexOf("(") - 1);
|
||||
name = name.substring(0, name.indexOf('(') - 1);
|
||||
}
|
||||
//Special timeshifted name
|
||||
if(name.startsWith("XX")) {
|
||||
name = name.substring(name.indexOf("(") + 1, name.length() - 1);
|
||||
name = name.substring(name.indexOf('(') + 1, name.length() - 1);
|
||||
}
|
||||
return name.replace("\u2014", "-").replace("\u2019", "'")
|
||||
.replace("\u00C6", "AE").replace("\u00E6", "ae")
|
||||
|
|
@ -456,7 +456,7 @@ public class WizardCardsImageSource implements CardImageSource {
|
|||
} else {
|
||||
link = setLinks.get(Integer.toString(number - 21));
|
||||
if (link != null) {
|
||||
link = link.replace(Integer.toString(number - 20), (Integer.toString(number - 20) + "a"));
|
||||
link = link.replace(Integer.toString(number - 20), (Integer.toString(number - 20) + 'a'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,12 +325,12 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
int tokenImages = 0;
|
||||
for (CardDownloadData card : cardsToDownload) {
|
||||
logger.debug((card.isToken() ? "Token" : "Card") + " image to download: " + card.getName() + " (" + card.getSet() + ")");
|
||||
logger.debug((card.isToken() ? "Token" : "Card") + " image to download: " + card.getName() + " (" + card.getSet() + ')');
|
||||
if (card.isToken()) {
|
||||
tokenImages++;
|
||||
}
|
||||
}
|
||||
logger.info("Check download images (total card images: " + numberCardImages + ", total token images: " + numberAllTokenImages + ")");
|
||||
logger.info("Check download images (total card images: " + numberCardImages + ", total token images: " + numberAllTokenImages + ')');
|
||||
logger.info(" => Missing card images: " + (cardsToDownload.size() - tokenImages));
|
||||
logger.info(" => Missing token images: " + tokenImages);
|
||||
return new ArrayList<>(cardsToDownload);
|
||||
|
|
@ -445,7 +445,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
CardDownloadData card = cardsToDownload.get(i);
|
||||
|
||||
logger.debug("Downloading card: " + card.getName() + " (" + card.getSet() + ")");
|
||||
logger.debug("Downloading card: " + card.getName() + " (" + card.getSet() + ')');
|
||||
|
||||
String url;
|
||||
if (ignoreUrls.contains(card.getSet()) || card.isToken()) {
|
||||
|
|
@ -470,7 +470,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
} catch (Exception ex) {
|
||||
}
|
||||
} else if (cardImageSource.getTotalImages() == -1) {
|
||||
logger.info("Card not available on " + cardImageSource.getSourceName() + ": " + card.getName() + " (" + card.getSet() + ")");
|
||||
logger.info("Card not available on " + cardImageSource.getSourceName() + ": " + card.getName() + " (" + card.getSet() + ')');
|
||||
synchronized (sync) {
|
||||
update(cardIndex + 1, cardsToDownload.size());
|
||||
}
|
||||
|
|
@ -540,7 +540,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
try {
|
||||
filePath.append(Constants.IO.imageBaseDir);
|
||||
if (!useSpecifiedPaths && card != null) {
|
||||
filePath.append(card.hashCode()).append(".").append(card.getName().replace(":", "").replace("//", "-")).append(".jpg");
|
||||
filePath.append(card.hashCode()).append('.').append(card.getName().replace(":", "").replace("//", "-")).append(".jpg");
|
||||
temporaryFile = new File(filePath.toString());
|
||||
}
|
||||
String imagePath;
|
||||
|
|
@ -650,7 +650,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
if (card != null && !useSpecifiedPaths) {
|
||||
logger.warn("Image download for " + card.getName()
|
||||
+ (!card.getDownloadName().equals(card.getName()) ? " downloadname: " + card.getDownloadName() : "")
|
||||
+ "(" + card.getSet() + ") failed - responseCode: " + responseCode + " url: " + url.toString());
|
||||
+ '(' + card.getSet() + ") failed - responseCode: " + responseCode + " url: " + url.toString());
|
||||
}
|
||||
if (logger.isDebugEnabled()) { // Shows the returned html from the request to the web server
|
||||
logger.debug("Returned HTML ERROR:\n" + convertStreamToString(((HttpURLConnection) httpConn).getErrorStream()));
|
||||
|
|
@ -658,7 +658,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
}
|
||||
|
||||
} catch (AccessDeniedException e) {
|
||||
logger.error("The file " + (outputFile != null ? outputFile.toString() : "to add the image of " + card.getName() + "(" + card.getSet() + ")") + " can't be accessed. Try rebooting your system to remove the file lock.");
|
||||
logger.error("The file " + (outputFile != null ? outputFile.toString() : "to add the image of " + card.getName() + '(' + card.getSet() + ')') + " can't be accessed. Try rebooting your system to remove the file lock.");
|
||||
} catch (Exception e) {
|
||||
logger.error(e, e);
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -255,11 +255,11 @@ public class ImageCache {
|
|||
* Returns the map key for a card, without any suffixes for the image size.
|
||||
*/
|
||||
private static String getKey(CardView card, String name, String suffix) {
|
||||
return name + "#" + card.getExpansionSetCode() + "#" + card.getType() + "#" + card.getCardNumber() + "#"
|
||||
return name + '#' + card.getExpansionSetCode() + '#' + card.getType() + '#' + card.getCardNumber() + '#'
|
||||
+ (card.getTokenSetCode() == null ? "" : card.getTokenSetCode())
|
||||
+ suffix
|
||||
+ (card.getUsesVariousArt() ? "#usesVariousArt" : "")
|
||||
+ (card.getTokenDescriptor() != null ? "#" + card.getTokenDescriptor() : "#");
|
||||
+ (card.getTokenDescriptor() != null ? '#' + card.getTokenDescriptor() : "#");
|
||||
}
|
||||
|
||||
// /**
|
||||
|
|
|
|||
|
|
@ -168,11 +168,11 @@ public class CardImageUtils {
|
|||
String imageDir = getImageDir(card, imagesPath);
|
||||
String imageName;
|
||||
|
||||
String type = card.getType() != 0 ? " " + Integer.toString(card.getType()) : "";
|
||||
String type = card.getType() != 0 ? ' ' + Integer.toString(card.getType()) : "";
|
||||
String name = card.getFileName().isEmpty() ? card.getName().replace(":", "").replace("//", "-") : card.getFileName();
|
||||
|
||||
if (card.getUsesVariousArt()) {
|
||||
imageName = name + "." + card.getCollectorId() + ".full.jpg";
|
||||
imageName = name + '.' + card.getCollectorId() + ".full.jpg";
|
||||
} else {
|
||||
imageName = name + type + ".full.jpg";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue