|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: |
//This is the class whose object i am storing in the vector
public class StoreBufferedImage implements Serializable {
private BufferedImage bufferimage;
private int current_index;
public StoreBufferedImage(BufferedImage bufferimage, int current_index) {
super();
this.bufferimage = bufferimage;
this.current_index = current_index;
}
public BufferedImage getBufferimage() {
return bufferimage;
}
public void setBufferimage(BufferedImage bufferimage) {
this.bufferimage = bufferimage;
}
public int getCurrent_index() {
return current_index;
}
public void setCurrent_index(int current_index) {
this.current_index = current_index;
}
}
public class TestPanel extends JPanel
{
public Vector<StoreBufferedImage> undoredo=new Vector<StoreBufferedImage>();
private BufferedImage img;
public BufferedImage getImg() {
return img;
}
public void setImg(BufferedImage img) {
this.img = img;
repaint();
}
public void refreshImage(Graphics g)
{
if(img==null)
{
int w=getWidth();
int h=getHeight();
img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
setImg(img);
Graphics2D gd=img.createGraphics();
gd.setPaint(Color.WHITE);
gd.fillRect(0, 0, w, h);
gd.dispose();
}
g.drawImage(getImg(), 0, 0, (int)(getImg().getWidth()),(int)(getImg().getHeight()), this);
}
public void paint(Graphics g) {
super.paint(g);
refreshImage(g);
repaint();
}
public void undoAction()
{
StoreBufferedImage sbi=(StoreBufferedImage)undoredo.firstElement();
// i am getting the object properly.
setImg(sbi.getBufferimage());
repaint();
//on repaint new image is not loaded into jpanel
}
}
// This is the mouse listener in which i am drawing rectangle in drawbox method (not shown
// here in which i am simply drawing the rectangle)
public class TestMouseListener extends MouseAdapter{
TestPanel tp;
int count=0;
public TestMouseListener(TestPanel tp)
{
this.tp=tp;
}
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
tp.setStartpt(e.getPoint());
}
public void mouseReleased(MouseEvent e) {
tp.setEndpt(e.getPoint());
tp.drawBox(false);
StoreBufferedImage sbi=new StoreBufferedImage(tp.getImg(),++count);
tp.undoredo.add(sbi);
}
}
// I am having undo button in my jframe class (not shown here) . I am calling undoAction method // of TestPanel to perform undo operation.
|
Advertisement
| Hall of Fame |