Java 8 View - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 View class.

This code example shows how to use the following methods:getPreferredSpan, setSize
     */ 
    private Dimension calculatePreferredSize(JLabel labelWithHtmlText, boolean width, int preferredSize) {
 
        View view = (View) labelWithHtmlText.getClientProperty(BasicHTML.propertyKey);
 
        view.setSize(width ? preferredSize : 0,
                     width ? 0 : preferredSize);
 
        float w = view.getPreferredSpan(View.X_AXIS);
        float h = view.getPreferredSpan(View.Y_AXIS);
 
        return new Dimension((int) Math.ceil(w),
                (int) Math.ceil(h));
    } 
 
    @Override 
    public void actionPerformed(ActionEvent e) {
        if (ACTION_HOMEPAGE.equals(e.getActionCommand())) {
            UrlDisplayHelper.displayUrl(this, GCVIEWER_HOMEPAGE);
        } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPreferredSpan, setSize
 
        if (v == null) {
            return superPreferred;
        } 
 
        v.setSize(width, 0);
        int w = (int) Math.ceil(v.getPreferredSpan(View.X_AXIS));
        int h = (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS));
 
        oldPreferred = new Dimension(w, h);
        return oldPreferred;
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getEndOffset, getStartOffset, modelToView
				ble.printStackTrace(); // Never happens
				return null; 
			} 
		} 
 
		if (p0 == view.getStartOffset() && p1 == view.getEndOffset()) {
			// Contained in view, can just use bounds. 
			Rectangle alloc;
			if (viewBounds instanceof Rectangle) {
				alloc = (Rectangle) viewBounds;
			} else { 
				alloc = viewBounds.getBounds();
			} 
			g.fillRect(alloc.x, alloc.y, alloc.width, alloc.height);
			return alloc;
		} 
 
		// Should only render part of View. 
		Graphics2D g2d = (Graphics2D)g;
		try { 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAlignment, getChildAllocation, getElement, getView, getViewCount
        } 
        return -1; 
    } 
 
    private static int getBaseline(View view, Shape bounds) {
        if (view.getViewCount() == 0) {
            return -1; 
        } 
        AttributeSet attributes = view.getElement().getAttributes();
        Object name = null; 
        if (attributes != null) {
            name = attributes.getAttribute(StyleConstants.NameAttribute);
        } 
        int index = 0;
        if (name == HTML.Tag.HTML && view.getViewCount() > 1) {
            // For html on widgets the header is not visible, skip it. 
            index++;
        } 
        bounds = view.getChildAllocation(index, bounds);
        if (bounds == null) { 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPreferredSpan, setSize
	    host = c;
	    factory = f;
	    view = v;
	    view.setParent(this);
	    // initially layout to the preferred size 
	    setSize(view.getPreferredSpan(X_AXIS), view.getPreferredSpan(Y_AXIS));
        } 
 
        public AttributeSet getAttributes() {
	    return null; 
	} 
 
         public float getPreferredSpan(int axis) {
	    if (axis == X_AXIS) {
		// width currently laid out to 
		return width;
	    } 
	    return view.getPreferredSpan(axis);
        } 
          

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getEndOffset, getStartOffset, modelToView
			g2d.setColor(c.getSelectionColor());
		else 
			g2d.setPaint(paint);
 
		// Contained in view, can just use bounds. 
		if (offs0==view.getStartOffset() && offs1==view.getEndOffset()) {
 
			Rectangle alloc;
			if (bounds instanceof Rectangle)
				alloc = (Rectangle)bounds;
			else 
				alloc = bounds.getBounds();
			 
			g2d.fillRect(alloc.x, alloc.y, alloc.width, alloc.height);
 
			// Restore state from before translucency if necessary. 
			if (getAlpha()<1.0f) 
				g2d.setComposite(originalComposite);
 
			return alloc;

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPreferredSpan, setParent, setSize
            Renderer(JComponent c, ViewFactory f, View v) {
                super(null); 
            host = c;
            factory = f;
            view = v;
            view.setParent(this);
            // initially layout to the preferred size 
            setSize(view.getPreferredSpan(X_AXIS), view.getPreferredSpan(Y_AXIS));
            } 
 
        /** 
         * Fetches the attributes to use when rendering.  At the root 
         * level there are no attributes.  If an attribute is resolved 
         * up the view hierarchy this is the end of the line. 
         */ 
            @Override 
            public AttributeSet getAttributes() {
            return null; 
        } 
 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getPreferredSpan
        final int textWidth;
        final int textHeight;
        if ( html != null )
        { 
            // Text is HTML 
            textWidth = ( int ) html.getPreferredSpan ( View.X_AXIS );
            textHeight = ( int ) html.getPreferredSpan ( View.Y_AXIS );
        } 
        else 
        { 
            // Text isn't HTML 
            final String text = menuItem.getText ();
            textWidth = text != null && text.length () > 0 ? fm.stringWidth ( text ) : 0;
            textHeight = fm.getHeight ();
        } 
 
        // Icon-Text gap 
        final int gap = textWidth > 0 && iconPlaceholderWidth > 0 ? menuItem.getIconTextGap () : 0;
 
        // Acceleration text and its gap 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createFragment, getEndOffset, getStartOffset
       } 
 
       public static class HTMLFlowStrategy extends FlowStrategy {
           protected View createView(FlowView fv, int startOffset, int spanLeft, int rowIndex) {
               View res=super.createView(fv, startOffset, spanLeft, rowIndex);
               if (res.getEndOffset()-res.getStartOffset()> MAX_VIEW_SIZE) {
                   res = res.createFragment(startOffset, startOffset+ MAX_VIEW_SIZE);
               } 
               return res;
           } 
 
       } 
       public int getResizeWeight(int axis) {
           return 0; 
       } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMinimumSpan, getView
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 View Methods: