Example usage for java.awt TextComponent getText

List of usage examples for java.awt TextComponent getText

Introduction

In this page you can find the example usage for java.awt TextComponent getText.

Prototype

public synchronized String getText() 

Source Link

Document

Returns the text that is presented by this text component.

Usage

From source file:edworld.pdfreader4humans.PDFReader.java

private void addText(TextComponent component, Component container, List<String> lines) {
    if (container == lastContainer && consecutiveText(lastComponent, component, container)) {
        String lastText = lines.get(lines.size() - 1);
        lines.set(lines.size() - 1, joinConsecutiveText(lastText, component.getText()));
    } else//  ww  w  .  j  a v a  2s  .  c om
        lines.add(component.getText());
    lastContainer = container;
    lastComponent = component;
}

From source file:edworld.pdfreader4humans.PDFReader.java

private boolean consecutiveText(TextComponent component1, TextComponent component2, Component container) {
    if (component1 == null)
        return false;
    if (component1.consecutive(component2, true))
        return true;
    if (alignedToCenter(component1, component2, container))
        return false;
    int nextWordLength = Math.min(5, (component2.getText() + SPACE).indexOf(SPACE)) + 1;
    return component1.getToX() + nextWordLength * component1.getAverageCharacterWidth() > container.getToX()
            && (alignedToRight(component1, component2, container)
                    || component2.getFromX() - component2.getAverageCharacterWidth() < component1.getFromX())
            && component1.getToX() > component2.getFromX()
            && component1.getToX() + nextWordLength * component1.getAverageCharacterWidth() > component2
                    .getToX()//from  ww w .  ja  v a 2 s.c om
            && component2.getFromY() - component1.getToY() < Math.max(component1.getHeight(),
                    component2.getHeight());
}