Java 类javax.swing.text.PlainView 实例源码

项目:cn1    文件:ParagraphViewTest.java   
public void testSetParent() {
    final Marker propertiesMarker = new Marker(true);
    view = new ParagraphView(block) {
        protected void setPropertiesFromAttributes() {
            propertiesMarker.setOccurred();
            super.setPropertiesFromAttributes();
        }
    };
    assertTrue(propertiesMarker.isOccurred());
    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());

    view.setParent(new PlainView(doc.getDefaultRootElement()));
    assertTrue(propertiesMarker.isOccurred());

    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());
}
项目:cn1    文件:BlockViewTest.java   
public void testSetParent() {
    final Marker propertiesMarker = new Marker(true);
    view = new BlockView(block, Y_AXIS) {
        protected void setPropertiesFromAttributes() {
            propertiesMarker.setOccurred();
            super.setPropertiesFromAttributes();
        }
    };
    assertFalse(propertiesMarker.isOccurred());
    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());

    view.setParent(new PlainView(doc.getDefaultRootElement()));
    assertTrue(propertiesMarker.isOccurred());

    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());
}
项目:cn1    文件:ParagraphView_RequirementsTest.java   
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
                               * (getEndOffset() - getStartOffset());
                    }
                    return super.getPreferredSpan(axis);
                }
            };
            return result;
        }
    };
    view = new ParagraphViewImpl(doc.getParagraphElement(10), factory);
    SizeRequirements sr =
        view.calculateMinorAxisRequirements(View.X_AXIS, null);
    assertEquals(8 * CHAR_WIDTH, sr.minimum);
    assertEquals(13 * CHAR_WIDTH, sr.preferred);
    assertEquals(Integer.MAX_VALUE, sr.maximum);
}
项目:cn1    文件:BasicTextAreaUITest.java   
public void testCreateElement() throws Exception {
    Document doc = jta.getDocument();
    Element elem = doc.getDefaultRootElement();
    BasicTextUI ui = (BasicTextUI) jta.getUI();
    assertTrue(ui.create(elem) instanceof PlainView);
    jta.setLineWrap(true);
    assertTrue(ui.create(elem) instanceof WrappedPlainView);
    jta.setLineWrap(false);
    elem = elem.getElement(0);
    assertTrue(ui.create(elem) instanceof PlainView);
    jta.setLineWrap(true);
    assertTrue(ui.create(elem) instanceof WrappedPlainView);

    try {      
        new BasicTextAreaUI().create(null);  
        fail("NPE should be thrown");
    } catch (NullPointerException npe) {              
        // PASSED            
    } 
}
项目:freeVM    文件:BasicTextAreaUITest.java   
public void testCreateElement() throws Exception {
    Document doc = jta.getDocument();
    Element elem = doc.getDefaultRootElement();
    BasicTextUI ui = (BasicTextUI) jta.getUI();
    assertTrue(ui.create(elem) instanceof PlainView);
    jta.setLineWrap(true);
    assertTrue(ui.create(elem) instanceof WrappedPlainView);
    jta.setLineWrap(false);
    elem = elem.getElement(0);
    assertTrue(ui.create(elem) instanceof PlainView);
    jta.setLineWrap(true);
    assertTrue(ui.create(elem) instanceof WrappedPlainView);

    try {      
        new BasicTextAreaUI().create(null);  
        fail("NPE should be thrown");
    } catch (NullPointerException npe) {              
        // PASSED            
    } 
}
项目:freeVM    文件:ParagraphViewTest.java   
public void testSetParent() {
    final Marker propertiesMarker = new Marker(true);
    view = new ParagraphView(block) {
        protected void setPropertiesFromAttributes() {
            propertiesMarker.setOccurred();
            super.setPropertiesFromAttributes();
        }
    };
    assertTrue(propertiesMarker.isOccurred());
    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());

    view.setParent(new PlainView(doc.getDefaultRootElement()));
    assertTrue(propertiesMarker.isOccurred());

    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());
}
项目:freeVM    文件:BlockViewTest.java   
public void testSetParent() {
    final Marker propertiesMarker = new Marker(true);
    view = new BlockView(block, Y_AXIS) {
        protected void setPropertiesFromAttributes() {
            propertiesMarker.setOccurred();
            super.setPropertiesFromAttributes();
        }
    };
    assertFalse(propertiesMarker.isOccurred());
    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());

    view.setParent(new PlainView(doc.getDefaultRootElement()));
    assertTrue(propertiesMarker.isOccurred());

    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());
}
项目:freeVM    文件:ParagraphView_RequirementsTest.java   
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
                               * (getEndOffset() - getStartOffset());
                    }
                    return super.getPreferredSpan(axis);
                }
            };
            return result;
        }
    };
    view = new ParagraphViewImpl(doc.getParagraphElement(10), factory);
    SizeRequirements sr =
        view.calculateMinorAxisRequirements(View.X_AXIS, null);
    assertEquals(8 * CHAR_WIDTH, sr.minimum);
    assertEquals(13 * CHAR_WIDTH, sr.preferred);
    assertEquals(Integer.MAX_VALUE, sr.maximum);
}
项目:freeVM    文件:ParagraphViewTest.java   
public void testSetParent() {
    final Marker propertiesMarker = new Marker(true);
    view = new ParagraphView(block) {
        protected void setPropertiesFromAttributes() {
            propertiesMarker.setOccurred();
            super.setPropertiesFromAttributes();
        }
    };
    assertTrue(propertiesMarker.isOccurred());
    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());

    view.setParent(new PlainView(doc.getDefaultRootElement()));
    assertTrue(propertiesMarker.isOccurred());

    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());
}
项目:freeVM    文件:BlockViewTest.java   
public void testSetParent() {
    final Marker propertiesMarker = new Marker(true);
    view = new BlockView(block, Y_AXIS) {
        protected void setPropertiesFromAttributes() {
            propertiesMarker.setOccurred();
            super.setPropertiesFromAttributes();
        }
    };
    assertFalse(propertiesMarker.isOccurred());
    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());

    view.setParent(new PlainView(doc.getDefaultRootElement()));
    assertTrue(propertiesMarker.isOccurred());

    view.setParent(null);
    assertFalse(propertiesMarker.isOccurred());
}
项目:freeVM    文件:ParagraphView_RequirementsTest.java   
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
                               * (getEndOffset() - getStartOffset());
                    }
                    return super.getPreferredSpan(axis);
                }
            };
            return result;
        }
    };
    view = new ParagraphViewImpl(doc.getParagraphElement(10), factory);
    SizeRequirements sr =
        view.calculateMinorAxisRequirements(View.X_AXIS, null);
    assertEquals(8 * CHAR_WIDTH, sr.minimum);
    assertEquals(13 * CHAR_WIDTH, sr.preferred);
    assertEquals(Integer.MAX_VALUE, sr.maximum);
}
项目:freeVM    文件:BasicTextAreaUITest.java   
public void testCreateElement() throws Exception {
    Document doc = jta.getDocument();
    Element elem = doc.getDefaultRootElement();
    BasicTextUI ui = (BasicTextUI) jta.getUI();
    assertTrue(ui.create(elem) instanceof PlainView);
    jta.setLineWrap(true);
    assertTrue(ui.create(elem) instanceof WrappedPlainView);
    jta.setLineWrap(false);
    elem = elem.getElement(0);
    assertTrue(ui.create(elem) instanceof PlainView);
    jta.setLineWrap(true);
    assertTrue(ui.create(elem) instanceof WrappedPlainView);

    try {      
        new BasicTextAreaUI().create(null);  
        fail("NPE should be thrown");
    } catch (NullPointerException npe) {              
        // PASSED            
    } 
}
项目:javify    文件:BasicTextAreaUI.java   
/**
 * Create the view.  Returns a WrappedPlainView if the text area
 * has lineWrap set to true, otherwise returns a PlainView.  If
 * lineWrap is true has to check whether the wrap style is word
 * or character and return an appropriate WrappedPlainView.
 *
 * @param elem the element to create a View for
 * @return an appropriate View for the element
 */
public View create(Element elem)
{
  JTextArea comp = (JTextArea) getComponent();
  if (comp.getLineWrap())
    {
      if (comp.getWrapStyleWord())
        return new WrappedPlainView(elem, true);
      else
        return new WrappedPlainView(elem, false);
    }
  else
    return new PlainView(elem);
}
项目:jvm-stm    文件:BasicTextAreaUI.java   
/**
 * Create the view.  Returns a WrappedPlainView if the text area
 * has lineWrap set to true, otherwise returns a PlainView.  If
 * lineWrap is true has to check whether the wrap style is word 
 * or character and return an appropriate WrappedPlainView.
 * 
 * @param elem the element to create a View for
 * @return an appropriate View for the element
 */
public View create(Element elem)
{
  JTextArea comp = (JTextArea) getComponent();
  if (comp.getLineWrap())
    {
      if (comp.getWrapStyleWord())
        return new WrappedPlainView(elem, true);
      else
        return new WrappedPlainView(elem, false);
    }
  else
    return new PlainView(elem);
}
项目:cn1    文件:BasicTextAreaUI.java   
@Override
public View create(final Element element) {
    Document doc = element.getDocument();
    Boolean i18n = (Boolean)doc.getProperty(StringConstants.BIDI_PROPERTY);
    if (i18n.booleanValue()) {
        return AccessController.doPrivileged(new PrivilegedAction<View>() {
            public View run() {
                try {
                    Class cls = Class.forName(PLAIN_VIEW_I18N_CLASS);
                    Constructor constructor =
                        cls.getConstructor(new Class[] {Element.class});
                    constructor.setAccessible(true);
                    return (View)constructor.newInstance(new Object[] {element});
                } catch (Exception e) {
                    return null;
                }
            }
        });
    }

    JTextComponent comp = getComponent();
    boolean lineWrap = false;
    boolean wordWrap = false;
    if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea)getComponent();
        lineWrap = c.getLineWrap();
        wordWrap = c.getWrapStyleWord();
    }
    if (lineWrap) {
        return new WrappedPlainView(element, wordWrap);
    }

    return new PlainView(element);

}
项目:cn1    文件:ComponentViewTest.java   
public void testSetParent_View() {
    // Regression test for HARMONY-1767 
    PlainDocument doc = new PlainDocument();
    Element e = doc.getDefaultRootElement();
    ComponentView obj = new ComponentView(new TestElement());
    obj.setParent(new PlainView(e));
}
项目:cn1    文件:BasicTextUITest.java   
public void testSetView() throws Exception {
    jta.wasCallInvalidate = false;
    view = new PlainView(jta.getDocument().getDefaultRootElement());
    ((BasicTextUI) jta.getUI()).setView(view);
    wasCallInvalidate = jta.wasCallInvalidate;
    assertTrue(wasCallInvalidate);
    assertEquals(view, ((BasicTextUI) jta.getUI()).getRootView(jta).getView(0));
}
项目:JamVM-PH    文件:BasicTextAreaUI.java   
/**
 * Create the view.  Returns a WrappedPlainView if the text area
 * has lineWrap set to true, otherwise returns a PlainView.  If
 * lineWrap is true has to check whether the wrap style is word 
 * or character and return an appropriate WrappedPlainView.
 * 
 * @param elem the element to create a View for
 * @return an appropriate View for the element
 */
public View create(Element elem)
{
  JTextArea comp = (JTextArea) getComponent();
  if (comp.getLineWrap())
    {
      if (comp.getWrapStyleWord())
        return new WrappedPlainView(elem, true);
      else
        return new WrappedPlainView(elem, false);
    }
  else
    return new PlainView(elem);
}
项目:classpath    文件:BasicTextAreaUI.java   
/**
 * Create the view.  Returns a WrappedPlainView if the text area
 * has lineWrap set to true, otherwise returns a PlainView.  If
 * lineWrap is true has to check whether the wrap style is word
 * or character and return an appropriate WrappedPlainView.
 *
 * @param elem the element to create a View for
 * @return an appropriate View for the element
 */
public View create(Element elem)
{
  JTextArea comp = (JTextArea) getComponent();
  if (comp.getLineWrap())
    {
      if (comp.getWrapStyleWord())
        return new WrappedPlainView(elem, true);
      else
        return new WrappedPlainView(elem, false);
    }
  else
    return new PlainView(elem);
}
项目:freeVM    文件:BasicTextAreaUI.java   
@Override
public View create(final Element element) {
    Document doc = element.getDocument();
    Boolean i18n = (Boolean)doc.getProperty(StringConstants.BIDI_PROPERTY);
    if (i18n.booleanValue()) {
        return AccessController.doPrivileged(new PrivilegedAction<View>() {
            public View run() {
                try {
                    Class cls = Class.forName(PLAIN_VIEW_I18N_CLASS);
                    Constructor constructor =
                        cls.getConstructor(new Class[] {Element.class});
                    constructor.setAccessible(true);
                    return (View)constructor.newInstance(new Object[] {element});
                } catch (Exception e) {
                    return null;
                }
            }
        });
    }

    JTextComponent comp = getComponent();
    boolean lineWrap = false;
    boolean wordWrap = false;
    if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea)getComponent();
        lineWrap = c.getLineWrap();
        wordWrap = c.getWrapStyleWord();
    }
    if (lineWrap) {
        return new WrappedPlainView(element, wordWrap);
    }

    return new PlainView(element);

}
项目:freeVM    文件:BasicTextUITest.java   
public void testSetView() throws Exception {
    jta.wasCallInvalidate = false;
    view = new PlainView(jta.getDocument().getDefaultRootElement());
    ((BasicTextUI) jta.getUI()).setView(view);
    wasCallInvalidate = jta.wasCallInvalidate;
    assertTrue(wasCallInvalidate);
    assertEquals(view, ((BasicTextUI) jta.getUI()).getRootView(jta).getView(0));
}
项目:freeVM    文件:BasicTextAreaUI.java   
@Override
public View create(final Element element) {
    Document doc = element.getDocument();
    Boolean i18n = (Boolean)doc.getProperty(StringConstants.BIDI_PROPERTY);
    if (i18n.booleanValue()) {
        return AccessController.doPrivileged(new PrivilegedAction<View>() {
            public View run() {
                try {
                    Class cls = Class.forName(PLAIN_VIEW_I18N_CLASS);
                    Constructor constructor =
                        cls.getConstructor(new Class[] {Element.class});
                    constructor.setAccessible(true);
                    return (View)constructor.newInstance(new Object[] {element});
                } catch (Exception e) {
                    return null;
                }
            }
        });
    }

    JTextComponent comp = getComponent();
    boolean lineWrap = false;
    boolean wordWrap = false;
    if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea)getComponent();
        lineWrap = c.getLineWrap();
        wordWrap = c.getWrapStyleWord();
    }
    if (lineWrap) {
        return new WrappedPlainView(element, wordWrap);
    }

    return new PlainView(element);

}
项目:freeVM    文件:ComponentViewTest.java   
public void testSetParent_View() {
    // Regression test for HARMONY-1767 
    PlainDocument doc = new PlainDocument();
    Element e = doc.getDefaultRootElement();
    ComponentView obj = new ComponentView(new TestElement());
    obj.setParent(new PlainView(e));
}
项目:freeVM    文件:BasicTextUITest.java   
public void testSetView() throws Exception {
    jta.wasCallInvalidate = false;
    view = new PlainView(jta.getDocument().getDefaultRootElement());
    ((BasicTextUI) jta.getUI()).setView(view);
    wasCallInvalidate = jta.wasCallInvalidate;
    assertTrue(wasCallInvalidate);
    assertEquals(view, ((BasicTextUI) jta.getUI()).getRootView(jta).getView(0));
}
项目:incubator-netbeans    文件:OutputEditorKit.java   
public View create(Element element) {
    return (element instanceof OutputDocument.RootElement)
           ? new OutputView(element)
           : new PlainView(element);
}