|
From: <d3...@us...> - 2003-07-20 23:57:52
|
Update of /cvsroot/yacr/analysis/src/exdigsim/guilayer/profiling
In directory sc8-pr-cvs1:/tmp/cvs-serv30541
Modified Files:
ProfilingDiagramm.java
Log Message:
Sync
Index: ProfilingDiagramm.java
===================================================================
RCS file: /cvsroot/yacr/analysis/src/exdigsim/guilayer/profiling/ProfilingDiagramm.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ProfilingDiagramm.java 19 Jul 2003 12:09:38 -0000 1.1
+++ ProfilingDiagramm.java 20 Jul 2003 23:57:49 -0000 1.2
@@ -1,22 +1,36 @@
package exdigsim.guilayer.profiling;
import javax.swing.JPanel;
+import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
+import java.awt.event.MouseEvent;
import java.util.ArrayList;
import exdigsim.logiclayer.analysekomponenten.ZaehlAnalysepunkt;
import exdigsim.guilayer.bausteingui.BausteinGUI;
class ProfilingDiagramm extends JPanel
{
- private ArrayList analysepunkte = null;
- private final ProfilingFrame frame;
- private ProfilingObjectLookupTable lookupTable;
+ private static final int OVAL_X = 7;
+ private static final int OVAL_Y = 7;
+ private static final Color COLOR_TABLE[];
+
+ static
+ {
+ COLOR_TABLE = new Color[256];
+
+ for (int i = 0; i < COLOR_TABLE.length; ++i)
+ COLOR_TABLE[i] = new Color (255, 255-i, i/3);
+ }
+
+
+ private ArrayList analysepunkte = null;
+ private final ProfilingFrame frame;
+ private HeatMatrix heatMatrix;
+
private int resolutionX;
private int resolutionY;
- private int grainX = 0;
- private int grainY = 0;
public ProfilingDiagramm (ProfilingFrame frame,
@@ -28,8 +42,8 @@
this.frame = frame;
this.resolutionX = resolutionX;
this.resolutionY = resolutionY;
- this.grainX = 0;
- this.grainY = 0;
+
+ //TODO: füge Mouse
}
@@ -45,29 +59,14 @@
public int getResolutionY ()
{ return this.resolutionY; }
- public int getGrainX()
- { return this.grainX; }
-
- public int getGrainY()
- { return this.grainY; }
-
-
public void setAnalysepunkte (ArrayList l)
{ this.analysepunkte = l; }
- public void repaint()
- {}
-
- public void update (Graphics g)
- {
- System.out.println ("update()");
- paint (g);
- }
+ public void setHeatMatrix (HeatMatrix m)
+ { this.heatMatrix = m; }
public void paint (Graphics g)
{
- System.out.println ("paint");
-
if (g == null)
return;
g.setColor (java.awt.Color.white);
@@ -89,55 +88,79 @@
return;
}
- graphics.setColor (java.awt.Color.black);
+
- for (int i = 0; i < this.analysepunkte.size(); ++i)
- {
- ZaehlAnalysepunkt p = (ZaehlAnalysepunkt)this.analysepunkte.get (i);
+ float grainX = 0.0f;
+ float grainY = 0.0f;
+ float grainMatrixX = 0.0f;
+ float grainMatrixY = 0.0f;
+ float hitzeVerhaeltnis = 0.0f;
- if (p == null)
+ grainX = ((float)super.getWidth()) / ((float)this.resolutionX);
+ grainY = (float)super.getWidth() / ((float)this.resolutionY);
+ grainMatrixX = ((float)super.getWidth()) / ((float)this.heatMatrix.getWidth());
+ grainMatrixY = ((float)super.getHeight()) / ((float)this.heatMatrix.getHeight());
+ hitzeVerhaeltnis = 255f / (float)this.heatMatrix.getMax();
+
+ final int grainMatrixXInt = (int)grainMatrixX;
+ final int grainMatrixYInt = (int)grainMatrixY;
+
+ for (int i = 0; i < this.heatMatrix.getHeight(); ++i)
+ {
+ for (int j = 0; j < this.heatMatrix.getWidth(); ++j)
{
- System.err.println ("BUGME: ProfilingFrame::aktualisieren");
- continue;
- }
+ int wert = this.heatMatrix.get (i, j);
- BausteinGUI gui = p.getGatterGUI();
+ if (wert == 0)
+ continue;
- int x = gui.getX() * grainX;
- int y = gui.getY() * grainY;
+ final int colorIndex = (int)((float)wert * hitzeVerhaeltnis);;
+ int x = (int)(i*grainMatrixX);
+ int y = (int)(j*grainMatrixY);
- graphics.fillOval (x, y,
- this.grainX, this.grainY);
+ graphics.setColor (COLOR_TABLE[colorIndex/2]);
+ graphics.fillRect (x, y, grainMatrixXInt, grainMatrixYInt);
+
+ graphics.setColor (COLOR_TABLE[colorIndex]);
+ graphics.fillOval (x, y, grainMatrixXInt, grainMatrixYInt);
+
+ if (wert > 1)
+ { // _dreckiger_ Workaround
+ String s = String.valueOf (wert);
+ char sb[] = s.toCharArray();
+ java.awt.FontMetrics metrics = g.getFontMetrics();
+
+ graphics.setColor (Color.black);
+
+ graphics.drawChars (sb, 0, sb.length, x+(grainMatrixXInt-metrics.charsWidth (sb, 0, sb.length))/2, y+(metrics.getHeight()+grainMatrixYInt)/2);
+ }
+ }
}
- }
- public void aktualisiere ()
- {
- this.updateLookupTable();
- this.repaint();
- }
- private void updateLookupTable()
- {
- if (this.analysepunkte == null)
- return;
-
- this.grainX = this.resolutionX / super.getWidth();
- this.grainY = this.resolutionY / super.getHeight();
+// graphics.setColor (java.awt.Color.black);
- this.lookupTable =
- new ProfilingObjectLookupTable (this.resolutionX,
- this.resolutionY,
- this.grainX,
- this.grainY);
+// for (int i = 0; i < this.analysepunkte.size(); ++i)
+// {
+// ZaehlAnalysepunkt p = (ZaehlAnalysepunkt)this.analysepunkte.get (i);
-
- for (int i = 0; i < this.analysepunkte.size(); ++i)
- {
- ZaehlAnalysepunkt a = (ZaehlAnalysepunkt)this.analysepunkte.get (i);
- BausteinGUI gui = a.getGatterGUI();
-
- this.lookupTable.insert (a, gui.getX(), gui.getY());
- }
+// if (p == null)
+// {
+// System.err.println ("BUGME: ProfilingFrame::aktualisieren");
+// continue;
+// }
+
+// BausteinGUI gui = p.getGatterGUI();
+
+// int x = (int)(gui.getX() * grainX);
+// int y = (int)(gui.getY() * grainY);
+
+// graphics.fillOval (x, y, OVAL_X, OVAL_Y);
+// }
+ }
+
+ protected void processMouseEvent (MouseEvent e)
+ {
+ System.out.println ("processMouseEvent");
}
}
|