Skip to content

Commit

Permalink
Merge pull request #453 from cmu-phil/fang
Browse files Browse the repository at this point in the history
fang
  • Loading branch information
espinoj authored Jun 13, 2017
2 parents 68660d8 + f6be1be commit c10a64d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ public StandardizedSemImEditor(final StandardizedSemImWrapper wrapper) {
boolean shown = wrapper.isShowErrors();
graph.setShowErrorTerms(shown);

errorTerms = new JMenuItem();

if (shown) {
errorTerms.setText("Hide Error Terms");
}
else {
errorTerms.setText("Show Error Terms");
}
// errorTerms = new JMenuItem();
//
// if (shown) {
// errorTerms.setText("Hide Error Terms");
// }
// else {
// errorTerms.setText("Show Error Terms");
// }

errorTerms.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Expand Down Expand Up @@ -142,7 +142,7 @@ else if ("Show Error Terms".equals(menuItem.getText())) {
// } else {
// errorTerms.setText("Show Error Terms");
// }
//

// errorTerms.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// JMenuItem menuItem = (JMenuItem) e.getSource();
Expand All @@ -159,12 +159,12 @@ else if ("Show Error Terms".equals(menuItem.getText())) {
// }
// });

JMenu params = new JMenu("Parameters");
params.add(errorTerms);
// JMenu params = new JMenu("Parameters");
// params.add(errorTerms);
// params.addSeparator();
// params.addSeparator();

menuBar.add(params);
// menuBar.add(params);
menuBar.add(new LayoutMenu(this));

add(menuBar, BorderLayout.NORTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ private void beginEdgeEdit(final Edge edge) {
}

private void setEditorToEdge(Edge edge) {
if (edge.getNode1().getNodeType() == NodeType.ERROR || edge.getNode2().getNodeType() == NodeType.ERROR) {
return;
}

if (editingEdge != null) {
try {
double value = Double.parseDouble(valueField.getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class KnowledgeBoxEditor extends JPanel {
private boolean showRequiredByGroups = true;
private boolean showForbiddenByGroups = true;
private JTextArea textArea;

// Unused, moved to KnowledgeBoxModel. Keeping for serialization. Can delete after a while. 2017.06.17
private int numTiers = 2;
private final KnowledgeBoxModel knowledgeBoxModel;
private JTabbedPane tabbedPane = null;
Expand Down Expand Up @@ -229,11 +231,11 @@ public void stateChanged(ChangeEvent e) {
// }

private Box tierDisplay() {
if (numTiers < 0) {
if (getNumTiers() < 0) {
int numTiers = getKnowledge().getNumTiers();
int _default = (int) (Math.pow(varNames.size(), 0.5) + 1);
numTiers = numTiers < _default ? _default : numTiers;
this.numTiers = numTiers;
setNumDisplayTiers(numTiers);
}

Box b = Box.createVerticalBox();
Expand Down Expand Up @@ -800,11 +802,11 @@ private JTextArea getTextArea() {
}

private int getNumTiers() {
return numTiers;
return knowledgeBoxModel.getNumTiers();
}

private void setNumTiers(int numTiers) {
this.numTiers = numTiers;
knowledgeBoxModel.setNumTiers(numTiers);
}

private Graph getSourceGraph() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class KnowledgeBoxModel implements SessionModel, ParamsResettable, Knowle
private List<String> variableNames = new ArrayList<>();
private final Graph sourceGraph = new EdgeListGraph();
private IKnowledge knowledge = new Knowledge2();
private int numTiers = 3;


public KnowledgeBoxModel(GeneralAlgorithmRunner runner) {
this.knowledge = runner.getKnowledge();
Expand Down Expand Up @@ -186,6 +188,14 @@ KnowledgeBoxInput getKnowledgeBoxInput() {
void setKnowledgeBoxInput(KnowledgeBoxInput knowledgeBoxInput) {
this.knowledgeBoxInput = knowledgeBoxInput;
}

public int getNumTiers() {
return numTiers;
}

public void setNumTiers(int numTiers) {
this.numTiers = numTiers;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,12 +1246,14 @@ private void adjustForNewModelNodes() {
return;
}

if (graph.isHighlighted(modelEdge)) displayEdge.setHighlighted(true);
if (graph.isHighlighted(modelEdge)) {
displayEdge.setHighlighted(true);
}

boolean dashed = modelEdge.getProperties().contains(Edge.Property.nl) || modelEdge.isDashed();

Color lineColor = modelEdge.getProperties().contains(Edge.Property.dd) ?
Color.green : modelEdge.getLineColor();
Color.green : graph.isHighlighted(modelEdge) ? displayEdge.getHighlightedColor() : modelEdge.getLineColor();

displayEdge.setLineColor(lineColor);
displayEdge.setDashed(dashed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public DecoratedGraph orient() {
graph.removeEdges(edge.getNode1(), edge.getNode2());

graph.addDirectedEdge(edge.getNode2(), edge.getNode1());
graph.setHighlighted(graph.getEdge(edge.getNode2(), edge.getNode1()), true);

edges.add(graph.getEdge(edge.getNode2(), edge.getNode1()));
edges.addAll(new HashSet<>(getChangedEdges().get(this.graph)));
Expand Down Expand Up @@ -272,6 +273,7 @@ public DecoratedGraph orient() {
Graph graph = new EdgeListGraphSingleConnections(this.graph);
graph.removeEdges(edge.getNode1(), edge.getNode2());
graph.addDirectedEdge(edge.getNode1(), edge.getNode2());
graph.setHighlighted(graph.getEdge(edge.getNode1(), edge.getNode2()), true);

edges.add(graph.getEdge(edge.getNode1(), edge.getNode2()));
edges.addAll(new HashSet<>(getChangedEdges().get(this.graph)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2237,9 +2237,9 @@ public static Graph chooseDagInPattern(Graph graph) {
// }
// }
//
// PatternToDag search = new PatternToDag(new Pattern(newGraph));
// Graph dag = search.patternToDagMeekRules();
// DataGraphUtils.arrangeBySourceGraph(dag, graph);
// PatternToDag search = new PatternToDag(new EdgeListGraph(newGraph));
// Graph dag = search.patternToDagMeek();
// GraphUtils.arrangeBySourceGraph(dag, graph);
// return dag;
}

Expand Down

0 comments on commit c10a64d

Please sign in to comment.