SlideShare a Scribd company logo
Creating a Facebook Clone - Part V
Š Codename One 2017 all rights reserved
public class RichTextView extends Container {
private String text;
private final float fontSize = 2.6f;
private EventDispatcher listeners = new EventDispatcher();
private Font currentFont;
private int currentColor = 0;
private String currentLink;
private Style lastCmp;
private Font defaultFont;
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
RichTextView
public class RichTextView extends Container {
private String text;
private final float fontSize = 2.6f;
private EventDispatcher listeners = new EventDispatcher();
private Font currentFont;
private int currentColor = 0;
private String currentLink;
private Style lastCmp;
private Font defaultFont;
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
RichTextView
public class RichTextView extends Container {
private String text;
private final float fontSize = 2.6f;
private EventDispatcher listeners = new EventDispatcher();
private Font currentFont;
private int currentColor = 0;
private String currentLink;
private Style lastCmp;
private Font defaultFont;
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
RichTextView
public class RichTextView extends Container {
private String text;
private final float fontSize = 2.6f;
private EventDispatcher listeners = new EventDispatcher();
private Font currentFont;
private int currentColor = 0;
private String currentLink;
private Style lastCmp;
private Font defaultFont;
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
RichTextView
public class RichTextView extends Container {
private String text;
private final float fontSize = 2.6f;
private EventDispatcher listeners = new EventDispatcher();
private Font currentFont;
private int currentColor = 0;
private String currentLink;
private Style lastCmp;
private Font defaultFont;
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
RichTextView
public class RichTextView extends Container {
private String text;
private final float fontSize = 2.6f;
private EventDispatcher listeners = new EventDispatcher();
private Font currentFont;
private int currentColor = 0;
private String currentLink;
private Style lastCmp;
private Font defaultFont;
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
RichTextView
private Font boldFont;
private Font italicFont;
private int sizeOfSpace;
public RichTextView() {
init();
}
public RichTextView(String text) {
init();
setText(text);
}
private void init() {
defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize);
boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize);
italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize);
sizeOfSpace = defaultFont.charWidth(' ');
currentFont = defaultFont;
}
public void setAlignment(int align) {
((FlowLayout)getLayout()).setAlign(align);
}
RichTextView
}
private void init() {
defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize);
boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize);
italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize);
sizeOfSpace = defaultFont.charWidth(' ');
currentFont = defaultFont;
}
public void setAlignment(int align) {
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
RichTextView
}
private void init() {
defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize);
boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize);
italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize);
sizeOfSpace = defaultFont.charWidth(' ');
currentFont = defaultFont;
}
public void setAlignment(int align) {
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
RichTextView
}
private void init() {
defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize);
boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize);
italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize);
sizeOfSpace = defaultFont.charWidth(' ');
currentFont = defaultFont;
}
public void setAlignment(int align) {
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
RichTextView
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
RichTextView
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
RichTextView
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
RichTextView
((FlowLayout)getLayout()).setAlign(align);
}
private void createComponent(String t) {
if(t.indexOf(' ') > -1) {
for(String s : StringUtil.tokenize(t, ' ')) {
createComponent(s);
}
return;
}
Label l;
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
RichTextView
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPadding(0, 0, 0, sizeOfSpace);
s.setMargin(0, 0, 0, 0);
lastCmp = s;
add(l);
}
public final void setText(String text) {
this.text = text;
removeAll();
try {
char[] chrs = ("<body>" + text + "</body>").toCharArray();
RichTextView
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPadding(0, 0, 0, sizeOfSpace);
s.setMargin(0, 0, 0, 0);
lastCmp = s;
add(l);
}
public final void setText(String text) {
this.text = text;
removeAll();
try {
char[] chrs = ("<body>" + text + "</body>").toCharArray();
RichTextView
if(currentLink != null) {
Button b = new Button(t, "Label");
final String currentLinkValue = currentLink;
b.addActionListener(e -> listeners.fireActionEvent(
new ActionEvent(currentLinkValue)));
l = b;
} else {
l = new Label(t);
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPadding(0, 0, 0, sizeOfSpace);
s.setMargin(0, 0, 0, 0);
lastCmp = s;
add(l);
}
public final void setText(String text) {
this.text = text;
removeAll();
try {
char[] chrs = ("<body>" + text + "</body>").toCharArray();
RichTextView
}
Style s = l.getAllStyles();
s.setFont(currentFont);
s.setFgColor(currentColor);
s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
s.setPadding(0, 0, 0, sizeOfSpace);
s.setMargin(0, 0, 0, 0);
lastCmp = s;
add(l);
}
public final void setText(String text) {
this.text = text;
removeAll();
try {
char[] chrs = ("<body>" + text + "</body>").toCharArray();
new Parser().eventParser(new CharArrayReader(chrs));
} catch(IOException err) {
log(err);
}
}
public String getText() {
return text;
RichTextView
this.text = text;
removeAll();
try {
char[] chrs = ("<body>" + text + "</body>").toCharArray();
new Parser().eventParser(new CharArrayReader(chrs));
} catch(IOException err) {
log(err);
}
}
public String getText() {
return text;
}
public void addLinkListener(ActionListener al) {
listeners.addListener(al);
}
public void removeLinkListener(ActionListener al) {
listeners.removeListener(al);
}
class Parser extends XMLParser {
@Override
RichTextView
}
public void removeLinkListener(ActionListener al) {
listeners.removeListener(al);
}
class Parser extends XMLParser {
@Override
protected void textElement(String text) {
if(text.length() > 0) {
if(lastCmp != null && text.startsWith(" ")) {
lastCmp.setPadding(0, 0, 0, sizeOfSpace);
}
createComponent(text);
if(!text.endsWith(" ")) {
lastCmp.setPadding(0, 0, 0, 0);
}
}
}
@Override
protected boolean startTag(String tag) {
switch(tag.toLowerCase()) {
case "a":
RichTextView
}
public void removeLinkListener(ActionListener al) {
listeners.removeListener(al);
}
class Parser extends XMLParser {
@Override
protected void textElement(String text) {
if(text.length() > 0) {
if(lastCmp != null && text.startsWith(" ")) {
lastCmp.setPadding(0, 0, 0, sizeOfSpace);
}
createComponent(text);
if(!text.endsWith(" ")) {
lastCmp.setPadding(0, 0, 0, 0);
}
}
}
@Override
protected boolean startTag(String tag) {
switch(tag.toLowerCase()) {
case "a":
RichTextView
}
public void removeLinkListener(ActionListener al) {
listeners.removeListener(al);
}
class Parser extends XMLParser {
@Override
protected void textElement(String text) {
if(text.length() > 0) {
if(lastCmp != null && text.startsWith(" ")) {
lastCmp.setPadding(0, 0, 0, sizeOfSpace);
}
createComponent(text);
if(!text.endsWith(" ")) {
lastCmp.setPadding(0, 0, 0, 0);
}
}
}
@Override
protected boolean startTag(String tag) {
switch(tag.toLowerCase()) {
case "a":
RichTextView
}
public void removeLinkListener(ActionListener al) {
listeners.removeListener(al);
}
class Parser extends XMLParser {
@Override
protected void textElement(String text) {
if(text.length() > 0) {
if(lastCmp != null && text.startsWith(" ")) {
lastCmp.setPadding(0, 0, 0, sizeOfSpace);
}
createComponent(text);
if(!text.endsWith(" ")) {
lastCmp.setPadding(0, 0, 0, 0);
}
}
}
@Override
protected boolean startTag(String tag) {
switch(tag.toLowerCase()) {
case "a":
RichTextView
createComponent(text);
if(!text.endsWith(" ")) {
lastCmp.setPadding(0, 0, 0, 0);
}
}
}
@Override
protected boolean startTag(String tag) {
switch(tag.toLowerCase()) {
case "a":
currentColor = 0x4267B2;
break;
case "b":
currentFont = boldFont;
break;
case "i":
currentFont = italicFont;
break;
}
return true;
}
@Override
RichTextView
break;
case "b":
currentFont = boldFont;
break;
case "i":
currentFont = italicFont;
break;
}
return true;
}
@Override
protected void endTag(String tag) {
currentColor = 0;
currentLink = null;
currentFont = defaultFont;
}
@Override
protected void attribute(
String tag, String attributeName, String value) {
if(tag.toLowerCase().equals("a") &&
attributeName.toLowerCase().equals("href")) {
currentLink = value;
RichTextView
@Override
protected void endTag(String tag) {
currentColor = 0;
currentLink = null;
currentFont = defaultFont;
}
@Override
protected void attribute(
String tag, String attributeName, String value) {
if(tag.toLowerCase().equals("a") &&
attributeName.toLowerCase().equals("href")) {
currentLink = value;
}
}
@Override
protected void notifyError(int errorId, String tag,
String attribute, String value, String description) {
log("Error during parsing: " + tag);
}
}
}
RichTextView

More Related Content

Similar to Creating a Facebook Clone - Part V.pdf

C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607
Kevin Hazzard
 
MaintainStaffTable
MaintainStaffTableMaintainStaffTable
MaintainStaffTable
William Rutherford
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Kotlin, why?
Kotlin, why?Kotlin, why?
Kotlin, why?
Paweł Byszewski
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
Mark Needham
 
Real time and reliable processing with Apache Storm
Real time and reliable processing with Apache StormReal time and reliable processing with Apache Storm
Real time and reliable processing with Apache Storm
Andrea Iacono
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
John Ferguson Smart Limited
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architecture
Viktor Nyblom
 
Linq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net FrameworkLinq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net Framework
rushputin
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
tdc-globalcode
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
ShaiAlmog1
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
arjuncorner565
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
heinrich.wendel
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
Michael Galpin
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
bleis tift
 
C# Generics
C# GenericsC# Generics
C# Generics
Rohit Vipin Mathews
 
Creating an Uber Clone - Part XX - Transcript.pdf
Creating an Uber Clone - Part XX - Transcript.pdfCreating an Uber Clone - Part XX - Transcript.pdf
Creating an Uber Clone - Part XX - Transcript.pdf
ShaiAlmog1
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
Edward Cleveland
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
saydin_soft
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 

Similar to Creating a Facebook Clone - Part V.pdf (20)

C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607
 
MaintainStaffTable
MaintainStaffTableMaintainStaffTable
MaintainStaffTable
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
Kotlin, why?
Kotlin, why?Kotlin, why?
Kotlin, why?
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Real time and reliable processing with Apache Storm
Real time and reliable processing with Apache StormReal time and reliable processing with Apache Storm
Real time and reliable processing with Apache Storm
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
Reactive clean architecture
Reactive clean architectureReactive clean architecture
Reactive clean architecture
 
Linq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net FrameworkLinq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net Framework
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
仕事で使うF#
仕事で使うF#仕事で使うF#
仕事で使うF#
 
C# Generics
C# GenericsC# Generics
C# Generics
 
Creating an Uber Clone - Part XX - Transcript.pdf
Creating an Uber Clone - Part XX - Transcript.pdfCreating an Uber Clone - Part XX - Transcript.pdf
Creating an Uber Clone - Part XX - Transcript.pdf
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
 
Working With JQuery Part1
Working With JQuery Part1Working With JQuery Part1
Working With JQuery Part1
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 

More from ShaiAlmog1

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
ShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
ShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
ShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
ShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
ShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
ShaiAlmog1
 
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfCreating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdf
ShaiAlmog1
 

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 
Creating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdfCreating a Whatsapp Clone - Part IX.pdf
Creating a Whatsapp Clone - Part IX.pdf
 

Recently uploaded

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo GĂłmez Abajo
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 

Recently uploaded (20)

zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 

Creating a Facebook Clone - Part V.pdf

  • 1. Creating a Facebook Clone - Part V
  • 2. Š Codename One 2017 all rights reserved
  • 3. public class RichTextView extends Container { private String text; private final float fontSize = 2.6f; private EventDispatcher listeners = new EventDispatcher(); private Font currentFont; private int currentColor = 0; private String currentLink; private Style lastCmp; private Font defaultFont; private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); RichTextView
  • 4. public class RichTextView extends Container { private String text; private final float fontSize = 2.6f; private EventDispatcher listeners = new EventDispatcher(); private Font currentFont; private int currentColor = 0; private String currentLink; private Style lastCmp; private Font defaultFont; private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); RichTextView
  • 5. public class RichTextView extends Container { private String text; private final float fontSize = 2.6f; private EventDispatcher listeners = new EventDispatcher(); private Font currentFont; private int currentColor = 0; private String currentLink; private Style lastCmp; private Font defaultFont; private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); RichTextView
  • 6. public class RichTextView extends Container { private String text; private final float fontSize = 2.6f; private EventDispatcher listeners = new EventDispatcher(); private Font currentFont; private int currentColor = 0; private String currentLink; private Style lastCmp; private Font defaultFont; private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); RichTextView
  • 7. public class RichTextView extends Container { private String text; private final float fontSize = 2.6f; private EventDispatcher listeners = new EventDispatcher(); private Font currentFont; private int currentColor = 0; private String currentLink; private Style lastCmp; private Font defaultFont; private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); RichTextView
  • 8. public class RichTextView extends Container { private String text; private final float fontSize = 2.6f; private EventDispatcher listeners = new EventDispatcher(); private Font currentFont; private int currentColor = 0; private String currentLink; private Style lastCmp; private Font defaultFont; private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); RichTextView
  • 9. private Font boldFont; private Font italicFont; private int sizeOfSpace; public RichTextView() { init(); } public RichTextView(String text) { init(); setText(text); } private void init() { defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize); boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize); italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize); sizeOfSpace = defaultFont.charWidth(' '); currentFont = defaultFont; } public void setAlignment(int align) { ((FlowLayout)getLayout()).setAlign(align); } RichTextView
  • 10. } private void init() { defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize); boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize); italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize); sizeOfSpace = defaultFont.charWidth(' '); currentFont = defaultFont; } public void setAlignment(int align) { ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); RichTextView
  • 11. } private void init() { defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize); boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize); italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize); sizeOfSpace = defaultFont.charWidth(' '); currentFont = defaultFont; } public void setAlignment(int align) { ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); RichTextView
  • 12. } private void init() { defaultFont = Font.createTrueTypeFont(NATIVE_MAIN_LIGHT, fontSize); boldFont = Font.createTrueTypeFont(NATIVE_MAIN_BOLD, fontSize); italicFont = Font.createTrueTypeFont(NATIVE_ITALIC_LIGHT, fontSize); sizeOfSpace = defaultFont.charWidth(' '); currentFont = defaultFont; } public void setAlignment(int align) { ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); RichTextView
  • 13. ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); RichTextView
  • 14. ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); RichTextView
  • 15. ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); RichTextView
  • 16. ((FlowLayout)getLayout()).setAlign(align); } private void createComponent(String t) { if(t.indexOf(' ') > -1) { for(String s : StringUtil.tokenize(t, ' ')) { createComponent(s); } return; } Label l; if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); RichTextView
  • 17. if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); s.setPadding(0, 0, 0, sizeOfSpace); s.setMargin(0, 0, 0, 0); lastCmp = s; add(l); } public final void setText(String text) { this.text = text; removeAll(); try { char[] chrs = ("<body>" + text + "</body>").toCharArray(); RichTextView
  • 18. if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); s.setPadding(0, 0, 0, sizeOfSpace); s.setMargin(0, 0, 0, 0); lastCmp = s; add(l); } public final void setText(String text) { this.text = text; removeAll(); try { char[] chrs = ("<body>" + text + "</body>").toCharArray(); RichTextView
  • 19. if(currentLink != null) { Button b = new Button(t, "Label"); final String currentLinkValue = currentLink; b.addActionListener(e -> listeners.fireActionEvent( new ActionEvent(currentLinkValue))); l = b; } else { l = new Label(t); } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); s.setPadding(0, 0, 0, sizeOfSpace); s.setMargin(0, 0, 0, 0); lastCmp = s; add(l); } public final void setText(String text) { this.text = text; removeAll(); try { char[] chrs = ("<body>" + text + "</body>").toCharArray(); RichTextView
  • 20. } Style s = l.getAllStyles(); s.setFont(currentFont); s.setFgColor(currentColor); s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); s.setPadding(0, 0, 0, sizeOfSpace); s.setMargin(0, 0, 0, 0); lastCmp = s; add(l); } public final void setText(String text) { this.text = text; removeAll(); try { char[] chrs = ("<body>" + text + "</body>").toCharArray(); new Parser().eventParser(new CharArrayReader(chrs)); } catch(IOException err) { log(err); } } public String getText() { return text; RichTextView
  • 21. this.text = text; removeAll(); try { char[] chrs = ("<body>" + text + "</body>").toCharArray(); new Parser().eventParser(new CharArrayReader(chrs)); } catch(IOException err) { log(err); } } public String getText() { return text; } public void addLinkListener(ActionListener al) { listeners.addListener(al); } public void removeLinkListener(ActionListener al) { listeners.removeListener(al); } class Parser extends XMLParser { @Override RichTextView
  • 22. } public void removeLinkListener(ActionListener al) { listeners.removeListener(al); } class Parser extends XMLParser { @Override protected void textElement(String text) { if(text.length() > 0) { if(lastCmp != null && text.startsWith(" ")) { lastCmp.setPadding(0, 0, 0, sizeOfSpace); } createComponent(text); if(!text.endsWith(" ")) { lastCmp.setPadding(0, 0, 0, 0); } } } @Override protected boolean startTag(String tag) { switch(tag.toLowerCase()) { case "a": RichTextView
  • 23. } public void removeLinkListener(ActionListener al) { listeners.removeListener(al); } class Parser extends XMLParser { @Override protected void textElement(String text) { if(text.length() > 0) { if(lastCmp != null && text.startsWith(" ")) { lastCmp.setPadding(0, 0, 0, sizeOfSpace); } createComponent(text); if(!text.endsWith(" ")) { lastCmp.setPadding(0, 0, 0, 0); } } } @Override protected boolean startTag(String tag) { switch(tag.toLowerCase()) { case "a": RichTextView
  • 24. } public void removeLinkListener(ActionListener al) { listeners.removeListener(al); } class Parser extends XMLParser { @Override protected void textElement(String text) { if(text.length() > 0) { if(lastCmp != null && text.startsWith(" ")) { lastCmp.setPadding(0, 0, 0, sizeOfSpace); } createComponent(text); if(!text.endsWith(" ")) { lastCmp.setPadding(0, 0, 0, 0); } } } @Override protected boolean startTag(String tag) { switch(tag.toLowerCase()) { case "a": RichTextView
  • 25. } public void removeLinkListener(ActionListener al) { listeners.removeListener(al); } class Parser extends XMLParser { @Override protected void textElement(String text) { if(text.length() > 0) { if(lastCmp != null && text.startsWith(" ")) { lastCmp.setPadding(0, 0, 0, sizeOfSpace); } createComponent(text); if(!text.endsWith(" ")) { lastCmp.setPadding(0, 0, 0, 0); } } } @Override protected boolean startTag(String tag) { switch(tag.toLowerCase()) { case "a": RichTextView
  • 26. createComponent(text); if(!text.endsWith(" ")) { lastCmp.setPadding(0, 0, 0, 0); } } } @Override protected boolean startTag(String tag) { switch(tag.toLowerCase()) { case "a": currentColor = 0x4267B2; break; case "b": currentFont = boldFont; break; case "i": currentFont = italicFont; break; } return true; } @Override RichTextView
  • 27. break; case "b": currentFont = boldFont; break; case "i": currentFont = italicFont; break; } return true; } @Override protected void endTag(String tag) { currentColor = 0; currentLink = null; currentFont = defaultFont; } @Override protected void attribute( String tag, String attributeName, String value) { if(tag.toLowerCase().equals("a") && attributeName.toLowerCase().equals("href")) { currentLink = value; RichTextView
  • 28. @Override protected void endTag(String tag) { currentColor = 0; currentLink = null; currentFont = defaultFont; } @Override protected void attribute( String tag, String attributeName, String value) { if(tag.toLowerCase().equals("a") && attributeName.toLowerCase().equals("href")) { currentLink = value; } } @Override protected void notifyError(int errorId, String tag, String attribute, String value, String description) { log("Error during parsing: " + tag); } } } RichTextView