Skip to content

Commit 94748f2

Browse files
authored
Merge branch 'master' into review/anirudh_manoj/2869
2 parents 209c1b2 + 8ce0116 commit 94748f2

23 files changed

+679
-510
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: java

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ version = '6.8.0'
2626
sourceSets {
2727
main {
2828
java {
29-
srcDir 'src/projections'
29+
srcDir 'src'
3030
}
3131
}
3232
}

src/projections/Tools/Timeline/Data.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private void storeRangeToPersistantStorage(){
395395

396396

397397
/** Use the new set of PEs. The PEs will be stored internally in a Linked List */
398-
public void setProcessorList(SortedSet<Integer> processorList){
398+
public void setProcessorList(Collection<Integer> processorList){
399399
peToLine.clear();
400400

401401
if(isSMPRun()){
@@ -428,16 +428,18 @@ public void setProcessorList(SortedSet<Integer> processorList){
428428
if(curNID != prevNID){
429429
//encounter a new set of PEs of a node, add the comm thd
430430
//of the previous node
431-
peToLine.add(prevCommPE);
432-
commPEs.add(prevCommPE);
431+
if (!commPEs.contains(prevCommPE)) {
432+
peToLine.add(prevCommPE);
433+
commPEs.add(prevCommPE);
434+
}
433435

434436
prevNID = curNID;
435437
prevCommPE = getCommThdPE(pe);
436438
}
437439
peToLine.add(pe);
438440
}
439441
}
440-
if(!isLastAdded) peToLine.add(prevCommPE);
442+
if(!commPEs.contains(prevCommPE) && !isLastAdded) peToLine.add(prevCommPE);
441443
}else{
442444
peToLine.addAll(processorList);
443445
}

src/projections/Tools/Timeline/EntryMethodObject.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,11 @@ public boolean isDisplayed() {
763763
}
764764

765765

766-
public int paintMe(Graphics2D g2d, int actualDisplayWidth, int maxFilledX){
766+
public boolean paintMe(Graphics2D g2d, int actualDisplayWidth, MainPanel.MaxFilledX maxFilledX){
767+
boolean paintedEP = false;
767768
// If it is hidden, we may not display it
768769
if(!isDisplayed()){
769-
return -1;
770+
return paintedEP;
770771
}
771772

772773
int leftCoord = data.timeToScreenPixel(beginTime, actualDisplayWidth);
@@ -798,7 +799,9 @@ public int paintMe(Graphics2D g2d, int actualDisplayWidth, int maxFilledX){
798799
}
799800

800801
// Only draw this EMO if it covers some pixel that hasn't been filled yet
801-
if (right > maxFilledX) {
802+
if (right > maxFilledX.ep) {
803+
maxFilledX.ep = right;
804+
paintedEP = true;
802805

803806
// Determine the base color
804807
Paint c = determineColor();
@@ -878,7 +881,10 @@ public int paintMe(Graphics2D g2d, int actualDisplayWidth, int maxFilledX){
878881
// Compute the end pixel coordinate relative to the containing panel
879882
int packEndCoordX = data.timeToScreenPixelRight(packEndTime);
880883

881-
g2d.fillRect(packBeginCoordX, topCoord+verticalInset+rectHeight, (packEndCoordX-packBeginCoordX+1), data.messagePackHeight());
884+
if (packEndCoordX > maxFilledX.pack) {
885+
maxFilledX.pack = packEndCoordX;
886+
g2d.fillRect(packBeginCoordX, topCoord + verticalInset + rectHeight, (packEndCoordX - packBeginCoordX + 1), data.messagePackHeight());
887+
}
882888

883889
}
884890
}
@@ -898,13 +904,15 @@ public int paintMe(Graphics2D g2d, int actualDisplayWidth, int maxFilledX){
898904
{
899905
// Compute the pixel coordinate relative to the containing panel
900906
int msgCoordX = data.timeToScreenPixel(msgtime);
901-
902-
g2d.drawLine(msgCoordX, topCoord+verticalInset+rectHeight, msgCoordX, topCoord+verticalInset+rectHeight+data.messageSendHeight());
907+
if (msgCoordX > maxFilledX.msg) {
908+
maxFilledX.msg = msgCoordX;
909+
g2d.drawLine(msgCoordX, topCoord + verticalInset + rectHeight, msgCoordX, topCoord + verticalInset + rectHeight + data.messageSendHeight());
910+
}
903911
}
904912
}
905913
}
906914

907-
return right;
915+
return paintedEP;
908916
}
909917

910918

src/projections/Tools/Timeline/MainPanel.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.awt.Graphics2D;
1010
import java.awt.Point;
1111
import java.awt.Rectangle;
12+
import java.awt.RenderingHints;
1213
import java.awt.event.MouseEvent;
1314
import java.awt.event.MouseListener;
1415
import java.awt.event.MouseMotionListener;
@@ -115,10 +116,12 @@ public void run() {
115116
/** Paint the entire opaque panel*/
116117
public void paintComponent(Graphics g) {
117118
synchronized(data){
119+
Graphics2D g2 = (Graphics2D)g;
120+
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
118121
if(RenderInParallel && data.numPs()>1){
119-
paintInParallel((Graphics2D)g);
122+
paintInParallel(g2);
120123
} else {
121-
paintSequentially((Graphics2D)g);
124+
paintSequentially(g2);
122125
}
123126
}
124127
}
@@ -207,6 +210,18 @@ public void paintInParallel(Graphics g){
207210

208211
}
209212

213+
/**
214+
* Stores the maximum x coordinates of what has been drawn so far to avoid unnecessary overlapped drawing
215+
*/
216+
public class MaxFilledX {
217+
public int ep, pack, msg;
218+
219+
public MaxFilledX() {
220+
ep = 0;
221+
pack = 0;
222+
msg = 0;
223+
}
224+
}
210225
/**
211226
* Paint the desired clipped region for this component
212227
*
@@ -231,13 +246,14 @@ public long paintAll(Graphics2D g){
231246

232247
if(l != null){ // FIXME: this shouldn't be here but is to fix a race condition with reloading ranges once something is displayed
233248
Iterator<EntryMethodObject> iter = l.iterator(leftClipTime, rightClipTime);
234-
int maxFilledX = 0; // Tracks maximum x index of filled pixels for this PE, used to optimize away
235-
// drawing of multiple overlapping single pixel entry methods
249+
250+
// Saves the furthest right position EPs and msg lines have been drawn in
251+
// order to optimize performance by only drawing when new pixels will be colored in
252+
MaxFilledX maxFilledX = new MaxFilledX();
253+
236254
while(iter.hasNext()){
237255
EntryMethodObject o = iter.next();
238-
int emoMaxFilledX = o.paintMe((Graphics2D) g, getWidth(), maxFilledX);
239-
if (emoMaxFilledX > maxFilledX) {
240-
maxFilledX = emoMaxFilledX;
256+
if(o.paintMe((Graphics2D) g, getWidth(), maxFilledX)) {
241257
count1++;
242258
}
243259
}

src/projections/Tools/Timeline/WindowControls.java

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
import java.awt.event.ItemEvent;
1010
import java.awt.event.ItemListener;
1111
import java.io.File;
12+
import java.io.FileReader;
1213
import java.net.URL;
1314
import java.text.DecimalFormat;
15+
import java.util.ArrayList;
16+
import java.util.Scanner;
1417

1518
import javax.swing.ButtonGroup;
1619
import javax.swing.ImageIcon;
@@ -26,6 +29,7 @@
2629
import javax.swing.JRadioButtonMenuItem;
2730
import javax.swing.JTextField;
2831
import javax.swing.SwingWorker;
32+
import javax.swing.JFileChooser;
2933

3034
import projections.gui.ChooseEntriesWindow;
3135
import projections.gui.FloatJTextField;
@@ -59,7 +63,7 @@ class WindowControls extends JPanel implements ActionListener,
5963
// basic zoom controls
6064
private JButton bDecrease, bIncrease, bReset;
6165

62-
private JButton bZoomSelected, bLoadSelected, bRanges;
66+
private JButton bZoomSelected, bLoadSelected, bRanges, bOrder;
6367

6468
private JTextField highlightTime, selectionBeginTime, selectionEndTime, selectionDiff;
6569

@@ -114,7 +118,9 @@ class WindowControls extends JPanel implements ActionListener,
114118
private JMenuItem mDisplayLegend;
115119

116120
private JMenuItem mDisplayTopTimesText;
117-
121+
122+
private JFileChooser chooseOrderfc;
123+
118124
protected WindowControls(TimelineWindow parentWindow_,
119125
Data data_) {
120126

@@ -132,7 +138,40 @@ protected WindowControls(TimelineWindow parentWindow_,
132138
userEventWindow = new UserEventWindow(cbUserTable);
133139

134140
}
135-
141+
142+
143+
protected void showOrderDialog() {
144+
chooseOrderfc = new JFileChooser();
145+
int returnVal = chooseOrderfc.showOpenDialog(parentWindow);
146+
if(returnVal == JFileChooser.APPROVE_OPTION) {
147+
String chosenFile = chooseOrderfc.getSelectedFile().getName();
148+
String homeDir = System.getProperty("user.home");
149+
String fullPath = String.join(File.separator, homeDir, chosenFile);
150+
151+
ArrayList<Integer> orderedList = readOrderFromFile(fullPath);
152+
data.setProcessorList(orderedList);
153+
parentWindow.refreshDisplay(true);
154+
parentWindow.setVisible(true);
155+
}
156+
157+
}
158+
159+
protected ArrayList<Integer> readOrderFromFile(String fileName) {
160+
Scanner in = null;
161+
try {
162+
in = new Scanner(new FileReader(fileName));
163+
} catch (java.io.FileNotFoundException ex) {
164+
System.out.println("File not found: " + fileName);
165+
}
166+
ArrayList<Integer> orderedList = new ArrayList<Integer>();
167+
String pe = null;
168+
169+
while (in.hasNextInt()) {
170+
orderedList.add(in.nextInt());
171+
}
172+
in.close();
173+
return orderedList;
174+
}
136175

137176
protected void showDialog() {
138177
if(dialog == null){
@@ -424,6 +463,10 @@ else if (c == bRanges) {
424463
showDialog();
425464
}
426465

466+
else if (c == bOrder) {
467+
showOrderDialog();
468+
}
469+
427470
else if (c == bLoadSelected) {
428471
loadSelected();
429472
parentWindow.refreshDisplay(true);
@@ -743,6 +786,7 @@ private void CreateLayout() {
743786
bZoomSelected = new JButton("Zoom Selection");
744787
bLoadSelected = new JButton("Load Selection");
745788
bRanges = new JButton("Load New Time/PE Range");
789+
bOrder = new JButton("Set PE Order");
746790

747791
bZoomSelected.setEnabled(false);
748792
bLoadSelected.setEnabled(false);
@@ -751,6 +795,7 @@ private void CreateLayout() {
751795
bZoomSelected.addActionListener(this);
752796
bLoadSelected.addActionListener(this);
753797
bRanges.addActionListener(this);
798+
bOrder.addActionListener(this);
754799

755800

756801
highlightTime = new JTextField(" ");
@@ -774,6 +819,7 @@ private void CreateLayout() {
774819
Util.gblAdd(zoomPanel, selectionEndTime, gbc, 4, 2, 1, 1, 1, 1);
775820
Util.gblAdd(zoomPanel, selectionDiff, gbc, 5, 2, 1, 1, 1, 1);
776821
Util.gblAdd(zoomPanel, bRanges, gbc, 0, 1, 1, 1, 1, 1);
822+
Util.gblAdd(zoomPanel, bOrder, gbc, 1, 1, 1, 1, 1, 1);
777823
Util.gblAdd(zoomPanel, new JLabel("Time At Mouse Cursor", JLabel.CENTER), gbc, 2, 1, 1, 1, 1, 1);
778824
Util.gblAdd(zoomPanel, new JLabel("Selection Begin Time", JLabel.CENTER), gbc, 3, 1, 1, 1, 1, 1);
779825
Util.gblAdd(zoomPanel, new JLabel("Selection End Time", JLabel.CENTER), gbc, 4, 1, 1, 1, 1, 1);

0 commit comments

Comments
 (0)