forked from External/mage
Big refactoring
I used Intellij IDEA to automatically refactor code to achive 3 goals. 1) get rid of anonymouse classes, and replace the with lamba to get more readeable and clean code (like in TableWaitingDialog). 2) make effectively final variables actually final to avoid inadvertent changes on it in further releases and keep objects as immutable, as possible. 3) Get rid of unused imports (most of the changes) in whole project classes.
This commit is contained in:
parent
a9f2c8c407
commit
076840df53
247 changed files with 1919 additions and 3682 deletions
|
|
@ -68,12 +68,12 @@ public class CardPluginImpl implements CardPlugin {
|
|||
private static final float STACK_SPACING_Y = 0.10f;
|
||||
private static final float ATTACHMENT_SPACING_Y = 0.13f;
|
||||
|
||||
private int landStackMax = 5;
|
||||
private final int landStackMax = 5;
|
||||
// private int cardWidthMin = 50, cardWidthMax = Constants.CARD_SIZE_FULL.width;
|
||||
private int cardWidthMin = (int) GUISizeHelper.battlefieldCardMinDimension.getWidth();
|
||||
private int cardWidthMax = (int) GUISizeHelper.battlefieldCardMaxDimension.getWidth();
|
||||
|
||||
private boolean stackVertical = false;
|
||||
private final boolean stackVertical = false;
|
||||
|
||||
private int playAreaWidth, playAreaHeight;
|
||||
private int cardWidth, cardHeight;
|
||||
|
|
@ -422,7 +422,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
return height - cardSpacingY + GUTTER_Y * 2;
|
||||
}
|
||||
|
||||
private static enum RowType {
|
||||
private enum RowType {
|
||||
land, creature, other, attached;
|
||||
|
||||
public boolean isType(MagePermanent card) {
|
||||
|
|
@ -581,7 +581,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
@Override
|
||||
public void onAddCard(MagePermanent card, int count) {
|
||||
if (card != null) {
|
||||
Animation.showCard((CardPanel) card, count > 0 ? count : 1);
|
||||
Animation.showCard(card, count > 0 ? count : 1);
|
||||
try {
|
||||
while ((card).getAlpha() + 0.05f < 1) {
|
||||
Thread.sleep(30);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ package org.mage.plugins.card.dl;
|
|||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.IndexedPropertyChangeEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
|
@ -55,12 +53,7 @@ public class DownloadGui extends JPanel {
|
|||
p.setBorder(BorderFactory.createTitledBorder("Progress:"));
|
||||
p.add(progress);
|
||||
JButton b = new JButton("X");
|
||||
b.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getDownloader().dispose();
|
||||
}
|
||||
});
|
||||
b.addActionListener(e -> getDownloader().dispose());
|
||||
p.add(b, BorderLayout.EAST);
|
||||
add(p, BorderLayout.NORTH);
|
||||
|
||||
|
|
@ -160,14 +153,11 @@ public class DownloadGui extends JPanel {
|
|||
setBorder(BorderFactory.createTitledBorder(job.getName()));
|
||||
add(bar = new JProgressBar(job.getProgress()));
|
||||
JButton b = new JButton("X");
|
||||
b.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch(getJob().getState()) {
|
||||
case NEW:
|
||||
case WORKING:
|
||||
getJob().setState(State.ABORTED);
|
||||
}
|
||||
b.addActionListener(e -> {
|
||||
switch(getJob().getState()) {
|
||||
case NEW:
|
||||
case WORKING:
|
||||
getJob().setState(State.ABORTED);
|
||||
}
|
||||
});
|
||||
add(b, BorderLayout.EAST);
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ import org.mage.plugins.card.utils.CardImageUtils;
|
|||
*/
|
||||
public class DownloadJob extends AbstractLaternaBean {
|
||||
|
||||
public static enum State {
|
||||
public enum State {
|
||||
|
||||
NEW, WORKING, FINISHED, ABORTED;
|
||||
NEW, WORKING, FINISHED, ABORTED
|
||||
}
|
||||
|
||||
private final String name;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import java.beans.PropertyChangeListener;
|
|||
* @author Clemens Koza
|
||||
*/
|
||||
public abstract class AbstractBoundBean implements BoundBean {
|
||||
protected PropertyChangeSupport s = new PropertyChangeSupport(this);
|
||||
protected final PropertyChangeSupport s = new PropertyChangeSupport(this);
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
s.addPropertyChangeListener(listener);
|
||||
|
|
|
|||
|
|
@ -41,11 +41,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
final Iterable<T> it = Iterables.concat(new ArrayList<Iterable<T>>(l));
|
||||
|
||||
//transform to singleton iterators
|
||||
return new Iterable<T>() {
|
||||
public Iterator<T> iterator() {
|
||||
return new SingletonIterator<T>(it.iterator());
|
||||
}
|
||||
};
|
||||
return () -> new SingletonIterator<T>(it.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +67,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
private class ListenerIterator<T> extends AbstractIterator<T> {
|
||||
|
||||
private final Class<? extends T> listenerClass;
|
||||
private Object[] listeners = listenerList;
|
||||
private final Object[] listeners = listenerList;
|
||||
private int index = listeners.length;
|
||||
|
||||
private ListenerIterator(Class<? extends T> listenerClass) {
|
||||
|
|
@ -96,12 +92,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
private class ClassToIterableFunction<T> implements Function<Class<? extends T>, Iterable<T>> {
|
||||
|
||||
public Iterable<T> apply(final Class<? extends T> from) {
|
||||
return new Iterable<T>() {
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return new ListenerIterator<T>(from);
|
||||
}
|
||||
};
|
||||
return () -> new ListenerIterator<T>(from);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,8 +102,8 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
|
|||
*/
|
||||
private static class SingletonIterator<T> extends AbstractIterator<T> {
|
||||
|
||||
private Iterator<T> it;
|
||||
private HashSet<T> previous = new HashSet<T>();
|
||||
private final Iterator<T> it;
|
||||
private final HashSet<T> previous = new HashSet<T>();
|
||||
|
||||
public SingletonIterator(Iterator<T> it) {
|
||||
this.it = it;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.mage.plugins.card.dl.beans;
|
|||
public class PropertyChangeSupport extends java.beans.PropertyChangeSupport {
|
||||
private static final long serialVersionUID = -4241465377828790076L;
|
||||
|
||||
private Object sourceBean;
|
||||
private final Object sourceBean;
|
||||
|
||||
public PropertyChangeSupport(Object sourceBean) {
|
||||
super(sourceBean);
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ public final class ListenableCollections {
|
|||
private static class ListenableList<E> extends AbstractList<E> implements RandomAccess, Serializable {
|
||||
private static final long serialVersionUID = 8622608480525537692L;
|
||||
|
||||
private List<E> delegate;
|
||||
private ListListener<E> listener;
|
||||
private final List<E> delegate;
|
||||
private final ListListener<E> listener;
|
||||
|
||||
public ListenableList(List<E> delegate, ListListener<E> listener) {
|
||||
this.delegate = delegate;
|
||||
|
|
@ -110,8 +110,8 @@ public final class ListenableCollections {
|
|||
private static class ListenableSequentialList<E> extends AbstractSequentialList<E> implements Serializable {
|
||||
private static final long serialVersionUID = 3630474556578001885L;
|
||||
|
||||
private List<E> delegate;
|
||||
private ListListener<E> listener;
|
||||
private final List<E> delegate;
|
||||
private final ListListener<E> listener;
|
||||
|
||||
public ListenableSequentialList(List<E> delegate, ListListener<E> listener) {
|
||||
this.delegate = delegate;
|
||||
|
|
@ -185,23 +185,23 @@ public final class ListenableCollections {
|
|||
}
|
||||
}
|
||||
|
||||
public static interface SetListener<E> extends Serializable {
|
||||
public interface SetListener<E> extends Serializable {
|
||||
/**
|
||||
* Notified after a value was added to the set.
|
||||
*/
|
||||
public void add(E newValue);
|
||||
void add(E newValue);
|
||||
|
||||
/**
|
||||
* Notified after a value was removed from the set.
|
||||
*/
|
||||
public void remove(E oldValue);
|
||||
void remove(E oldValue);
|
||||
}
|
||||
|
||||
private static class ListenableSet<E> extends AbstractSet<E> implements Serializable {
|
||||
private static final long serialVersionUID = 7728087988927063221L;
|
||||
|
||||
private Set<E> delegate;
|
||||
private SetListener<E> listener;
|
||||
private final Set<E> delegate;
|
||||
private final SetListener<E> listener;
|
||||
|
||||
public ListenableSet(Set<E> set, SetListener<E> listener) {
|
||||
delegate = set;
|
||||
|
|
@ -220,7 +220,7 @@ public final class ListenableCollections {
|
|||
listener.add(o);
|
||||
}
|
||||
return b;
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
|
@ -268,29 +268,29 @@ public final class ListenableCollections {
|
|||
}
|
||||
}
|
||||
|
||||
public static interface MapListener<K, V> extends Serializable {
|
||||
public interface MapListener<K, V> extends Serializable {
|
||||
/**
|
||||
* Notified after a value was put into the map.
|
||||
*/
|
||||
public void put(K key, V newValue);
|
||||
void put(K key, V newValue);
|
||||
|
||||
/**
|
||||
* Notified after a value in the map was changed.
|
||||
*/
|
||||
public void set(K key, V oldValue, V newValue);
|
||||
void set(K key, V oldValue, V newValue);
|
||||
|
||||
/**
|
||||
* Notified after a value was removed from the map.
|
||||
*/
|
||||
public void remove(K key, V oldValue);
|
||||
void remove(K key, V oldValue);
|
||||
}
|
||||
|
||||
private static class ListenableMap<K, V> extends AbstractMap<K, V> implements Serializable {
|
||||
private static final long serialVersionUID = 4032087477448965103L;
|
||||
|
||||
private Map<K, V> delegate;
|
||||
private MapListener<K, V> listener;
|
||||
private Set<Entry<K, V>> entrySet;
|
||||
private final Map<K, V> delegate;
|
||||
private final MapListener<K, V> listener;
|
||||
private final Set<Entry<K, V>> entrySet;
|
||||
|
||||
public ListenableMap(Map<K, V> map, MapListener<K, V> listener) {
|
||||
this.listener = listener;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.Set;
|
|||
* @author Clemens Koza
|
||||
*/
|
||||
public class CompoundProperties extends AbstractProperties {
|
||||
private List<Properties> delegates;
|
||||
private final List<Properties> delegates;
|
||||
|
||||
public CompoundProperties(Properties... delegates) {
|
||||
this.delegates = asList(delegates);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import org.mage.plugins.card.dl.beans.collections.ListenableCollections.ListList
|
|||
public class PropertyChangeListListener<E> implements ListListener<E> {
|
||||
private static final long serialVersionUID = 625853864429729560L;
|
||||
|
||||
private PropertyChangeSupport s;
|
||||
private String propertyName;
|
||||
private final PropertyChangeSupport s;
|
||||
private final String propertyName;
|
||||
|
||||
public PropertyChangeListListener(PropertyChangeSupport s, String propertyName) {
|
||||
this.s = s;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import org.mage.plugins.card.dl.beans.collections.ListenableCollections.MapListe
|
|||
public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
|
||||
private static final long serialVersionUID = 625853864429729560L;
|
||||
|
||||
private PropertyChangeSupport s;
|
||||
private Map<K, V> map;
|
||||
private String propertyName;
|
||||
private final PropertyChangeSupport s;
|
||||
private final Map<K, V> map;
|
||||
private final String propertyName;
|
||||
|
||||
public PropertyChangeMapListener(PropertyChangeSupport s, Map<K, V> map, String propertyName) {
|
||||
this.s = s;
|
||||
|
|
@ -49,8 +49,8 @@ public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
|
|||
public static abstract class MapEvent<K, V> extends PropertyChangeEvent {
|
||||
private static final long serialVersionUID = -651568020675693544L;
|
||||
|
||||
private Map<K, V> map;
|
||||
private K key;
|
||||
private final Map<K, V> map;
|
||||
private final K key;
|
||||
|
||||
public MapEvent(Object source, String propertyName, Map<K, V> map, K key) {
|
||||
super(source, propertyName, null, null);
|
||||
|
|
@ -77,7 +77,7 @@ public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
|
|||
public static class MapPutEvent<K, V> extends MapEvent<K, V> {
|
||||
private static final long serialVersionUID = 6006291474676939650L;
|
||||
|
||||
private V newElement;
|
||||
private final V newElement;
|
||||
|
||||
public MapPutEvent(Object source, String propertyName, Map<K, V> map, K key, V newElement) {
|
||||
super(source, propertyName, map, key);
|
||||
|
|
@ -92,7 +92,8 @@ public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
|
|||
public static class MapSetEvent<K, V> extends MapEvent<K, V> {
|
||||
private static final long serialVersionUID = -2419438379909500079L;
|
||||
|
||||
private V oldElement, newElement;
|
||||
private final V oldElement;
|
||||
private final V newElement;
|
||||
|
||||
public MapSetEvent(Object source, String propertyName, Map<K, V> map, K key, V oldElement, V newElement) {
|
||||
super(source, propertyName, map, key);
|
||||
|
|
@ -112,7 +113,7 @@ public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
|
|||
public static class MapRemoveEvent<K, V> extends MapEvent<K, V> {
|
||||
private static final long serialVersionUID = -2644879706878221895L;
|
||||
|
||||
private V oldElement;
|
||||
private final V oldElement;
|
||||
|
||||
public MapRemoveEvent(Object source, String propertyName, Map<K, V> map, K key, V oldElement) {
|
||||
super(source, propertyName, map, key);
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import org.mage.plugins.card.dl.beans.collections.ListenableCollections.SetListe
|
|||
public class PropertyChangeSetListener<E> implements SetListener<E> {
|
||||
private static final long serialVersionUID = 625853864429729560L;
|
||||
|
||||
private PropertyChangeSupport s;
|
||||
private Set<E> set;
|
||||
private String propertyName;
|
||||
private final PropertyChangeSupport s;
|
||||
private final Set<E> set;
|
||||
private final String propertyName;
|
||||
|
||||
public PropertyChangeSetListener(PropertyChangeSupport s, Set<E> set, String propertyName) {
|
||||
this.s = s;
|
||||
|
|
@ -45,7 +45,7 @@ public class PropertyChangeSetListener<E> implements SetListener<E> {
|
|||
public static abstract class SetEvent<E> extends PropertyChangeEvent {
|
||||
private static final long serialVersionUID = -651568020675693544L;
|
||||
|
||||
private Set<E> set;
|
||||
private final Set<E> set;
|
||||
|
||||
public SetEvent(Object source, String propertyName, Set<E> set) {
|
||||
super(source, propertyName, null, null);
|
||||
|
|
@ -67,7 +67,7 @@ public class PropertyChangeSetListener<E> implements SetListener<E> {
|
|||
public static class SetAddEvent<E> extends SetEvent<E> {
|
||||
private static final long serialVersionUID = 9041766866796759871L;
|
||||
|
||||
private E newElement;
|
||||
private final E newElement;
|
||||
|
||||
public SetAddEvent(Object source, String propertyName, Set<E> set, E newElement) {
|
||||
super(source, propertyName, set);
|
||||
|
|
@ -82,7 +82,7 @@ public class PropertyChangeSetListener<E> implements SetListener<E> {
|
|||
public static class SetRemoveEvent<E> extends SetEvent<E> {
|
||||
private static final long serialVersionUID = -1315342339926392385L;
|
||||
|
||||
private E oldElement;
|
||||
private final E oldElement;
|
||||
|
||||
public SetRemoveEvent(Object source, String propertyName, Set<E> set, E oldElement) {
|
||||
super(source, propertyName, set);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ import org.mage.plugins.card.dl.beans.properties.bound.BoundProperties;
|
|||
*/
|
||||
public class AbstractLaternaBean extends AbstractBoundBean {
|
||||
protected static final Logger log = Logger.getLogger(AbstractLaternaBean.class);
|
||||
protected Properties properties = new BoundProperties(s);
|
||||
protected final Properties properties = new BoundProperties(s);
|
||||
protected EventListenerList listeners = new EventListenerList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,9 @@
|
|||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import org.mage.plugins.card.images.DownloadPictures;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
|
|||
|
|
@ -28,11 +28,9 @@
|
|||
package org.mage.plugins.card.dl.sources;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.images.CardDownloadData;
|
||||
import org.mage.plugins.card.images.DownloadPictures;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ public class MythicspoilerComSource implements CardImageSource {
|
|||
cardName = cardLink.substring(6, cardLink.length() - 4);
|
||||
} else if (aliasesStart.contains(cardLink)) {
|
||||
cardName = cardLink.substring(0, cardLink.length() - 4);
|
||||
;
|
||||
}
|
||||
if (cardName != null && !cardName.isEmpty()) {
|
||||
if (cardNameAliases.containsKey(cardSet + "-" + cardName)) {
|
||||
|
|
@ -209,11 +208,7 @@ public class MythicspoilerComSource implements CardImageSource {
|
|||
if (card.isFlippedSide()) { //doesn't support rotated images
|
||||
return null;
|
||||
}
|
||||
Map<String, String> setLinks = sets.get(cardSet);
|
||||
if (setLinks == null) {
|
||||
setLinks = getSetLinks(cardSet);
|
||||
sets.put(cardSet, setLinks);
|
||||
}
|
||||
Map<String, String> setLinks = sets.computeIfAbsent(cardSet, k -> getSetLinks(cardSet));
|
||||
String searchName = card.getDownloadName().toLowerCase()
|
||||
.replaceAll(" ", "")
|
||||
.replaceAll("-", "")
|
||||
|
|
|
|||
|
|
@ -440,11 +440,7 @@ public class WizardCardsImageSource implements CardImageSource {
|
|||
}
|
||||
String setNames = setsAliases.get(cardSet);
|
||||
if (setNames != null) {
|
||||
Map<String, String> setLinks = sets.get(cardSet);
|
||||
if (setLinks == null) {
|
||||
setLinks = getSetLinks(cardSet);
|
||||
sets.put(cardSet, setLinks);
|
||||
}
|
||||
Map<String, String> setLinks = sets.computeIfAbsent(cardSet, k -> getSetLinks(cardSet));
|
||||
String link = setLinks.get(card.getDownloadName().toLowerCase());
|
||||
if (link == null) {
|
||||
int length = collectorId.length();
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ public class CardDownloadData {
|
|||
private String set;
|
||||
private String tokenSetCode;
|
||||
private String tokenDescriptor;
|
||||
private String collectorId;
|
||||
private Integer type;
|
||||
private final String collectorId;
|
||||
private final Integer type;
|
||||
private boolean token;
|
||||
private boolean twoFacedCard;
|
||||
private boolean secondSide;
|
||||
private final boolean twoFacedCard;
|
||||
private final boolean secondSide;
|
||||
private boolean flipCard;
|
||||
private boolean flippedSide;
|
||||
private boolean splitCard;
|
||||
private boolean usesVariousArt;
|
||||
private final boolean usesVariousArt;
|
||||
private boolean isType2;
|
||||
|
||||
public CardDownloadData(String name, String set, String collectorId, boolean usesVariousArt, Integer type, String tokenSetCode, String tokenDescriptor) {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package org.mage.plugins.card.images;
|
|||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
|
|
@ -69,11 +67,11 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
private static final Logger logger = Logger.getLogger(DownloadPictures.class);
|
||||
|
||||
private JProgressBar bar;
|
||||
private final JProgressBar bar;
|
||||
private final JOptionPane dlg;
|
||||
private boolean cancel;
|
||||
private final JButton closeButton;
|
||||
private JButton startDownloadButton;
|
||||
private final JButton startDownloadButton;
|
||||
private int cardIndex;
|
||||
private List<CardDownloadData> cards;
|
||||
private List<CardDownloadData> type2cards;
|
||||
|
|
@ -111,12 +109,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
String title = "Downloading";
|
||||
|
||||
final JDialog dialog = this.dlg.createDialog(frame, title);
|
||||
closeButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
});
|
||||
closeButton.addActionListener(e -> dialog.setVisible(false));
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
|
@ -159,51 +152,45 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
jComboBox1.setModel(jComboBox1Model);
|
||||
jComboBox1.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jComboBox1.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JComboBox cb = (JComboBox) e.getSource();
|
||||
switch (cb.getSelectedIndex()) {
|
||||
case 0:
|
||||
cardImageSource = MagicCardsImageSource.getInstance();
|
||||
break;
|
||||
case 1:
|
||||
cardImageSource = WizardCardsImageSource.getInstance();
|
||||
break;
|
||||
case 2:
|
||||
cardImageSource = MythicspoilerComSource.getInstance();
|
||||
break;
|
||||
case 3:
|
||||
cardImageSource = TokensMtgImageSource.getInstance();
|
||||
break;
|
||||
case 4:
|
||||
cardImageSource = MtgOnlTokensImageSource.getInstance();
|
||||
break;
|
||||
case 5:
|
||||
cardImageSource = AltMtgOnlTokensImageSource.getInstance();
|
||||
break;
|
||||
case 6:
|
||||
cardImageSource = GrabbagImageSource.getInstance();
|
||||
break;
|
||||
case 7:
|
||||
cardImageSource = MagidexImageSource.getInstance();
|
||||
break;
|
||||
}
|
||||
updateCardsToDownload();
|
||||
jComboBox1.addActionListener(e -> {
|
||||
JComboBox cb = (JComboBox) e.getSource();
|
||||
switch (cb.getSelectedIndex()) {
|
||||
case 0:
|
||||
cardImageSource = MagicCardsImageSource.getInstance();
|
||||
break;
|
||||
case 1:
|
||||
cardImageSource = WizardCardsImageSource.getInstance();
|
||||
break;
|
||||
case 2:
|
||||
cardImageSource = MythicspoilerComSource.getInstance();
|
||||
break;
|
||||
case 3:
|
||||
cardImageSource = TokensMtgImageSource.getInstance();
|
||||
break;
|
||||
case 4:
|
||||
cardImageSource = MtgOnlTokensImageSource.getInstance();
|
||||
break;
|
||||
case 5:
|
||||
cardImageSource = AltMtgOnlTokensImageSource.getInstance();
|
||||
break;
|
||||
case 6:
|
||||
cardImageSource = GrabbagImageSource.getInstance();
|
||||
break;
|
||||
case 7:
|
||||
cardImageSource = MagidexImageSource.getInstance();
|
||||
break;
|
||||
}
|
||||
updateCardsToDownload();
|
||||
});
|
||||
p0.add(jComboBox1);
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
// Start
|
||||
startDownloadButton = new JButton("Start download");
|
||||
startDownloadButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Thread(DownloadPictures.this).start();
|
||||
startDownloadButton.setEnabled(false);
|
||||
checkBox.setEnabled(false);
|
||||
}
|
||||
startDownloadButton.addActionListener(e -> {
|
||||
new Thread(DownloadPictures.this).start();
|
||||
startDownloadButton.setEnabled(false);
|
||||
checkBox.setEnabled(false);
|
||||
});
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
|
|
@ -223,12 +210,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
p0.add(checkBox);
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
|
||||
checkBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateCardsToDownload();
|
||||
}
|
||||
});
|
||||
checkBox.addActionListener(e -> updateCardsToDownload());
|
||||
|
||||
// JOptionPane
|
||||
Object[] options = {startDownloadButton, closeButton = new JButton("Cancel")};
|
||||
|
|
@ -669,7 +651,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
if (responseCode == 200 || useTempFile) {
|
||||
if (!useTempFile) {
|
||||
try (BufferedInputStream in = new BufferedInputStream(((HttpURLConnection) httpConn).getInputStream())) {
|
||||
try (BufferedInputStream in = new BufferedInputStream(httpConn.getInputStream())) {
|
||||
//try (BufferedInputStream in = new BufferedInputStream(url.openConnection(p).getInputStream())) {
|
||||
out = new BufferedOutputStream(new TFileOutputStream(temporaryFile));
|
||||
byte[] buf = new byte[1024];
|
||||
|
|
|
|||
|
|
@ -63,18 +63,15 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
|||
return;
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!card.equals(currentCard)) {
|
||||
return;
|
||||
}
|
||||
TextLines textLines = GuiDisplayUtil.getTextLinesfromCardView(card);
|
||||
StringBuilder buffer = GuiDisplayUtil.getRulefromCardView(card, textLines);
|
||||
resizeTooltipIfNeeded(container, textLines.basicTextLength, textLines.lines.size());
|
||||
setText(buffer.toString());
|
||||
setCaretPosition(0);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (!card.equals(currentCard)) {
|
||||
return;
|
||||
}
|
||||
TextLines textLines = GuiDisplayUtil.getTextLinesfromCardView(card);
|
||||
StringBuilder buffer = GuiDisplayUtil.getRulefromCardView(card, textLines);
|
||||
resizeTooltipIfNeeded(container, textLines.basicTextLength, textLines.lines.size());
|
||||
setText(buffer.toString());
|
||||
setCaretPosition(0);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class Transparency {
|
|||
public static Image makeColorTransparent(Image im, final Color color) {
|
||||
ImageFilter filter = new RGBImageFilter() {
|
||||
// the color we are looking for... Alpha bits are set to opaque
|
||||
public int markerRGB = color.getRGB() | 0xFF000000;
|
||||
public final int markerRGB = color.getRGB() | 0xFF000000;
|
||||
|
||||
@Override
|
||||
public final int filterRGB(int x, int y, int rgb) {
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
|
||||
private static final Logger log = Logger.getLogger(ThemePluginImpl.class);
|
||||
private static BufferedImage background;
|
||||
private List flist = new List();
|
||||
private String BackgroundDir = "backgrounds" + File.separator;
|
||||
private final List flist = new List();
|
||||
private final String BackgroundDir = "backgrounds" + File.separator;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue