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

项目:MPL    文件:BnJaggedEditorKit.java   
@Override
public View create(Element elem) {
  String kind = elem.getName();
  if (kind != null) {
    if (kind.equals(AbstractDocument.ContentElementName)) {
      return createLabelView(elem);
    } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
      // return new MyParagraphView(elem);
      return new ParagraphView(elem);
    } else if (kind.equals(AbstractDocument.SectionElementName)) {
      return new BoxView(elem, View.Y_AXIS);
    } else if (kind.equals(StyleConstants.ComponentElementName)) {
      return new ComponentView(elem);
    } else if (kind.equals(StyleConstants.IconElementName)) {
      return new IconView(elem);
    }
  } // default to text display
  return new LabelView(elem);
}
项目:chatty    文件:ExtendedTextPane.java   
@Override
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }
    return new LabelView(elem);
}
项目:stendhal    文件:KTextEdit.java   
@Override
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }

    // default to text display
    return new LabelView(elem);
}
项目:tellervo    文件:SamplePrintEditor.java   
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null)
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new LabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            // We changed this so we can mess with tab stops
            return new SPParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
            // we changed this so we can zoom in on text
            //return new ScaledBoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    // default to text display
    return new LabelView(elem);
}
项目:Chatty-Twitch-Client    文件:ExtendedTextPane.java   
@Override
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }
    return new LabelView(elem);
}
项目:cn1    文件:StyleSheet_BoxPainterTest.java   
public void testGetInsetWithPaddingPercentWithParent() throws Exception {
    BoxView parent = new BoxView(doc.getDefaultRootElement(), View.Y_AXIS) {
        public int getWidth() {
            return 361;
        }
        public int getHeight() {
            return 257;
        }
    };
    view.setParent(parent);
    ss.addCSSAttribute(attrs, Attribute.PADDING, "10%");
    assertEquals(4, attrs.getAttributeCount());
    final float width  = isHarmony() ? 361 * 0.1f : 0;
    assertEquals(width, bp.getInset(View.TOP, view), 1e-5f);
    assertEquals(width, bp.getInset(View.RIGHT, view), 1e-5f);
    assertEquals(width, bp.getInset(View.BOTTOM, view), 1e-5f);
    assertEquals(width, bp.getInset(View.LEFT, view), 1e-5f);
}
项目:hortonmachine    文件:WrapEditorKit.java   
public View create( Element elem ) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }

    // default to text display
    return new LabelView(elem);
}
项目:K-scope    文件:InformationDialog.java   
/**
       * 要素に基づいてビューを作成します。
       * @param elem        作成対象要素
       * @return            ビュー
       */
      @Override
public View create(Element elem) {
          String kind = elem.getName();
          if(kind != null) {
              if(kind.equals(AbstractDocument.ContentElementName)) {
                  return new LabelView(elem);
              }else if(kind.equals(AbstractDocument.ParagraphElementName)) {
                  return new NoWrapParagraphView(elem);
              }else if(kind.equals(AbstractDocument.SectionElementName)) {
                  return new BoxView(elem, View.Y_AXIS);
              }else if(kind.equals(StyleConstants.ComponentElementName)) {
                  return new ComponentView(elem);
              }else if(kind.equals(StyleConstants.IconElementName)) {
                  return new IconView(elem);
              }
          }
          return new LabelView(elem);
      }
项目:K-scope    文件:SwingUtils.java   
/**
 * 要素に基づいてビューを作成します。
 * 
 * @param elem
 *            作成対象要素
 * @return ビュー
 */
@Override
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new LabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new NoWrapParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }
    return new LabelView(elem);
}
项目:K-scope    文件:CodePane.java   
/**
 * 要素に基づいてビューを作成します。
 * @param elem      作成対象要素
 * @return          ビュー
 */
@Override
public View create(Element elem) {
    String kind = elem.getName();
    if(kind != null) {
        if(kind.equals(AbstractDocument.ContentElementName)) {
            return new LabelView(elem);
        }else if(kind.equals(AbstractDocument.ParagraphElementName)) {
            return new WordWrapParagraphView(elem);
        }else if(kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        }else if(kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        }else if(kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }
    return new LabelView(elem);
}
项目:TwitchChatClient    文件:ExtendedTextPane.java   
@Override
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }
    return new LabelView(elem);
}
项目:desktopclient-java    文件:MessageList.java   
@Override
public javax.swing.text.View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        switch (kind) {
            case AbstractDocument.ContentElementName:
                return new WrapLabelView(elem);
            case AbstractDocument.ParagraphElementName:
                return new ParagraphView(elem);
            case AbstractDocument.SectionElementName:
                return new BoxView(elem, javax.swing.text.View.Y_AXIS);
            case StyleConstants.ComponentElementName:
                return new ComponentView(elem);
            case StyleConstants.IconElementName:
                return new IconView(elem);
        }
    }
    // default to text display
    return new LabelView(elem);
}
项目:HexScape    文件:WrapTextPane.java   
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }

    // default to text display
    return new LabelView(elem);
}
项目:freeVM    文件:StyleSheet_BoxPainterTest.java   
public void testGetInsetWithPaddingPercentWithParent() throws Exception {
    BoxView parent = new BoxView(doc.getDefaultRootElement(), View.Y_AXIS) {
        public int getWidth() {
            return 361;
        }
        public int getHeight() {
            return 257;
        }
    };
    view.setParent(parent);
    ss.addCSSAttribute(attrs, Attribute.PADDING, "10%");
    assertEquals(4, attrs.getAttributeCount());
    final float width  = isHarmony() ? 361 * 0.1f : 0;
    assertEquals(width, bp.getInset(View.TOP, view), 1e-5f);
    assertEquals(width, bp.getInset(View.RIGHT, view), 1e-5f);
    assertEquals(width, bp.getInset(View.BOTTOM, view), 1e-5f);
    assertEquals(width, bp.getInset(View.LEFT, view), 1e-5f);
}
项目:freeVM    文件:StyleSheet_BoxPainterTest.java   
public void testGetInsetWithPaddingPercentWithParent() throws Exception {
    BoxView parent = new BoxView(doc.getDefaultRootElement(), View.Y_AXIS) {
        public int getWidth() {
            return 361;
        }
        public int getHeight() {
            return 257;
        }
    };
    view.setParent(parent);
    ss.addCSSAttribute(attrs, Attribute.PADDING, "10%");
    assertEquals(4, attrs.getAttributeCount());
    final float width  = isHarmony() ? 361 * 0.1f : 0;
    assertEquals(width, bp.getInset(View.TOP, view), 1e-5f);
    assertEquals(width, bp.getInset(View.RIGHT, view), 1e-5f);
    assertEquals(width, bp.getInset(View.BOTTOM, view), 1e-5f);
    assertEquals(width, bp.getInset(View.LEFT, view), 1e-5f);
}
项目:JTChat    文件:ChatroomPanel.java   
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new ChatroomPanel.WrapLabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }

    // default to text display
    return new LabelView(elem);
}
项目:cn1    文件:TableTagView.java   
public void preferenceChanged(View child, boolean width, boolean height) {
    areColumnSizeRequirementsValid = false;

    super.preferenceChanged(this, width, height);

    for (int i = 0; i < getViewCount(); i++) {
        if (getView(i) instanceof BoxView) {
            ((BoxView)getView(i)).layoutChanged(X_AXIS);
        }
    }
}
项目:cn1    文件:TableTagView.java   
protected void forwardUpdate(ElementChange change, DocumentEvent event, Shape shape, ViewFactory factory) {
    boolean xValid = isLayoutValid(X_AXIS);

    super.forwardUpdate(change, event, shape, factory);

    if (xValid && !isLayoutValid(X_AXIS)) {
        Rectangle rc = shape.getBounds();
        getContainer().repaint(rc.x, rc.y, ((BoxView)getParent()).getWidth(), rc.height);
    }
}
项目:cn1    文件:CSS.java   
Object resolveRelativeValue(final View view) {
    if (view == null) {
        return ZERO;
    }

    final AttributeSet attr = view.getAttributes();

    switch (relativeUnits) {
    case RELATIVE_UNITS_EM:
    case RELATIVE_UNITS_EX:
        final Object fs = attr.getAttribute(Attribute.FONT_SIZE);
        final float fontSize = fs != null
                               ? ((Length)fs).floatValue(view)
                               : FontSize.getDefaultValue().floatValue();

        float result = fontSize * theValue.floatValue();
        if (relativeUnits == RELATIVE_UNITS_EX) {
            result /= 2;
        }
        return new Float(result);

    case RELATIVE_UNITS_PERCENTAGE:
        View parent = view.getParent();
        if (!(parent instanceof BoxView)) {
            return ZERO;
        }
        float width = ((BoxView)parent).getWidth();
        if (width >= Integer.MAX_VALUE) {
            return ZERO;
        }

        return new Float(width * theValue.floatValue() / 100);

    default:
        System.err.println(Messages.getString("swing.err.07")); //$NON-NLS-1$
    }
    return ZERO;
}
项目:freeVM    文件:TableTagView.java   
public void preferenceChanged(View child, boolean width, boolean height) {
    areColumnSizeRequirementsValid = false;

    super.preferenceChanged(this, width, height);

    for (int i = 0; i < getViewCount(); i++) {
        if (getView(i) instanceof BoxView) {
            ((BoxView)getView(i)).layoutChanged(X_AXIS);
        }
    }
}
项目:freeVM    文件:TableTagView.java   
protected void forwardUpdate(ElementChange change, DocumentEvent event, Shape shape, ViewFactory factory) {
    boolean xValid = isLayoutValid(X_AXIS);

    super.forwardUpdate(change, event, shape, factory);

    if (xValid && !isLayoutValid(X_AXIS)) {
        Rectangle rc = shape.getBounds();
        getContainer().repaint(rc.x, rc.y, ((BoxView)getParent()).getWidth(), rc.height);
    }
}
项目:freeVM    文件:CSS.java   
Object resolveRelativeValue(final View view) {
    if (view == null) {
        return ZERO;
    }

    final AttributeSet attr = view.getAttributes();

    switch (relativeUnits) {
    case RELATIVE_UNITS_EM:
    case RELATIVE_UNITS_EX:
        final Object fs = attr.getAttribute(Attribute.FONT_SIZE);
        final float fontSize = fs != null
                               ? ((Length)fs).floatValue(view)
                               : FontSize.getDefaultValue().floatValue();

        float result = fontSize * theValue.floatValue();
        if (relativeUnits == RELATIVE_UNITS_EX) {
            result /= 2;
        }
        return new Float(result);

    case RELATIVE_UNITS_PERCENTAGE:
        View parent = view.getParent();
        if (!(parent instanceof BoxView)) {
            return ZERO;
        }
        float width = ((BoxView)parent).getWidth();
        if (width >= Integer.MAX_VALUE) {
            return ZERO;
        }

        return new Float(width * theValue.floatValue() / 100);

    default:
        System.err.println(Messages.getString("swing.err.07")); //$NON-NLS-1$
    }
    return ZERO;
}
项目:freeVM    文件:TableTagView.java   
public void preferenceChanged(View child, boolean width, boolean height) {
    areColumnSizeRequirementsValid = false;

    super.preferenceChanged(this, width, height);

    for (int i = 0; i < getViewCount(); i++) {
        if (getView(i) instanceof BoxView) {
            ((BoxView)getView(i)).layoutChanged(X_AXIS);
        }
    }
}
项目:freeVM    文件:TableTagView.java   
protected void forwardUpdate(ElementChange change, DocumentEvent event, Shape shape, ViewFactory factory) {
    boolean xValid = isLayoutValid(X_AXIS);

    super.forwardUpdate(change, event, shape, factory);

    if (xValid && !isLayoutValid(X_AXIS)) {
        Rectangle rc = shape.getBounds();
        getContainer().repaint(rc.x, rc.y, ((BoxView)getParent()).getWidth(), rc.height);
    }
}
项目:freeVM    文件:CSS.java   
Object resolveRelativeValue(final View view) {
    if (view == null) {
        return ZERO;
    }

    final AttributeSet attr = view.getAttributes();

    switch (relativeUnits) {
    case RELATIVE_UNITS_EM:
    case RELATIVE_UNITS_EX:
        final Object fs = attr.getAttribute(Attribute.FONT_SIZE);
        final float fontSize = fs != null
                               ? ((Length)fs).floatValue(view)
                               : FontSize.getDefaultValue().floatValue();

        float result = fontSize * theValue.floatValue();
        if (relativeUnits == RELATIVE_UNITS_EX) {
            result /= 2;
        }
        return new Float(result);

    case RELATIVE_UNITS_PERCENTAGE:
        View parent = view.getParent();
        if (!(parent instanceof BoxView)) {
            return ZERO;
        }
        float width = ((BoxView)parent).getWidth();
        if (width >= Integer.MAX_VALUE) {
            return ZERO;
        }

        return new Float(width * theValue.floatValue() / 100);

    default:
        System.err.println(Messages.getString("swing.err.07")); //$NON-NLS-1$
    }
    return ZERO;
}
项目:cn1    文件:HRuleTagView.java   
private int getWidthAttr() {
    Object value = getAttributes().getAttribute(CSS.Attribute.WIDTH);
    return value != null
        ? ((CSS.FloatValue)value).intValue(this)
        : ((BoxView)getParent().getParent()).getWidth();
}
项目:freeVM    文件:HRuleTagView.java   
private int getWidthAttr() {
    Object value = getAttributes().getAttribute(CSS.Attribute.WIDTH);
    return value != null
        ? ((CSS.FloatValue)value).intValue(this)
        : ((BoxView)getParent().getParent()).getWidth();
}
项目:freeVM    文件:HRuleTagView.java   
private int getWidthAttr() {
    Object value = getAttributes().getAttribute(CSS.Attribute.WIDTH);
    return value != null
        ? ((CSS.FloatValue)value).intValue(this)
        : ((BoxView)getParent().getParent()).getWidth();
}