@Override public <T> Component getVertexLabelRendererComponent( JComponent arg0, Object arg1, Font arg2, boolean arg3, T arg4) { if (arg4 instanceof String) { BNode node = getBNode((String) arg4); if (node != null) { String str = StringUtils.getHtmlRendering(node.getId()); if (currentState.getNodeIds(AnchoredRule.class).contains(node.getId())) { str = "<font size=\"6\" color=\"gray\">" + str + "</font>"; } JLabel jlabel = new JLabel("<html>" + str + "</html>"); jlabel.setFont(new Font("Arial bold", Font.PLAIN, 24)); return jlabel; } } return new JLabel(); }
@Override public String transform(String nodeGraphId) { BNode node = getBNode(nodeGraphId); if (node != null) { String prettyPrintNode = node.toString(); String htmlDistrib = "<html> " + prettyPrintNode.replace("\n", " " + "<br> ") + "<br></html>"; htmlDistrib = htmlDistrib .replace("if", "<b>if</b>") .replace("then", "<b>then</b><br> ") .replace("else", "<b>else</b><br> ") .replace( "<b>else</b><br> <b>if</b>", "<b>else if</b>"); return StringUtils.getHtmlRendering(htmlDistrib); } else { return ""; } }
/** * Performs the dialogue turn in the simulator. * * @param systemAction the last system action. @ */ private synchronized boolean performTurn(Value systemAction) { boolean turnPerformed = false; simulatorState.setParameters(domain.getParameters()); Assignment systemAssign = new Assignment(system.getSettings().systemOutput, systemAction); simulatorState.addToState(systemAssign); while (!simulatorState.getNewVariables().isEmpty()) { Set<String> toProcess = simulatorState.getNewVariables(); simulatorState.reduce(); for (Model model : domain.getModels()) { if (model.isTriggered(simulatorState, toProcess)) { boolean change = model.trigger(simulatorState); if (change && model.isBlocking()) { break; } } } if (!simulatorState.getUtilityNodeIds().isEmpty()) { double reward = simulatorState.queryUtil(); String comment = "Reward: " + StringUtils.getShortForm(reward); system.displayComment(comment); system .getState() .addEvidence(new Assignment("R(" + systemAssign.addPrimes() + ")", reward)); simulatorState.removeNodes(simulatorState.getUtilityNodeIds()); } if (addNewObservations()) { turnPerformed = true; } simulatorState.addEvidence(simulatorState.getSample()); } return turnPerformed; }