Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.TextArea$Paragraph$ParagraphListenerList


   
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
   
    // instantiate cloner
    BookCloner987 bookCloner987 = new BookCloner987();
View Full Code Here


  public static void main(String[] args) {
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
   
    // instantiate cloner
    BookCloner988 bookCloner = new BookCloner988();
View Full Code Here

                if (text == null || text.isEmpty()) {
                    return;
                }

                TextArea toolTipTextArea = new TextArea();

                toolTipTextArea.setText(text);
                toolTipTextArea.getStyles().put("wrapText", true);

                tooltip.setContent(toolTipTextArea);

                Point location = comp.getDisplay().getMouseLocation();
                x = location.x;
                y = location.y;

                // Ensure that the tooltip stays on screen
                Display display = comp.getDisplay();
                int tooltipHeight = tooltip.getPreferredHeight();
                if (y + tooltipHeight > display.getHeight()) {
                    y -= tooltipHeight;
                }

                int tooltipXOffset = 16;
                int padding = 15;

                toolTipTextArea.setMaximumWidth(display.getWidth() - ( x + tooltipXOffset + padding) );
                tooltip.setLocation(x + tooltipXOffset, y);
                tooltip.open(comp.getWindow());
            }
        });
View Full Code Here

    @Override
    public void install(Component component) {
        super.install(component);

        TextArea textArea = (TextArea)component;
        textArea.getTextAreaListeners().add(this);
        textArea.getTextAreaSelectionListeners().add(this);

        textArea.setCursor(Cursor.TEXT);

        Document document = textArea.getDocument();
        if (document != null) {
            documentView = (DocumentView)createNodeView(document);
            documentView.attach();
            updateSelection();
        }
View Full Code Here

    }

    @Override
    public void layout() {
        if (documentView != null) {
            TextArea textArea = (TextArea)getComponent();
            int width = getWidth();

            documentView.setBreakWidth(Math.max(width - (margin.left + margin.right), 0));
            documentView.validate();

            updateSelection();
            caretX = caret.x;

            if (textArea.isFocused()) {
                scrollCharacterToVisible(textArea.getSelectionStart());
            }

            showCaret(textArea.isFocused()
                && textArea.getSelectionLength() == 0);
        }
    }
View Full Code Here

        }
    }

    @Override
    public void paint(Graphics2D graphics) {
        TextArea textArea = (TextArea)getComponent();
        int width = getWidth();
        int height = getHeight();

        if (backgroundColor != null) {
            graphics.setColor(backgroundColor);
            graphics.fillRect(0, 0, width, height);
        }

        if (documentView != null) {
            // Draw the selection highlight
            if (selection != null) {
                graphics.setColor(textArea.isFocused()
                    && textArea.isEditable() ?
                    selectionBackgroundColor : inactiveSelectionBackgroundColor);
                graphics.fill(selection);
            }

            // Draw the document content
            graphics.translate(margin.left, margin.top);
            documentView.paint(graphics);
            graphics.translate(-margin.left, -margin.top);

            // Draw the caret
            if (selection == null
                && caretOn
                && textArea.isFocused()) {
                graphics.setColor(textArea.isEditable() ? color : inactiveColor);
                graphics.fill(caret);
            }
        }
    }
View Full Code Here

        return characterBounds;
    }

    private void scrollCharacterToVisible(int offset) {
        TextArea textArea = (TextArea)getComponent();
        Bounds characterBounds = getCharacterBounds(offset);

        if (characterBounds != null) {
            textArea.scrollAreaToVisible(characterBounds.x, characterBounds.y,
                characterBounds.width, characterBounds.height);
        }
    }
View Full Code Here

    @Override
    public boolean mouseMove(Component component, int x, int y) {
        boolean consumed = super.mouseMove(component, x, y);

        if (Mouse.getCapturer() == component) {
            TextArea textArea = (TextArea)getComponent();

            Bounds visibleArea = textArea.getVisibleArea();
            visibleArea = new Bounds(visibleArea.x, visibleArea.y,
                visibleArea.width, visibleArea.height);

            if (y >= visibleArea.y
                && y < visibleArea.y + visibleArea.height) {
                // Stop the scroll selection timer
                if (scheduledScrollSelectionCallback != null) {
                    scheduledScrollSelectionCallback.cancel();
                    scheduledScrollSelectionCallback = null;
                }

                scrollDirection = null;
                int offset = getInsertionPoint(x, y);

                if (offset != -1) {
                    // Select the range
                    if (offset > anchor) {
                        textArea.setSelection(anchor, offset - anchor);
                    } else {
                        textArea.setSelection(offset, anchor - offset);
                    }
                }
            } else {
                if (scheduledScrollSelectionCallback == null) {
                    scrollDirection = (y < visibleArea.y) ? Direction.BACKWARD : Direction.FORWARD;
View Full Code Here

    @Override
    public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
        boolean consumed = super.mouseDown(component, button, x, y);

        if (button == Mouse.Button.LEFT) {
            TextArea textArea = (TextArea)component;

            anchor = getInsertionPoint(x, y);

            if (anchor != -1) {
                if (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) {
                    // Select the range
                    int selectionStart = textArea.getSelectionStart();

                    if (anchor > selectionStart) {
                        textArea.setSelection(selectionStart, anchor - selectionStart);
                    } else {
                        textArea.setSelection(anchor, selectionStart - anchor);
                    }
                } else {
                    // Move the caret to the insertion point
                    textArea.setSelection(anchor, 0);
                    consumed = true;
                }
            }

            caretX = caret.x;

            // Set focus to the text input
            textArea.requestFocus();
        }

        return consumed;
    }
View Full Code Here

    @Override
    public boolean keyTyped(final Component component, char character) {
        boolean consumed = super.keyTyped(component, character);

        final TextArea textArea = (TextArea)getComponent();

        if (textArea.isEditable()) {
            Document document = textArea.getDocument();

            if (document != null) {
                // Ignore characters in the control range and the ASCII delete
                // character as well as meta key presses
                if (character > 0x1F
                    && character != 0x7F
                    && !Keyboard.isPressed(Keyboard.Modifier.META)) {
                    textArea.insertText(character);
                    showCaret(true);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.TextArea$Paragraph$ParagraphListenerList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.