DepthViewPaint.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.depth;
00002 
00003 import java.util.Queue;
00004 import java.util.concurrent.ExecutorService;
00005 import java.util.concurrent.atomic.AtomicInteger;
00006 
00007 import org.eclipse.core.runtime.IProgressMonitor;
00008 import org.eclipse.swt.graphics.Device;
00009 import org.eclipse.swt.graphics.GC;
00010 import org.eclipse.ui.IWorkbenchWindow;
00011 
00012 import edu.rice.cs.hpc.traceviewer.data.db.TimelineDataSet;
00013 import edu.rice.cs.hpc.traceviewer.painter.BasePaintThread;
00014 import edu.rice.cs.hpc.traceviewer.painter.BaseViewPaint;
00015 import edu.rice.cs.hpc.traceviewer.painter.ISpaceTimeCanvas;
00016 import edu.rice.cs.hpc.traceviewer.painter.ImagePosition;
00017 import edu.rice.cs.hpc.traceviewer.painter.ImageTraceAttributes;
00018 import edu.rice.cs.hpc.traceviewer.spaceTimeData.SpaceTimeDataController;
00019 import edu.rice.cs.hpc.traceviewer.timeline.BaseTimelineThread;
00020 
00021 /******************************************************
00022  * 
00023  * Painting class for depth view
00024  *
00025  ******************************************************/
00026 public class DepthViewPaint extends BaseViewPaint {
00027 
00028     private final GC masterGC;
00029     private float numPixels;
00030     
00031     public DepthViewPaint(IWorkbenchWindow window, final GC masterGC, SpaceTimeDataController _data,
00032             ImageTraceAttributes _attributes, boolean _changeBound, ISpaceTimeCanvas canvas, 
00033             ExecutorService threadExecutor) {
00034         
00035         super("Depth view", _data, _attributes, _changeBound,  window, canvas, threadExecutor);
00036         this.masterGC = masterGC;
00037     }
00038 
00039     @Override
00040     protected boolean startPainting(int linesToPaint, int numThreads, boolean changedBounds) {
00041         int process = attributes.getPosition().process;
00042         
00043         // we need to check if the data is ready.
00044         // data is ready iff 
00045         //  - a process has been selected for the depth view (within the range)
00046         //  - and the main view has finished generated the timelines
00047         
00048         if (process >= attributes.getProcessBegin() && process <= attributes.getProcessEnd()) {
00049             
00050             if ( controller.getDepthTrace() != null) {
00051                 numPixels = attributes.numPixelsDepthV/(float)controller.getMaxDepth();
00052                 return changedBounds;
00053             }
00054         }
00055         return false;
00056     }
00057 
00058 
00059     @Override
00060     protected int getNumberOfLines() {
00061         return Math.min(attributes.numPixelsDepthV, controller.getMaxDepth());
00062     }
00063 
00064     @Override
00065     protected BaseTimelineThread getTimelineThread(ISpaceTimeCanvas canvas, double xscale, double yscale,
00066             Queue<TimelineDataSet> queue, AtomicInteger timelineDone, IProgressMonitor monitor) {
00067         return new TimelineDepthThread( controller, yscale, queue, timelineDone, 
00068                 controller.isEnableMidpoint(), monitor);
00069     }
00070 
00071     @Override
00072     protected void launchDataGettingThreads(boolean changedBounds,
00073             int numThreads) {
00074         //We don't want to get data here.
00075     }
00076 
00077     @Override
00078     protected BasePaintThread getPaintThread(
00079             Queue<TimelineDataSet> queue, int linesToPaint, AtomicInteger timelineDone, Device device, int width) {
00080 
00081         return new DepthPaintThread(controller, queue, linesToPaint, timelineDone, device, width);
00082     }
00083 
00084     @Override
00085     protected void drawPainting(ISpaceTimeCanvas canvas,
00086             ImagePosition img) {
00087         if (masterGC != null && !masterGC.isDisposed())
00088         {
00089             masterGC.drawImage(img.image, 0, 0, img.image.getBounds().width, 
00090                     img.image.getBounds().height, 0, 
00091                     Math.round(img.position*numPixels), 
00092                     img.image.getBounds().width, img.image.getBounds().height);
00093             
00094             img.image.dispose();
00095         }
00096     }
00097 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1