Skip to content

Method: lambda$renderDetails$0(MusicArtist)

1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.ui.audio.explorer.impl;
28:
29: import javax.annotation.Nonnull;
30: import it.tidalwave.dci.annotation.DciRole;
31: import it.tidalwave.bluemarine2.model.MediaItem;
32: import it.tidalwave.bluemarine2.model.audio.AudioFile;
33: import it.tidalwave.bluemarine2.model.audio.Record;
34: import it.tidalwave.bluemarine2.model.role.AudioFileSupplier;
35: import static java.util.stream.Collectors.*;
36: import static it.tidalwave.role.ui.Displayable._Displayable_;
37: import static it.tidalwave.bluemarine2.model.MediaItem.Metadata.*;
38:
39: /***********************************************************************************************************************
40: *
41: * The role for an {@link AudioFileSupplier} that is capable to render details upon selection, in the context of
42: * {@link DefaultAudioExplorerPresentationControl}.
43: *
44: * @stereotype Role
45: *
46: * @author Fabrizio Giudici
47: *
48: **********************************************************************************************************************/
49: @DciRole(datumType = AudioFileSupplier.class, context = DefaultAudioExplorerPresentationControl.class)
50: public class AudioFileDetailRendererSelectable extends DetailRendererSelectable<AudioFileSupplier>
51: {
52: public AudioFileDetailRendererSelectable (@Nonnull final AudioFileSupplier audioFileSupplier)
53: {
54: super(audioFileSupplier);
55: }
56:
57: @Override
58: protected void renderDetails()
59: {
60: final AudioFile audioFile = this.owner.getAudioFile();
61: final MediaItem.Metadata metadata = audioFile.getMetadata();
62:
63: final String details = String.format("%s%n%s%n%s%n%s%n%s",
64: audioFile.findMakers().stream().map(m -> m.as(_Displayable_).getDisplayName())
65: .collect(joining(", ", "Artist: ", "")),
66: audioFile.findComposers().stream().map(e -> e.as(_Displayable_).getDisplayName())
67: .collect(joining(", ", "Composer: ", "")),
68: metadata.get(BIT_RATE).map(br -> "Bit rate: " + br + " kbps").orElse(""),
69: metadata.get(SAMPLE_RATE).map(sr -> String.format("Sample rate: %.1f kHz", sr / 1000.0)).orElse(""),
70: metadata.get(YEAR).map(y -> "Year: " + y).orElse(""));
71:
72: renderDetails(details);
73: renderCoverArt(audioFile.getRecord().flatMap(Record::getImageUrl));
74: }
75: }