DetailViewPaint.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.traceviewer.main;
00002 
00003 import java.io.IOException;
00004 import java.util.Queue;
00005 import java.util.concurrent.ExecutorService;
00006 import java.util.concurrent.atomic.AtomicInteger;
00007 
00008 import org.eclipse.core.commands.Command;
00009 import org.eclipse.core.commands.State;
00010 import org.eclipse.core.runtime.IProgressMonitor;
00011 import org.eclipse.swt.graphics.Device;
00012 import org.eclipse.swt.graphics.GC;
00013 import org.eclipse.swt.graphics.Point;
00014 import org.eclipse.ui.IWorkbenchWindow;
00015 import org.eclipse.ui.commands.ICommandService;
00016 import org.eclipse.ui.handlers.RegistryToggleState;
00017 import org.eclipse.ui.services.ISourceProviderService;
00018 
00019 import edu.rice.cs.hpc.traceviewer.actions.OptionRecordsDisplay;
00020 import edu.rice.cs.hpc.traceviewer.data.db.TimelineDataSet;
00021 import edu.rice.cs.hpc.traceviewer.painter.BasePaintThread;
00022 import edu.rice.cs.hpc.traceviewer.painter.BaseViewPaint;
00023 import edu.rice.cs.hpc.traceviewer.painter.ISpaceTimeCanvas;
00024 import edu.rice.cs.hpc.traceviewer.painter.ImagePosition;
00025 import edu.rice.cs.hpc.traceviewer.painter.ImageTraceAttributes;
00026 import edu.rice.cs.hpc.traceviewer.services.ProcessTimelineService;
00027 import edu.rice.cs.hpc.traceviewer.spaceTimeData.SpaceTimeDataController;
00028 import edu.rice.cs.hpc.traceviewer.timeline.BaseTimelineThread;
00029 
00030 /******************************************************
00031  * 
00032  * Painting class for detail view (space-time view)
00033  *
00034  ******************************************************/
00035 public class DetailViewPaint extends BaseViewPaint {
00036         
00038     static public final int MAX_RECORDS_DISPLAY = 99;
00040     static public final String TOO_MANY_RECORDS = ">" + String.valueOf(MAX_RECORDS_DISPLAY) ;
00041     
00042     final private Point maxTextSize;
00043 
00044     private final GC masterGC;
00045     private final GC origGC;
00046     
00047     final private ProcessTimelineService ptlService;
00048     final private boolean debug;
00049     
00050     public DetailViewPaint(final GC masterGC, final GC origGC, SpaceTimeDataController _data,
00051             ImageTraceAttributes _attributes, boolean _changeBound,
00052             IWorkbenchWindow window, ISpaceTimeCanvas canvas, ExecutorService threadExecutor) 
00053     {
00054         super("Main trace view", _data, _attributes, _changeBound, window, canvas, threadExecutor);
00055         this.masterGC = masterGC;
00056         this.origGC   = origGC;
00057 
00058         ISourceProviderService sourceProviderService = (ISourceProviderService) window.getService(
00059                 ISourceProviderService.class);
00060         ptlService = (ProcessTimelineService) sourceProviderService.
00061                 getSourceProvider(ProcessTimelineService.PROCESS_TIMELINE_PROVIDER); 
00062         
00063         // check if we need to print the text information on the canvas
00064         
00065         ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
00066         final Command showCount = commandService.getCommand( OptionRecordsDisplay.commandId );
00067         final State state = showCount.getState(RegistryToggleState.STATE_ID);
00068         if (state != null) {
00069             Boolean isDebug = (Boolean) state.getValue();
00070             debug = isDebug.booleanValue();
00071         } else {
00072             debug = false;
00073         }
00074         // initialize the size of maximum text
00075         //  the longest text should be: ">99(>99)"
00076         maxTextSize = masterGC.textExtent(TOO_MANY_RECORDS + "(" + TOO_MANY_RECORDS + ")");
00077     }
00078 
00079     @Override
00080     protected boolean startPainting(int linesToPaint, int numThreads, boolean changedBounds) {
00081 
00082         return true;
00083     }
00084 
00085     @Override
00086     protected int getNumberOfLines() {
00087         return Math.min(attributes.numPixelsV, attributes.getProcessInterval() );
00088     }
00089 
00090     @Override
00091     protected BaseTimelineThread getTimelineThread(ISpaceTimeCanvas canvas, double xscale,
00092             double yscale, Queue<TimelineDataSet> queue, AtomicInteger timelineDone
00093             , IProgressMonitor monitor) {
00094 
00095         return new TimelineThread(this.window, controller, ptlService, changedBounds,   
00096                 yscale, queue, timelineDone, monitor);
00097     }
00098 
00099     @Override
00100     protected void launchDataGettingThreads(boolean changedBounds,
00101             int numThreads) throws IOException {
00102         controller.fillTracesWithData( changedBounds, numThreads);
00103     }
00104 
00105     @Override
00106     protected BasePaintThread getPaintThread(
00107             Queue<TimelineDataSet> queue, int numLines, AtomicInteger timelineDone, Device device, int width) {
00108 
00109         return new DetailPaintThread( controller, queue, numLines, timelineDone, device, width, maxTextSize, debug);
00110     }
00111 
00112     @Override
00113     protected void drawPainting(ISpaceTimeCanvas canvas,
00114             ImagePosition imagePosition) {
00115         
00116         DetailImagePosition imgDetailLine = (DetailImagePosition)imagePosition;
00117         double yscale = Math.max(canvas.getScalePixelsPerRank(), 1);
00118 
00119         int yposition = (int) Math.round(imgDetailLine.position * yscale);
00120         // put the image onto the canvas
00121         masterGC.drawImage(imgDetailLine.image, 0, yposition);
00122         origGC.drawImage(imgDetailLine.imageOriginal, 0, imgDetailLine.position);
00123         
00124         imgDetailLine.image.dispose();
00125         imgDetailLine.imageOriginal.dispose();
00126     }
00127 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1