Package javax.swing.text

Examples of javax.swing.text.Element


      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
    Element el = doc.getDefaultRootElement();
    TestZoneView zv = new TestZoneView(el, View.X_AXIS);

    // Try valid zone.
    View zone = zv.createZone(0, 9);
    h.check(zone instanceof AsyncBoxView);
View Full Code Here


   * @param h the test harness
   */
  private void testSimple(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    Element el = doc.getDefaultRootElement();
    ZoneView zv = new ZoneView(el, View.X_AXIS);
    h.check(zv.getAxis(), View.X_AXIS);
    h.check(zv.getElement(), el);
    zv = new ZoneView(el, View.Y_AXIS);
    h.check(zv.getAxis(), View.Y_AXIS);
View Full Code Here

  }

  private void testDefaultValues(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    Element el = doc.getDefaultRootElement();
    ZoneView zv = new ZoneView(el, View.X_AXIS);
    h.check(zv.getMaximumZoneSize(), 8192);
    h.check(zv.getMaxZonesLoaded(), 3);
  }
View Full Code Here

        }
        HTMLDocument hdoc = (HTMLDocument)doc;
        int start = getSelectionStart();
        int end = getSelectionEnd();

        Element element = hdoc.getParagraphElement(start);
        MutableAttributeSet newAttrs = new SimpleAttributeSet(element.getAttributes());
        newAttrs.addAttribute(StyleConstants.NameAttribute, tag);

        hdoc.setParagraphAttributes(start, end - start, newAttrs, true);
    }
View Full Code Here

            StyledDocument document = (StyledDocument)getDocument();
            int dot = evt.getDot();
            //SwingX #257--ensure display shows the valid attributes
            dot = dot > 0 ? dot - 1 : dot;
           
            Element elem = document.getCharacterElement(dot);
            AttributeSet set = elem.getAttributes();

            // JW: see comment in updateActionState
            ActionManager manager = ActionManager.getInstance();
            manager.setSelected("font-bold", StyleConstants.isBold(set));
            manager.setSelected("font-italic", StyleConstants.isItalic(set));
            manager.setSelected("font-underline", StyleConstants.isUnderline(set));

            elem = document.getParagraphElement(dot);
            set = elem.getAttributes();

            // Update the paragraph selector if applicable.
            if (selector != null) {
                selector.setSelectedItem(set.getAttribute(StyleConstants.NameAttribute));
            }
View Full Code Here

      }
    });
  }

  private Element findElement(Element root, Tag tag) {
    Element body = null;
    for (int i = 0; i < root.getElementCount(); i++) {
      Element element = root.getElement(i);
      if (element.getAttributes().getAttribute(
          StyleConstants.NameAttribute) == tag) {
        body = element;
        break;
      }
    }
View Full Code Here

  public String getText() {
    String text = super.getText();
    HTMLDocument document = (HTMLDocument) this.getDocument();
    // #0 is the HTML element, #1 the bidi-root
    Element[] roots = document.getRootElements();
    Element body = findElement(roots[0], HTML.Tag.BODY);
    Element p = findElement(body, HTML.Tag.P);

    Document realText = p.getDocument();
    try {
      text = realText.getText(0, realText.getLength());
    } catch (BadLocationException ex) {
      ExceptionTool.showError(ex);
    }
View Full Code Here

    }

    protected void writeBody() throws IOException, BadLocationException {
        writeStartTag("<body>");

        Element root = getDocument().getDefaultRootElement();
        for (int i = root.getElementIndex(getStartOffset());
             i < root.getElementCount();
             i++) {

            Element e = root.getElement(i);
            if (!inRange(e)) {
                break;
            }
            writeStartParagraph(e);
            writeParagraphElements(e);
View Full Code Here

            throws IOException, BadLocationException {

        for (int i = paragraph.getElementIndex(getStartOffset());
             i < paragraph.getElementCount();
             i++) {
            Element e = paragraph.getElement(i);
            if (!inRange(e)) {
                break;
            }
            if (isText(e)) {
                writeContent(e, isLineEmpty());
View Full Code Here

        }
        if (pos > doc.getLength()) {
            throw new BadLocationException("Invalid position", pos);
        }
        if (doc.getLength() != 0) {
            Element body = doc.getElement(doc.getDefaultRootElement(),
                                          StyleConstants.NameAttribute,
                                          HTML.Tag.BODY);
            if (pos < body.getStartOffset() || pos > body.getEndOffset()) {
                throw new RuntimeException("Must insert inside body element");
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.Element

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.