Changeset 401
- Timestamp:
- 08/11/10 00:51:48 (1 year ago)
- Files:
-
- kahina/trunk/src/org/kahina/lp/gui/profiler/LogicProgrammingProfileWindow.java (modified) (2 diffs)
- kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfile.java (modified) (3 diffs)
- kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfiler.java (modified) (3 diffs)
- kahina/trunk/src/org/kahina/tralesld/profiler/TraleSLDProfiler.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/tralesld/visual/fs/TraleSLDVariableBindingSetViewPanel.java (modified) (1 diff)
- kahina/trunk/src/org/kahina/tralesld/visual/fs/VariableBindingTableModel.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
kahina/trunk/src/org/kahina/lp/gui/profiler/LogicProgrammingProfileWindow.java
r400 r401 1 1 package org.kahina.lp.gui.profiler; 2 2 3 import java.awt.Component; 4 5 import javax.swing.BoxLayout; 3 6 import javax.swing.JFrame; 7 import javax.swing.JPanel; 8 import javax.swing.JScrollPane; 9 import javax.swing.JTable; 4 10 import javax.swing.WindowConstants; 5 11 … … 17 23 { 18 24 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 19 // TODO everything 25 setSize(800, 600); 26 add(createMainPanel(profile)); 27 } 28 29 private Component createMainPanel(LogicProgrammingProfile profile) 30 { 31 JPanel result = new JPanel(); 32 result.setLayout(new BoxLayout(result, BoxLayout.X_AXIS)); 33 result.add(new JScrollPane(createTable(profile))); 34 return result; 35 } 36 37 private Component createTable(LogicProgrammingProfile profile) 38 { 39 JTable result = new JTable(profile.getTableModel()); 40 result.setAutoCreateRowSorter(true); 41 result.setFillsViewportHeight(true); 42 return result; 20 43 } 21 44 kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfile.java
r400 r401 3 3 import java.io.Serializable; 4 4 import java.util.HashMap; 5 import java.util.HashSet; 5 6 import java.util.Map; 7 import java.util.Set; 8 9 import javax.swing.table.AbstractTableModel; 10 import javax.swing.table.TableModel; 6 11 7 12 import org.kahina.core.profiler.ProfileEntry; … … 13 18 */ 14 19 private static final long serialVersionUID = 4869556554829662187L; 20 21 private static final String[] COLUMN_NAMES = {"Category", "Name", "Calls", "Redos", "Exits", "Fails"}; 15 22 16 private final Map<ProfileEntry, Integer> callsByEntry = new HashMap<ProfileEntry, Integer>();23 private final Map<ProfileEntry, Integer> callsByEntry = new HashMap<ProfileEntry, Integer>(); 17 24 18 private final Map<ProfileEntry, Integer> failsByEntry = new HashMap<ProfileEntry, Integer>();25 private final Map<ProfileEntry, Integer> failsByEntry = new HashMap<ProfileEntry, Integer>(); 19 26 20 private final Map<ProfileEntry, Integer> exitsByEntry = new HashMap<ProfileEntry, Integer>();27 private final Map<ProfileEntry, Integer> exitsByEntry = new HashMap<ProfileEntry, Integer>(); 21 28 22 private final Map<ProfileEntry, Integer> redosByEntry = new HashMap<ProfileEntry, Integer>();29 private final Map<ProfileEntry, Integer> redosByEntry = new HashMap<ProfileEntry, Integer>(); 23 30 24 31 public void call(ProfileEntry entry) … … 52 59 count(entry, exitsByEntry); 53 60 } 61 62 public TableModel getTableModel() 63 { 64 Set<ProfileEntry> entrySet = new HashSet<ProfileEntry>(); 65 entrySet.addAll(callsByEntry.keySet()); 66 entrySet.addAll(redosByEntry.keySet()); 67 entrySet.addAll(exitsByEntry.keySet()); 68 entrySet.addAll(failsByEntry.keySet()); 69 final int size = entrySet.size(); 70 final String[] category = new String[size]; 71 final String[] name = new String[size]; 72 int[] calls = new int[size]; 73 int[] redos = new int[size]; 74 int[] exits = new int[size]; 75 int[] fails = new int[size]; 76 int i = 0; 77 for (ProfileEntry entry : entrySet) 78 { 79 category[i] = entry.getCategory(); 80 name[i] = entry.getName(); 81 calls[i] = nullToZero(callsByEntry.get(entry)); 82 redos[i] = nullToZero(redosByEntry.get(entry)); 83 exits[i] = nullToZero(exitsByEntry.get(entry)); 84 fails[i] = nullToZero(failsByEntry.get(entry)); 85 i++; 86 } 87 final int[][] numbers = new int[][] {null, null, calls, redos, exits, fails}; 88 return new AbstractTableModel() 89 { 90 91 /** 92 * 93 */ 94 private static final long serialVersionUID = -8811999723282268512L; 95 96 @Override 97 public int getColumnCount() 98 { 99 return 6; 100 } 101 102 @Override 103 public int getRowCount() 104 { 105 return size; 106 } 107 108 @Override 109 public Object getValueAt(int rowIndex, int columnIndex) 110 { 111 if (columnIndex == 0) 112 { 113 return category[rowIndex]; 114 } 115 if (columnIndex == 1) 116 { 117 return name[rowIndex]; 118 } 119 return numbers[columnIndex][rowIndex]; 120 } 121 122 @Override 123 public String getColumnName(int columnIndex) 124 { 125 return COLUMN_NAMES[columnIndex]; 126 } 127 128 }; 129 } 130 131 private int nullToZero(Integer integer) 132 { 133 if (integer == null) 134 { 135 return 0; 136 } 137 return integer; 138 } 54 139 } kahina/trunk/src/org/kahina/lp/profiler/LogicProgrammingProfiler.java
r400 r401 17 17 public class LogicProgrammingProfiler implements KahinaListener 18 18 { 19 20 private static final boolean VERBOSE = true; 19 21 20 22 private final Mapper<String, ProfileEntry> mapper; … … 91 93 public LogicProgrammingProfile profileSubtree(KahinaTree tree, int subtreeRootID) 92 94 { 95 if (VERBOSE) 96 { 97 System.err.println(this + ".profileSubtree(" + tree + ", " + subtreeRootID + ")"); 98 } 93 99 LogicProgrammingProfile result = new LogicProgrammingProfile(); 94 100 profileSubtree(tree, subtreeRootID, result, new HashSet<Integer>()); … … 117 123 } 118 124 119 protected void profileNode(ProfileEntry entry, LogicProgrammingStep step, KahinaTree tree, int stepID, LogicProgrammingProfile profile 2, Set<Integer> externalIDs)125 protected void profileNode(ProfileEntry entry, LogicProgrammingStep step, KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 120 126 { 121 127 if (step.isRedone()) kahina/trunk/src/org/kahina/tralesld/profiler/TraleSLDProfiler.java
r400 r401 52 52 protected void profileNode(ProfileEntry entry, LogicProgrammingStep step, KahinaTree tree, int stepID, LogicProgrammingProfile profile, Set<Integer> externalIDs) 53 53 { 54 super.profileNode( step, tree, stepID, profile, externalIDs);54 super.profileNode(entry, step, tree, stepID, profile, externalIDs); 55 55 if (tree.getNodeStatus(stepID) == TraleSLDStepType.FINISHED) 56 56 { kahina/trunk/src/org/kahina/tralesld/visual/fs/TraleSLDVariableBindingSetViewPanel.java
r357 r401 26 26 private final JPanel innerPanel; 27 27 28 private final VariableBindingTableModel tableModel = new VariableBindingTableModel(); ;28 private final VariableBindingTableModel tableModel = new VariableBindingTableModel(); 29 29 30 private VisualizationUtility util = VisualizationUtility.getDefault();30 private final VisualizationUtility util = VisualizationUtility.getDefault(); 31 31 32 32 public TraleSLDVariableBindingSetViewPanel() kahina/trunk/src/org/kahina/tralesld/visual/fs/VariableBindingTableModel.java
r354 r401 17 17 private static final long serialVersionUID = 3379369094266283475L; 18 18 19 private static final String[] columnNames= new String[] { "Variable", "Type" };19 private static final String[] COLUMN_NAMES = new String[] { "Variable", "Type" }; 20 20 21 21 private String[] variableNames = new String[0]; … … 28 28 public String getColumnName(int columnIndex) 29 29 { 30 return columnNames[columnIndex];30 return COLUMN_NAMES[columnIndex]; 31 31 } 32 32
