Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
W1nt0r committed Dec 7, 2018
2 parents 3e1957f + 0da168a commit fad7593
Show file tree
Hide file tree
Showing 25 changed files with 707 additions and 186 deletions.
6 changes: 3 additions & 3 deletions bintray.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
]
},
"version": {
"name": "1.1",
"released": "2018-11-15",
"name": "1.2",
"released": "2018-12-07",
"gpgSign": false
},
"files": [
{
"includePattern": "build/libs/(.*)",
"uploadPattern": "/ch/hsr/adv/adv-ui/1.1/$1",
"uploadPattern": "/ch/hsr/adv/adv-ui/1.2/$1",
"matrixParams": {
"override": 1
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'ch.hsr.adv'
version = '1.1'
version = '1.2'

/****************************************
* instructions for all projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import ch.hsr.adv.commons.array.logic.domain.ArrayElement;
import ch.hsr.adv.commons.core.logic.domain.ModuleGroup;
import ch.hsr.adv.commons.core.logic.domain.styles.ADVStyle;
import ch.hsr.adv.commons.core.logic.domain.styles.presets
.ADVDefaultElementStyle;
import ch.hsr.adv.commons.core.logic.domain.styles.presets.ADVDefaultElementStyle;
import ch.hsr.adv.ui.core.presentation.widgets.AutoScalePane;
import ch.hsr.adv.ui.core.presentation.widgets.LabeledNode;
import ch.hsr.adv.ui.core.presentation.widgets.IndexPosition;
import ch.hsr.adv.ui.core.presentation.widgets.IndexedNode;
import com.google.inject.Singleton;
import javafx.geometry.Pos;
import javafx.scene.layout.HBox;
Expand All @@ -25,11 +25,12 @@ public class ArrayDefaultLayouter {
* Layouts an array to look like a primitive array.
*
* @param moduleGroup moduleGroup to layout
* @param showIndices flag to show indices above array
* @return layouted pane
*/
public Pane layout(ModuleGroup moduleGroup) {
public Pane layout(ModuleGroup moduleGroup, boolean showIndices) {
initializeContainer();
drawElements(moduleGroup);
drawElements(moduleGroup, showIndices);

scalePane.addChildren(valueContainer);

Expand All @@ -42,19 +43,21 @@ private void initializeContainer() {
valueContainer.setAlignment(Pos.CENTER);
}

private void drawElements(ModuleGroup moduleGroup) {
private void drawElements(ModuleGroup moduleGroup, boolean showIndices) {
for (int i = 0; i < moduleGroup.getElements().size(); i++) {
ArrayElement element =
(ArrayElement) moduleGroup.getElements().get(i);

moduleGroup.getElements().forEach(e -> {
ArrayElement element = (ArrayElement) e;
ADVStyle style = element.getStyle();
if (style == null) {
style = new ADVDefaultElementStyle();
}

LabeledNode valueNode = new LabeledNode(element
.getContent(), style);
IndexedNode valueNode = new IndexedNode(i, element.getContent(),
style, false, showIndices,
IndexPosition.TOP);

valueContainer.getChildren().add(valueNode);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,29 @@ public ArrayLayouter(ArrayObjectReferenceLayouter objectLayouter,
* Delegates the layout of an array to the correct array layouter.
*
* @param moduleGroup to be layouted
* @param flags to switch between primitive array and object references
* @param flags to switch between primitive array and object
* references
* @return layouted snapshot
*/
@Override
public Pane layout(ModuleGroup moduleGroup, List<String> flags) {

boolean showObjectRelations = false;
boolean showIndices = false;
if (flags != null) {
showObjectRelations = flags.stream()
.anyMatch(f -> f.equals(SHOW_OBJECT_RELATIONS));
showIndices = flags.stream()
.anyMatch(f -> f.equals(ConstantsArray.SHOW_ARRAY_INDICES));
}

if (showObjectRelations) {
logger.info("Use Object Reference Array Layouter");
return arrayObjectReferenceLayouter.layout(moduleGroup);
return arrayObjectReferenceLayouter.layout(
moduleGroup, showIndices);
} else {
logger.info("Use Default Array Layouter");
return arrayDefaultLayouter.layout(moduleGroup);
return arrayDefaultLayouter.layout(moduleGroup, showIndices);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
import ch.hsr.adv.commons.array.logic.domain.ArrayElement;
import ch.hsr.adv.commons.core.logic.domain.ModuleGroup;
import ch.hsr.adv.commons.core.logic.domain.styles.ADVStyle;
import ch.hsr.adv.commons.core.logic.domain.styles.presets
.ADVDefaultElementStyle;
import ch.hsr.adv.commons.core.logic.domain.styles.presets
.ADVDefaultRelationStyle;
import ch.hsr.adv.ui.core.presentation.widgets.AutoScalePane;
import ch.hsr.adv.ui.core.presentation.widgets.ConnectorType;
import ch.hsr.adv.ui.core.presentation.widgets.LabeledEdge;
import ch.hsr.adv.ui.core.presentation.widgets.LabeledNode;
import ch.hsr.adv.commons.core.logic.domain.styles.presets.ADVDefaultElementStyle;
import ch.hsr.adv.commons.core.logic.domain.styles.presets.ADVDefaultRelationStyle;
import ch.hsr.adv.ui.core.presentation.widgets.*;
import com.google.inject.Singleton;
import javafx.geometry.Pos;
import javafx.scene.layout.HBox;
Expand All @@ -33,11 +28,12 @@ public class ArrayObjectReferenceLayouter {
* Layouts an array with object references
*
* @param moduleGroup moduleGroup to layout
* @param showIndices flag to show indices above array
* @return layouted pane
*/
public Pane layout(ModuleGroup moduleGroup) {
public Pane layout(ModuleGroup moduleGroup, boolean showIndices) {
initializeContainer();
drawElements(moduleGroup);
drawElements(moduleGroup, showIndices);

boxContainer.getChildren()
.addAll(referenceContainer, valueContainer);
Expand All @@ -57,28 +53,32 @@ private void initializeContainer() {
boxContainer.setSpacing(SPACING);
}

private void drawElements(ModuleGroup moduleGroup) {
moduleGroup.getElements().forEach(e -> {
ArrayElement element = (ArrayElement) e;
private void drawElements(ModuleGroup moduleGroup, boolean showIndices) {
for (int i = 0; i < moduleGroup.getElements().size(); i++) {
ArrayElement element =
(ArrayElement) moduleGroup.getElements().get(i);

ADVStyle style = element.getStyle();
if (style == null) {
style = new ADVDefaultElementStyle();
}

LabeledNode referenceNode;
IndexedNode referenceNode;
if (element.getContent() != null) {
LabeledNode valueNode = new LabeledNode(
element.getContent(), style);
referenceNode = new LabeledNode("*", style);
drawRelations(referenceNode, valueNode);
referenceNode = createIndexedNode("*", showIndices, i,
style);
drawRelations(referenceNode.getLabeledNode(), valueNode);

valueContainer.getChildren().add(valueNode);
} else {
referenceNode = new LabeledNode("null", style);
referenceNode = createIndexedNode("null", showIndices, i,
style);
}

referenceContainer.getChildren().addAll(referenceNode);
});
}
}

private void drawRelations(LabeledNode referenceNode,
Expand All @@ -92,4 +92,10 @@ private void drawRelations(LabeledNode referenceNode,

scalePane.addChildren(relation);
}

private IndexedNode createIndexedNode(String label, boolean showIndices,
long index, ADVStyle style) {
return new IndexedNode(index, label, style, false,
showIndices, IndexPosition.TOP);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void setUp() throws IOException, TimeoutException {
@Test
public void layoutTest() {
// WHEN
Pane actual = sut.layout(moduleGroup);
Pane actual = sut.layout(moduleGroup, false);

// THEN
ObservableList<Node> children = actual.getChildren();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.hsr.adv.ui.array.presentation;

import ch.hsr.adv.commons.array.logic.ConstantsArray;
import ch.hsr.adv.commons.core.logic.domain.ModuleGroup;
import ch.hsr.adv.ui.array.logic.ArrayParser;
import ch.hsr.adv.ui.core.access.FileDatastoreAccess;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void layoutDefaultTest(ArrayDefaultLayouter mockDefaultLayouter) {
sut.layout(moduleGroup, null);

// THEN
verify(mockDefaultLayouter).layout(moduleGroup);
verify(mockDefaultLayouter).layout(moduleGroup, false);
}

@Test
Expand All @@ -59,7 +60,28 @@ public void layoutObjectReferenceTest(ArrayObjectReferenceLayouter
sut.layout(moduleGroup, flags);

// THEN
verify(mockObjectReferenceLayouter).layout(moduleGroup);
verify(mockObjectReferenceLayouter).layout(moduleGroup, false);
}

@Test
public void layoutShowArrayIndicesTest(
ArrayDefaultLayouter mockDefaultLayouter) {
List<String> flags = new ArrayList<>();
flags.add(ConstantsArray.SHOW_ARRAY_INDICES);
sut.layout(moduleGroup, flags);

verify(mockDefaultLayouter).layout(moduleGroup, true);
}

@Test
public void layoutObjectReferenceAndShowArrayIndicesTest(
ArrayObjectReferenceLayouter mockObjectReferenceLayouter) {
List<String> flags = new ArrayList<>();
flags.add(ConstantsArray.SHOW_ARRAY_INDICES);
flags.add(SHOW_OBJECT_RELATIONS);
sut.layout(moduleGroup, flags);

verify(mockObjectReferenceLayouter).layout(moduleGroup, true);
}

public static class Module extends JukitoModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void setUp() throws IOException, TimeoutException {
@Test
public void layoutTest() {
// WHEN
Pane actual = sut.layout(moduleGroup);
Pane actual = sut.layout(moduleGroup, false);

// THEN
ObservableList<Node> children = actual.getChildren();
Expand Down
Loading

0 comments on commit fad7593

Please sign in to comment.