program towards Interface rather than implementations

This commit is contained in:
Ingmar Goudt 2020-02-10 10:39:56 +01:00
parent b04c436801
commit ae7919cd07
100 changed files with 218 additions and 209 deletions

View file

@ -132,7 +132,7 @@ public abstract class CardRenderer {
}
}
protected void parseRules(List<String> stringRules, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules) {
protected void parseRules(List<String> stringRules, List<TextboxRule> keywords, List<TextboxRule> rules) {
// Translate the textbox text and remove card hints
for (String rule : stringRules) {
// remove all card hints

View file

@ -1170,7 +1170,7 @@ public class ModernCardRenderer extends CardRenderer {
return layout;
}
protected void drawRulesText(Graphics2D g, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules, int x, int y, int w, int h, boolean forceRules) {
protected void drawRulesText(Graphics2D g, List<TextboxRule> keywords, List<TextboxRule> rules, int x, int y, int w, int h, boolean forceRules) {
// Gather all rules to render
List<TextboxRule> allRules = new ArrayList<>(rules);
@ -1271,7 +1271,7 @@ public class ModernCardRenderer extends CardRenderer {
}
// Get the first line of the textbox, the keyword string
private static String getKeywordRulesString(ArrayList<TextboxRule> keywords) {
private static String getKeywordRulesString(List<TextboxRule> keywords) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < keywords.size(); ++i) {
builder.append(keywords.get(i).text);

View file

@ -25,8 +25,8 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
String typeLineString;
String manaCostString;
ObjectColor color;
ArrayList<TextboxRule> rules = new ArrayList<>();
ArrayList<TextboxRule> keywords = new ArrayList<>();
List<TextboxRule> rules = new ArrayList<>();
List<TextboxRule> keywords = new ArrayList<>();
}
private static ArrayList<CardType> ONLY_LAND_TYPE = new ArrayList<CardType>() {

View file

@ -1,6 +1,7 @@
package org.mage.card.arcane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by stravant@gmail.com on 2016-09-14.
@ -8,7 +9,7 @@ import java.util.ArrayList;
public class TextboxBasicManaRule extends TextboxRule {
private final String basicManaSymbol;
public TextboxBasicManaRule(String rule, ArrayList<AttributeRegion> regions, String basicManaSymbol) {
public TextboxBasicManaRule(String rule, List<AttributeRegion> regions, String basicManaSymbol) {
super(rule, regions, TextboxRuleType.BASIC_MANA);
this.basicManaSymbol = basicManaSymbol;

View file

@ -30,7 +30,7 @@ public final class TextboxRuleParser {
// the textbox of a card.
public static TextboxRule parse(CardView source, String rule) {
// List of regions to apply
ArrayList<TextboxRule.AttributeRegion> regions = new ArrayList<>();
java.util.List<TextboxRule.AttributeRegion> regions = new ArrayList<>();
// Leveler / loyalty / basic
boolean isLeveler = false;

View file

@ -7,6 +7,7 @@ import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author spjspj
@ -69,9 +70,9 @@ public enum AltMtgOnlTokensImageSource implements CardImageSource {
return null;
}
HashMap<String, String> copyUrlToImage = null;
HashMap<String, String> copyImageToUrl = null;
HashMap<String, Integer> copyUrlToImageDone = null;
Map<String, String> copyUrlToImage = null;
Map<String, String> copyImageToUrl = null;
Map<String, Integer> copyUrlToImageDone = null;
private void setupLinks() {
if (copyUrlToImage != null) {

View file

@ -4,6 +4,8 @@ package org.mage.plugins.card.dl.sources;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.mage.plugins.card.dl.DownloadJob;
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
import static org.mage.plugins.card.dl.DownloadJob.toFile;
@ -40,7 +42,7 @@ public class CardFrames implements Iterable<DownloadJob> {
@Override
public Iterator<DownloadJob> iterator() {
ArrayList<DownloadJob> jobs = new ArrayList<>();
List<DownloadJob> jobs = new ArrayList<>();
for (String texture : TEXTURES) {
jobs.add(generateDownloadJob(TEXTURES_FOLDER, texture));
}

View file

@ -49,7 +49,7 @@ public interface CardImageSource {
void doPause(String httpImageUrl);
default ArrayList<String> getSupportedSets() {
default List<String> getSupportedSets() {
return new ArrayList<>();
}

View file

@ -23,10 +23,10 @@ public enum CopyPasteImageSource implements CardImageSource {
private Set<String> supportedSets = new LinkedHashSet<String>();
private Set<String> missingCards = new LinkedHashSet<String>();
HashMap<String, String> singleLinks = null;
Map<String, String> singleLinks = null;
boolean loadedFromDialog = false;
boolean viewMissingCards = true;
HashMap<String, Integer> singleLinksDone = null;
Map<String, Integer> singleLinksDone = null;
private static int maxTimes = 2;
@Override
@ -225,13 +225,11 @@ public enum CopyPasteImageSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
public List<String> getSupportedSets() {
setupLinks();
ArrayList<String> supportedSetsCopy = new ArrayList<>();
List<String> supportedSetsCopy = new ArrayList<>();
if (supportedSets.isEmpty()) {
for (String setCode : Sets.getInstance().keySet()) {
supportedSets.add(setCode);
}
supportedSets.addAll(Sets.getInstance().keySet());
}
supportedSetsCopy.addAll(supportedSets);

View file

@ -10,10 +10,7 @@ import mage.client.constants.Constants;
import org.mage.plugins.card.dl.DownloadJob;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.*;
import static org.mage.plugins.card.dl.DownloadJob.fromURL;
import static org.mage.plugins.card.dl.DownloadJob.toFile;
@ -48,7 +45,7 @@ public class DirectLinksForDownload implements Iterable<DownloadJob> {
@Override
public Iterator<DownloadJob> iterator() {
ArrayList<DownloadJob> jobs = new ArrayList<>();
List<DownloadJob> jobs = new ArrayList<>();
for (Map.Entry<String, String> url : directLinks.entrySet()) {
File dst = new File(outDir, url.getKey());

View file

@ -1,11 +1,7 @@
package org.mage.plugins.card.dl.sources;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.*;
import mage.cards.ExpansionSet;
import mage.cards.Sets;
@ -286,7 +282,7 @@ public class GathererSets implements Iterable<DownloadJob> {
c.setTime(new Date());
c.add(Calendar.DATE, DAYS_BEFORE_RELEASE_TO_DOWNLOAD);
Date compareDate = c.getTime();
ArrayList<DownloadJob> jobs = new ArrayList<>();
List<DownloadJob> jobs = new ArrayList<>();
boolean canDownload;
setsToDownload.clear();

View file

@ -69,7 +69,7 @@ public enum GrabbagImageSource implements CardImageSource {
return null;
}
HashMap<String, String> singleLinks = null;
Map<String, String> singleLinks = null;
private void setupLinks() {
if (singleLinks != null) {
@ -485,10 +485,8 @@ public enum GrabbagImageSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
public List<String> getSupportedSets() {
return new ArrayList<>(supportedSets);
}
@Override

View file

@ -289,9 +289,7 @@ public enum MagidexImageSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
public List<String> getSupportedSets() {
return new ArrayList<>(supportedSets);
}
}

View file

@ -7,6 +7,7 @@ import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author spjspj
@ -69,9 +70,9 @@ public enum MtgOnlTokensImageSource implements CardImageSource {
return null;
}
HashMap<String, String> copyUrlToImage = null;
HashMap<String, String> copyImageToUrl = null;
HashMap<String, Integer> copyUrlToImageDone = null;
Map<String, String> copyUrlToImage = null;
Map<String, String> copyImageToUrl = null;
Map<String, Integer> copyUrlToImageDone = null;
private void setupLinks() {
if (copyUrlToImage != null) {

View file

@ -259,7 +259,7 @@ public enum MythicspoilerComSource implements CardImageSource {
cardNameAliases.put("RIX-tetzimocdeathprimordial", "tetzimocprimaldeath");
// <card name, card link>
manualLinks = new HashMap<>();
HashMap<String, String> links = new HashMap<>();
Map<String, String> links = new HashMap<>();
links.put("templeofaclazotz", "templeofaclazotz");
links.put("conquerorsfoothold", "conquerorsfoothold");
links.put("primalwellspring", "primalwellspring");
@ -272,7 +272,7 @@ public enum MythicspoilerComSource implements CardImageSource {
links.put("spitfirebastion", "spitfirebastion");
manualLinks.put("XLN", links);
HashMap<String, String> linksRix = new HashMap<>();
Map<String, String> linksRix = new HashMap<>();
linksRix.put("vaultofcatlacan", "vaultofcatlacan");
linksRix.put("atzalcaveofeternity", "atzalcaveofeternity");
linksRix.put("wingedtempleoforazca", "wingedtempleoforazca");
@ -283,7 +283,7 @@ public enum MythicspoilerComSource implements CardImageSource {
manualLinks.put("RIX", linksRix);
cardNameAliasesStart = new HashMap<>();
HashSet<String> names = new HashSet<>();
Set<String> names = new HashSet<>();
names.add("eldrazidevastator.jpg");
cardNameAliasesStart.put("BFZ", names);
}
@ -450,10 +450,8 @@ public enum MythicspoilerComSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
public List<String> getSupportedSets() {
return new ArrayList<>(supportedSets);
}
}

View file

@ -309,11 +309,10 @@ public enum ScryfallImageSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
public List<String> getSupportedSets() {
// cards
supportedSetsCopy.addAll(ScryfallImageSupportCards.getSupportedSets());
List<String> supportedSetsCopy = new ArrayList<>(ScryfallImageSupportCards.getSupportedSets());
// tokens
for (String code : ScryfallImageSupportTokens.getSupportedSets().keySet()) {

View file

@ -52,7 +52,7 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
@Override
public Iterator<DownloadJob> iterator() {
ArrayList<DownloadJob> jobs = new ArrayList<>();
List<DownloadJob> jobs = new ArrayList<>();
// all symbols on one page
jobs.add(generateDownloadJob());

View file

@ -151,10 +151,8 @@ public enum TokensMtgImageSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
public List<String> getSupportedSets() {
return new ArrayList<>(supportedSets);
}
@Override

View file

@ -625,7 +625,7 @@ public enum WizardCardsImageSource implements CardImageSource {
}
String languageName = languageAliases.get(preferredLanguage);
HashMap<String, Integer> localizedLanguageIds = getlocalizedMultiverseIds(multiverseId);
Map<String, Integer> localizedLanguageIds = getlocalizedMultiverseIds(multiverseId);
if (localizedLanguageIds.containsKey(languageName)) {
return localizedLanguageIds.get(languageName);
} else {
@ -633,11 +633,11 @@ public enum WizardCardsImageSource implements CardImageSource {
}
}
private HashMap<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException {
private Map<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException {
String cardLanguagesUrl = "https://gatherer.wizards.com/Pages/Card/Languages.aspx?multiverseid=" + englishMultiverseId;
Document cardLanguagesDoc = CardImageUtils.downloadHtmlDocument(cardLanguagesUrl);
Elements languageTableRows = cardLanguagesDoc.select("tr.cardItem");
HashMap<String, Integer> localizedIds = new HashMap<>();
Map<String, Integer> localizedIds = new HashMap<>();
if (!languageTableRows.isEmpty()) {
for (Element languageTableRow : languageTableRows) {
Elements languageTableColumns = languageTableRow.select("td");
@ -714,10 +714,8 @@ public enum WizardCardsImageSource implements CardImageSource {
}
@Override
public ArrayList<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
public List<String> getSupportedSets() {
return new ArrayList<>(supportedSets);
}
}

View file

@ -277,7 +277,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
private Object[] getSetsForCurrentImageSource() {
// Set the available sets to the combo box
ArrayList<String> supportedSets = selectedSource.getSupportedSets();
List<String> supportedSets = selectedSource.getSupportedSets();
List<String> setNames = new ArrayList<>();
// multiple sets selection
@ -490,8 +490,8 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
return Collections.synchronizedList(new ArrayList<>(cardsToDownload));
}
public static ArrayList<CardDownloadData> getTokenCardUrls() throws RuntimeException {
ArrayList<CardDownloadData> list = new ArrayList<>();
public static List<CardDownloadData> getTokenCardUrls() throws RuntimeException {
List<CardDownloadData> list = new ArrayList<>();
InputStream in = DownloadPicturesService.class.getClassLoader().getResourceAsStream("card-pictures-tok.txt");
if (in == null) {