Skip to content

Commit

Permalink
[DG] Update DG to include implementation of avatar setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Goh committed Nov 7, 2017
1 parent 6d868a6 commit b09cac4
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,42 @@ standardised the handling of font size change requests through events.
**Pros:** Less tedious to implement and very intuitive for the user +
**Cons:** Users who prefer typing commands will not have the option of editing their font sizes using the CLI

=== Setting Avatar on ViewPersonPanel

The following function allows the setting of URL for the `ImageView` attribute within the `ViewPersonPanel` class:
[source,java]
----
private void initializeAvatar() {
try {
String avatarPath = person.getAvatar().value;
if (!avatarPath.equals("")) {
logger.info("Initializing avatar to image at saved URL");
Image newImage = new Image(avatarPath);
avatarImage.setImage(newImage);
}
} catch (Exception e) {
e.printStackTrace();
}
}
----

The `initializeAvatar` method piggybacks on the `handlePersonPanelSelectionChangedEvent` event handler. Whenever there is
a change in the person selection panel, this function will call the `initializeAvatar` method, which will update
the `ImageView` attribute.
[source,java]
----
@Subscribe
private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedEvent event) {
logger.info(LogsCenter.getEventHandlingLogMessage(event));
this.person = event.getNewSelection().person;
initializeWithPerson(person);
initializeAvatar();
}
----

[NOTE]
As of version 1.5rc, the avatar field supports only URLs sourced online. References to local files may not work at the moment.

// tag::undoredo[]
=== Undo/Redo mechanism

Expand Down

0 comments on commit b09cac4

Please sign in to comment.