Frame.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.traceviewer.spaceTimeData;
00002
00003 import java.io.Serializable;
00004
00005 import edu.rice.cs.hpc.traceviewer.data.util.Debugger;
00006
00007
00008
00009
00010
00011
00012
00013
00014 public class Frame implements Serializable
00015 {
00016
00017 private static final long serialVersionUID = 1L;
00018
00020 public long begTime, endTime;
00021
00023 public int begProcess, endProcess;
00024
00025 public Position position;
00026
00028 public int depth;
00029
00030 public Frame()
00031 {
00032 begTime = endTime = 0L;
00033 begProcess = endProcess = 0;
00034 position = new Position(0,0);
00035 depth = 0;
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 public Frame(long timeBeg, long timeEnd, int ProcBeg, int ProcEnd,
00052 int depth, long time, int process)
00053 {
00054 position = new Position(time, process);
00055 set(timeBeg, timeEnd, ProcBeg, ProcEnd);
00056
00057 this.depth = depth;
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067 public Frame(Frame frame)
00068 {
00069 this.begProcess = frame.begProcess;
00070 this.endProcess = frame.endProcess;
00071 this.begTime = frame.begTime;
00072 this.endTime = frame.endTime;
00073 this.depth = frame.depth;
00074 this.position = new Position(frame.position.time, frame.position.process);
00075 }
00076
00077 public Frame(Position position)
00078 {
00079 this.position = position;
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 public void set(long begTime, long endTime, int begProcess, int endProcess)
00091 {
00092 this.begProcess = begProcess;
00093 this.endProcess = endProcess;
00094 this.begTime = begTime;
00095 this.endTime = endTime;
00096
00097 fixPosition();
00098 }
00099
00100 public boolean equals(Frame other)
00101 {
00102 return (begProcess == other.begProcess
00103 && begTime == other.begTime
00104 && endProcess == other.endProcess
00105 && endTime == other.endTime
00106 && depth == other.depth
00107 && position.isEqual(other.position) );
00108 }
00109
00110 public boolean equalDimension(Frame other) {
00111 return (begProcess == other.begProcess
00112 && begTime == other.begTime
00113 && endProcess == other.endProcess
00114 && endTime == other.endTime
00115 && depth == other.depth);
00116 }
00117
00119 public void fixPosition(){
00120 if (position.process >= endProcess
00121 || position.process < begProcess ) {
00122
00123 position.process = (begProcess + endProcess) >> 1;
00124 }
00125 if (position.time <= begTime || position.time >= endTime) {
00126
00127 position.time = (begTime + endTime ) >> 1;
00128 }
00129 if (position.time < 0 || position.process < 0 || begTime < 0 || endTime < 0)
00130 Debugger.printDebug(1, "Error: negative attribute(s) " + position +
00131 ", t0=" + begTime + " , t1=" + endTime);
00132 }
00133
00134 @Override
00135 public String toString() {
00136 String time = "[ " + (begTime/1000)/1000.0 + "s, " + (endTime/1000)/1000.0+"s ]";
00137 String proc = " and [ " + begProcess + ", " + endProcess + " ]";
00138 return time + proc;
00139 }
00140 }