Package javax.swing.text

Examples of javax.swing.text.Element


   * @param h
   */
  private void testForceBreakable(TestHarness h)
  {
    DefaultStyledDocument doc = new DefaultStyledDocument();
    Element el = doc.new BranchElement(null, null);
    TestFlowView fv = new TestFlowView(el, View.Y_AXIS);
    // Create one row and fill it with one oversized testview.
    TestFlowView.TestRow row = (TestFlowView.TestRow) fv.createRow();
    fv.replace(0, 0, new View[]{row});
    row.breakWeight = View.ForcedBreakWeight;
View Full Code Here


      }
    catch (BadLocationException ex)
      {
        harness.fail("BadLocationException");
      }
    Element root = doc.getRootElements()[0];
    harness.check(root instanceof AbstractDocument.BranchElement);
    harness.check(root.getElementCount(), 2);
    Element el1 = root.getElement(0);
    harness.check(el1 instanceof AbstractDocument.LeafElement);
    harness.check(el1.getStartOffset(), 0);
    harness.check(el1.getEndOffset(), 6);
    Element el2 = root.getElement(1);
    harness.check(el2 instanceof AbstractDocument.LeafElement);
    harness.check(el2.getStartOffset(), 6);
    harness.check(el2.getEndOffset(), 12);
  }
View Full Code Here

      }
    catch (BadLocationException ex)
      {
        harness.fail("BadLocationException");
      }
    Element root = doc.getRootElements()[0];
    harness.check(root instanceof AbstractDocument.BranchElement);
    harness.check(root.getElementCount(), 1);
    Element el1 = root.getElement(0);
    harness.check(el1 instanceof AbstractDocument.LeafElement);
    harness.check(el1.getStartOffset(), 0);
    harness.check(el1.getEndOffset(), 12);
  }
View Full Code Here

         int elementIndex,
        int startOffset,
        int endOffset,
                    String text)
  {
    Element e = doc.getDefaultRootElement();
    Element child = e.getElement(elementIndex);

    harness.check(child.getStartOffset(), startOffset);
    harness.check(child.getEndOffset(), endOffset);

    String retrievedText = null;
    try
      {
        retrievedText = doc.getText(startOffset, endOffset-startOffset);
View Full Code Here

        harness.debug(ex);
      }

    // Now we should have the following child elements below the single
    // root and single paragraph: (0, 5) (5, 10) (10, 21)
    Element root = doc.getDefaultRootElement();
    harness.check(root.getStartOffset(), 0);
    harness.check(root.getEndOffset(), 21);
    harness.check(root.getElementCount(), 1);

    Element par = root.getElement(0);
    harness.check(par.getStartOffset(), 0);
    harness.check(par.getEndOffset(), 21);
    harness.check(par.getElementCount(), 1);

    Element child1 = par.getElement(0);
    harness.check(child1.getStartOffset(), 0);
    harness.check(child1.getEndOffset(), 21);
  }
View Full Code Here

        harness.debug(ex);
      }

    // Now we should have the following child elements below the single
    // root and single paragraph: (0, 5) (5, 10) (10, 21)
    Element root = doc.getDefaultRootElement();
    harness.check(root.getStartOffset(), 0);
    harness.check(root.getEndOffset(), 21);
    harness.check(root.getElementCount(), 1);

    Element par = root.getElement(0);
    harness.check(par.getStartOffset(), 0);
    harness.check(par.getEndOffset(), 21);
    harness.check(par.getElementCount(), 3);

    Element child1 = par.getElement(0);
    harness.check(child1.getStartOffset(), 0);
    harness.check(child1.getEndOffset(), 5);

    Element child2 = par.getElement(1);
    harness.check(child2.getStartOffset(), 5);
    harness.check(child2.getEndOffset(), 10);

    Element child3 = par.getElement(2);
    harness.check(child3.getStartOffset(), 10);
    harness.check(child3.getEndOffset(), 21);
  }
View Full Code Here

      {
        harness.debug(ex);
      }

    // Now we should have two paragraphs (0, 11)(11, 27)
    Element root = doc.getDefaultRootElement();
    harness.check(root.getStartOffset(), 0);
    harness.check(root.getEndOffset(), 27);
    harness.check(root.getElementCount(), 2);

    Element par1 = root.getElement(0);
    harness.check(par1.getStartOffset(), 0);
    harness.check(par1.getEndOffset(), 11);
    harness.check(par1.getElementCount(), 1);

    Element par2 = root.getElement(1);
    harness.check(par2.getStartOffset(), 11);
    harness.check(par2.getEndOffset(), 27);
    harness.check(par2.getElementCount(), 1);
  }
View Full Code Here

      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
    Element el = doc.getDefaultRootElement();
    TestZoneView zv = new TestZoneView(el, View.X_AXIS);
    zv.append(zv.createZone(0, 3));
    zv.append(zv.createZone(3, 7));
    zv.append(zv.createZone(7, 10));
View Full Code Here

        pd.insertString(0, "abc\ndef\n", null);

        // Delete the 'c'.
        pd.remove(2, 1);

        Element re = pd.getDefaultRootElement();
       
        // There should still be two separate lines
        // (no Element merge should have taken place).
        index0 = re.getElementIndex(2);
        index1 = re.getElementIndex(3);
      }
    catch (BadLocationException ble)
      {
        // Very odd. This should not happen.
        index0 = -1;
View Full Code Here

      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
    Element el = doc.getDefaultRootElement();
    TestZoneView zv = new TestZoneView(el, View.Y_AXIS);
    zv.loadChildren(zv.getViewFactory());
    h.check(zv.getViewCount(), 1);
    View child = zv.getView(0);
    h.check(child.getStartOffset(), 0);
    h.check(child.getEndOffset(), el.getEndOffset());
  }
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.