Fixed the token image bug in ImageCache

Changed CardDetailPanel to display all the info in separate lines
added support for multiselect dialogs in Display, adapted it in Devour
This commit is contained in:
jendave
2011-08-06 03:27:22 +00:00
parent 4099d3fc0b
commit c595bca3db
8 changed files with 216 additions and 200 deletions

View File

@@ -5,8 +5,8 @@
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>0</int> <int>0</int>
<int>1018</int> <int>1280</int>
<int>693</int> <int>707</int>
</object> </object>
</void> </void>
<void id="ArrayList0" property="children"> <void id="ArrayList0" property="children">
@@ -16,8 +16,8 @@
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>0</int> <int>0</int>
<int>249</int> <int>276</int>
<int>693</int> <int>707</int>
</object> </object>
</void> </void>
<void id="ArrayList1" property="children"> <void id="ArrayList1" property="children">
@@ -27,8 +27,8 @@
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>0</int> <int>0</int>
<int>249</int> <int>276</int>
<int>96</int> <int>135</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -47,8 +47,8 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>96</int> <int>135</int>
<int>249</int> <int>276</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -62,9 +62,9 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>106</int> <int>145</int>
<int>249</int> <int>276</int>
<int>177</int> <int>132</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -83,8 +83,8 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>283</int> <int>277</int>
<int>249</int> <int>276</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -98,9 +98,9 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>293</int> <int>287</int>
<int>249</int> <int>276</int>
<int>84</int> <int>107</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -119,8 +119,8 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>377</int> <int>394</int>
<int>249</int> <int>276</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -134,9 +134,9 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>387</int> <int>404</int>
<int>249</int> <int>276</int>
<int>96</int> <int>141</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -155,8 +155,8 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>483</int> <int>545</int>
<int>249</int> <int>276</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -170,9 +170,9 @@
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>0</int> <int>0</int>
<int>493</int> <int>555</int>
<int>249</int> <int>276</int>
<int>200</int> <int>152</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -202,10 +202,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>249</int> <int>276</int>
<int>0</int> <int>0</int>
<int>10</int> <int>10</int>
<int>693</int> <int>707</int>
</object> </object>
</void> </void>
<void property="parent"> <void property="parent">
@@ -217,10 +217,10 @@
<object id="MultiSplitLayout$Split2" class="org.jdesktop.swingx.MultiSplitLayout$Split"> <object id="MultiSplitLayout$Split2" class="org.jdesktop.swingx.MultiSplitLayout$Split">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>0</int> <int>0</int>
<int>470</int> <int>765</int>
<int>693</int> <int>707</int>
</object> </object>
</void> </void>
<void id="ArrayList2" property="children"> <void id="ArrayList2" property="children">
@@ -228,10 +228,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>0</int> <int>0</int>
<int>470</int> <int>765</int>
<int>119</int> <int>124</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -249,9 +249,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>119</int> <int>124</int>
<int>470</int> <int>765</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -264,10 +264,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>129</int> <int>134</int>
<int>470</int> <int>765</int>
<int>120</int> <int>121</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -285,9 +285,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>249</int> <int>255</int>
<int>470</int> <int>765</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -300,10 +300,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>259</int> <int>265</int>
<int>470</int> <int>765</int>
<int>135</int> <int>162</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -321,9 +321,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>394</int> <int>427</int>
<int>470</int> <int>765</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -336,10 +336,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>404</int> <int>437</int>
<int>470</int> <int>765</int>
<int>143</int> <int>122</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -357,9 +357,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>547</int> <int>559</int>
<int>470</int> <int>765</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -372,10 +372,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>259</int> <int>286</int>
<int>557</int> <int>569</int>
<int>470</int> <int>765</int>
<int>136</int> <int>138</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -408,10 +408,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>729</int> <int>1051</int>
<int>0</int> <int>0</int>
<int>10</int> <int>10</int>
<int>693</int> <int>707</int>
</object> </object>
</void> </void>
<void property="parent"> <void property="parent">
@@ -423,10 +423,10 @@
<object id="MultiSplitLayout$Split3" class="org.jdesktop.swingx.MultiSplitLayout$Split"> <object id="MultiSplitLayout$Split3" class="org.jdesktop.swingx.MultiSplitLayout$Split">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>739</int> <int>1061</int>
<int>0</int> <int>0</int>
<int>279</int> <int>219</int>
<int>693</int> <int>707</int>
</object> </object>
</void> </void>
<void id="ArrayList3" property="children"> <void id="ArrayList3" property="children">
@@ -434,10 +434,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>739</int> <int>1061</int>
<int>0</int> <int>0</int>
<int>279</int> <int>219</int>
<int>469</int> <int>396</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">
@@ -455,9 +455,9 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Divider"> <object class="org.jdesktop.swingx.MultiSplitLayout$Divider">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>739</int> <int>1061</int>
<int>469</int> <int>396</int>
<int>279</int> <int>219</int>
<int>10</int> <int>10</int>
</object> </object>
</void> </void>
@@ -470,10 +470,10 @@
<object class="org.jdesktop.swingx.MultiSplitLayout$Leaf"> <object class="org.jdesktop.swingx.MultiSplitLayout$Leaf">
<void property="bounds"> <void property="bounds">
<object class="java.awt.Rectangle"> <object class="java.awt.Rectangle">
<int>739</int> <int>1061</int>
<int>479</int> <int>406</int>
<int>279</int> <int>219</int>
<int>214</int> <int>301</int>
</object> </object>
</void> </void>
<void property="name"> <void property="name">

View File

@@ -9,6 +9,7 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Vector; import java.util.Vector;
@@ -2877,7 +2878,6 @@ public class CardFactory implements NewConstants {
public void execute() { public void execute() {
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController()); PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
CardList creatsToSac = new CardList();
CardList creats = new CardList(play.getCards()); CardList creats = new CardList(play.getCards());
creats = creats.filter(new CardListFilter() { creats = creats.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(Card c) {
@@ -2888,23 +2888,12 @@ public class CardFactory implements NewConstants {
//System.out.println("Creats size: " + creats.size()); //System.out.println("Creats size: " + creats.size());
if(card.getController().equals(Constant.Player.Human)) { if(card.getController().equals(Constant.Player.Human)) {
Object o = null; List<Card> selection = AllZone.Display.getChoices("Select creature to sacrifice",
int creatsSize = creats.size(); creats.toArray());
for(int k = 0; k < creatsSize; k++) { numCreatures[0] = selection.size();
o = AllZone.Display.getChoiceOptional("Select creature to sacrifice", for(int m = 0; m < selection.size(); m++) {
creats.toArray()); AllZone.GameAction.sacrifice(selection.get(m));
if(o == null) break;
Card c = (Card) o;
creatsToSac.add(c);
creats.remove(c);
}
numCreatures[0] = creatsToSac.size();
for(int m = 0; m < creatsToSac.size(); m++) {
AllZone.GameAction.sacrifice(creatsToSac.get(m));
} }
}//human }//human

View File

@@ -1,12 +1,25 @@
package forge;
public interface Display {
public <T> T getChoice(String message, T[] choices);
public <T> T getChoiceOptional(String message, T[] choices); package forge;
import java.util.List;
public interface Display {
public <T> T getChoice(String message, T... choices);
public <T> T getChoiceOptional(String message, T... choices);
public <T> List<T> getChoices(String message, T... choices);
public <T> List<T> getChoicesOptional(String message, T... choices);
public void showMessage(String s); public void showMessage(String s);
public MyButton getButtonOK(); public MyButton getButtonOK();
public MyButton getButtonCancel(); public MyButton getButtonCancel();
// public void showStatus(String message); // public void showStatus(String message);
public void showCombat(String message); public void showCombat(String message);

View File

@@ -9,6 +9,7 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionAdapter;
import java.util.List;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
@@ -198,34 +199,42 @@ public class GuiDisplay2 extends javax.swing.JFrame implements CardContainer, Di
} }
//returned Object could be null //returned Object could be null
public <T> T getChoiceOptional(String message, T[] choices) { public <T> T getChoiceOptional(String message, T... choices) {
ListChooser<T> c = new ListChooser<T>(message, 0, 1, choices); if(choices == null || choices.length == 0) return null;
final JList list = c.getJList(); List<T> choice = getChoices(message, 0, 1, choices);
if(choices[0] instanceof Card) { return choice.isEmpty()? null:choice.get(0);
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent ev) {
if(list.getSelectedValue() instanceof Card) setCard((Card) list.getSelectedValue());
}
});
}
if(!c.show()) return null;
return c.getSelectedValue();
}//getChoiceOptional() }//getChoiceOptional()
// returned Object will never be null // returned Object will never be null
public <T> T getChoice(String message, T[] choices) { public <T> T getChoice(String message, T... choices) {
ListChooser<T> c = new ListChooser<T>(message, 1, choices); List<T> choice = getChoices(message, 1, 1, choices);
assert choice.size() == 1;
return choice.get(0);
}//getChoice()
// returned Object will never be null
public <T> List<T> getChoicesOptional(String message, T... choices) {
return getChoices(message, 0, choices.length, choices);
}//getChoice()
// returned Object will never be null
public <T> List<T> getChoices(String message, T... choices) {
return getChoices(message, 1, choices.length, choices);
}//getChoice()
// returned Object will never be null
public <T> List<T> getChoices(String message, int min, int max, T... choices) {
ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
final JList list = c.getJList(); final JList list = c.getJList();
if(choices[0] instanceof Card) { list.addListSelectionListener(new ListSelectionListener() {
list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) {
public void valueChanged(ListSelectionEvent ev) { if(list.getSelectedValue() instanceof Card) {
if(list.getSelectedValue() instanceof Card) setCard((Card) list.getSelectedValue()); setCard((Card) list.getSelectedValue());
} }
}); }
} });
c.show(); c.show();
return c.getSelectedValue(); return c.getSelectedValues();
}//getChoice() }//getChoice()
private void addListeners() { private void addListeners() {

View File

@@ -31,6 +31,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
@@ -256,39 +257,42 @@ public class GuiDisplay3 extends JFrame implements CardContainer, Display, NewCo
} }
//returned Object could be null //returned Object could be null
public <T> T getChoiceOptional(String message, T[] choices) { public <T> T getChoiceOptional(String message, T... choices) {
if(choices == null || choices.length == 0) return null; if(choices == null || choices.length == 0) return null;
ListChooser<T> c = new ListChooser<T>(message, 0, 1, choices); List<T> choice = getChoices(message, 0, 1, choices);
final JList list = c.getJList(); return choice.isEmpty()? null:choice.get(0);
if(choices[0] instanceof Card) {
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent ev) {
if(list.getSelectedValue() instanceof Card) {
setCard((Card) list.getSelectedValue());
}
}
});
}
if(!c.show()) return null;
return c.getSelectedValue();
}//getChoiceOptional() }//getChoiceOptional()
// returned Object will never be null // returned Object will never be null
public <T> T getChoice(String message, T[] choices) { public <T> T getChoice(String message, T... choices) {
ListChooser<T> c = new ListChooser<T>(message, 1, choices); List<T> choice = getChoices(message, 1, 1, choices);
assert choice.size() == 1;
return choice.get(0);
}//getChoice()
// returned Object will never be null
public <T> List<T> getChoicesOptional(String message, T... choices) {
return getChoices(message, 0, choices.length, choices);
}//getChoice()
// returned Object will never be null
public <T> List<T> getChoices(String message, T... choices) {
return getChoices(message, 1, choices.length, choices);
}//getChoice()
// returned Object will never be null
public <T> List<T> getChoices(String message, int min, int max, T... choices) {
ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
final JList list = c.getJList(); final JList list = c.getJList();
if(choices[0] instanceof Card) { list.addListSelectionListener(new ListSelectionListener() {
list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent ev) {
public void valueChanged(ListSelectionEvent ev) { if(list.getSelectedValue() instanceof Card) {
if(list.getSelectedValue() instanceof Card) { setCard((Card) list.getSelectedValue());
setCard((Card) list.getSelectedValue());
}
} }
}); }
} });
c.show(); c.show();
return c.getSelectedValue(); return c.getSelectedValues();
}//getChoice() }//getChoice()
private void addListeners() { private void addListeners() {

View File

@@ -72,11 +72,10 @@ public class ImageCache implements NewConstants {
if(key.endsWith(TOKEN)) { if(key.endsWith(TOKEN)) {
key = key.substring(0, key.length() - TOKEN.length()); key = key.substring(0, key.length() - TOKEN.length());
path = ForgeProps.getFile(IMAGE_TOKEN); path = ForgeProps.getFile(IMAGE_TOKEN);
System.out.println("path + key: "+ path + " " + key);
} else path = ForgeProps.getFile(IMAGE_BASE); } else path = ForgeProps.getFile(IMAGE_BASE);
File file = new File(path, key + ".jpg"); File file = new File(path, key + ".jpg");
if(!file.exists()) { if(!file.exists()) {
System.out.println("File not found, no image created"); System.out.println("File not found, no image created: " + file);
return null; return null;
} }
BufferedImage image = ImageUtil.getImage(file); BufferedImage image = ImageUtil.getImage(file);
@@ -164,8 +163,9 @@ public class ImageCache implements NewConstants {
private static String getKey(Card card) { private static String getKey(Card card) {
String key = card.getImageName(); String key = card.getImageName();
if(card.isBasicLand() && card.getRandomPicture() != 0) key += card.getRandomPicture(); if(card.isBasicLand() && card.getRandomPicture() != 0) key += card.getRandomPicture();
key = GuiDisplayUtil.cleanString(key);
if(card.isToken()) key += TOKEN; if(card.isToken()) key += TOKEN;
return GuiDisplayUtil.cleanString(key); return key;
} }
/** /**
@@ -180,18 +180,18 @@ public class ImageCache implements NewConstants {
if(srcWidth == tgtWidth && srcHeight == tgtHeight) return original; if(srcWidth == tgtWidth && srcHeight == tgtHeight) return original;
/*AffineTransform at = new AffineTransform(); // AffineTransform at = new AffineTransform();
at.scale((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight); // at.scale((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight);
// at.translate(srcHeight, 0); //// at.translate(srcHeight, 0);
// at.rotate(PI / 2); //// at.rotate(PI / 2);
double scale = min((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight); // double scale = min((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight);
//
BufferedImage image = new BufferedImage(tgtWidth, tgtHeight, BufferedImage.TYPE_INT_ARGB); // BufferedImage image = new BufferedImage(tgtWidth, tgtHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D) image.getGraphics(); // Graphics2D g2d = (Graphics2D) image.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); // g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.drawImage(scale < 0.5? ImageUtil.getBlurredImage(original, 6, 1.0f):original, at, null); // g2d.drawImage(scale < 0.5? ImageUtil.getBlurredImage(original, 6, 1.0f):original, at, null);
g2d.dispose();*/ // g2d.dispose();
ResampleOp resampleOp = new ResampleOp (tgtWidth, tgtHeight); //defaults to Lanczos3 ResampleOp resampleOp = new ResampleOp(tgtWidth, tgtHeight); //defaults to Lanczos3
BufferedImage image = resampleOp.filter(original, null); BufferedImage image = resampleOp.filter(original, null);
return image; return image;
} }
@@ -205,19 +205,19 @@ public class ImageCache implements NewConstants {
int tgtWidth = Constant.Runtime.width[0]; int tgtWidth = Constant.Runtime.width[0];
int tgtHeight = Constant.Runtime.height[0]; int tgtHeight = Constant.Runtime.height[0];
/*AffineTransform at = new AffineTransform(); // AffineTransform at = new AffineTransform();
at.scale((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight); // at.scale((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight);
at.translate(srcHeight, 0); // at.translate(srcHeight, 0);
at.rotate(Math.PI / 2); // at.rotate(Math.PI / 2);
//
double scale = min((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight); // double scale = min((double) tgtWidth / srcWidth, (double) tgtHeight / srcHeight);
//
BufferedImage image = new BufferedImage(tgtHeight, tgtWidth, BufferedImage.TYPE_INT_ARGB); // BufferedImage image = new BufferedImage(tgtHeight, tgtWidth, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D) image.getGraphics(); // Graphics2D g2d = (Graphics2D) image.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); // g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.drawImage(scale < 0.5? ImageUtil.getBlurredImage(original, 6, 1.0f):original, at, null); // g2d.drawImage(scale < 0.5? ImageUtil.getBlurredImage(original, 6, 1.0f):original, at, null);
g2d.dispose();*/ // g2d.dispose();
ResampleOp resampleOp = new ResampleOp (tgtWidth, tgtHeight); //defaults to Lanczos3 ResampleOp resampleOp = new ResampleOp(tgtWidth, tgtHeight); //defaults to Lanczos3
BufferedImage image = resampleOp.filter(original, null); BufferedImage image = resampleOp.filter(original, null);
return image; return image;
} }
@@ -228,16 +228,17 @@ public class ImageCache implements NewConstants {
private static BufferedImage getFullSizeImage(BufferedImage original, double scale) { private static BufferedImage getFullSizeImage(BufferedImage original, double scale) {
if(scale == 1) return original; if(scale == 1) return original;
/*AffineTransform at = new AffineTransform(); // AffineTransform at = new AffineTransform();
at.scale(scale, scale); // at.scale(scale, scale);
//
BufferedImage image = new BufferedImage((int) (original.getWidth() * scale), // BufferedImage image = new BufferedImage((int) (original.getWidth() * scale),
(int) (original.getHeight() * scale), BufferedImage.TYPE_INT_ARGB); // (int) (original.getHeight() * scale), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D) image.getGraphics(); // Graphics2D g2d = (Graphics2D) image.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); // g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.drawImage(scale < 0.5? ImageUtil.getBlurredImage(original, 6, 1.0f):original, at, null); // g2d.drawImage(scale < 0.5? ImageUtil.getBlurredImage(original, 6, 1.0f):original, at, null);
g2d.dispose();*/ // g2d.dispose();
ResampleOp resampleOp = new ResampleOp ((int) (original.getWidth() * scale), (int) (original.getHeight() * scale)); //defaults to Lanczos3 ResampleOp resampleOp = new ResampleOp((int) (original.getWidth() * scale),
(int) (original.getHeight() * scale)); //defaults to Lanczos3
BufferedImage image = resampleOp.filter(original, null); BufferedImage image = resampleOp.filter(original, null);
return image; return image;
} }

View File

@@ -119,7 +119,6 @@ public class ListChooser<T> {
this.maxChoices = maxChoices; this.maxChoices = maxChoices;
this.list = unmodifiableList(list); this.list = unmodifiableList(list);
jList = new JList(new ChooserListModel()); jList = new JList(new ChooserListModel());
jList.getSelectionModel().addListSelectionListener(null);
ok = new CloseAction(OK_OPTION, "OK"); ok = new CloseAction(OK_OPTION, "OK");
ok.setEnabled(minChoices == 0); ok.setEnabled(minChoices == 0);
cancel = new CloseAction(CANCEL_OPTION, "Cancel"); cancel = new CloseAction(CANCEL_OPTION, "Cancel");
@@ -134,6 +133,10 @@ public class ListChooser<T> {
jList.addMouseListener(new DblListener()); jList.addMouseListener(new DblListener());
} }
public List<T> getChoices() {
return list;
}
/** /**
* Returns the JList used in the list chooser. this is useful for registering listeners before showing the * Returns the JList used in the list chooser. this is useful for registering listeners before showing the
* dialog. * dialog.
@@ -158,19 +161,6 @@ public class ListChooser<T> {
if(value != OK_OPTION) jList.clearSelection(); if(value != OK_OPTION) jList.clearSelection();
//can't stop closing by ESC, so repeat if cancelled //can't stop closing by ESC, so repeat if cancelled
} while(minChoices != 0 && value != OK_OPTION); } while(minChoices != 0 && value != OK_OPTION);
/* an assertion checks if some condition is true. if not, an AssertionError is thrown, signaling an
* error in the program's logic
* by default, assertions are disabled at runtime, meaning the boolean expression is not evaluated.
* that is why you should NEVER do critical operations in the assert statement.
* instead of
*
* assert showConfirmDialog(...) == OK_OPTION;
*
* write
*
* int value = showConfirmDialog(...);
* assert value == OK_OPTION;
*/
//this assert checks if we really don't return on a cancel if input is mandatory //this assert checks if we really don't return on a cancel if input is mandatory
assert minChoices == 0 || value == OK_OPTION; assert minChoices == 0 || value == OK_OPTION;
called = true; called = true;

View File

@@ -113,10 +113,11 @@ public class CardDetailPanel extends JPanel implements CardContainer {
StringBuilder area = new StringBuilder(); StringBuilder area = new StringBuilder();
//Token //Token
if(card.isToken()) area.append("Token\n"); if(card.isToken()) area.append("Token");
if(!faceDown) { if(!faceDown) {
//card text //card text
if(area.length() != 0) area.append("\n");
area.append(card.getText()); area.append(card.getText());
} }
@@ -124,14 +125,15 @@ public class CardDetailPanel extends JPanel implements CardContainer {
Counters[] counters = Counters.values(); Counters[] counters = Counters.values();
for(Counters counter:counters) { for(Counters counter:counters) {
if(card.getCounters(counter) != 0) { if(card.getCounters(counter) != 0) {
if(area.length() != 0) area.append("\n");
area.append(counter.getName() + " counters: "); area.append(counter.getName() + " counters: ");
area.append(card.getCounters(counter)); area.append(card.getCounters(counter));
area.append("\n");
} }
} }
//chosen type //chosen type
if(card.getChosenType() != "") { if(card.getChosenType() != "") {
if(area.length() != 0) area.append("\n");
area.append("(chosen type: "); area.append("(chosen type: ");
area.append(card.getChosenType()); area.append(card.getChosenType());
area.append(")"); area.append(")");
@@ -139,6 +141,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
//chosen color //chosen color
if(card.getChosenColor() != "") { if(card.getChosenColor() != "") {
if(area.length() != 0) area.append("\n");
area.append("(chosen color: "); area.append("(chosen color: ");
area.append(card.getChosenColor()); area.append(card.getChosenColor());
area.append(")"); area.append(")");
@@ -146,6 +149,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
//named card //named card
if(card.getNamedCard() != "") { if(card.getNamedCard() != "") {
if(area.length() != 0) area.append("\n");
area.append("(named card: "); area.append("(named card: ");
area.append(card.getNamedCard()); area.append(card.getNamedCard());
area.append(")"); area.append(")");
@@ -153,6 +157,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
//equipping //equipping
if(card.getEquipping().size() > 0) { if(card.getEquipping().size() > 0) {
if(area.length() != 0) area.append("\n");
area.append("=Equipping "); area.append("=Equipping ");
area.append(card.getEquipping().get(0)); area.append(card.getEquipping().get(0));
area.append("="); area.append("=");
@@ -160,6 +165,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
//equipped by //equipped by
if(card.getEquippedBy().size() > 0) { if(card.getEquippedBy().size() > 0) {
if(area.length() != 0) area.append("\n");
area.append("=Equipped by "); area.append("=Equipped by ");
for(Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) { for(Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
area.append(it.next()); area.append(it.next());
@@ -170,6 +176,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
//enchanting //enchanting
if(card.getEnchanting().size() > 0) { if(card.getEnchanting().size() > 0) {
if(area.length() != 0) area.append("\n");
area.append("*Enchanting "); area.append("*Enchanting ");
area.append(card.getEnchanting().get(0)); area.append(card.getEnchanting().get(0));
area.append("*"); area.append("*");
@@ -186,7 +193,10 @@ public class CardDetailPanel extends JPanel implements CardContainer {
} }
//uncastable //uncastable
if(card.isUnCastable()) area.append("This card can't be cast."); if(card.isUnCastable()) {
if(area.length() != 0) area.append("\n");
area.append("This card can't be cast.");
}
cdArea.setText(area.toString()); cdArea.setText(area.toString());
} }