Browse Source

first commit

Debashis Chandra 5 years ago
commit
6fcabbb48f
88 changed files with 9833 additions and 0 deletions
  1. BIN
      CertainTrustSimple Documentation.docx
  2. BIN
      CertainTrustSimple Documentation.pdf
  3. BIN
      Consensus-Discounting Documentation.docx
  4. BIN
      Consensus-Discounting Documentation.pdf
  5. 7 0
      Java/Java_Examples/JavaDemonstrator/.classpath
  6. 18 0
      Java/Java_Examples/JavaDemonstrator/.project
  7. BIN
      Java/Java_Examples/JavaDemonstrator/CertainTrustSDK-1.0.jar
  8. 0 0
      Java/Java_Examples/JavaDemonstrator/This is an Eclipse Juno project
  9. BIN
      Java/Java_Examples/JavaDemonstrator/bin/ANDObserver.class
  10. BIN
      Java/Java_Examples/JavaDemonstrator/bin/CONSENSUSObserver.class
  11. BIN
      Java/Java_Examples/JavaDemonstrator/bin/DISCOUNTINGObserver.class
  12. BIN
      Java/Java_Examples/JavaDemonstrator/bin/Demonstrator.class
  13. BIN
      Java/Java_Examples/JavaDemonstrator/bin/DemonstratorCD.class
  14. BIN
      Java/Java_Examples/JavaDemonstrator/bin/DemonstratorStarter.class
  15. BIN
      Java/Java_Examples/JavaDemonstrator/bin/Minimal.class
  16. BIN
      Java/Java_Examples/JavaDemonstrator/bin/ORObserver.class
  17. BIN
      Java/Java_Examples/JavaDemonstrator/demonstrator.jar
  18. 35 0
      Java/Java_Examples/JavaDemonstrator/src/ANDObserver.java
  19. 35 0
      Java/Java_Examples/JavaDemonstrator/src/CONSENSUSObserver.java
  20. 35 0
      Java/Java_Examples/JavaDemonstrator/src/DISCOUNTINGObserver.java
  21. 152 0
      Java/Java_Examples/JavaDemonstrator/src/Demonstrator.java
  22. 152 0
      Java/Java_Examples/JavaDemonstrator/src/DemonstratorCD.java
  23. 25 0
      Java/Java_Examples/JavaDemonstrator/src/DemonstratorStarter.java
  24. 62 0
      Java/Java_Examples/JavaDemonstrator/src/Minimal.java
  25. 35 0
      Java/Java_Examples/JavaDemonstrator/src/ORObserver.java
  26. 7 0
      Java/Java_Examples/JavaSDKExample/.classpath
  27. 17 0
      Java/Java_Examples/JavaSDKExample/.project
  28. BIN
      Java/Java_Examples/JavaSDKExample/bin/Minimal.class
  29. 62 0
      Java/Java_Examples/JavaSDKExample/src/Minimal.java
  30. 7 0
      Java/Java_SDK/.classpath
  31. 17 0
      Java/Java_SDK/.project
  32. BIN
      Java/Java_SDK/CertainTrustSDK-1.0.jar
  33. BIN
      Java/Java_SDK/CertainTrustSDK_Update.jar
  34. 373 0
      Java/Java_SDK/Mozilla Public License Version 2.0.txt
  35. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrust.class
  36. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas$1.class
  37. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas$2.class
  38. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas.class
  39. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$1.class
  40. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$2.class
  41. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$3.class
  42. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$CertainTrustActionFocusListener.class
  43. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustHTI.class
  44. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimple.class
  45. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas$1.class
  46. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas$2.class
  47. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas.class
  48. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$1.class
  49. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$2.class
  50. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$3.class
  51. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$CertainTrustActionFocusListener.class
  52. BIN
      Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI.class
  53. 373 0
      Java/Java_SDK/bin/CertainTrust/Mozilla Public License Version 2.0.txt
  54. BIN
      Java/Java_SDK/bin/CertainTrust/VerticalLabelUI.class
  55. 782 0
      Java/Java_SDK/src/CertainTrust/CertainTrust.java
  56. 177 0
      Java/Java_SDK/src/CertainTrust/CertainTrustCanvas.java
  57. 289 0
      Java/Java_SDK/src/CertainTrust/CertainTrustHTI.java
  58. 650 0
      Java/Java_SDK/src/CertainTrust/CertainTrustSimple.java
  59. 177 0
      Java/Java_SDK/src/CertainTrust/CertainTrustSimpleCanvas.java
  60. 289 0
      Java/Java_SDK/src/CertainTrust/CertainTrustSimpleHTI.java
  61. 373 0
      Java/Java_SDK/src/CertainTrust/Mozilla Public License Version 2.0.txt
  62. 197 0
      Java/Java_SDK/src/CertainTrust/VerticalLabelUI.java
  63. 984 0
      JavaScript/JavaScript_Examples/CertainTrust.js
  64. 373 0
      JavaScript/JavaScript_Examples/Mozilla Public License Version 2.0.txt
  65. 34 0
      JavaScript/JavaScript_Examples/certainTrustHTI.css
  66. 461 0
      JavaScript/JavaScript_Examples/certainTrustHTI.js
  67. 38 0
      JavaScript/JavaScript_Examples/certainTrustTViz.css
  68. 328 0
      JavaScript/JavaScript_Examples/certainTrustTViz.js
  69. 59 0
      JavaScript/JavaScript_Examples/consensus_operator.html
  70. 78 0
      JavaScript/JavaScript_Examples/demoTViz.html
  71. 110 0
      JavaScript/JavaScript_Examples/demonstrator.html
  72. 100 0
      JavaScript/JavaScript_Examples/demonstrator_cfusion.html
  73. 185 0
      JavaScript/JavaScript_Examples/demonstrator_updated.html
  74. 142 0
      JavaScript/JavaScript_Examples/demonstrator_updated_test.html
  75. 110 0
      JavaScript/JavaScript_Examples/evidences.html
  76. 58 0
      JavaScript/JavaScript_Examples/index.html
  77. BIN
      JavaScript/JavaScript_Examples/logo_softwarecluster.png
  78. BIN
      JavaScript/JavaScript_Examples/logo_tudarmstadt.png
  79. 41 0
      JavaScript/JavaScript_Examples/minimal.html
  80. 217 0
      JavaScript/JavaScript_Examples/multinomial.html
  81. 935 0
      JavaScript/JavaScript_SDK/CertainTrust.js
  82. 373 0
      JavaScript/JavaScript_SDK/Mozilla Public License Version 2.0.txt
  83. 34 0
      JavaScript/JavaScript_SDK/certainTrustHTI.css
  84. 461 0
      JavaScript/JavaScript_SDK/certainTrustHTI.js
  85. 38 0
      JavaScript/JavaScript_SDK/certainTrustTViz.css
  86. 328 0
      JavaScript/JavaScript_SDK/certainTrustTViz.js
  87. BIN
      QuickStart.pdf
  88. BIN
      Tutorial.pdf

BIN
CertainTrustSimple Documentation.docx


BIN
CertainTrustSimple Documentation.pdf


BIN
Consensus-Discounting Documentation.docx


BIN
Consensus-Discounting Documentation.pdf


+ 7 - 0
Java/Java_Examples/JavaDemonstrator/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="D:/Hiwi/CertainTrustSDK-1.0_Update/Java/Java_SDK/CertainTrustSDK_Update.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 18 - 0
Java/Java_Examples/JavaDemonstrator/.project

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JavaDemonstrator</name>
+	<comment></comment>
+	<projects>
+		<project>CertainTrust</project>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

BIN
Java/Java_Examples/JavaDemonstrator/CertainTrustSDK-1.0.jar


+ 0 - 0
Java/Java_Examples/JavaDemonstrator/This is an Eclipse Juno project


BIN
Java/Java_Examples/JavaDemonstrator/bin/ANDObserver.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/CONSENSUSObserver.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/DISCOUNTINGObserver.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/Demonstrator.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/DemonstratorCD.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/DemonstratorStarter.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/Minimal.class


BIN
Java/Java_Examples/JavaDemonstrator/bin/ORObserver.class


BIN
Java/Java_Examples/JavaDemonstrator/demonstrator.jar


+ 35 - 0
Java/Java_Examples/JavaDemonstrator/src/ANDObserver.java

@@ -0,0 +1,35 @@
+/**
+ * CertainTrust Demonstrator in Java
+ * 
+ * The ANDObserver is used to update the result of the AND operation
+ * when the operands change and display the result in the result HTI.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.util.Observable;
+import java.util.Observer;
+
+import CertainTrust.CertainTrust;
+
+
+public class ANDObserver implements Observer {
+
+	private CertainTrust Operand1;
+	private CertainTrust Operand2;
+	private CertainTrust Result;
+	
+	public ANDObserver(CertainTrust Operand1, CertainTrust Operand2, CertainTrust Result) {
+		this.Operand1 = Operand1;
+		this.Operand2 = Operand2;
+		this.Result = Result;
+	}
+
+	@Override
+	public void update(Observable arg0, Object arg1) {
+		// calculate the result of the AND operation and update the Result CertainTrust data object
+		CertainTrust ANDResult = this.Operand1.AND(this.Operand2);
+		this.Result.setF(ANDResult.getF());
+		this.Result.setTC(ANDResult.getT(), ANDResult.getC());
+	}
+}

+ 35 - 0
Java/Java_Examples/JavaDemonstrator/src/CONSENSUSObserver.java

@@ -0,0 +1,35 @@
+/**
+ * CertainTrust Demonstrator in Java
+ * 
+ * The ANDObserver is used to update the result of the AND operation
+ * when the operands change and display the result in the result HTI.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.util.Observable;
+import java.util.Observer;
+
+import CertainTrust.CertainTrust;
+
+
+public class CONSENSUSObserver implements Observer {
+
+	private CertainTrust Operand1;
+	private CertainTrust Operand2;
+	private CertainTrust Result;
+	
+	public CONSENSUSObserver(CertainTrust Operand1, CertainTrust Operand2, CertainTrust Result) {
+		this.Operand1 = Operand1;
+		this.Operand2 = Operand2;
+		this.Result = Result;
+	}
+
+	@Override
+	public void update(Observable arg0, Object arg1) {
+		// calculate the result of the CONSENSUS operation and update the Result CertainTrust data object
+		CertainTrust CONSENSUSResult = this.Operand1.CONSENSUS(this.Operand2);
+		this.Result.setF(CONSENSUSResult.getF());
+		this.Result.setTC(CONSENSUSResult.getT(), CONSENSUSResult.getC());
+	}
+}

+ 35 - 0
Java/Java_Examples/JavaDemonstrator/src/DISCOUNTINGObserver.java

@@ -0,0 +1,35 @@
+/**
+ * CertainTrust Demonstrator in Java
+ * 
+ * The ANDObserver is used to update the result of the AND operation
+ * when the operands change and display the result in the result HTI.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.util.Observable;
+import java.util.Observer;
+
+import CertainTrust.CertainTrust;
+
+
+public class DISCOUNTINGObserver implements Observer {
+
+	private CertainTrust Operand1;
+	private CertainTrust Operand2;
+	private CertainTrust Result;
+	
+	public DISCOUNTINGObserver(CertainTrust Operand1, CertainTrust Operand2, CertainTrust Result) {
+		this.Operand1 = Operand1;
+		this.Operand2 = Operand2;
+		this.Result = Result;
+	}
+
+	@Override
+	public void update(Observable arg0, Object arg1) {
+		// calculate the result of the DISCOUNTING operation and update the Result CertainTrust data object
+		CertainTrust DISCOUNTINGResult = this.Operand1.DISCOUNTING(this.Operand2);
+		this.Result.setF(DISCOUNTINGResult.getF());
+		this.Result.setTC(DISCOUNTINGResult.getT(), DISCOUNTINGResult.getC());
+	}
+}

+ 152 - 0
Java/Java_Examples/JavaDemonstrator/src/Demonstrator.java

@@ -0,0 +1,152 @@
+/**
+ * CertainTrust Demonstrator in Java
+ * 
+ * Demonstrates some capabilities of the CertainTrust SDK
+ * using a Java applet that interactively calculates
+ * AND and OR of two CertainTrust data objects and
+ * visually displays both the input objects and the output.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Label;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JApplet;
+import javax.swing.JPanel;
+
+import CertainTrust.CertainTrust;
+import CertainTrust.CertainTrustHTI;
+
+
+public class Demonstrator extends JApplet {
+	private static final long serialVersionUID = -7397289934413234935L;
+	
+	// the CertainTrust data objects
+	private CertainTrust AndOperand1;
+	private CertainTrust AndOperand2;
+	private CertainTrust AndResult;
+	private CertainTrust OrOperand1;
+	private CertainTrust OrOperand2;
+	private CertainTrust OrResult;
+	private static int N = 10;
+	
+	// the HTI objects that hold the CertainTrust data
+	private CertainTrustHTI HTIAndOperand1;
+	private CertainTrustHTI HTIAndOperand2;
+	private CertainTrustHTI HTIAndResult;
+	private CertainTrustHTI HTIOrOperand1;
+	private CertainTrustHTI HTIOrOperand2;
+	private CertainTrustHTI HTIOrResult;
+	
+
+	public Demonstrator() {
+		setupUI();
+		setupLogic();
+	}
+	
+	@Override
+	public void init() {
+		// make sure nothing is cut off due to a too small applet
+		setSize(1200, 500);
+	}
+	
+	/**
+	 * setupUI() creates the user interface and
+	 * binds all HTIs to the related CertainTrust data objects
+	 */
+	private void setupUI() {
+		// use GridBayLayout to align all the elements
+		GridBagConstraints constraints = new GridBagConstraints();
+		setLayout(new GridBagLayout());
+		
+		// title line "Demonstrator for CertainTrust"
+		constraints.gridwidth = GridBagConstraints.REMAINDER;
+		constraints.gridheight = 1;
+		constraints.insets = new Insets(10, 0, 0, 0);
+		Label title = new Label("Demonstrator for CertainTrust");
+		title.setFont(new Font("Sans Serif", Font.BOLD, 24));
+		add(title, constraints);
+		
+		// subtitle line
+		constraints.insets = new Insets(0, 0, 10, 0);
+		add(new Label("CertainTrust provides a means for the evaluation of propositional logic terms under uncertainty."), constraints);
+		
+		
+		// operands and result for AND operation
+		JPanel AndPanel = new JPanel();
+		AndPanel.setLayout(new FlowLayout());
+		
+		this.AndOperand1 = new CertainTrust(N);
+		this.HTIAndOperand1 = new CertainTrustHTI(this.AndOperand1);
+		AndPanel.add(this.HTIAndOperand1);
+
+		AndPanel.add(new Label("AND"));
+		
+		this.AndOperand2 = new CertainTrust(N);
+		this.HTIAndOperand2 = new CertainTrustHTI(this.AndOperand2);
+		AndPanel.add(this.HTIAndOperand2);
+		
+		AndPanel.add(new Label("="));
+		
+		this.AndResult = new CertainTrust(N);
+		Map<String,String> htiConfig = new HashMap<String, String>();
+		htiConfig.put("readonly", "true");
+		this.HTIAndResult = new CertainTrustHTI(this.AndResult, htiConfig);
+		AndPanel.add(this.HTIAndResult);
+		
+		constraints.insets = new Insets(30, 0, 10, 0);
+		constraints.gridwidth = GridBagConstraints.REMAINDER;
+		add(AndPanel, constraints);
+		
+		
+		// operands and result for OR operation
+		JPanel OrPanel = new JPanel();
+		OrPanel.setLayout(new FlowLayout());
+		
+		this.OrOperand1 = new CertainTrust(N);
+		this.HTIOrOperand1 = new CertainTrustHTI(this.OrOperand1);
+		OrPanel.add(this.HTIOrOperand1);
+
+		OrPanel.add(new Label("OR"));
+		
+		this.OrOperand2 = new CertainTrust(N);
+		this.HTIOrOperand2 = new CertainTrustHTI(this.OrOperand2);
+		OrPanel.add(this.HTIOrOperand2);
+		
+		OrPanel.add(new Label("="));
+		
+		this.OrResult = new CertainTrust(N);
+		this.HTIOrResult = new CertainTrustHTI(this.OrResult, htiConfig);
+		OrPanel.add(this.HTIOrResult);
+		
+		add(OrPanel, constraints);
+	}
+
+	/**
+	 * setupLogic() implements the wiring between the different CertainTrust data objects,
+	 * the HTIs get updates automatically due to the used Observer pattern
+	 */
+	private void setupLogic() {
+		// wire all components forming the AND operation
+		ANDObserver andObserver = new ANDObserver(AndOperand1, AndOperand2, AndResult);
+		AndOperand1.addObserver(andObserver);
+		AndOperand2.addObserver(andObserver);
+		
+		// do an initial update
+		andObserver.update(null, null);
+		
+		
+		// same for the OR operation
+		ORObserver orObserver = new ORObserver(OrOperand1, OrOperand2, OrResult);
+		OrOperand1.addObserver(orObserver);
+		OrOperand2.addObserver(orObserver);
+		orObserver.update(null, null);
+	}
+}

+ 152 - 0
Java/Java_Examples/JavaDemonstrator/src/DemonstratorCD.java

@@ -0,0 +1,152 @@
+/**
+ * CertainTrust Demonstrator in Java for CONSENSUS and DISCOUNTING
+ * 
+ * Demonstrates some capabilities of the CertainTrust SDK
+ * using a Java applet that interactively calculates
+ * AND and OR of two CertainTrust data objects and
+ * visually displays both the input objects and the output.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Label;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.JApplet;
+import javax.swing.JPanel;
+
+import CertainTrust.CertainTrust;
+import CertainTrust.CertainTrustHTI;
+
+
+public class DemonstratorCD extends JApplet {
+	private static final long serialVersionUID = -7397289934413234935L;
+	
+	// the CertainTrust data objects
+	private CertainTrust CONOperand1;
+	private CertainTrust CONOperand2;
+	private CertainTrust CONResult;
+	private CertainTrust DISOperand1;
+	private CertainTrust DISOperand2;
+	private CertainTrust DISResult;
+	private static int N = 10;
+	
+	// the HTI objects that hold the CertainTrust data
+	private CertainTrustHTI HTIAndOperand1;
+	private CertainTrustHTI HTIAndOperand2;
+	private CertainTrustHTI HTIAndResult;
+	private CertainTrustHTI HTIOrOperand1;
+	private CertainTrustHTI HTIOrOperand2;
+	private CertainTrustHTI HTIOrResult;
+	
+
+	public DemonstratorCD() {
+		setupUI();
+		setupLogic();
+	}
+	
+	@Override
+	public void init() {
+		// make sure nothing is cut off due to a too small applet
+		setSize(1200, 500);
+	}
+	
+	/**
+	 * setupUI() creates the user interface and
+	 * binds all HTIs to the related CertainTrust data objects
+	 */
+	private void setupUI() {
+		// use GridBayLayout to align all the elements
+		GridBagConstraints constraints = new GridBagConstraints();
+		setLayout(new GridBagLayout());
+		
+		// title line "Demonstrator for CertainTrust"
+		constraints.gridwidth = GridBagConstraints.REMAINDER;
+		constraints.gridheight = 1;
+		constraints.insets = new Insets(10, 0, 0, 0);
+		Label title = new Label("Demonstrator for CertainTrust");
+		title.setFont(new Font("Sans Serif", Font.BOLD, 24));
+		add(title, constraints);
+		
+		// subtitle line
+		constraints.insets = new Insets(0, 0, 10, 0);
+		add(new Label("CertainTrust provides a means for the evaluation of propositional logic terms under uncertainty."), constraints);
+		
+		
+		// operands and result for CONSENSUS operation
+		JPanel CONPanel = new JPanel();
+		CONPanel.setLayout(new FlowLayout());
+		
+		this.CONOperand1 = new CertainTrust(N);
+		this.HTIAndOperand1 = new CertainTrustHTI(this.CONOperand1);
+		CONPanel.add(this.HTIAndOperand1);
+
+		CONPanel.add(new Label("CONSENSUS"));
+		
+		this.CONOperand2 = new CertainTrust(N);
+		this.HTIAndOperand2 = new CertainTrustHTI(this.CONOperand2);
+		CONPanel.add(this.HTIAndOperand2);
+		
+		CONPanel.add(new Label("="));
+		
+		this.CONResult = new CertainTrust(N);
+		Map<String,String> htiConfig = new HashMap<String, String>();
+		htiConfig.put("readonly", "true");
+		this.HTIAndResult = new CertainTrustHTI(this.CONResult, htiConfig);
+		CONPanel.add(this.HTIAndResult);
+		
+		constraints.insets = new Insets(30, 0, 10, 0);
+		constraints.gridwidth = GridBagConstraints.REMAINDER;
+		add(CONPanel, constraints);
+		
+		
+		// operands and result for DISCOUNTING operation
+		JPanel DISPanel = new JPanel();
+		DISPanel.setLayout(new FlowLayout());
+		
+		this.DISOperand1 = new CertainTrust(N);
+		this.HTIOrOperand1 = new CertainTrustHTI(this.DISOperand1);
+		DISPanel.add(this.HTIOrOperand1);
+
+		DISPanel.add(new Label("DISCOUNTING"));
+		
+		this.DISOperand2 = new CertainTrust(N);
+		this.HTIOrOperand2 = new CertainTrustHTI(this.DISOperand2);
+		DISPanel.add(this.HTIOrOperand2);
+		
+		DISPanel.add(new Label("="));
+		
+		this.DISResult = new CertainTrust(N);
+		this.HTIOrResult = new CertainTrustHTI(this.DISResult, htiConfig);
+		DISPanel.add(this.HTIOrResult);
+		
+		add(DISPanel, constraints);
+	}
+
+	/**
+	 * setupLogic() implements the wiring between the different CertainTrust data objects,
+	 * the HTIs get updates automatically due to the used Observer pattern
+	 */
+	private void setupLogic() {
+		// wire all components forming the CONSENSUS operation
+		CONSENSUSObserver conObserver = new CONSENSUSObserver(CONOperand1, CONOperand2, CONResult);
+		CONOperand1.addObserver(conObserver);
+		CONOperand2.addObserver(conObserver);
+		
+		// do an initial update
+		conObserver.update(null, null);
+		
+		
+		// same for the OR operation
+		DISCOUNTINGObserver disObserver = new DISCOUNTINGObserver(DISOperand1, DISOperand2, DISResult);
+		DISOperand1.addObserver(disObserver);
+		DISOperand2.addObserver(disObserver);
+		disObserver.update(null, null);
+	}
+}

+ 25 - 0
Java/Java_Examples/JavaDemonstrator/src/DemonstratorStarter.java

@@ -0,0 +1,25 @@
+/**
+ * CertainTrust Demonstrator in Java
+ * 
+ * This class allows the applet to run as Java application.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+public class DemonstratorStarter {
+
+	public static void main(String[] args) {
+		// create the applet
+		DemonstratorCD demonstrator = new DemonstratorCD();
+		demonstrator.init();
+		demonstrator.start();
+		
+		// host the applet in a swing window
+		javax.swing.JFrame window = new javax.swing.JFrame("CertainLogic Demonstrator");
+		window.setContentPane(demonstrator);
+		window.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
+		window.pack();
+		window.setVisible(true);
+	}
+
+}

+ 62 - 0
Java/Java_Examples/JavaDemonstrator/src/Minimal.java

@@ -0,0 +1,62 @@
+/**
+ * Minimal CertainTrust Demonstrator in Java
+ * 
+ * Demonstrates the basic usage of the CertainTrust SDK.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+
+import CertainTrust.CertainTrust;
+import CertainTrust.CertainTrustHTI;
+
+
+public class Minimal extends JFrame implements ActionListener {
+	private static final long serialVersionUID = -447167281994322634L;
+
+	// this object stores the trust data and implements the operators
+	CertainTrust ctObject;
+	
+	public Minimal() {
+		setTitle("Minimal CertainTrust SDK Demonstrator");
+		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		setLayout(new FlowLayout());
+		
+		
+		// display a single HTI
+		ctObject = new CertainTrust(10); // first, we need a CertainTrust data object
+		add(new CertainTrustHTI(ctObject));
+		
+		// add a button to read the CertainTrust values
+		JButton button = new JButton("Read CertainTrust values");
+		button.addActionListener(this);
+		add(button);
+		
+		
+		this.setSize(450, 250);
+		this.setVisible(true);
+	}
+	
+	@Override
+	public void actionPerformed(ActionEvent arg0) {
+		// whenever the button is clicked
+		JOptionPane.showMessageDialog(this,
+				"Values of the CertainTrust object:\n"
+				+ "\nInit. value: "	+ this.ctObject.getF()
+				+ "\nTrust: "		+ this.ctObject.getT()
+				+ "\nCertainty: "	+ this.ctObject.getC()
+				+ "\nExpectation: "	+ this.ctObject.getExpectation());
+	}
+	
+	
+	public static void main(String[] args) {
+		new Minimal();
+	}
+}

+ 35 - 0
Java/Java_Examples/JavaDemonstrator/src/ORObserver.java

@@ -0,0 +1,35 @@
+/**
+ * CertainTrust Demonstrator in Java
+ * 
+ * The ORObserver is used to update the result of the OR operation
+ * when the operands change and display the result in the result HTI.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.util.Observable;
+import java.util.Observer;
+
+import CertainTrust.CertainTrust;
+
+
+public class ORObserver implements Observer {
+
+	private CertainTrust Operand1;
+	private CertainTrust Operand2;
+	private CertainTrust Result;
+	
+	public ORObserver(CertainTrust Operand1, CertainTrust Operand2, CertainTrust Result) {
+		this.Operand1 = Operand1;
+		this.Operand2 = Operand2;
+		this.Result = Result;
+	}
+
+	@Override
+	public void update(Observable arg0, Object arg1) {
+		// calculate the result of the AND operation and update the Result CertainTrust data object
+		CertainTrust ORResult = this.Operand1.OR(this.Operand2);
+		this.Result.setF(ORResult.getF());
+		this.Result.setTC(ORResult.getT(), ORResult.getC());
+	}
+}

+ 7 - 0
Java/Java_Examples/JavaSDKExample/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="D:/Hiwi/CertainTrustSDK-1.0_Update/Java/Java_SDK/CertainTrustSDK_Update.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 17 - 0
Java/Java_Examples/JavaSDKExample/.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JavaSDKExample</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

BIN
Java/Java_Examples/JavaSDKExample/bin/Minimal.class


+ 62 - 0
Java/Java_Examples/JavaSDKExample/src/Minimal.java

@@ -0,0 +1,62 @@
+/**
+ * Minimal CertainTrustSimple Demonstrator in Java
+ * 
+ * Demonstrates the basic usage of the CertainTrust SDK.
+ * 
+ * @author	Florian Volk <florian.volk@cased.de>
+ */
+
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+
+import CertainTrust.CertainTrustSimple;
+import CertainTrust.CertainTrustSimpleHTI;
+
+
+public class Minimal extends JFrame implements ActionListener {
+	private static final long serialVersionUID = -447167281994322634L;
+
+	// this object stores the trust data and implements the operators
+	CertainTrustSimple ctObject;
+	
+	public Minimal() {
+		setTitle("Minimal CertainTrust SDK Demonstrator");
+		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		setLayout(new FlowLayout());
+		
+		
+		// display a single HTI
+		ctObject = new CertainTrustSimple(10); // first, we need a CertainTrust data object
+		add(new CertainTrustSimpleHTI(ctObject));
+		
+		// add a button to read the CertainTrust values
+		JButton button = new JButton("Read CertainTrust values");
+		button.addActionListener(this);
+		add(button);
+		
+		
+		this.setSize(450, 250);
+		this.setVisible(true);
+	}
+	
+	@Override
+	public void actionPerformed(ActionEvent arg0) {
+		// whenever the button is clicked
+		JOptionPane.showMessageDialog(this,
+				"Values of the CertainTrust object:\n"
+				+ "\nInit. value: "	+ this.ctObject.getF()
+				+ "\nTrust: "		+ this.ctObject.getT()
+				+ "\nCertainty: "	+ this.ctObject.getC()
+				+ "\nExpectation: "	+ this.ctObject.getExpectation());
+	}
+	
+	
+	public static void main(String[] args) {
+		new Minimal();
+	}
+}

+ 7 - 0
Java/Java_SDK/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="lib" path="CertainTrustSDK-1.0.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 17 - 0
Java/Java_SDK/.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>Java_SDK</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

BIN
Java/Java_SDK/CertainTrustSDK-1.0.jar


BIN
Java/Java_SDK/CertainTrustSDK_Update.jar


+ 373 - 0
Java/Java_SDK/Mozilla Public License Version 2.0.txt

@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in 
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.

BIN
Java/Java_SDK/bin/CertainTrust/CertainTrust.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas$1.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas$2.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustCanvas.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$1.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$2.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$3.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI$CertainTrustActionFocusListener.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustHTI.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimple.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas$1.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas$2.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleCanvas.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$1.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$2.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$3.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI$CertainTrustActionFocusListener.class


BIN
Java/Java_SDK/bin/CertainTrust/CertainTrustSimpleHTI.class


+ 373 - 0
Java/Java_SDK/bin/CertainTrust/Mozilla Public License Version 2.0.txt

@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in 
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.

BIN
Java/Java_SDK/bin/CertainTrust/VerticalLabelUI.class


+ 782 - 0
Java/Java_SDK/src/CertainTrust/CertainTrust.java

@@ -0,0 +1,782 @@
+/**
+ * CertainTrust SDK
+ * 
+ * Implements the computational trust model "CertainTrust"
+ * in Java.
+ * See <http://www.tk.informatik.tu-darmstadt.de/de/research/smart-security-and-trust/> for further details.
+ * 
+ * 
+ * Telecooperation Department, Technische Universit�t Darmstadt
+ * <http://www.tk.informatik.tu-darmstadt.de/>
+ * 
+ * Prof. Dr. Max Mühlhäuser <max@informatik.tu-darmstadt.de>
+ * Florian Volk <florian.volk@cased.de>
+ * 
+ * 
+ * @author	Maria Pelevina
+ * @author	David Kalnischkies
+ * @version	1.1
+ */
+
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+package CertainTrust;
+import java.util.Observable;
+
+/**
+ * 
+ * t - average rating value, [0; 1], from very negative to very positive
+ * c - certainty value, [0; 1] from low certainty (no evidence) to the maximal maximal certainty.
+ * f - initial trust value
+ * w - weight
+ * r - number of positive evidence
+ * s - number of negative evidence
+ * n - maximal number of expected evidence
+ * doc - degree of conflict
+ * 
+ */
+public class CertainTrust extends Observable {
+	
+	private double c, t, f, r, s, doc;
+	private int n, weight = 2;
+
+//=========== Constructors =================
+	/**
+	 * Constructs a CertainTrust object with predefined n value.
+	 * @param n - maximal number of expected evidence
+	 */
+	public CertainTrust(int n) {
+		if (n > 0) {
+			this.n = n;
+			c = 0;
+			t = 0.5;
+			f = 0.5;
+			r = 0;
+			s = 0;
+		}
+		else throw new IllegalArgumentException("N should be greater than 0. Entered n = " + n + "\n");
+	}
+	
+	/**
+	 * Constructs a CertainTrust object with predefined r, s, n values. 
+	 * @param r - number of positive evidence
+	 * @param s - number of negative evidence
+	 * @param n - maximal number of expected evidence
+	 */
+	public CertainTrust(double r, double s, int n) {
+		if (n > 0) {
+			this.n = n;
+			this.c = 0;
+			this.t = 0.5;
+			this.f = 0.5;
+			this.doc = 0;
+			setRS(r, s);
+		}
+		else throw new IllegalArgumentException("N should be greater than 0. Entered n = " + n + "\n");
+	}
+	
+	/**
+	 * Constructs a CertainTrust object with predefined c, t, f, n values. 
+	 * @param c - certainty
+	 * @param t - average rating
+	 * @param f - initial trust value
+	 * @param n - maximal number of expected evidence
+	 */
+	public CertainTrust(double t, double c, double f, int n) {
+		this(t,c,f,n,0);
+	}
+	
+	/**
+	 * Constructs a CertainTrust object with predefined c, t, f, n values. 
+	 * @param c - certainty
+	 * @param t - average rating
+	 * @param f - initial trust value
+	 * @param n - maximal number of expected evidence
+	 * @param doc - initial degree of conflict
+	 */
+	private CertainTrust(double t, double c, double f, int n, double doc) {
+		if (n > 0) {
+			if (f <= 1 && f >= 0) {
+				this.n = n;
+				this.f = f;
+				this.r = 0;
+				this.s = 0;
+				this.doc = doc;
+				setTC(t, c);
+			}
+			else throw new IllegalArgumentException("f should lie within [0;1]. Entered f = " + f + "\n");
+		}
+		else throw new IllegalArgumentException("N should be greater than 0. Entered n = " + n + "\n");
+	}
+	
+	//=========== Setters =================
+	/**
+	 * Resets N value. Renormalises r and s values, recalculates c and t accordingly.  
+	 * @param n - new maximal number of expected evidence
+	 */
+	public void setN(int n) {
+		if (n > 0) {
+			this.n = n;
+			normaliseRS();
+			calculateRStoTC();
+			
+			setChanged();
+			notifyObservers();
+		}
+		else throw new IllegalArgumentException("N should be greater than 0. Entered n = " + n + "\n");
+	}
+	
+	/**
+	 * Sets f value.
+	 * @param f - initial trust value.
+	 */
+	public void setF(double f) {
+		if (f >= 0 && f <= 1) {
+			this.f = f;
+			
+			setChanged();
+			notifyObservers();
+		}
+		
+		else throw new IllegalArgumentException("f should lie within [0;1]. Entered f = " + f + "\n");
+	}
+
+	/**
+	  * Sets Distance of Conflict value.
+	  * @param doc is the new value for DoC
+	  */
+	public void setDoC(double doc) {
+		if (doc > 0) {
+			this.doc = doc;
+		}
+		else throw new IllegalArgumentException("DoC should be greater than 0. Entered DoC = " + doc + "\n");
+	}
+	
+	/**
+	 * Sets c and t values. Recalculates r and s values accordingly.
+	 * @param t - new average trust value
+	 * @param c - new certainty value
+	 */
+	public void setTC(double t, double c) {
+		if (c >= 0 && c <= 1) {
+			if (t >= 0 && t <= 1) {
+				this.c = c;
+				this.t = t;
+				calculateTCtoRS();
+				
+				setChanged();
+				notifyObservers();
+			}
+			else throw new IllegalArgumentException("t should be greater than 0. Entered t = " + t + "\n");
+		}
+		else throw new IllegalArgumentException("c should lie within [0;1]. Entered c = " + c + "\n");
+	}
+	/**
+	 * Sets r and s values. Recalculates c and t values accordingly.
+	 * @param r - new number of positive evidence
+	 * @param s - new number of negative evidence
+	 */
+	public void setRS(double r, double s) {
+		if (r >= 0) {
+			if (s >= 0) {
+				this.r = r;
+				this.s = s;
+				normaliseRS();
+				calculateRStoTC();
+				
+				setChanged();
+				notifyObservers();
+			}
+			else throw new IllegalArgumentException("s should be positive. Entered s = " + s + "\n");
+		}
+		else throw new IllegalArgumentException("r should be positive. Entered r = " + r + "\n");
+	}
+	
+	/**
+	 * Add some positive evidence to r.
+	 * @param posEvidence - number of new positive evidences
+	 */
+	public void addR(int posEvidence) {
+		if (posEvidence >= 0) {
+			r += posEvidence;
+			normaliseRS();
+			calculateRStoTC();
+			
+			setChanged();
+			notifyObservers();
+		}
+		else throw new IllegalArgumentException("Number of positive evidences should be positive. Entered " + posEvidence + "\n");
+	}
+	
+	/**
+	 * Add some negative evidence to s.
+	 * @param negEvidence - number of new negative evidences
+	 */
+	public void addS(int negEvidence) {
+		if (negEvidence >= 0) {
+			s += negEvidence;
+			normaliseRS();
+			calculateRStoTC();
+			
+			setChanged();
+			notifyObservers();
+		}
+		else throw new IllegalArgumentException("Number of negative evidences should be positive. Entered " + negEvidence + "\n");
+	}
+	
+//=========== Internal Calculations ==========
+	/**
+	 * Normalises r and s values according to n - maximal number of expected evidence
+	 * Important! Doesn't notify observers.
+	 */
+	private void normaliseRS() {
+		if (r + s > n){
+			double initR = r;
+			r = r*n / (initR + s);
+			s = s*n / (initR + s);
+		}
+	}
+	/**
+	 * Calculates c and t values based on existing r and s values
+	 * Important! Doesn't notify observers.
+	 */
+	private void calculateRStoTC() {
+		c = n * (r + s) / ( weight*(n-r-s) + n*(r+s));
+		if (c == 0)
+			t = 0.5;
+		else t = r / (r + s);
+	}
+	
+	/**
+	 * Calculates r and s values based on existing c and t values
+	 * Important! Doesn't notify observers.
+	 */
+	private void calculateTCtoRS() {
+		if (c == 0) {
+			r = 0;
+			s = 0;
+			t = 0.5;
+		}
+		else {
+			r = (2*c*weight*n*t) / (2*c*weight + n - c*n);
+			s = (2*c*weight*n - 2*c*weight*n*t) / (2*c*weight + n - c*n);
+		}
+	}
+	
+//=========== Getters =================
+	public double getC() {
+		return c;
+	}
+
+	public double getT() {
+		return t;
+	}
+
+	public double getF() {
+		return f;
+	}
+
+	public double getR() {
+		return r;
+	}
+
+	public double getS() {
+		return s;
+	}
+
+	public int getN() {
+		return n;
+	}
+	
+	public double getDoC() {
+		return doc;
+	}
+	
+	public double getExpectation() {
+		return t*c + (1-c)*f;
+	}
+	
+//=========== Logic =================
+	/**
+	 * Computes OR function for this CertainTrust object and the specified argument. Result is returned as a new object,
+	 * argument and this CertainTrust object remain unchanged.
+	 * N values of both objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param arg - CertainTrust object
+	 * @return - result of OR computation for this object and an argument.
+	 */
+	
+	private CertainTrust OR(CertainTrust arg){
+		double c1 = getC();
+		double t1 = getT();
+		double f1 = getF();
+		
+		double c2 = arg.getC();
+		double t2 = arg.getT();
+		double f2 = arg.getF();
+		
+		double resT = 0.5, resF = 0.5, resC = 0;
+		
+		if (this.getN() != arg.getN()) 
+			throw new IllegalStateException("Different N values. Operation not allowed. \n");
+				
+		resF = f1 + f2 - f1*f2;
+		if (almostEqual(resF, 0))
+			resC = c1 + c2 - c1*c2;
+		else 
+			resC = c1 + c2 - c1*c2 - (c1*f2*(1-c2)*(1-t1)+c2*f1*(1-c1)*(1-t2)) / resF;
+		
+		if (almostEqual(resC, 0)) 
+			resT = 0.5;	
+		else resT = (1/resC) * (c1*t1 + c2*t2 - c1*c2*t1*t2);
+		
+		resT = adjustValue(resT);
+		resC = adjustValue(resC);
+		resF = adjustValue(resF);
+		
+		CertainTrust result = new CertainTrust(resT, resC, resF, n, 0); 
+			
+		return result;	
+	}
+	/**
+	 * Computes OR function for this CertainTrust object and the specified arguments. 
+	 * Result is returned as a new object, arguments and this CertainTrust object remain unchanged.
+	 * Example: a.OR(b, c, d) returns new CertainTrust object that equals a OR b OR c OR d.
+	 * Multiple arguments allowed, but not less than one.
+	 * N values of all objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param args - arguments
+	 * @return - result of OR computation for this object and all arguments.
+	 */
+	public CertainTrust OR(CertainTrust ...args) {
+		CertainTrust result = clone();
+		for (CertainTrust m: args) {
+			if (n != m.getN())
+				throw new IllegalStateException("Different N values. Operation not allowed. \n");
+			result = result.OR(m);
+		}
+			
+		return result;
+	}
+	
+	/**
+	 * Computes AND function for this CertainTrust object and the specified argument. Result is returned as a new object,
+	 * argument and this CertainTrust object remain unchanged.
+	 * N values of both objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param arg - CertainTrust object
+	 * @return - result of AND computation for this object and an argument.
+	 */
+	private CertainTrust AND(CertainTrust arg){
+		double c1 = getC();
+		double f1 = getF();
+		double t1 = getT();
+		
+		double c2 = arg.getC();
+		double f2 = arg.getF();
+		double t2 = arg.getT();
+		
+		double resC = 0, resT = 0.5, resF = 0.5;
+		
+		if (n != arg.getN()) 
+			throw new IllegalStateException("Different N values. Operation not allowed. \n");
+		
+		resF = f1*f2;
+		
+		if (almostEqual(resF, 1))		//avoid division by 0
+			resC = c1 + c2 - c1*c2;
+		else
+			resC = c1 + c2 - c1*c2 - (c2*t2*(1-c1)*(1-f1)+c1*t1*(1-c2)*(1-f2)) / (1 - resF);
+		
+		if (almostEqual(resC, 0)) 
+			resT = 0.5;
+		else if (almostEqual(resF, 1))	//avoid division by 0
+			resT = (1/resC) *  (c1*t1*c2*t2);
+		else resT = (1/resC) *  ((c1*t1*c2*t2) + (c1*f2*t1*(1-c2)*(1-f1)+c2*f1*t2*(1-c1)*(1-f2)) / (1 - resF));
+		
+		resT = adjustValue(resT);
+		resC = adjustValue(resC);
+		resF = adjustValue(resF);
+		
+		CertainTrust result = new CertainTrust(resT, resC, resF, n, 0);
+			
+		return result;
+	}
+	
+	/**
+	 * Computes AND function for this CertainTrust object and the specified arguments. 
+	 * Result is returned as a new object, arguments and this CertainTrust object remain unchanged.
+	 * Example: a.AND(b, c, d) returns new CertainTrust object that equals a AND b AND c AND d.
+	 * Multiple arguments allowed, but not less than one.
+	 * N values of all objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param args - arguments
+	 * @return - result of AND computation for this object and all arguments.
+	 */
+	public CertainTrust AND(CertainTrust ...args) {
+		CertainTrust result = clone();
+		for (CertainTrust m: args) {
+			if (n != m.getN())
+				throw new IllegalStateException("Different N values. Operation not allowed. \n");
+			result = result.AND(m);
+		}
+			
+		return result;
+	}
+	
+	/**
+	 * Returns NOT of this CertainTrust object.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @return - NOT of this CertainTrust object.
+	 */
+	public CertainTrust NOT(){
+		return new CertainTrust(getC(), adjustValue(1 - getT()), adjustValue(1 - getF()), n, 0);
+	}
+	
+	/**
+	 * an internal implementation of fusion function.
+	 * Is called by wFusion and cFusion
+	 * @param args - an array of CertainTrust objects
+	 * @param weights - an integer array of corresponding weights
+	 * @param doc - a degree of conflict (always 0 for wFusion)
+	 * @return - new CertainTrust object
+	 */
+	private static CertainTrust internalFusion(CertainTrust[] args, int[] weights, double doc) {
+		double resC, resT, resF;
+		boolean allOne = true;
+		boolean allZero = true;
+		boolean allWeightsZero = true;
+		boolean atLeastOne1 = false;
+		int arrLength = args.length;
+		
+		// set the flags about C and Weight values
+		for (int i = 0; i < arrLength; i++) 
+			if (args[i].getC() != 1) {
+				allOne = false;
+				i = arrLength;
+			}
+		for (int i = 0; i < arrLength; i++) 
+			if (args[i].getC() != 0) {
+				allZero = false;
+				i = arrLength;
+			}
+		for (int i = 0; i < arrLength; i++) 
+			if (weights[i] != 0) {
+				allWeightsZero = false;
+				i = arrLength;
+			}
+		for (int i = 0; i < arrLength; i++)
+			if (args[i].getC() == 1) {
+				atLeastOne1 = true;
+				i = arrLength;
+			}
+		
+		//Calculate T and C
+		
+		// 1. all C's  = 1
+		if (allOne) {
+			// set C
+			resC = 1 * (1 - doc);
+			// set T
+			if (allWeightsZero) {// save some calculation time 
+				resT = 0;
+			}
+			else {				// or use the function
+				double numeratorT = 0, denominatorT = 0;
+				for (int i = 0; i < arrLength; i++) {
+					numeratorT += weights[i] * args[i].getT();
+					denominatorT += weights[i];
+				}
+				resT = numeratorT/denominatorT;
+			}
+		}
+		
+		else {
+			if (atLeastOne1)
+				throw new IllegalStateException("Illeagal arguments. Either all C values must equal 1 or none of them. Operation not allowed \n");
+
+			// 2. Any other combination
+			if (allWeightsZero) { // save some calculation time
+				resT = 0;
+				resC = 0;
+			}
+			else {					// or use the function
+				double numeratorT = 0, denominatorT = 0, numeratorC = 0, denominatorC = 0, mult;
+				for (int i = 0; i < arrLength; i++) {
+					mult = 1;
+					for (int j = 0; j < arrLength; j++) // Count the product for each sum element
+						if (j != i) 
+							mult *= 1 - args[j].getC();	
+					numeratorT += weights[i] * args[i].getT() * args[i].getC() * mult;
+					denominatorT += weights[i] * args[i].getC() * mult;
+					denominatorC += weights[i] * mult;
+				}
+				numeratorC = denominatorT;
+				resC = (numeratorC/denominatorC) * (1 - doc);
+				if (allZero)
+					resT = 0.5;
+				else 		
+					resT = numeratorT/denominatorT;
+			}
+			
+			// Special case for T
+			if (allZero)
+				resT = 0.5;
+		}
+		
+		// Calculate F
+		if (allWeightsZero)
+			resF = 0;
+		else {
+			double numerator = 0, denominator = 0;
+			for (int i = 0; i < arrLength; i ++) {
+				numerator += weights[i] * args[i].getF();
+				denominator += weights[i];
+			}
+			resF = numerator/denominator;
+		}
+		return new CertainTrust(resT, resC, resF, args[0].getN(), doc);
+	}
+	
+	/**
+	 * Performs weighted fusion for an array of CertainTrust objects in correspondence with 
+	 * an array of weights. Returns new CertainTrust object.
+	 * Requirements: N values of CertainTrust objects must be equal.
+	 * Number of weights should equal the number of CertainTrust objects.
+	 * Arrays must be non-empty
+	 * Either all of CertainTrust must be of certainty 1 or none of them.
+	 * @param args - an array of CertainTrust objects
+	 * @param weights - an integer array of corresponding weights
+	 * @return - new CertainTrust object
+	 */
+	public static CertainTrust wFusion(CertainTrust[] args, int[] weights) {
+		//arrays should be equal
+		if (args.length == weights.length) {
+			//and not empty
+			if (args.length != 0) {
+				boolean equalNs = true;
+				int N = args[0].getN();
+				for (int i = 1; i < args.length; i++)
+					if (N != args[i].getN()) {
+						equalNs = false;
+						i = args.length;
+					}
+				//and all N's of TC's must be equal
+				if (equalNs) {
+					return internalFusion(args, weights, 0);
+				}
+				throw new IllegalStateException("Different N values. Operation not allowed. \n");
+			}
+			throw new IllegalStateException("Arrays are empty. Operation not allowed. \n");
+		}
+		throw new IllegalStateException("Different lengths of arrays. Operation not allowed. \n");
+	}
+	
+	/**
+	 * Conflicted Fusion is a variation of weighted fusion, which additionally computes the degree of conflict 
+	 * between given opinions (CertainTrust objects) and takes it into consideration while performing fusion.
+	 * The degree of conflict is then saved in the resulting CertainTrust object and may be checked with getDoC() function.
+	 * @param args - an array of CertainTrust objects
+	 * @param weights - an integer array of corresponding weights
+	 * @return - new CertainTrust object
+	 */
+	public static CertainTrust cFusion(CertainTrust[] args, int[] weights) {
+		//arrays should be equal
+		if (args.length == weights.length) {
+			//and not empty
+			if (args.length != 0) {
+				boolean equalNs = true;
+				int N = args[0].getN();
+				for (int i = 1; i < args.length; i++)
+					if (N != args[i].getN()) {
+						equalNs = false;
+						i = args.length;
+					}
+				//and all N's of TC's must be equal
+				if (equalNs) {
+					double denominator = args.length*(args.length - 1) / 2;
+					double numerator = 0;
+					for (int i = 0; i < args.length; i++) 
+						for (int j = i; j < args.length; j++)
+							numerator += Math.abs(args[i].getT() - args[j].getT()) * args[i].getC() * args[j].getC()*(1 - Math.abs((double)(weights[i] - weights[j])/(weights[i] + weights[j])));	
+					double doc = numerator/denominator;	
+					return internalFusion(args, weights, doc);
+				}
+				throw new IllegalStateException("Different N values. Operation not allowed. \n");
+			}
+			throw new IllegalStateException("Arrays are empty. Operation not allowed. \n");
+		}
+		throw new IllegalStateException("Different lengths of arrays. Operation not allowed. \n");
+	}
+	
+	/**
+	 * Computes CONSENSUS function for this CertainTrust object and the specified argument. Result is returned as a new object,
+	 * argument and this CertainTrust object remain unchanged.
+	 * N values of both objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param arg - CertainTrust object
+	 * @return - result of CONSENSUS computation for this object and an argument.
+	 */
+	private CertainTrust CONSENSUS(CertainTrust arg){
+		double c1 = getC();
+		double f1 = getF();
+		double t1 = getT();
+		
+		double c2 = arg.getC();
+		double f2 = arg.getF();
+		double t2 = arg.getT();
+		
+		double resC = 0, resT = 0.5, resF = 0.5;
+		
+		if (n != arg.getN()) 
+			throw new IllegalStateException("Different N values. Operation not allowed. \n");
+		
+		//resF = f1*f2;
+		
+		if (almostEqual(resF, 1))		//avoid division by 0
+			resC = (c1+c2-2*c1*c2)/(1-c1*c2);
+		else
+			resC = (c1+c2-2*c1*c2)/(1-c1*c2);
+		
+		if (almostEqual(resC, 0)) 
+			resT = 0.5;
+		else if (almostEqual(resF, 1))	//avoid division by 0
+			resT = (c1*t1*(1-c2)+c2*t2*(1-c1))/(c1*(1-c2)+c2*(1-c1));
+		else resT = (c1*t1*(1-c2)+c2*t2*(1-c1))/(c1*(1-c2)+c2*(1-c1));
+		
+		resT = adjustValue(resT);
+		resC = adjustValue(resC);
+		resF = adjustValue(resF);
+		
+		CertainTrust result = new CertainTrust(resT, resC, resF, n, 0);
+			
+		return result;
+	}
+	
+	/**
+	 * Computes CONSENSUS function for this CertainTrust object and the specified arguments. 
+	 * Result is returned as a new object, arguments and this CertainTrust object remain unchanged.
+	 * Example: a.CONSENSUS(b, c, d) returns new CertainTrust object that equals a CONSENSUS b CONSENSUS c CONSENSUS d.
+	 * Multiple arguments allowed, but not less than one.
+	 * N values of all objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param args - arguments
+	 * @return - result of CONSENSUS computation for this object and all arguments.
+	 */
+	public CertainTrust CONSENSUS(CertainTrust ...args) {
+		CertainTrust result = clone();
+		for (CertainTrust m: args) {
+			if (n != m.getN())
+				throw new IllegalStateException("Different N values. Operation not allowed. \n");
+			result = result.CONSENSUS(m);
+		}
+			
+		return result;
+	}
+
+	/**
+	 * Computes DISCOUNTING function for this CertainTrust object and the specified argument. Result is returned as a new object,
+	 * argument and this CertainTrust object remain unchanged.
+	 * N values of both objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param arg - CertainTrust object
+	 * @return - result of DISCOUNTING computation for this object and an argument.
+	 */
+	private CertainTrust DISCOUNTING(CertainTrust arg){
+		double c1 = getC();
+		double f1 = getF();
+		double t1 = getT();
+		
+		double c2 = arg.getC();
+		double f2 = arg.getF();
+		double t2 = arg.getT();
+		
+		double resC = 0, resT = 0.5, resF = 0.5;
+		
+		if (n != arg.getN()) 
+			throw new IllegalStateException("Different N values. Operation not allowed. \n");
+		
+		//resF = f1*f2;
+		
+		if (almostEqual(resF, 1))	
+			resC = t1*c1*c2;
+		else
+			resC = t1*c1*c2;
+		
+		if (almostEqual(resC, 0)) 
+			resT = 0.5;
+		else if (almostEqual(resF, 1))	
+			resT = t2;
+		else resT = t2;
+		
+		resT = adjustValue(resT);
+		resC = adjustValue(resC);
+		resF = adjustValue(resF);
+		
+		CertainTrust result = new CertainTrust(resT, resC, resF, n, 0);
+			
+		return result;
+	}
+	
+	/**
+	 * Computes DISCOUNTING function for this CertainTrust object and the specified arguments. 
+	 * Result is returned as a new object, arguments and this CertainTrust object remain unchanged.
+	 * Example: a.DISCOUNTING(b, c, d) returns new CertainTrust object that equals a DISCOUNTING b DISCOUNTING c DISCOUNTING d.
+	 * Multiple arguments allowed, but not less than one.
+	 * N values of all objects should be equal.
+	 * For detailed information see CertainLogic: A Logic for Modeling Trust and Uncertainty
+	 * @param args - arguments
+	 * @return - result of DISCOUNTING computation for this object and all arguments.
+	 */
+	public CertainTrust DISCOUNTING(CertainTrust ...args) {
+		CertainTrust result = clone();
+		for (CertainTrust m: args) {
+			if (n != m.getN())
+				throw new IllegalStateException("Different N values. Operation not allowed. \n");
+			result = result.DISCOUNTING(m);
+		}
+			
+		return result;
+	}
+	
+	
+//=========== Additional Functions =================	
+	
+	@Override
+	public CertainTrust clone() {
+		CertainTrust copy = new CertainTrust(n);
+		copy.c = this.c;
+		copy.t = this.t;
+		copy.f = this.f;
+		copy.r = this.r;
+		copy.s = this.s;
+		copy.doc = this.doc;
+		return copy;
+	}
+	
+	/**
+	 * Adjusts the value of a into the allowed range [0,1]. 
+	 * @param a - value to be adjusted
+	 */
+	private double adjustValue(double a) {
+		return Math.max(Math.min(a, 1), 0);
+	}
+	
+	/**
+	 * compares two double values using an epsilon
+	 * @param value - given value
+	 * @param target - expected value
+	 * @return
+	 */
+	private boolean almostEqual(double value, double target) {
+		return Math.abs(value - target) < 1E-10;
+	}
+
+}
+
+
+
+

+ 177 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustCanvas.java

@@ -0,0 +1,177 @@
+/**
+ * CertainTrust SDK
+ * 
+ * Implements the computational trust model "CertainTrust"
+ * in Java.
+ * See <http://www.tk.informatik.tu-darmstadt.de/de/research/smart-security-and-trust/> for further details.
+ * 
+ * 
+ * Telecooperation Department, Technische Universit�t Darmstadt
+ * <http://www.tk.informatik.tu-darmstadt.de/>
+ * 
+ * Prof. Dr. Max Mühlhäuser <max@informatik.tu-darmstadt.de>
+ * Florian Volk <florian.volk@cased.de>
+ * 
+ * 
+ * @author	David Kalnischkies
+ * @version	1.0
+ */
+
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+package CertainTrust;
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+
+/**
+ * The canvas is a lovely image trying to visualize
+ * certainty and trust in an easy understandable way.
+ *
+ * @author David Kalnischkies <kalnischkies@gmail.com>
+ */
+public class CertainTrustCanvas extends Canvas implements Observer {
+	private static final long serialVersionUID = -8020598465155085223L;
+
+	private static final int CROSSHAIRLENGTH = 5;
+	private CertainTrust cl;
+	private Map<String,String> config;
+
+	private Image buffer;
+	private double old_f = -1;
+
+	/**
+	 * Constructs a new Canvas to display the certainlogic element
+	 * @param certainlogic element to display
+	 */
+	public CertainTrustCanvas(CertainTrust certainlogic) {
+		setup(certainlogic, null);
+	}
+	/**
+	 * Constructs a new Canvas to display the certainlogic element
+	 * 
+	 * Supported config options are:
+	 * - readonly.mouse: disables all mouse actions if set to "true"
+	 * - canvas.height and canvas.width to define the dimensions
+	 * 
+	 * @param certainlogic element to display
+	 * @param config to use for this HTI
+	 */
+	public CertainTrustCanvas(CertainTrust certainlogic, Map<String,String> config) {
+		setup(certainlogic, config);
+	}
+	
+	private void setup(CertainTrust certainlogic, Map<String,String> config) {
+		if (config != null)
+			this.config = config;
+		else
+			this.config = new HashMap<String,String>();
+		
+		// set the requested dimensions
+		if (this.config.containsKey("canvas.width") == false)
+			this.config.put("canvas.width", "120");
+		if (this.config.containsKey("canvas.height") == false)
+			this.config.put("canvas.height", "100");
+		final int canvasWidth = Integer.parseInt(this.config.get("canvas.width")); 
+		final int canvasHeight = Integer.parseInt(this.config.get("canvas.height"));
+		setPreferredSize(new Dimension(canvasWidth, canvasHeight));
+		
+		cl = certainlogic;
+		cl.addObserver(this);
+
+		// register for mouse events if required
+		if (this.config.containsKey("readonly") == false) {
+			if (this.config.containsKey("readonly.mouse") == false)
+				this.config.put("readonly.mouse", "false");
+		} else {
+			String readOnly = this.config.get("readonly");
+			if (this.config.containsKey("readonly.mouse") == false)
+				this.config.put("readonly.mouse", readOnly);
+		}
+		if (this.config.get("readonly.mouse").compareToIgnoreCase("false") == 0) {
+			addMouseListener(new MouseAdapter () {
+			      @Override
+				public void mousePressed(MouseEvent e) {
+				  setTCByMouseEvent(e, canvasWidth, canvasHeight);
+			    }});
+	
+			 addMouseMotionListener(new MouseMotionAdapter () {
+			      @Override
+				public void mouseDragged(MouseEvent e) {
+				  setTCByMouseEvent(e, canvasWidth, canvasHeight);
+			     }});
+		} else if (this.config.get("readonly.mouse").compareToIgnoreCase("true") != 0)
+			throw new IllegalArgumentException("Mouse has no valid readonly setting");
+
+		// call paint() indirectly the first time
+		update(null, null);
+	}
+	
+	private void setTCByMouseEvent(MouseEvent e, int canvasWidth, int canvasHeight) {
+		// mouse position to x and y coordinate 
+		double pointer_x = Math.max(Math.min(canvasWidth, e.getX()), 0);
+		double pointer_y = Math.max(Math.min(canvasHeight, canvasHeight - e.getY()), 0);
+		// ensure that the value is in the interval [0;1]
+		double t = Math.max(Math.min(pointer_x / canvasWidth, 1.0), 0.0);
+		double c = Math.max(Math.min(pointer_y / canvasHeight, 1.0), 0.0);
+		cl.setTC(t, c);
+	}
+
+	@Override
+	public void update(Observable ignored1, Object ignored2) {
+		repaint();
+	}
+
+	@Override
+	public void paint(Graphics g) {
+		final int canvasWidth = Integer.parseInt(this.config.get("canvas.width")); 
+		final int canvasHeight = Integer.parseInt(this.config.get("canvas.height"));
+		if (null == buffer) {
+			buffer = createImage(canvasWidth, canvasHeight);
+		}
+
+		// do we need to update the colorgradient?
+		double initf = cl.getF();
+		if (old_f != initf) {
+			Graphics bg = buffer.getGraphics();
+			for (int y = 0; y < canvasHeight; ++y){
+				double certainty = 1 - ((double)y / canvasHeight);
+				double resultp2 = ((1 - certainty) * initf);
+				for (int x = 0;x < canvasWidth; ++x){
+					double trust = (double)x / canvasWidth;
+					double result = (trust * certainty) + resultp2;
+
+					if (result < 0.5) {
+						bg.setColor(new Color(255, (int) Math.min(255, (255 * 2 * result)), 0));
+					} else {
+						bg.setColor(new Color((int) Math.min(255, (2 - (2 * result)) * 255), 255, 0));
+					}
+
+					bg.drawLine(x, y, x, y);
+				}
+			}
+			old_f = initf;
+		}
+		g.drawImage(buffer, 0, 0, this);
+
+		// draw the crosshair
+		g.setColor(Color.BLACK);
+		int pointer_x = (int) Math.round(cl.getT() * canvasWidth);
+		int pointer_y = (int) Math.round((1 - cl.getC()) * canvasHeight);
+		g.drawLine(pointer_x - CROSSHAIRLENGTH, pointer_y, pointer_x + CROSSHAIRLENGTH, pointer_y);
+		g.drawLine(pointer_x, pointer_y - CROSSHAIRLENGTH, pointer_x, pointer_y + CROSSHAIRLENGTH);
+	}
+}

+ 289 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustHTI.java

@@ -0,0 +1,289 @@
+/**
+ * CertainTrust SDK
+ * 
+ * Implements the computational trust model "CertainTrust"
+ * in Java.
+ * See <http://www.tk.informatik.tu-darmstadt.de/de/research/smart-security-and-trust/> for further details.
+ * 
+ * 
+ * Telecooperation Department, Technische Universität Darmstadt
+ * <http://www.tk.informatik.tu-darmstadt.de/>
+ * 
+ * Prof. Dr. Max Mühlhäuser <max@informatik.tu-darmstadt.de>
+ * Florian Volk <florian.volk@cased.de>
+ * 
+ * 
+ * @author	David Kalnischkies
+ * @author	Florian Volk
+ * @version	1.0
+ */
+
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+package CertainTrust;
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import javax.swing.BoxLayout;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * The CertainTrustHTI includes a formular to change
+ * the C, T and F values of the given CertainTrust
+ * element and a canvas displaying the expectation
+ * calculated from these values
+ */
+public class CertainTrustHTI extends JPanel implements Observer {
+	private static final long serialVersionUID = -1194437596328826222L;
+
+	/**
+	 * Creates a new HTI to display a CertainTrust element
+	 * 
+	 * @param certainlogic element to display
+	 */
+	public CertainTrustHTI(CertainTrust certainlogic) {
+		setup(certainlogic, null);
+	}
+	
+	/**
+	 * Creates a new HTI to display a CertainTrust element
+	 * 
+	 * Supported config options are:
+	 * - label.lang: language for the text elements (available: "de" and "en" (default))
+	 * - label.f, label.c, label.t and label.e to set the text explicitly
+	 * - readonly: to effect the complete HTI (value either "true" or "false") and
+	 * - readonly.f, readonly.c, readonly.t, readonly.e to set explicitly
+	 * See also {@link CertainTrustCanvas#CertainTrustCanvas(CertainTrust, Map)} for
+	 * additional options which are accepted by the canvas element
+	 * 
+	 * @param certainlogic element to display
+	 * @param config to use for this HTI
+	 */
+	public CertainTrustHTI(CertainTrust certainlogic, Map<String, String> config) {
+		setup(certainlogic, config);
+	}
+	
+	private CertainTrust cl;
+	private JTextField f;
+	private JTextField c;
+	private JTextField t;
+	private JTextField e;
+	private CertainTrustCanvas ctc;
+	private Map<String,String> config;
+	
+	protected CertainTrustCanvas getCanvas() { return ctc; }
+	
+	private static JTextField appendInput(JPanel p, String name, char mnemonic, double value, String readOnly, CertainTrustActionFocusListener listener) {
+		JLabel l = new JLabel(name);
+		l.setBorder(new EmptyBorder(0, 0, 0, (int) (l.getFont().getSize() * 1.5)));
+		final JTextField f = new JTextField(CertainTrustHTI.formatFloat(value), 4);
+		if (readOnly.compareToIgnoreCase("true") == 0) {
+			f.setEditable(false);
+			f.setFocusable(false);
+		}
+		else if (readOnly.compareToIgnoreCase("false") != 0)
+			throw new IllegalArgumentException("Input element " + name + " has no valid readonly setting");
+		else if (listener != null) {
+			f.addActionListener(listener);
+			f.addFocusListener(listener);
+		}
+		l.setLabelFor(f);
+		if (mnemonic != '\0')
+			l.setDisplayedMnemonic(mnemonic);
+		p.add(l);
+		p.add(f);
+		return f;
+	}
+	
+	private abstract class CertainTrustActionFocusListener implements ActionListener, FocusListener {
+		@Override
+		public void focusGained(FocusEvent arg0) {}
+
+		@Override
+		public void focusLost(FocusEvent arg0) {
+			update();
+		}
+
+		@Override
+		public void actionPerformed(ActionEvent arg0) {
+			update();
+		}
+		
+		abstract void update();
+		
+		/**
+		 * parseInput tries to convert a textual input into a floating point number in [0;1]
+		 * It accepts both "." and "," as decimal delimiters.
+		 * If the conversion fails, a default value is used.
+		 * @param input	the textual input to convert into a floating point number
+		 * @param defaultValue	the default value used in case the conversion fails
+		 * @return	the floating point value generated from the textual input
+		 */
+		protected double parseInput(String input, double defaultValue) {
+			double result;
+			try {
+				// first, replace the first "," with a "." to understand German-language style floating point notation
+				String rawInput = input.replaceFirst(",", ".");
+				
+				result = Double.parseDouble(rawInput);
+				
+				// check, if the value in within our bounds of [0;1]
+				if ((1 < result) || (0 > result)) {
+					result = defaultValue;
+				}
+			}
+			catch (NumberFormatException e) {
+				result = defaultValue;
+			}
+			return result;
+		}
+	}
+	
+	private void setup(CertainTrust certainlogic, Map<String,String> config) {
+		cl = certainlogic;
+		if (config != null)
+			this.config = config;
+		else
+			this.config = new HashMap<String,String>();
+		
+		if (this.config.containsKey("label.lang") == false)
+			this.config.put("label.lang", "en");
+		if (this.config.get("label.lang") == "de") {
+			if (this.config.containsKey("label.f") == false)
+				this.config.put("label.f", "Initialwert");
+			if (this.config.containsKey("label.t") == false)
+				this.config.put("label.t", "Vertrauen");
+			if (this.config.containsKey("label.c") == false)
+				this.config.put("label.c", "Sicherheit");
+			if (this.config.containsKey("label.e") == false)
+				this.config.put("label.e", "Erwartung");
+		} else {
+			if (this.config.containsKey("label.f") == false)
+				this.config.put("label.f", "Init. value");
+			if (this.config.containsKey("label.t") == false)
+				this.config.put("label.t", "Trust");
+			if (this.config.containsKey("label.c") == false)
+				this.config.put("label.c", "Certainty");
+			if (this.config.containsKey("label.e") == false)
+				this.config.put("label.e", "Expectation");
+		}
+		
+		if (this.config.containsKey("readonly") == false) {
+			if (this.config.containsKey("readonly.f") == false)
+				this.config.put("readonly.f", "false");
+			if (this.config.containsKey("readonly.t") == false)
+				this.config.put("readonly.t", "false");
+			if (this.config.containsKey("readonly.c") == false)
+				this.config.put("readonly.c", "false");
+			if (this.config.containsKey("readonly.e") == false)
+				this.config.put("readonly.e", "true");
+		} else {
+			String readOnly = this.config.get("readonly");
+			if (this.config.containsKey("readonly.f") == false)
+				this.config.put("readonly.f", readOnly);
+			if (this.config.containsKey("readonly.t") == false)
+				this.config.put("readonly.t", readOnly);
+			if (this.config.containsKey("readonly.c") == false)
+				this.config.put("readonly.c", readOnly);
+			if (this.config.containsKey("readonly.e") == false)
+				this.config.put("readonly.e", readOnly);
+		}
+		
+		JPanel inputs = new JPanel(new GridLayout(5,2));
+		f = appendInput(inputs, this.config.get("label.f"), 'f', cl.getF(), this.config.get("readonly.f"),
+				new CertainTrustActionFocusListener() {
+					@Override
+					void update() {
+						cl.setF(this.parseInput(f.getText(), cl.getF()));
+					}
+				});
+		t = appendInput(inputs, this.config.get("label.t"), 't', cl.getT(), this.config.get("readonly.t"),
+				new CertainTrustActionFocusListener() {
+			@Override
+			void update() {
+				cl.setTC(this.parseInput(t.getText(), cl.getT()),
+						cl.getC());
+			}
+		});
+		c = appendInput(inputs, this.config.get("label.c"), 'c', cl.getC(), this.config.get("readonly.c"),
+				new CertainTrustActionFocusListener() {
+			@Override
+			void update() {
+				cl.setTC(cl.getT(),
+						this.parseInput(c.getText(), cl.getC()));
+			}
+		});
+		JLabel ignore0 = new JLabel("");
+		inputs.add(ignore0);
+		JLabel ignore1 = new JLabel("");
+		inputs.add(ignore1);
+		e = appendInput(inputs, this.config.get("label.e"),'\0', cl.getExpectation(), this.config.get("readonly.e"), null);
+		this.add(inputs);
+		
+		JPanel jp = new JPanel();
+		jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
+		JPanel jp1 = new JPanel();
+		JLabel certain = new JLabel(this.config.get("label.c") + "\u00a0\u2192");
+		certain.setUI(new VerticalLabelUI());
+		jp1.add(certain);
+		ctc = new CertainTrustCanvas(cl, this.config);
+		ctc.repaint();
+		jp1.add(ctc);
+		JPanel jp2 = new JPanel(new BorderLayout());
+		JLabel origin = new JLabel("0");
+		int fontsize = certain.getFont().getSize();
+		origin.setBorder(new EmptyBorder(0, fontsize, 0, fontsize));
+		jp2.add(origin, BorderLayout.LINE_START);
+		JLabel trust = new JLabel(this.config.get("label.t") + "\u00a0\u2192");
+		jp2.add(trust, BorderLayout.CENTER);
+		jp.add(jp1);
+		jp.add(jp2);
+		
+		this.add(jp);
+		this.setVisible(true);
+		cl.addObserver(this);
+	}
+
+	@Override
+	public void update(Observable ignored0, Object ignored1) {
+		f.setText(CertainTrustHTI.formatFloat(cl.getF()));
+		t.setText(CertainTrustHTI.formatFloat(cl.getT()));
+		c.setText(CertainTrustHTI.formatFloat(cl.getC()));
+		e.setText(CertainTrustHTI.formatFloat(cl.getExpectation()));
+	}
+	
+	/**
+	 * Rounds a number to at most 3 decimal places and converts it to a string
+	 * @param value	the number to round
+	 * @return	the rounded value as string
+	 */
+	static private String formatFloat(double value) {
+		// the explicit type cast from Long to double is required, otherwise rounded will always be 0
+		double rounded = ((double)Math.round(value * 1000) / 1000);
+		
+		// Use NumerFormat to omit trailing 0s as those which Double.toString() produces
+		NumberFormat formatter = new DecimalFormat("0.###");
+		String result = formatter.format(rounded);
+		
+		// for compatibility with the JS version, our decimal delimiter *always* is "."
+		result = result.replaceFirst(",", ".");
+		
+		return result;
+	}
+}

+ 650 - 0
Java/Java_SDK/src/CertainTrust/CertainTrustSimple.java

@@ -0,0 +1,650 @@
+/**
+ * CertainTrust SDK
+ * 
+ * Implements the computational trust model "CertainTrust"
+ * in Java.
+ * See <http://www.tk.informatik.tu-darmstadt.de/de/research/smart-security-and-trust/> for further details.
+ * 
+ * 
+ * Telecooperation Department, Technische Universit�t Darmstadt
+ * <http://www.tk.informatik.tu-darmstadt.de/>
+ * 
+ * Prof. Dr. Max Mühlhäuser <max@informatik.tu-darmstadt.de>
+ * Florian Volk <florian.volk@cased.de>
+ *