Browse Source

comments!!

MW 7 years ago
parent
commit
4e3a90213f

+ 0 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/graphs/MappingGraphManager.java

@@ -584,8 +584,6 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
 	}
 
 	private void autoMapSourcesAndSinks(GraphManager underlay, GraphManager operator) {
-		// TODO Andere Farbe für automatisch erstellte Mappingkanten von Quellen
-		// und Senken
 		for (MyNode operatorNode : getOperatorNodeSet()) {
 			if (operatorNode.getAttribute("typeofNode").toString().equals("source")) {
 				for (MyNode underlayNode : getUnderlayNodeSet()) {

+ 0 - 9
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSConditionException.java

@@ -1,9 +0,0 @@
-package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
-
-public class CSSConditionException extends CSSException {
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -3594305376563812699L;
-}

+ 27 - 15
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSDeclaration.java

@@ -1,37 +1,49 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
 
+/**
+ * Stores a single CSS property value Pair. Provides setter for both.
+ * 
+ * @author Matthias Wilhelm
+ */
 class CSSDeclaration {
-	// TODO comment
+	/**
+	 * The CSS Property name
+	 */
 	String property;
-	// TODO comment
+	/**
+	 * The CSS Value
+	 */
 	String value;
 
-	// TODO comment
+	/**
+	 * Creates a new CSSDeclaration.
+	 * 
+	 * @param property
+	 *            CSS property
+	 * @param value
+	 *            CSS value
+	 */
 	CSSDeclaration(String property, String value) {
 		this.property = property.trim();
 		this.value = value.trim();
 	}
 
-	// TODO comment
+	/**
+	 * 
+	 * @return CSS property
+	 */
 	String getProperty() {
 		return property;
 	}
 
-	// TODO comment
-	void setProperty(String property) {
-		this.property = property;
-	}
-
-	// TODO comment
+	/**
+	 * 
+	 * @return CSS value
+	 */
 	String getValue() {
 		return value;
 	}
 
-	// TODO comment
-	void setValue(String value) {
-		this.value = value;
-	}
-
 	@Override
 	public String toString() {
 		return property + ": " + value;

+ 0 - 10
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSException.java

@@ -1,10 +0,0 @@
-package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
-
-public abstract class CSSException extends Exception {
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 2158319179027554462L;
-
-}

+ 109 - 15
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSManager.java

@@ -5,24 +5,52 @@ import java.util.HashSet;
 
 import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
 
+/**
+ * Manages CSSables. Offers Functions to store rules and CSSables, to remove
+ * CSSables, to compare a given CSSable with all rules and to update the CSS for
+ * all stored CSSables.
+ * 
+ * @author Matthias Wilhelm
+ */
 public class CSSManager {
 	/**
-	 * Du zerstörst diesen REGEX und Matthias zerstört dich
+	 * REGEX to match CSS
 	 */
-	// TODO comment
 	private static final String CSS_MATCH_REGEX = "(\\s*([A-Za-z]+|[A-Za-z]*(\\.[A-Za-z_-]*)+\\s*\\,?)*\\s*\\{(\\s*[A-Za-z_-]+\\s*\\:\\s*[0-9A-Za-z\\(\\)\\_\\#\\'\\\"\\,\\s-]+\\s*\\;?)+\\s*\\})+\\s*";
 
-	// TODO comment
+	/**
+	 * A Set to store all rules.
+	 */
 	static HashSet<CSSRule> rules = new HashSet<CSSRule>();
-	// TODO comment
+	/**
+	 * A Set to store references to all CSSable interfaces
+	 */
 	private static HashSet<CSSable> cssAbles = new HashSet<CSSable>();
 
-	// TODO comment
+	/**
+	 * Add a new Rule to the Set. Doesn't check whether the rule is useful.
+	 * Prevents storing the same rule twice silently. Multiple rules are
+	 * recognized, if separated by whitespace only.<br/>
+	 * Updates all stored CSSabled afterwards.
+	 * 
+	 * @param rule
+	 *            the rule to add
+	 * 
+	 */
 	public static void addRule(String rule) {
 		addRule(rule, true);
 	}
 
-	// TODO comment
+	/**
+	 * Add a new Rule to the Set. Doesn't check whether the rule is useful.
+	 * Prevents storing the same rule twice silently. Multiple rules are
+	 * recognized, if separated by whitespace only.
+	 * 
+	 * @param rule
+	 *            the rule to add
+	 * @param updateCSSable
+	 *            Updates all stored CSSabled afterwards, if true
+	 */
 	public static void addRule(String rule, boolean updateCSSable) {
 		if (!rule.matches(CSS_MATCH_REGEX)) {
 			Debug.out("rule << " + rule + " >> doesn't match regex");
@@ -39,17 +67,35 @@ public class CSSManager {
 			updateCSSAble();
 	}
 
-	// TODO comment
+	/**
+	 * Stores a reference to the CSSable. Storing the reference allows this
+	 * Manager to update the CSS for the CSSables
+	 * 
+	 * @param ca
+	 *            the CSSable to store
+	 */
 	public static void addCSSAble(CSSable ca) {
 		cssAbles.add(ca);
 	}
 
-	// TODO comment
+	/**
+	 * Removes the reference to the CSSable. It will no longer get its CSS
+	 * updated by this Manager.
+	 * 
+	 * @param ca
+	 *            the CSSable to remove
+	 */
 	public static void removeCSSAble(CSSable ca) {
 		cssAbles.remove(ca);
 	}
 
-	// TODO comment
+	/**
+	 * Returns the best match of CSS declarations for the given CSSable
+	 * 
+	 * @param ca
+	 *            the CSSable
+	 * @return a String containing all CSS declarations
+	 */
 	public static String getCSS(CSSable ca) {
 		// <Property, <CSSValue, RuleValue>>
 		HashMap<String, CSSValueValue> cssDeclarations = new HashMap<>();
@@ -74,19 +120,39 @@ public class CSSManager {
 		return result.trim();
 	}
 
-	// TODO comment
+	/**
+	 * Iterates over every CSSable and calls its updateCSS function.
+	 */
 	private static void updateCSSAble() {
 		for (CSSable ca : cssAbles)
 			ca.updateCSS();
 	}
 
-	// TODO comment
+	/**
+	 * Converts a String into a Rule. Doesn't check for correct CSS. Check
+	 * should be handled beforehand.<br/>
+	 * String is expected to be in following form:<br/>
+	 * "selectors{declarations"
+	 * 
+	 * @param s
+	 *            the rule as String
+	 * @return the rule as CSSRule
+	 */
 	private static CSSRule extractRule(String s) {
 		String[] sArray = s.trim().split("\\{");
 		return new CSSRule(extractSelectors(sArray[0]), parseCss(sArray[1]));
 	}
 
-	// TODO comment
+	/**
+	 * Converts a String into selectors. Doesn't check for correct CSS. Check
+	 * should be handled beforehand.<br/>
+	 * String is expected to be in following form:<br/>
+	 * "selector(,selector)*"
+	 * 
+	 * @param s
+	 *            the selectors as String
+	 * @return the selectors in a HashSet
+	 */
 	private static HashSet<CSSSelector> extractSelectors(String s) {
 		HashSet<CSSSelector> selectors = new HashSet<>();
 		String[] sArray = s.trim().split("\\,");
@@ -96,7 +162,17 @@ public class CSSManager {
 		return selectors;
 	}
 
-	// TODO comment
+	/**
+	 * Converts a String into a selector. Doesn't check for correct CSS. Check
+	 * should be handled beforehand.<br/>
+	 * String is expected to be in one of the following forms:<br/>
+	 * "type(.class)*"<br/>
+	 * ".class(.class)*"
+	 * 
+	 * @param s
+	 *            the selector as String
+	 * @return the selector as CSSSelector
+	 */
 	private static CSSSelector extractSelector(String s) {
 		HashSet<String> classes = new HashSet<String>();
 		String[] sArray = s.trim().split("\\.");
@@ -106,7 +182,16 @@ public class CSSManager {
 		return new CSSSelector(sArray[0], classes);
 	}
 
-	// TODO comment
+	/**
+	 * Converts a String into declarations. Doesn't check for correct CSS. Check
+	 * should be handled beforehand.<br/>
+	 * String is expected to be in following form:<br/>
+	 * "declaration(;declaration)*"
+	 * 
+	 * @param s
+	 *            the declarations as String
+	 * @return the declarations in a HashSet
+	 */
 	private static HashSet<CSSDeclaration> parseCss(String s) {
 		HashSet<CSSDeclaration> declarations = new HashSet<CSSDeclaration>();
 		String[] sArray = s.trim().split("\\;");
@@ -124,7 +209,16 @@ public class CSSManager {
 		return declarations;
 	}
 
-	// TODO comment
+	/**
+	 * Converts a String into a declaration. Doesn't check for correct CSS.
+	 * Check should be handled beforehand.<br/>
+	 * String is expected to be in following form:<br/>
+	 * "property:value"
+	 * 
+	 * @param s
+	 *            the declaration as String
+	 * @return the declaration as CSSDeclaration
+	 */
 	private static CSSDeclaration parseCssStatement(String s) {
 		String[] sArray = s.trim().split("\\:");
 		return new CSSDeclaration(sArray[0], sArray[1]);

+ 32 - 17
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSRule.java

@@ -3,15 +3,31 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
 import java.util.HashSet;
 import java.util.Iterator;
 
+/**
+ * Stores a single Rule containing selectors and declarations. Offers a function
+ * to check whether a CSSable matches one selector.
+ * 
+ * @author Matthias Wilhelm
+ */
 class CSSRule {
-	// TODO comment
+	/**
+	 * A Set to store all selectors for the this rule.
+	 */
 	HashSet<CSSSelector> selectors = new HashSet<CSSSelector>();
-	// TODO comment
+	/**
+	 * A Set to store all declarations for the this rule.
+	 */
 	HashSet<CSSDeclaration> declarations = new HashSet<CSSDeclaration>();
-	// TODO comment
+	/**
+	 * A String to store the declarations in a human readable form.
+	 */
 	String css;
 
-	// TODO comment
+	/**
+	 * 
+	 * @param selectors
+	 * @param declarations
+	 */
 	CSSRule(HashSet<CSSSelector> selectors, HashSet<CSSDeclaration> declarations) {
 		super();
 		this.selectors = selectors;
@@ -23,7 +39,14 @@ class CSSRule {
 		css = css.trim();
 	}
 
-	// TODO comment
+	/**
+	 * Checks whether a CSSable matches one selector.
+	 * 
+	 * @param suspect
+	 *            the CSSable to check
+	 * @return a positive integer if the condition is met. The more difficult
+	 *         the rule was to meet, the greater the integer.
+	 */
 	int ConditionsMetBy(CSSable suspect) {
 		int result = 0;
 		Iterator<CSSSelector> i = selectors.iterator();
@@ -35,25 +58,17 @@ class CSSRule {
 			if (r > result)
 				result = r;
 		}
-
 		return result;
 	}
 
-	// TODO comment
-	public HashSet<CSSSelector> getSelectors() {
-		return selectors;
-	}
-
-	// TODO comment
+	/**
+	 * 
+	 * @return all stored declarations
+	 */
 	public HashSet<CSSDeclaration> getDeclarations() {
 		return declarations;
 	}
 
-	// TODO comment
-	String getCSS() {
-		return css;
-	}
-
 	@Override
 	public String toString() {
 		return selectors.toString().replace("[", "").replace("]", "") + " { " + css + " }";

+ 42 - 6
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSSelector.java

@@ -3,15 +3,39 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
 import java.util.HashSet;
 import java.util.Iterator;
 
+/**
+ * Stores a single CSSSelector consisting of a type and set of classes. Stores
+ * its value. The value is calculated by multiplying the amount of classes by
+ * Two and adding one if the selector has a type.
+ * 
+ * @author Matthias Wilhelm
+ */
 class CSSSelector {
-	// TODO comment
+	/**
+	 * the stored CSS type
+	 */
 	String type;
-	// TODO comment
+	/**
+	 * the stored CSS classes
+	 */
 	HashSet<String> classes;
-	// TODO comment
+	/**
+	 * the stored selector value.<br/>
+	 * The value is calculated by multiplying the amount of classes by Two and
+	 * adding one if the selector has a type
+	 */
 	int value;
 
-	// TODO comment
+	/**
+	 * Creates a new CSSSelector. Calculates its value.<br/>
+	 * The value is calculated by multiplying the amount of classes by Two and
+	 * adding one if the selector has a type
+	 * 
+	 * @param type
+	 *            CSS type
+	 * @param classes
+	 *            a Set CSS classes
+	 */
 	CSSSelector(String type, HashSet<String> classes) {
 		if (type != null && type.trim().length() > 0)
 			this.type = type;
@@ -19,7 +43,14 @@ class CSSSelector {
 		value = (type != null ? 1 : 0) + classes.size() << 1;
 	}
 
-	// TODO comment
+	/**
+	 * Compares the suspect to its conditions.
+	 * 
+	 * @param suspect
+	 *            the CSSable to check
+	 * @return true if the CSSable contains all classes of the selector and the
+	 *         type matches.
+	 */
 	boolean ConditionsMetBy(CSSable suspect) {
 		if (type != null && !type.equals(suspect.getType()))
 			return false;
@@ -32,7 +63,12 @@ class CSSSelector {
 		return true;
 	}
 
-	// TODO comment
+	/**
+	 * The value is calculated by multiplying the amount of classes by Two and
+	 * adding one if the selector has a type
+	 * 
+	 * @return the value of this CSS selector
+	 */
 	int getValue() {
 		return value;
 	}

+ 0 - 10
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSSytnaxException.java

@@ -1,10 +0,0 @@
-package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
-
-public class CSSSytnaxException extends CSSException {
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -4040313744607257567L;
-
-}

+ 27 - 5
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSValueValue.java

@@ -1,23 +1,45 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
 
+/**
+ * Value Value class. Provides a constructor and two getters for the values.
+ * 
+ * @author Matthias Wilhelm
+ */
 public class CSSValueValue {
-	// TODO comment
+	/**
+	 * the CSS value
+	 */
 	String cssValue;
-	// TODO comment
+	/**
+	 * the rule value
+	 */
 	int ruleValue;
 
-	// TODO comment
+	/**
+	 * Creates a new CSSValueValue pair.
+	 * 
+	 * @param cssValue
+	 *            the CSS value to store
+	 * @param ruleValue
+	 *            the rule value to store
+	 */
 	CSSValueValue(String cssValue, int ruleValue) {
 		this.cssValue = cssValue;
 		this.ruleValue = ruleValue;
 	}
 
-	// TODO comment
+	/**
+	 * 
+	 * @return the stored CSS value
+	 */
 	String getCssValue() {
 		return cssValue;
 	}
 
-	// TODO comment
+	/**
+	 * 
+	 * @return the stored rule value
+	 */
 	int getRuleValue() {
 		return ruleValue;
 	}

+ 6 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/css/CSSable.java

@@ -2,6 +2,12 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui.css;
 
 import java.util.HashSet;
 
+/**
+ * An Interface which offers functions to store, remove and toggle CSS classes
+ * and update a stored CSS String.
+ * 
+ * @author Matthias Wilhelm
+ */
 public interface CSSable {
 	/**
 	 * Adds a CSS class to the object. classes already added are ignored