Skip to content

Commit

Permalink
Update README badges (CS2103-AY1819S2-W10-1#2)
Browse files Browse the repository at this point in the history
Badges for Travis CI, AppVeyor, Coveralls, and Codacy.
  • Loading branch information
thomastanck authored and rlrh committed Feb 17, 2019
1 parent 231b72b commit 6b0a2fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
= Address Book (Level 4)
ifdef::env-github,env-browser[:relfileprefix: docs/]

https://travis-ci.org/se-edu/addressbook-level4[image:https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master[Build Status]]
https://ci.appveyor.com/project/damithc/addressbook-level4[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]]
https://coveralls.io/github/se-edu/addressbook-level4?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level4/badge.svg?branch=master[Coverage Status]]
https://www.codacy.com/app/damith/addressbook-level4?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level4&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]]
https://travis-ci.org/CS2103-AY1819S2-W10-1/main[image:https://travis-ci.org/CS2103-AY1819S2-W10-1/main.svg?branch=master[Build Status]]
https://ci.appveyor.com/project/thomastanck/main[image:https://ci.appveyor.com/api/projects/status/k99mmh3peur0nef5?svg=true[Build Status]]
https://coveralls.io/github/CS2103-AY1819S2-W10-1/main?branch=master[image:https://coveralls.io/repos/github/CS2103-AY1819S2-W10-1/main/badge.svg?branch=master[Coverage Status]]
https://www.codacy.com/app/thomastanck/main?utm_source=github.com&utm_medium=referral&utm_content=CS2103-AY1819S2-W10-1/main&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/cb4fa0d78e424d9d9eb3faf34102e157[Codacy Badge]]

ifdef::env-github[]
image::docs/images/Ui.png[width="600"]
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class PersonCard extends UiPart<Region> {

private static final String FXML = "PersonListCard.fxml";

private static final String[] TAG_COLOR_STYLES =
{ "red", "pink", "purple", "deepPurple", "indigo", "blue", "lightBlue", "cyan", "teal", "green",
"lightGreen", "lime", "yellow", "amber", "orange", "deepOrange", "brown", "gray", "blueGray" };

/**
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
* As a consequence, UI elements' variable names cannot be set to such keywords
Expand Down Expand Up @@ -47,7 +51,11 @@ public PersonCard(Person person, int displayedIndex) {
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
person.getTags().forEach(tag -> {
Label tagLabel = new Label(tag.tagName);
tagLabel.getStyleClass().add(getTagColorStyleFor(tag.tagName));
tags.getChildren().add(tagLabel);
});
}

@Override
Expand All @@ -67,4 +75,12 @@ public boolean equals(Object other) {
return id.getText().equals(card.id.getText())
&& person.equals(card.person);
}

/**
* Returns the color style for {@code tagName}'s label.
*/
private String getTagColorStyleFor(String tagName) {
// use hash code of tag name to generate random color, so color remains consistent between different runs
return TAG_COLOR_STYLES[Math.abs(tagName.hashCode()) % TAG_COLOR_STYLES.length];
}
}

0 comments on commit 6b0a2fd

Please sign in to comment.