當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewFactory.create方法代碼示例

本文整理匯總了Java中javax.swing.text.ViewFactory.create方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewFactory.create方法的具體用法?Java ViewFactory.create怎麽用?Java ViewFactory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.ViewFactory的用法示例。


在下文中一共展示了ViewFactory.create方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: elementReloadChildren

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * Loads child views by tracking child elements of the element
 * this view was created for.
 * @param index index at which the views should be added/replaced.
 * @param removeLength number of removed children views. It is useful
 *  when rebuilding children for a portion of the view.
 * @param elementIndex index of the first child element for which
 *  the view should be created
 * @param elementCount number of elements for which the views should be created.
 */
protected void elementReloadChildren(int index, int removeLength,
int elementCount) {

    Element e = getElement();
    View[] added = null;

    ViewFactory f = getViewFactory();
    // Null view factory can mean that one of the grand parents is already disconnected
    // from the view hierarchy. No added children for null factory.
        
    if (f != null) {
        added = new View[elementCount];
        for (int i = 0; i < elementCount; i++) {
            added[i] = f.create(e.getElement(index + i));
        }

    }

    replace(index, removeLength, added);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:GapBoxView.java

示例2: modelChanged

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * Indicates that the model of a text component has changed. This
 * triggers a rebuild of the view hierarchy.
 */
protected void modelChanged()
{
  if (textComponent == null || rootView == null)
    return;
  ViewFactory factory = rootView.getViewFactory();
  if (factory == null)
    return;
  Document doc = textComponent.getDocument();
  if (doc == null)
    return;
  Element elem = doc.getDefaultRootElement();
  if (elem == null)
    return;
  View view = factory.create(elem);
  setView(view);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:21,代碼來源:BasicTextUI.java

示例3: modelChanged

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * Indicates that the model of a text component has changed. This
 * triggers a rebuild of the view hierarchy.
 */
protected void modelChanged()
{
  if (textComponent == null || rootView == null) 
    return;
  ViewFactory factory = rootView.getViewFactory();
  if (factory == null) 
    return;
  Document doc = textComponent.getDocument();
  if (doc == null)
    return;
  Element elem = doc.getDefaultRootElement();
  if (elem == null)
    return;
  View view = factory.create(elem);
  setView(view);
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:21,代碼來源:BasicTextUI.java

示例4: createView

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
public static View createView(JXLabel c) {
    BasicEditorKit kit = getFactory();
    float rightIndent = 0;
    if (c.getIcon() != null && c.getHorizontalTextPosition() != SwingConstants.CENTER) {
        rightIndent = c.getIcon().getIconWidth() + c.getIconTextGap(); 
    }
    Document doc = kit.createDefaultDocument(c.getFont(), c.getForeground(), c.getTextAlignment(), rightIndent);
    Reader r = new StringReader(c.getText() == null ? "" : c.getText());
    try {
        kit.read(r, doc, 0);
    } catch (Throwable e) {
    }
    ViewFactory f = kit.getViewFactory();
    View hview = f.create(doc.getDefaultRootElement());
    View v = new Renderer(c, f, hview, true);
    return v;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:18,代碼來源:JXLabel.java

示例5: createHTMLView

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * Create an html renderer for the given component and
 * string of html.
 */
public static View createHTMLView(JComponent c, String html) {
    BasicEditorKit kit = getFactory();
    Document doc = kit.createDefaultDocument(c.getFont(),
                                             c.getForeground());
    Object base = c.getClientProperty(documentBaseKey);
    if (base instanceof URL) {
        ((HTMLDocument)doc).setBase((URL)base);
    }
    Reader r = new StringReader(html);
    try {
        kit.read(r, doc, 0);
    } catch (Throwable e) {
    }
    ViewFactory f = kit.getViewFactory();
    View hview = f.create(doc.getDefaultRootElement());
    View v = new Renderer(c, f, hview);
    return v;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:23,代碼來源:BasicHyperlinkUI.java

示例6: get

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * 	Get View from HTML String
 *	@param html html string
 *	@return renderer view
 */
public static HTMLRenderer get (String html)
{
	HTMLEditorKit kit = new HTMLEditorKit();
	HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument();
	try
	{
		doc.remove(0, doc.getLength());
		Reader r = new StringReader(html);
		kit.read(r, doc, 0);
	}
	catch (Exception e)
	{
		log.error("", e);
	}
	//	Create Renderer
	Element element = doc.getDefaultRootElement();
	ViewFactory factory = kit.getViewFactory();
	View view = factory.create(element);	//	Y_AXIS is main
	HTMLRenderer renderer = new HTMLRenderer (factory, view);
	renderer.preferenceChanged (null, true, true);
	return renderer;
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:28,代碼來源:HTMLRenderer.java

示例7: create

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * The table itself acts as a factory for the various views that actually
 * represent pieces of the table. All other factory activity is delegated to
 * the factory returned by the parent of the table.
 */
public View create(Element elem) {
	Object o = elem.getAttributes().getAttribute(
			StyleConstants.NameAttribute);
	if (o instanceof HTML.Tag) {
		HTML.Tag kind = (HTML.Tag) o;
		if (kind == HTML.Tag.TR) {
			return createTableRow(elem);
		} else if ((kind == HTML.Tag.TD) || (kind == HTML.Tag.TH)) {
			return new CellView(elem);
		} else if (kind == HTML.Tag.CAPTION) {
			return new javax.swing.text.html.ParagraphView(elem);
		}
	}
	// default is to delegate to the normal factory
	View p = getParent();
	if (p != null) {
		ViewFactory f = p.getViewFactory();
		if (f != null) {
			return f.create(elem);
		}
	}
	return null;
}
 
開發者ID:lexml,項目名稱:lexml-swing-editorhtml,代碼行數:29,代碼來源:EkitTableView.java

示例8: createCustomView

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
protected @Override View createCustomView(ViewFactory f,
int startOffset, int maxEndOffset, int elementIndex) {
    if (elementIndex == -1) {
        throw new IllegalStateException("Need underlying line element structure"); // NOI18N
    }
    
    View view = null;

    Element elem = getElement();
    Element lineElem = elem.getElement(elementIndex);
    view = f.create(lineElem);
    return view;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:DrawEngineDocView.java

示例9: reloadChildren

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
protected @Override void reloadChildren(int index, int removeLength, int startOffset, int endOffset) {
    // TODO uncomment assert (index == 0 && removeLength == 0
        // && startOffset == getStartOffset() && endOffset == getEndOffset());

    // Rebuild all the present child views completely
    index = 0;
    removeLength = getViewCount();

    Element lineElem = getElement(); // starting line element
    View[] added = null;
    ViewFactory f = getViewFactory();
    if (f != null) {
        int lineElemEndOffset = lineElem.getEndOffset();
        // Ending offset of the previously created view - here start with
        //   begining of the first line
        int lastViewEndOffset = lineElem.getStartOffset();

        List childViews = new ArrayList();
        // Append ending fragment if necessary
        // asserted non-empty list => foldEndOffset populated
        if (lastViewEndOffset < lineElemEndOffset) { // need ending fragment
            View lineView = f.create(lineElem);
            View endingFrag = lineView.createFragment(lastViewEndOffset, lineElemEndOffset);
            childViews.add(endingFrag);
            // lastViewEndOffset = lineElemEndOffset;  <- can be ignored here
        }

        added = new View[childViews.size()];
        childViews.toArray(added);
    }

    
    replace(index, removeLength, added);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:FoldMultiLineView.java

示例10: loadChildren

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
protected void loadChildren(ViewFactory f)
{
  // Load the columns here.
  Element el = getElement();
  View[] columns = new View[numViews[X_AXIS]];
  int offset = row * numViews[X_AXIS];
  for (int c = 0; c < numViews[X_AXIS]; c++)
    {
      Element child = el.getElement(offset + c);
      columns[c] = f.create(child);
    }
  replace(0, 0, columns);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:14,代碼來源:FrameSetView.java

示例11: create

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
/**
 * Implementation of the ViewFactory interface for creating the
 * child views correctly.
 */
public View create(Element elem)
{
  View view = null;
  AttributeSet atts = elem.getAttributes();
  Object name = atts.getAttribute(StyleConstants.NameAttribute);
  AttributeSet pAtts = elem.getParentElement().getAttributes();
  Object pName = pAtts.getAttribute(StyleConstants.NameAttribute);

  if (name == HTML.Tag.TR && pName == HTML.Tag.TABLE)
    view = new RowView(elem);
  else if ((name == HTML.Tag.TD || name == HTML.Tag.TH)
           && pName == HTML.Tag.TR)
    view = new CellView(elem);
  else if (name == HTML.Tag.CAPTION)
    view = new ParagraphView(elem);
  else
    {
      // If we haven't mapped the element, then fall back to the standard
      // view factory.
      View parent = getParent();
      if (parent != null)
        {
          ViewFactory vf = parent.getViewFactory();
          if (vf != null)
            view = vf.create(elem);
        }
    }
  return view;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:34,代碼來源:TableView.java

示例12: getViewFactory

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
@Override
public ViewFactory getViewFactory() {
    final ViewFactory sf = super.getViewFactory();
    return new ViewFactory() {
        public View create(Element element) {
            if (element.getName().equals(AbstractDocument.ParagraphElementName)) {
                return new ParagraphView(element) {
                    @Override
                    public void layout(int width, int height) {
                        try {
                            super.layout(Short.MAX_VALUE, height);
                        } catch (Throwable t) {
                            // this method sometimes throws an error
                            // which prevents the component from
                            // initializing. Just ignore any errors.
                            logger.log(Level.WARNING, "Error in layout", 
                                       t);
                        }
                    }

                    @Override
                    public float getMinimumSpan(int axis) {
                        return super.getPreferredSpan(axis);
                    }
                };
            }

            return sf.create(element);
        }
    };
}
 
開發者ID:josmas,項目名稱:openwonderland,代碼行數:32,代碼來源:LogViewerFrame.java

示例13: loadChildren

import javax.swing.text.ViewFactory; //導入方法依賴的package包/類
@Override
protected void loadChildren(ViewFactory f)
{
    if (f == null) { return; }
    Element e = getElement();

    if (e.getElementCount() > 0)
    {
        View[] added = new View[1];
        // load children (element) using ViewFactory (a new View)
        // elements should contain only 1 LeafElement
        added[0] = f.create(e.getElement(0));
        replace(0, 1, added);
    }
}
 
開發者ID:mantlik,項目名稱:swingbox-javahelp-viewer,代碼行數:16,代碼來源:DelegateView.java


注:本文中的javax.swing.text.ViewFactory.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。