1 package be
.nikiroo
.jvcard
.tui
.panes
;
4 import java
.util
.Base64
;
7 import javax
.swing
.ImageIcon
;
9 import be
.nikiroo
.jvcard
.Contact
;
10 import be
.nikiroo
.jvcard
.Data
;
11 import be
.nikiroo
.jvcard
.TypeInfo
;
12 import be
.nikiroo
.jvcard
.tui
.ImageText
;
13 import be
.nikiroo
.jvcard
.tui
.KeyAction
;
14 import be
.nikiroo
.jvcard
.tui
.KeyAction
.DataType
;
16 import com
.googlecode
.lanterna
.TerminalSize
;
17 import com
.googlecode
.lanterna
.gui2
.BorderLayout
;
18 import com
.googlecode
.lanterna
.gui2
.Panel
;
19 import com
.googlecode
.lanterna
.gui2
.TextBox
;
21 public class ContactDetails
extends MainContent
{
22 private Contact contact
;
25 public DataType
getDataType() {
30 public List
<KeyAction
> getKeyBindings() {
31 // TODO Auto-generated method stub
35 public ContactDetails(Contact contact
) {
36 this.contact
= contact
;
38 BorderLayout blayout
= new BorderLayout();
39 setLayoutManager(blayout
);
41 Panel top
= new Panel();
42 if (contact
!= null) {
43 Data photo
= contact
.getPreferredData("PHOTO");
45 TypeInfo encoding
= null;
47 for (TypeInfo info
: photo
.getTypes()) {
48 if (info
.getName() != null) {
49 if (info
.getName().equalsIgnoreCase("ENCODING"))
51 if (info
.getName().equalsIgnoreCase("TYPE"))
56 if (encoding
!= null && encoding
.getValue() != null
57 && encoding
.getValue().equalsIgnoreCase("b")) {
59 Image img
= new ImageIcon(Base64
.getDecoder().decode(
60 photo
.getValue())).getImage();
62 TerminalSize size
= new TerminalSize(40, 20);
63 size
= new TerminalSize(120, 50);
65 String str
= new ImageText(img
, size
).getText();
66 top
.addComponent(new TextBox(size
, str
));
71 addComponent(top
, BorderLayout
.Location
.TOP
);