001 /** 002 * Created by IntelliJ IDEA. 003 * User: Wei Wang 004 * Date: Nov 28, 2002 005 * Time: 3:12:09 AM 006 */ 007 008 package EVolve.util.Painters; 009 010 import EVolve.visualization.AutoImage; 011 012 import java.awt.*; 013 import java.util.Stack; 014 015 public class StackHotspotPainter extends Painter{ 016 private Stack currentStack; 017 018 public void paint(AutoImage image, int x, int y, int z) { 019 020 if (z == Integer.MAX_VALUE) {// method return; 021 image.setColor(x,y,Color.black); 022 if (!currentStack.empty()) { 023 currentStack.pop(); 024 if (!currentStack.empty()) { 025 image.setColor(x,((Integer)currentStack.peek()).intValue(),Color.red ); 026 } 027 } 028 } else { 029 for (int i=0; i<currentStack.size(); i++) { 030 image.setColor(x,((Integer)currentStack.get(i)).intValue(),Color.blue); 031 } 032 image.setColor(x,y,Color.red); 033 currentStack.push(new Integer(y)); 034 } 035 } 036 037 public void setStack(Stack stack) { 038 currentStack = stack; 039 } 040 041 }