New feedback panel (supports mana symbols).

This commit is contained in:
magenoxx 2010-12-25 22:52:16 +03:00
parent faa09b45b7
commit b9eba43ccf
9 changed files with 429 additions and 12 deletions

View file

@ -0,0 +1,58 @@
package mage.client.util.gui;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
public class BufferedImageBuilder {
private static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB;
public BufferedImage bufferImage(Image image) {
return bufferImage(image, DEFAULT_IMAGE_TYPE);
}
public BufferedImage bufferImage(Image image, int type) {
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
Graphics2D g = bufferedImage.createGraphics();
g.drawImage(image, null, null);
//waitForImage(bufferedImage);
return bufferedImage;
}
private void waitForImage(BufferedImage bufferedImage) {
final ImageLoadStatus imageLoadStatus = new ImageLoadStatus();
bufferedImage.getHeight(new ImageObserver() {
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
if (infoflags == ALLBITS) {
imageLoadStatus.heightDone = true;
return true;
}
return false;
}
});
bufferedImage.getWidth(new ImageObserver() {
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
if (infoflags == ALLBITS) {
imageLoadStatus.widthDone = true;
return true;
}
return false;
}
});
while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
}
}
}
class ImageLoadStatus {
public boolean widthDone = false;
public boolean heightDone = false;
}
}

View file

@ -1,10 +1,8 @@
package mage.client.util.gui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.util.ArrayList;
import java.util.List;
@ -17,8 +15,8 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import mage.client.constants.Constants;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Constants;
public class ColorsChooser extends JComboBox implements ListCellRenderer {

View file

@ -0,0 +1,18 @@
package mage.client.util.gui;
import com.mortennobel.imagescaling.ResampleOp;
import java.awt.*;
import java.awt.image.BufferedImage;
/**
* @author nantuko
*/
public class ImageResizeUtil {
public static BufferedImage getResizedImage(BufferedImage original, Rectangle sizeNeed) {
ResampleOp resampleOp = new ResampleOp(sizeNeed.width, sizeNeed.height);
BufferedImage image = resampleOp.filter(original, null);
return image;
}
}