DetailPaintThread.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.traceviewer.main;
00002
00003 import java.util.Queue;
00004 import java.util.concurrent.atomic.AtomicInteger;
00005
00006 import org.eclipse.swt.graphics.Color;
00007 import org.eclipse.swt.graphics.GC;
00008 import org.eclipse.swt.graphics.Image;
00009 import org.eclipse.swt.graphics.Device;
00010 import org.eclipse.swt.graphics.Point;
00011
00012 import edu.rice.cs.hpc.traceviewer.data.db.BaseDataVisualization;
00013 import edu.rice.cs.hpc.traceviewer.data.db.TimelineDataSet;
00014 import edu.rice.cs.hpc.traceviewer.data.util.Constants;
00015 import edu.rice.cs.hpc.traceviewer.painter.BasePaintThread;
00016 import edu.rice.cs.hpc.traceviewer.painter.ImagePosition;
00017 import edu.rice.cs.hpc.traceviewer.spaceTimeData.SpaceTimeDataController;
00018
00019
00020
00021
00022
00023
00024
00025
00026 public class DetailPaintThread
00027 extends BasePaintThread
00028 {
00029 final private boolean debugMode;
00030
00031 final private Point maxTextSize;
00032
00033 private Image lineFinal;
00034 private Image lineOriginal;
00035 private GC gcFinal;
00036 private GC gcOriginal;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 public DetailPaintThread( SpaceTimeDataController stData, Queue<TimelineDataSet> list, int numLines,
00053 AtomicInteger paintDone, Device device, int width, Point maxTextSize, boolean debugMode) {
00054
00055 super(stData, list, numLines, paintDone, device, width);
00056
00057 this.maxTextSize = maxTextSize;
00058 this.debugMode = debugMode;
00059 }
00060
00061 private void paintText(GC gc, int odInitPixel, int odFinalPixel, int box_height,
00062 int depth, Color color, int sampleCount) {
00063 if (!debugMode) {
00064 return;
00065 }
00066 final int box_width = odFinalPixel - odInitPixel;
00067
00068 String decoration = String.valueOf(depth);
00069
00070 String count = String.valueOf(sampleCount);
00071 if (sampleCount>DetailViewPaint.MAX_RECORDS_DISPLAY)
00072 count = DetailViewPaint.TOO_MANY_RECORDS;
00073 decoration += "(" + count + ")";
00074
00075
00076 if((box_width - maxTextSize.x) >= 4) {
00077
00078
00079 if ((box_height - maxTextSize.y) >= 4) {
00080
00081 gc.setBackground(color);
00082
00083
00084
00085 if (color.getRed()+color.getBlue()+color.getGreen()>Constants.DARKEST_COLOR_FOR_BLACK_TEXT)
00086 gc.setForeground(Constants.COLOR_BLACK);
00087 else
00088 gc.setForeground(Constants.COLOR_WHITE);
00089
00090 Point textSize = gc.textExtent(decoration);
00091 gc.drawText(decoration, odInitPixel+((box_width - textSize.x)/2), ((box_height - textSize.y)/2));
00092 }
00093 }
00094 }
00095
00096 @Override
00097 protected void initPaint(Device device, int width, int height) {
00098
00099 lineFinal = new Image(device, width, height);
00100 lineOriginal = new Image(device, width, 1);
00101
00102 gcFinal = new GC(lineFinal);
00103 gcOriginal = new GC(lineOriginal);
00104 }
00105
00106 @Override
00107 protected void paint(int position, BaseDataVisualization data, int height) {
00108
00109
00110
00111
00112 paint(gcOriginal, data.x_start, data.x_end, 1, data.color);
00113
00114
00115 paint(gcFinal, data.x_start, data.x_end, height, data.color);
00116
00117
00118 final DetailDataVisualization dataDetail = (DetailDataVisualization) data;
00119 paintText(gcFinal, data.x_start, data.x_end, height,
00120 data.depth, data.color, dataDetail.sample_counts);
00121 }
00122
00123 @Override
00124 protected ImagePosition finalizePaint(int linenum) {
00125
00126 gcOriginal.dispose();
00127 gcFinal.dispose();
00128
00129 final ImagePosition imgPos = new DetailImagePosition(linenum, lineFinal, lineOriginal);
00130
00131 return imgPos;
00132 }
00133
00134 @Override
00135 protected int getNumberOfCreatedData() {
00136
00137 return stData.getNumberOfLines();
00138 }
00139 }