use of org.apache.pivot.wtk.text.ImageNode in project pivot by apache.
the class TextPaneSkinImageNodeView method getPreferredSize.
@Override
public Dimensions getPreferredSize(int breakWidth) {
ImageNode imageNode = (ImageNode) getNode();
Image image = imageNode.getImage();
if (image == null) {
return Dimensions.ZERO;
}
return image.getSize();
}
use of org.apache.pivot.wtk.text.ImageNode in project pivot by apache.
the class HyperlinkButtonTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame = new Frame();
frame.setTitle("Hyperlink Button Test");
frame.setPreferredSize(480, 360);
HyperlinkButton button1 = new HyperlinkButton("http://pivot.apache.org");
HyperlinkButton button2 = new HyperlinkButton("Apache website", "http://apache.org");
TextPane textPane = new TextPane();
Document document = new Document();
TextNode text1 = new TextNode("Link to the Apache Pivot site: ");
TextNode text2 = new TextNode("Main Apache Software Foundation website: ");
ComponentNode compNode1 = new ComponentNode(button1);
ComponentNode compNode2 = new ComponentNode(button2);
Paragraph para1 = new Paragraph();
para1.add(text1);
document.add(para1);
document.add(compNode1);
Paragraph para2 = new Paragraph();
para2.add(text2);
document.add(para2);
document.add(compNode2);
ImageNode image1 = new ImageNode("/org/apache/pivot/tests/house.png");
document.add(image1);
textPane.setDocument(document);
frame.setContent(textPane);
frame.open(display);
}
use of org.apache.pivot.wtk.text.ImageNode in project pivot by apache.
the class TextPane method insertImage.
public void insertImage(Image image) {
Utils.checkNull(image, "image");
checkDocumentExists();
if (selectionLength > 0) {
removeDocumentRange(selectionStart, selectionLength);
}
// If the insertion is at the end of the document, then just add
if (selectionStart >= document.getCharacterCount() - 1) {
document.add(new ImageNode(image));
} else {
// Walk up the tree until we find a block
Node descendant = document.getDescendantAt(selectionStart);
while (!(descendant instanceof Block)) {
descendant = descendant.getParent();
}
Element parent = descendant.getParent();
if (parent != null) {
int index = parent.indexOf(descendant);
parent.insert(new ImageNode(image), index + 1);
}
}
// Set the selection start to the character following the insertion
setSelection(selectionStart + 1, selectionLength);
}
use of org.apache.pivot.wtk.text.ImageNode in project pivot by apache.
the class TextPaneSkinImageNodeView method attach.
@Override
protected void attach() {
super.attach();
ImageNode imageNode = (ImageNode) getNode();
imageNode.getImageNodeListeners().add(this);
Image image = imageNode.getImage();
if (image != null) {
image.getImageListeners().add(this);
}
}
use of org.apache.pivot.wtk.text.ImageNode in project pivot by apache.
the class TextPaneSkinImageNodeView method getBaseline.
@Override
public int getBaseline() {
ImageNode imageNode = (ImageNode) getNode();
Image image = imageNode.getImage();
int baseline = -1;
if (image != null) {
baseline = image.getBaseline();
}
return baseline;
}
Aggregations