Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 86350a5b

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

jsDoc, dropped unused functionality, minor improvements

Zobrazit rozdíly:

sources/src/main/webapp/css/main.css
259 259
	flex: 1;
260 260
}
261 261

  
262
.lollipop--cross > line {
263
	stroke: red;
264
}
265

  
266
.lollipop--tick > line {
267
	stroke: green;
268
}
269

  
270 262
.viewport .edge {
271 263
	stroke: black;
272 264
    stroke-width: 1;
273 265
}
274 266

  
275
.viewport .edge .lollipop {
267
.viewport .edge .arrow {
276 268
	fill: white;
277 269
    stroke-width: 2;
278 270
}
......
295 287
    stroke-width: 2;
296 288
}
297 289

  
298
.viewport .edge--highlighted .lollipop {
290
.viewport .edge--highlighted .arrow {
299 291
	stroke: red;
300 292
}
301 293

  
......
341 333
	fill: yellow;
342 334
}
343 335

  
344
.viewport .vertex .interface {
345
    fill: white;
346
    stroke: black;
347
    stroke-width: 1px;
336
.viewport .vertex .archetype {
337
	dominant-baseline: central;
348 338
}
349 339

  
350 340
.context-menu {
sources/src/main/webapp/js/components/group.js
19 19
		width: 70,
20 20
		height: 70,
21 21
	};
22
	var requiredCounter = 0;
23
	var providedCounter = 0;
24 22
	var floater = null;
25 23

  
26 24
	var pan = false;
......
75 73
			vertexListComponent.appendChild(vertex);
76 74
		}
77 75

  
78
		requiredCounter += vertex.getInEdgeList().length;
79
		providedCounter += vertex.getOutEdgeList().length;
80

  
81 76
		vertexList.push(vertex);
82 77
	};
83 78

  
......
106 101
			vertexListComponent.removeChild(vertex);
107 102
		}
108 103

  
109
		requiredCounter -= vertex.getInEdgeList().length;
110
		providedCounter -= vertex.getOutEdgeList().length;
111

  
112 104
		vertexList.splice(vertexList.indexOf(vertex), 1);
113 105
	};
114 106
	
......
265 257

  
266 258
	/**
267 259
	 * Toggles highlighting of the group to mark it as requirement of some other node.
268
	 * @param {boolean} newValue True to highlight the group as required, false to unhighlight.
260
	 * @param {boolean} newValue True to highlight, false to unhighlight.
269 261
	 */
270 262
	this.setHighlightedRequired = function(newValue) {
271 263
		highlightedRequired = newValue;
......
279 271
	
280 272
	/**
281 273
	 * Toggles highlighting of the group to mark it as dependent of some other node.
282
	 * @param {boolean} newValue True to highlight the group as provided, false to unhighlight.
274
	 * @param {boolean} newValue True to highlight, false to unhighlight.
283 275
	 */
284 276
	this.setHighlightedProvided = function(newValue) {
285 277
		highlightedProvided = newValue;
......
457 449
		// name
458 450
		var nameText = app.utils.createSvgElement('text', {
459 451
			'class': 'group-name',
460
			'x': 0,
452
			'x': 20,
461 453
			'y': 15,
462 454
		});
463 455
		nameText.appendChild(document.createTextNode(this.name));
......
580 572
		});
581 573
		svg.appendChild(group);
582 574

  
575
		/*
583 576
		// required
584 577
		var required = app.utils.createSvgElement('g', {
585 578
			'class': 'required-counter',
......
649 642
		});
650 643
		providedCounterText.appendChild(document.createTextNode(providedCounter));
651 644
		provided.appendChild(providedCounterText);
645
		*/
652 646

  
653 647
		// symbol
654 648
		var symbolText = app.utils.createHtmlElement('span', {
......
763 757
		}
764 758
	}
765 759

  
766
	/**
767
	 * Highlights the group as a requirement.
768
	 */
769
	function requiredClick() {
770
		this.setHighlighted(!highlighted);
771
		this.setHighlightedRequiredNeighbours(highlighted);
772
		this.setHighlightedProvidedNeighbours(false);
773

  
774
		highlightRequiredNeighbours.call(this);
775
	}
776

  
777
	/**
778
	 * Highlights the group as a dependent.
779
	 */
780
	function providedClick() {
781
		this.setHighlighted(!highlighted);
782
		this.setHighlightedRequiredNeighbours(false);
783
		this.setHighlightedProvidedNeighbours(highlighted);
784

  
785
		highlightProvidedNeighbours.call(this);
786
	}
787

  
788 760
	/**
789 761
	 * Includes the group back to the viewport.
790 762
	 */
sources/src/main/webapp/js/components/groupVertexList.js
5 5
 * @param {Group} parentalGroup Group this vertex list is bound to.
6 6
 */
7 7
function GroupVertexList(parentalGroup) {
8
	const lineHeight = 18;
9

  
8 10
	var rootElement;
11
	var listItemCounter = 0;
9 12

  
10 13
	/**
11 14
	 * Adds a new vertex to the list. Binds user interactions to local handler functions.
......
16 19
		if (parentalGroup.isExcluded()) {
17 20
			listItemElement = app.utils.createHtmlElement('li', {});
18 21
		} else {
19
			listItemElement = app.utils.createSvgElement('text', {});
22
			listItemElement = app.utils.createSvgElement('text', {
23
				'y': listItemCounter * lineHeight,
24
			});
20 25
		}
21 26

  
22 27
		listItemElement.setAttribute('data-id', vertex.id);
......
24 29
		listItemElement.addEventListener('click', listItemClick.bind(vertex));
25 30

  
26 31
		rootElement.appendChild(listItemElement);
32

  
33
		listItemCounter++;
27 34
	};
28 35

  
29 36
	/**
sources/src/main/webapp/js/components/vertex.js
13 13
	/** @prop {array} symbol Symbol of the group. */
14 14
	this.symbol = app.markSymbol.getMarkSymbol();
15 15

  
16
	const oneCharacterWidth = 8.3;	// approximate width (in pixels) of one character using Consolas at 15px font size
17
	const minimumWidth = 200;
18

  
16 19
	var rootElement;
17 20
	var symbolListComponent;
18 21

  
19 22
	var position = new Coordinates(0, 0);
20 23
	var size = {
21
		width: Math.max(30 + this.name.length * 8.3, 200),	// 8.3 is approximate width (in pixels) of one character using Consolas at 15px font size
24
		width: Math.max(30 + this.name.length * oneCharacterWidth, minimumWidth),
22 25
		height: 30,
23 26
	};
24 27
	var group = null;
......
69 72
	};
70 73

  
71 74
	/**
72
	 * @returns {array<Edge>} Array of edges going to the vertex.
75
	 * @returns {array<Edge>} Array of edges incoming to the vertex.
73 76
	 */
74 77
	this.getInEdgeList = function() {
75 78
		return inEdgeList;
76 79
	};
77 80

  
78 81
	/**
79
	 * @returns {array<Edge>} Array of edges going from the vertex.
82
	 * @returns {array<Edge>} Array of edges outgoing from the vertex.
80 83
	 */
81 84
	this.getOutEdgeList = function() {
82 85
		return outEdgeList;
......
94 97
		symbolListComponent.appendChild(symbol);
95 98
	};
96 99

  
100
	/**
101
	 * Removes symbol from the list of symbols displayed next to the vertex.
102
	 * @param {array} symbol Node symbol to be removed.
103
	 */
97 104
	this.removeSymbol = function(symbol) {
98 105
		symbolList.splice(symbolList.indexOf(symbol), 1);
99 106

  
......
115 122

  
116 123
	/**
117 124
	 * Updates the current position of the vertex in graph.
125
	 * @param {Coordinates} New position of the vertex.
118 126
	 */
119 127
	this.setPosition = function(coords) {
120 128
		if (!(coords instanceof Coordinates)) {
......
125 133
	};
126 134

  
127 135
	/**
128
	 * @returns {Coordinates} Centre of the group.
136
	 * @returns {Coordinates} Centre of the vertex.
129 137
	 */
130 138
	this.getCenter = function() {
131 139
		return new Coordinates(
......
162 170
	};
163 171

  
164 172
	/**
165
	 * @returns {Group} Group this vertex is part of. If the vertex stands alone, null is returned.
173
	 * @returns {Group} Group this vertex is currently part of. If the vertex stands alone, null is returned.
166 174
	 */
167 175
	this.getGroup = function() {
168 176
		return group;
......
220 228

  
221 229
	/**
222 230
	 * Toggles highlighting of the vertex.
223
	 * @param {boolean} newValue True to highlight the vertex, otherwise false.
231
	 * @param {boolean} newValue True to highlight the vertex, false to unhighlight.
224 232
	 */
225 233
	this.setHighlighted = function(newValue) {
226 234
		highlighted = newValue;
......
234 242

  
235 243
	/**
236 244
	 * Toggles highlighting of the vertex to mark it as requirement of some other node.
237
	 * @param {boolean} newValue True to highlight the vertex as required, false to unhighlight.
245
	 * @param {boolean} newValue True to highlight, false to unhighlight.
238 246
	 */
239 247
	this.setHighlightedRequired = function(newValue) {
240 248
		highlightedRequired = newValue;
......
252 260
	
253 261
	/**
254 262
	 * Toggles highlighting of the vertex to mark it as dependent of some other node.
255
	 * @param {boolean} newValue True to highlight the vertex as provided, false to unhighlight.
263
	 * @param {boolean} newValue True to highlight, false to unhighlight.
256 264
	 */
257 265
	this.setHighlightedProvided = function(newValue) {
258 266
		highlightedProvided = newValue;
......
436 444
			'y': 1,
437 445
		}));
438 446

  
439
		// archetype
440
		var archetype = app.utils.createSvgElement('g', {
447
		// archetype icon
448
		var archetypeIcon = app.dom.createSvgElement('g', {
441 449
			'class': 'archetype',
442
			'data-vertexId': this.id,
443 450
			'transform': 'translate(7, 6)',
444 451
		});
445
		archetype.addEventListener('click', archetypeClick.bind(this));
452
		archetypeIcon.addEventListener('click', archetypeClick.bind(this));
446 453

  
447
		archetype.innerHTML = app.archetype.icon[this.archetype.name];
454
		archetypeIcon.innerHTML = app.archetype.icon[app.archetype.vertex[this.archetype].name];
448 455

  
449
		rootElement.appendChild(archetype);
456
		rootElement.appendChild(archetypeIcon);
450 457

  
451 458
		// name
452 459
		var nameText = app.utils.createSvgElement('text', {
......
472 479
	 * @returns {Element} HTML DOM element.
473 480
	 */
474 481
	function renderExcluded() {
475
		rootElement = app.utils.createHtmlElement('li', {
482
		rootElement = app.dom.createHtmlElement('li', {
476 483
			'class': 'node vertex',
477 484
			'data-id': this.id,
478 485
		});
479 486

  
480
		var svg = app.utils.createSvgElement('svg', {
487
		var svg = app.dom.createSvgElement('svg', {
481 488
			'xmlns': 'http://www.w3.org/2000/svg',
482 489
			'height': 60,
483 490
			'width': 46,
484 491
		});
485 492
		rootElement.appendChild(svg);
486 493

  
487
		var group = app.utils.createSvgElement('g', {
494
		var group = app.dom.createSvgElement('g', {
488 495
			'transform': 'translate(60,10)',
489 496
		});
490 497
		svg.appendChild(group);
......
598 605
		showSymbolButton.addEventListener('click', showIconClick.bind(this));
599 606
		buttonGroup.appendChild(showSymbolButton);
600 607

  
601
		// to change button
602
		var toChangeButton = app.utils.createHtmlElement('button', {
603
			'class': 'change-button button',
604
			'title': 'Set component for change',
605
		});
606
		toChangeButton.appendChild(app.utils.createHtmlElement('img', {
607
			'src': 'images/tochange/tochange-trans.gif',
608
			'alt': 'Icon of "set component for change" action',
609
		}));
610
		toChangeButton.addEventListener('click', addToChange.bind(this));
611
		buttonGroup.appendChild(toChangeButton);
612

  
613 608
		// include button
614 609
		var includeButton = app.utils.createHtmlElement('button', {
615 610
			'class': 'include-button button',
......
643 638
	 * Vertex click interaction. Based on whether the vertex is excluded and currently selected mouse mode (move, exclude),
644 639
	 * the vertex is either highlighted or moved within the graph.
645 640
	 */
646
	function click() {
641
	function click(e) {
642
		e.stopPropagation();
643

  
647 644
		if (excluded) {
648 645
			this.setHighlighted(!highlighted);
649 646
			this.setHighlightedRequiredNeighbours(highlighted);
......
739 736
		}, this);
740 737
	}
741 738

  
742
	/**
743
	 * Adds the vertex to the list of components to be changed.
744
	 * @param {Event} e Click event.
745
	 */
746
	function addToChange(e) {
747
		app.sidebarComponent.addToChange(this);
748
	}
749

  
750 739
	/**
751 740
	 * Includes the group back to the viewport.
752 741
	 */
......
902 891
	}
903 892

  
904 893
	/**
905
	 * Highlights only neighbours the vertex that are required.
894
	 * Highlights only neighbours of the vertex that are required.
906 895
	 */
907 896
	function highlightRequiredNeighbours() {
908 897
		if (highlighted) {
......
922 911
	}
923 912

  
924 913
	/**
925
	 * Highlights only neighbours the vertex that are provided.
914
	 * Highlights only neighbours of the vertex that are provided.
926 915
	 */
927 916
	function highlightProvidedNeighbours() {
928 917
		if (highlighted) {

Také k dispozici: Unified diff