Projekt

Obecné

Profil

« Předchozí | Další » 

Revize c91081fb

Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)

Vertex/Edge attribute rendering

Zobrazit rozdíly:

sources/src/main/java/cz/zcu/kiv/offscreen/graph/GraphManager.java
541 541
                attrValue = new StringBuilder(attr.getValue().toString());
542 542
                break;
543 543
            case DATE:
544
                attrValue = new StringBuilder(attr.getValue().toString());
544
                Date value = (Date) attr.getValue();
545
                attrValue = new StringBuilder(String.valueOf(value.getTime()));
545 546
                break;
546 547
            case ENUM: // Enum attribute type must be a list of integers!
547 548
                List<Integer> valuePositions = (List<Integer>) attr.getValue();
sources/src/main/webapp/js/app.js
56 56
		icon: [],
57 57
	};
58 58

  
59
	/** TODO: jsDoc */
60
	this.attributeTypeList = [];
61

  
59 62
	/**
60 63
	 * Loads graph using diagram (if available).
61 64
	 * @param diagramId Diagram identifier.
sources/src/main/webapp/js/components/attribute.js
1
/**
2
 * TODO: jsDoc
3
 * @constructor
4
 * @param {array} props Details of the attribute.
5
 */
6
function Attribute(props) {
7
	var attributeType = app.attributeTypeList.find(function(attributeType) {
8
		return attributeType.name === props[0];
9
	});
10

  
11
	this.name = props[0];
12
	this.value = props[1];
13
	this.dataType = attributeType.dataType;
14

  
15
	var rootElement;
16

  
17
	this.render = function() {
18
		rootElement = app.utils.createHtmlElement('li', {});
19

  
20
		rootElement.appendChild(app.dom.createTextElement(this.name + ': '));
21
		rootElement.appendChild(renderValue.call(this));
22

  
23
		return rootElement;
24
	};
25

  
26
	function renderValue() {
27
		switch (this.name) {
28
			case 'URL':
29
				return app.dom.htmlStringToElement(`<a href="${this.value}" target="_blank">${this.value}</a>`);
30
			case 'Size':
31
				return app.dom.createTextElement(formatValue.call(this) + ' B');
32
			case 'Estimate':
33
			case 'Spent':
34
				return app.dom.createTextElement(formatValue.call(this) + ' h');
35
			case 'Progress':
36
				return app.dom.createTextElement(formatValue.call(this) + '%');
37
			default:
38
				return app.dom.createTextElement(formatValue.call(this));
39
		}
40
	}
41

  
42
	function formatValue() {
43
		switch (this.dataType) {
44
			case 'DATE':
45
				var date = new Date(parseInt(this.value));
46
				return date.toLocaleString();
47
			default:
48
			case 'STRING':
49
				if (Array.isArray(this.value)) {
50
					return this.value.filter(function(value) {
51
						return value !== '';
52
					}).join(', ');
53
				} else {
54
					return this.value;
55
				}
56
			}
57
	}
58
}
sources/src/main/webapp/js/components/edgePopover.js
26 26
			detailsListElement.appendChild(listItem);
27 27

  
28 28
			subedgeInfo.attributes.forEach(function(attribute) {
29
				var listItem = app.dom.createHtmlElement('li', {});
30
				listItem.appendChild(app.dom.createTextElement(`${attribute[0]}: ${attribute[1]}`));
31

  
32
				sublist.appendChild(listItem);
29
				sublist.appendChild(new Attribute(attribute).render());
33 30
			});
34 31
		});
35 32
	};
sources/src/main/webapp/js/components/vertexPopover.js
19 19
		if (attributeList.length === 0) return;
20 20

  
21 21
		attributeList.forEach(function(attribute) {
22
			var listItem = app.utils.createHtmlElement('li', {});
23
			listItem.appendChild(document.createTextNode(`${attribute[0]}: ${attribute[1]}`));
24

  
25
			detailsListElement.appendChild(listItem);
22
			detailsListElement.appendChild(new Attribute(attribute).render());
26 23
		});
27 24
	};
28 25

  
sources/src/main/webapp/js/graphLoader.js
20 20

  
21 21
		var canvasSize = ((data.vertices.length * 75) / Math.round(Math.sqrt(data.vertices.length))) + 1000;
22 22

  
23
		app.attributeTypeList = data.attributeTypes;
24

  
23 25
		// store archetypes
24 26
		app.archetype.vertex = data.vertexArchetypes;
25 27
		app.archetype.edge = data.edgeArchetypes;
sources/src/main/webapp/showGraph.jsp
19 19
		<script src="js/libs/saveSvgAsPng.js"></script>
20 20
		<script src="js/libs/jstree.min.js"></script>
21 21

  
22
		<script src="js/components/attribute.js"></script>
22 23
		<script src="js/components/edge.js"></script>
23 24
		<script src="js/components/edgePopover.js"></script>
24 25
		<script src="js/components/floatingPoint.js"></script>
......
30 31
		<script src="js/components/statusBar.js"></script>
31 32
		<script src="js/components/vertex.js"></script>
32 33
		<script src="js/components/vertexContextMenuList.js"></script>
33
		<script src="js/components/vertexLight.js"></script>
34 34
		<script src="js/components/vertexPopover.js"></script>
35 35
		<script src="js/components/vertexSymbolList.js"></script>
36 36
		<script src="js/components/viewport.js"></script>

Také k dispozici: Unified diff