Package javax.swing.text

Examples of javax.swing.text.ViewFactory


      private static final long serialVersionUID = 1L;

      @Override
      public ViewFactory getViewFactory() {
        return new ViewFactory() {

          public View create(Element elem) {
            String kind = elem.getName();
            if (kind != null) {
              if (kind.equals(AbstractDocument.ContentElementName)) {
View Full Code Here


               "<p>very LongWord" +
               "</body></html>");
        kit.read(reader, doc, 0);

        metrics = getFontMetrics(null, CHAR_WIDTH);
        factory = new ViewFactory() {
            public View create(final Element element) {
                InlineView result = new InlineView(element) {
                    protected FontMetrics getFontMetrics() {
                        return metrics;
                    }
View Full Code Here

        assertEquals((isHarmony() ? 14 : 13) * CHAR_WIDTH, sr.preferred);
        assertEquals(Integer.MAX_VALUE, sr.maximum);
    }

    public void testCalculateMinorAxisRequirements03() throws Exception {
        factory = new ViewFactory() {
            public View create(Element element) {
                LabelView result = new LabelView(element);
                result.setGlyphPainter(BlockViewTest.InlineViewFactory.painter);
                return result;
            }
View Full Code Here

        assertEquals((isHarmony() ? 13 : 12) * CHAR_WIDTH, sr.preferred);
        assertEquals(Integer.MAX_VALUE, sr.maximum);
    }

    public void testCalculateMinorAxisRequirements04() throws Exception {
        factory = new ViewFactory() {
            public View create(Element element) {
                PlainView result = new PlainView(element) {
                    public float getPreferredSpan(int axis) {
                        if (axis == X_AXIS) {
                            return CHAR_WIDTH
View Full Code Here

        final int[] createCount = new int[] {0};
        final int[] isVisibleCount = new int[] {0};
        final View[] viewsRequested = new View[elemCount];
        final boolean[] results = new boolean[elemCount];

        view = new ParagraphViewImpl(block, new ViewFactory() {
            public View create(final Element element) {
                ++createCount[0];
                return new InlineView(element) {
                    public boolean isVisible() {
                        viewsRequested[isVisibleCount[0]] = this;
View Full Code Here

        StringReader reader = new StringReader("<html><body>0000</body></html>");
        kit.read(reader, doc, 0);
        final boolean[] ordinaryViewVisible = new boolean[] {true};
        block = doc.getParagraphElement(1);

        view = new ParagraphViewImpl(block, new ViewFactory() {
            public View create(Element element) {
                return new InlineView(element) {
                    public boolean isVisible() {
                        return getElement().getAttributes()
                               .getAttribute("CR") != null
View Full Code Here

        pane.setCaretPosition(pane.getDocument().getLength() - 1);
        assertNotNull(editorKit.getInputAttributes());
    }

    public void testGetViewFactory() {
        ViewFactory factory = editorKit.getViewFactory();
        assertTrue(factory instanceof HTMLEditorKit.HTMLFactory);
        assertSame(factory, editorKit.getViewFactory());
        assertSame(factory, new HTMLEditorKit().getViewFactory());
    }
View Full Code Here

        // This customized StyledEditorKit prevents line-wrapping up to 30000 pixels wide.
        // 30000 is a good number; value higher than about 32768 will cause errors.
        this.log.setEditorKit(new StyledEditorKit() {
            private static final long serialVersionUID = 0;
            @Override public final ViewFactory getViewFactory() {
                return new ViewFactory() {
                    public final View create(Element x) {
                        if (!AbstractDocument.SectionElementName.equals(x.getName())) return defaultFactory.create(x);
                        return new BoxView(x, View.Y_AXIS) {
                            @Override public final float getMinimumSpan(int axis) { return super.getPreferredSpan(axis); }
                            @Override public final void layout(int width,int height) { super.layout(30000, height); }
View Full Code Here

   public OurSyntaxWidget
   (boolean enableSyntax, String text, String fontName, int fontSize, int tabSize, JComponent obj1, JComponent obj2) {
      this.obj1 = obj1;
      this.obj2 = obj2;
      final OurSyntaxWidget me = this;
      final ViewFactory defaultFactory = (new StyledEditorKit()).getViewFactory();
      doc.do_enableSyntax(enableSyntax);
      doc.do_setFont(fontName, fontSize, tabSize);
      pane.setEditorKit(new StyledEditorKit() { // Prevents line-wrapping up to width=30000, and tells it to use our Document obj
         @Override public Document createDefaultDocument() { return doc; }
         @Override public ViewFactory getViewFactory() {
            return new ViewFactory() {
               public View create(Element x) {
                  if (!AbstractDocument.SectionElementName.equals(x.getName())) return defaultFactory.create(x);
                  return new BoxView(x, View.Y_AXIS) { // 30000 is a good width to use here; value > 32767 appears to cause errors
                     @Override public final float getMinimumSpan(int axis) { return super.getPreferredSpan(axis); }
                     @Override public final void layout(int w, int h) { try {super.layout(30000, h);} catch(Throwable ex) {} }
                  };
               }
View Full Code Here

TOP

Related Classes of javax.swing.text.ViewFactory

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.