From 6b0a2fdec971aaaa91fd058aa53ec1ad342f304a Mon Sep 17 00:00:00 2001 From: Thomas Tan <829070+thomastanck@users.noreply.github.com> Date: Wed, 13 Feb 2019 22:38:43 +0800 Subject: [PATCH] Update README badges (#2) Badges for Travis CI, AppVeyor, Coveralls, and Codacy. --- README.adoc | 8 ++++---- src/main/java/seedu/address/ui/PersonCard.java | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.adoc b/README.adoc index fa50028b99d0..a34eec77075c 100644 --- a/README.adoc +++ b/README.adoc @@ -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"] diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f6727ea83abd..791dab312947 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -14,6 +14,10 @@ public class PersonCard extends UiPart { 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 @@ -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 @@ -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]; + } }