001 /** 002 * Created by IntelliJ IDEA. 003 * User: Wei Wang 004 * Date: Mar 11, 2003 005 * Time: 7:25:53 PM 006 */ 007 008 package EVolve.visualization.XYViz.ValValViz; 009 010 import EVolve.data.Element; 011 import EVolve.util.painters.*; 012 import EVolve.util.painters.shapes.Line; 013 import EVolve.visualization.AutoShapeImage; 014 import EVolve.visualization.Dimension; 015 import EVolve.Scene; 016 017 import javax.swing.*; 018 import java.awt.*; 019 020 public class AllocDensityMetricViz extends Metric{ 021 022 public AllocDensityMetricViz() { 023 super(); 024 } 025 026 public Dimension[] createDimension() { 027 super.createDimension(); 028 Dimension[] returnVal = new Dimension[2]; 029 030 returnVal[0] = xAxis; 031 returnVal[1] = yAxis; 032 033 return returnVal; 034 } 035 036 public JMenuItem[] createSelectionMenuItem() { 037 return null; 038 } 039 040 protected JPanel createConfigurationPanel() { 041 JPanel configurationPanel = new JPanel(new FlowLayout()); 042 configurationPanel.add(new JLabel("Interval: ")); 043 044 textInterval = new JTextField(String.valueOf(interval), 10); 045 configurationPanel.add(textInterval); 046 047 return configurationPanel; 048 } 049 050 public void preVisualize() { 051 image = new AutoShapeImage(new Line(0,0,1)); 052 xMax = 0; 053 installPainter(); 054 super.preVisualize(); 055 } 056 057 public void receiveElement(Element element) { 058 if (element.getField()[element.getField().length-1] == Integer.MAX_VALUE) 059 return; 060 061 long time = xAxis.getField(element); 062 long x = time / interval; 063 long y = yAxis.getField(element); 064 065 countEvents(time); 066 067 if (xOffset == -1) xOffset = x; 068 069 painter.paint(image,x-xOffset,y,time); 070 071 if (time > xMax) xMax = time; 072 } 073 074 public void visualize() { 075 canvas.setName(xAxis.getName() + " (" + xMax + ")", yAxis.getName() + "(" + 076 ((AllocDensityMetricPainter)painter).getMax() + ")"); 077 sort(); 078 } 079 080 protected void installPainter() { 081 painter = new AllocDensityMetricPainter(); 082 } 083 084 public void mouseMove(int x, int y) { 085 int X = canvas.getImageX(x); 086 087 if (image != null) { 088 float value = ((AllocDensityMetricPainter)painter).getValue(X); 089 if (value != -1) 090 Scene.setStatus("Alloc density: "+value); 091 else 092 Scene.setStatus(" "); 093 } 094 095 } 096 }