Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Latest commit

 

History

History
205 lines (174 loc) · 4.46 KB

Liu.md

File metadata and controls

205 lines (174 loc) · 4.46 KB

Liu

\out\production\resources\view\DarkTheme.css
#tags .blue {
    -fx-text-fill: white;
    -fx-background-color: blue;
}

#tags .cyan {
    -fx-text-fill: black;
    -fx-background-color: cyan;
}

#tags .green {
    -fx-text-fill: black;
    -fx-background-color: green;
}

#tags .magenta {
    -fx-text-fill: black;
    -fx-background-color: magenta;
}

#tags .orange {
    -fx-text-fill: white;
    -fx-background-color: orange;
}

#tags .blue {
    -fx-text-fill: white;
    -fx-background-color: blue;
}

#tags .pink {
    -fx-text-fill: black;
    -fx-background-color: pink;
}

#tags .red {
    -fx-text-fill: white;
    -fx-background-color: red;
}

#tags .yellow {
    -fx-text-fill: black;
    -fx-background-color: yellow;
}

#tags .teal {
    -fx-text-fill: white;
    -fx-background-color: teal;
}

#tags .brown {
    -fx-text-fill: white;
    -fx-background-color: brown;
}
\src\main\java\seedu\address\ui\PersonCard.java
    /**
     *Returns the color for {@code tagName}'s label
     */
    private String getTagColorFor(String tagName) {
        //Uses the hash code of the tag name to generate a color, such that each run of the program
        //produce the same color for that tag name
        return TAG_COLORS[Math.abs(tagName.hashCode()) % TAG_COLORS.length];
    }

    /**
     *Creates tag labels for {@code person}.
     */
    private void initTags(Person person) {
        person.getTags().forEach(tag -> {
            Label tagLabel = new Label(tag.tagName);
            tagLabel.getStyleClass().add(getTagColorFor(tag.tagName));
            tags.getChildren().add(tagLabel);
        });
    }

    //@author
    @Override
    public boolean equals(Object other) {
        // short circuit if same object
        if (other == this) {
            return true;
        }

        // instanceof handles nulls
        if (!(other instanceof PersonCard)) {
            return false;
        }

        // state check
        PersonCard card = (PersonCard) other;
        return id.getText().equals(card.id.getText())
                && person.equals(card.person);
    }
}
\src\main\resources\view\DarkTheme.css
#tags .blue {
    -fx-text-fill: white;
    -fx-background-color: blue;
}

#tags .cyan {
    -fx-text-fill: black;
    -fx-background-color: cyan;
}

#tags .green {
    -fx-text-fill: black;
    -fx-background-color: green;
}

#tags .magenta {
    -fx-text-fill: black;
    -fx-background-color: magenta;
}

#tags .orange {
    -fx-text-fill: white;
    -fx-background-color: orange;
}

#tags .blue {
    -fx-text-fill: white;
    -fx-background-color: blue;
}

#tags .pink {
    -fx-text-fill: black;
    -fx-background-color: pink;
}

#tags .red {
    -fx-text-fill: white;
    -fx-background-color: red;
}

#tags .yellow {
    -fx-text-fill: black;
    -fx-background-color: yellow;
}

#tags .teal {
    -fx-text-fill: white;
    -fx-background-color: teal;
}

#tags .brown {
    -fx-text-fill: white;
    -fx-background-color: brown;
}
\src\test\java\seedu\address\ui\testutil\GuiTestAssert.java
    /**
     * Returns the color for {@code tagName}. The tag's color is determined by looking up the color
     * in {@code PersonCard#TAG_COLORS}, using an index generated by the hash code of the tag's name.
     *
     * @see PersonCard#getTagColorFor(String)
     */
    private static String getTagColorFor(String tagName) {
        switch (tagName) {
        case "classmates":
        case "owesMoney":
            return "blue";

        case "colleagues":
        case "neighbours":
            return "green";

        case "family":
        case "friend":
            return "orange";

        case "friends":
            return "pink";

        case "husband":
            return "brown";

        default:
            fail(tagName + " does not have a color assigned.");
            return "";
        }
    }

    /**
     * Asserts that the tags in {@code actualCard} matches all the tags in {@code expectedPerson} with the correct
     * color.
     */
    private static void assertTagsEqual(Person expectedPerson, PersonCardHandle actualCard) {
        List<String> expectedTags = expectedPerson.getTags().stream()
                .map(tag -> tag.tagName).collect(Collectors.toList());
        assertEquals(expectedTags, actualCard.getTags());
        expectedTags.forEach(tag ->
                assertEquals(Arrays.asList(LABEL_DEFAULT_COLOR, getTagColorFor(tag)),
                        actualCard.getTagColorClasses(tag)));
    }