当前位置: 首页>>代码示例>>Java>>正文


Java View类代码示例

本文整理汇总了Java中javax.swing.text.View的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


View类属于javax.swing.text包,在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPreferredSpan

import javax.swing.text.View; //导入依赖的package包/类
@Override
public float getPreferredSpan(int axis) {
    if (axis == View.X_AXIS) {
        String desc = fold.getDescription(); // For empty desc a single-space text layout is returned
        float advance = 0;
        if (desc.length() > 0) {
            TextLayout textLayout = getTextLayout();
            if (textLayout == null) {
                return 0f;
            }
            advance = textLayout.getAdvance();
        }
        return advance + (2 * EXTRA_MARGIN_WIDTH);
    } else {
        EditorView.Parent parent = (EditorView.Parent) getParent();
        return (parent != null) ? parent.getViewRenderContext().getDefaultRowHeight() : 0f;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FoldView.java

示例2: calculateTabHeight

import javax.swing.text.View; //导入依赖的package包/类
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
    int height = 0;
    Component c = tabPane.getTabComponentAt(tabIndex);
    if (c != null) {
        height = c.getPreferredSize().height;
    } else {
        View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            height += (int) v.getPreferredSpan(View.Y_AXIS);
        } else {
            // plain text
            height += fontHeight;
        }
        Icon icon = getIconForTab(tabIndex);

        if (icon != null) {
            height = Math.max(height, icon.getIconHeight());
        }
    }
    Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
    height += tabInsets.top + tabInsets.bottom + 2;
    return height;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:BasicTabbedPaneUI.java

示例3: setParent

import javax.swing.text.View; //导入依赖的package包/类
public @Override void setParent(View parent) {
    if (parent != null) { // start listening
        JTextComponent component = (JTextComponent)parent.getContainer();
        TextUI tui = component.getUI();
        if (tui instanceof BaseTextUI){
            editorUI = ((BaseTextUI)tui).getEditorUI();
            if (editorUI!=null){
                editorUI.addPropertyChangeListener(this);
            }
        }
    }

    super.setParent(parent);
    
    if (parent == null) {
        if (editorUI!=null){
            editorUI.removePropertyChangeListener(this);
            editorUI = null;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:DrawEngineDocView.java

示例4: paintText

import javax.swing.text.View; //导入依赖的package包/类
private void paintText(SynthContext ss,
                         Graphics g, int tabPlacement,
                         Font font, FontMetrics metrics, int tabIndex,
                         String title, Rectangle textRect,
                         boolean isSelected) {
    g.setFont(font);

    View v = getTextViewForTab(tabIndex);
    if (v != null) {
        // html
        v.paint(g, textRect);
    } else {
        // plain text
        int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

        g.setColor(ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND));
        ss.getStyle().getGraphicsUtils(ss).paintText(ss, g, title,
                              textRect, mnemIndex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:SynthTabbedPaneUI.java

示例5: paintTitle

import javax.swing.text.View; //导入依赖的package包/类
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        // sja fix getTheme().setThemeTextColor(g, isSelected, isPressed && tracking, tabPane.isEnabledAt(tabIndex));
        if (tabPane.isEnabledAt(tabIndex)) {
            g2d.setColor(Color.black);
        } else {
            g2d.setColor(Color.gray);
        }
    } else {
        g2d.setColor(color);
    }

    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:AquaTabbedPaneUI.java

示例6: updateHtmlViews

import javax.swing.text.View; //导入依赖的package包/类
private void updateHtmlViews(int index) {
    final String title = tabPane.getTitleAt(index);
    final boolean isHTML = BasicHTML.isHTMLString(title);
    if (isHTML) {
        if (htmlViews == null) { // Initialize vector
            htmlViews = createHTMLVector();
        } else { // Vector already exists
            final View v = BasicHTML.createHTMLView(tabPane, title);
            htmlViews.insertElementAt(v, index);
        }
    } else { // Not HTML
        if (htmlViews != null) { // Add placeholder
            htmlViews.insertElementAt(null, index);
        } // else nada!
    }
    updateMnemonics();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:AquaTabbedPaneCopyFromBasicUI.java

示例7: paintLayeredHighlights

import javax.swing.text.View; //导入依赖的package包/类
@Override
public void paintLayeredHighlights(Graphics g, int lineStart, int lineEnd,
					Shape viewBounds, JTextComponent editor, View view) {
	paintListLayered(g, lineStart,lineEnd, viewBounds, editor, view, markedOccurrences);
	super.paintLayeredHighlights(g, lineStart, lineEnd, viewBounds, editor, view);
	paintListLayered(g, lineStart,lineEnd, viewBounds, editor, view, parserHighlights);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:8,代码来源:RSyntaxTextAreaHighlighter.java

示例8: updateIndex

import javax.swing.text.View; //导入依赖的package包/类
public int updateIndex(int viewIndex, int offset, View view, FlyView.Parent flyParent) {
    while (--viewIndex >= 0) {
        int startOffset = (flyParent != null)
            ? flyParent.getStartOffset(viewIndex)
            : view.getView(viewIndex).getStartOffset();
        if (startOffset != offset) { // view starts below offset
            if (lowerAdjacent) {
                viewIndex--; // return the lower view that ends at offset
            }

            break;
        }
    }
    
    return viewIndex + 1;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ViewUtilitiesImpl.java

示例9: getSingleLineTextBaseline

import javax.swing.text.View; //导入依赖的package包/类
/**
   * Returns the baseline for single line text components, like
   * <code>JTextField</code>.
   */
  private static int getSingleLineTextBaseline(JTextComponent textComponent,
                                               int h) {
      View rootView = textComponent.getUI().getRootView(textComponent);
      if (rootView.getViewCount() > 0) {
          Insets insets = textComponent.getInsets();
          int height = h - insets.top - insets.bottom;
          int y = insets.top;
          View fieldView = rootView.getView(0);
   int vspan = (int)fieldView.getPreferredSpan(View.Y_AXIS);
   if (height != vspan) {
int slop = height - vspan;
y += slop / 2;
   }
          FontMetrics fm = textComponent.getFontMetrics(
                               textComponent.getFont());
          y += fm.getAscent();
          return y;
      }
      return -1;
  }
 
开发者ID:fesch,项目名称:Moenagade,代码行数:25,代码来源:Baseline.java

示例10: paintText

import javax.swing.text.View; //导入依赖的package包/类
@Override
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title,
	Rectangle textRect, boolean isSelected)
{
	g.setFont(font);

	View v = getTextViewForTab(tabIndex);
	if( v != null )
	{
		// html
		v.paint(g, textRect);
	}
	else
	{
		// plain text
		int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

		if( tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex) )
		{
			g.setColor(isSelected ? Color.white : Color.black);
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
		}
		else
		{ // tab disabled
			g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
			g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
			BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x,
				textRect.y + metrics.getAscent());
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:FlatterTabbedPaneUI.java

示例11: testBackwardBias

import javax.swing.text.View; //导入依赖的package包/类
@RandomlyFails
public void testBackwardBias() throws Throwable {
    JEditorPane jep = createJep(PYRAMID);
    View rootView = Utilities.getRootView(jep, DrawEngineDocView.class);
    for(int i = 1; i < rootView.getViewCount(); i++) {
        int backwardBiasOffset = rootView.getView(i).getStartOffset();
        int previousLineEOLOffset = rootView.getView(i - 1).getEndOffset() - 1;
        
        Rectangle r1 = jep.getUI().modelToView(jep, backwardBiasOffset, Position.Bias.Backward);
        Rectangle r2 = jep.getUI().modelToView(jep, previousLineEOLOffset, Position.Bias.Forward);
        
        assertEquals("Wrong backward bias offset translation: offset = " + backwardBiasOffset
            + ", previousLineEOLOffset = " + previousLineEOLOffset
            + ", docLen = " + jep.getDocument().getLength(), r2, r1);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:DrawEngineTest.java

示例12: paintTitle

import javax.swing.text.View; //导入依赖的package包/类
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        g2d.setColor(getNonSelectedTabTitleColor());
        if (tabPane.getSelectedIndex() == tabIndex) {
            boolean pressed = isPressedAt(tabIndex);
            boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
            Color textColor = getSelectedTabTitleColor(enabled, pressed);
            Color shadowColor = getSelectedTabTitleShadowColor(enabled);
            AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
            return;
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:AquaTabbedPaneContrastUI.java

示例13: modelToView

import javax.swing.text.View; //导入依赖的package包/类
/**
 * Provides a mapping from the document model coordinate space
 * to the coordinate space of the view mapped to it.
 *
 * @param pos the position to convert &gt;= 0
 * @param a the allocated region to render into
 * @param b the bias toward the previous character or the
 *  next character represented by the offset, in case the
 *  position is a boundary of two views.
 * @return the bounding box of the given position is returned
 * @exception BadLocationException  if the given position does
 *   not represent a valid location in the associated document
 * @exception IllegalArgumentException for an invalid bias argument
 * @see View#viewToModel
 */
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
    int index = getViewIndex(pos, b);
    if (index >= 0) {
        Shape ca = getChildAllocation(index, a);

        // forward to the child view
        ViewLayoutState child = getChild(index);
        View cv = child.getView();
        return cv.modelToView(pos, ca, b);
    } else {
        Document doc = getDocument();
        int docLen = (doc != null) ? doc.getLength() : -1;
        throw new BadLocationException("Offset " + pos + " with bias " + b + " is outside of the view" //NOI18N
            + ", children = " + getViewCount() //NOI18N
            + (getViewCount() > 0 ? " covering offsets <" +  //NOI18N
                getView(0).getStartOffset() + ", " +  //NOI18N
                getView(getViewCount() - 1).getEndOffset() + ">" : "") + //NOI18N
                ", docLen=" + docLen
            , pos);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:GapBoxView.java

示例14: paint

import javax.swing.text.View; //导入依赖的package包/类
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SynthToolTipUI.java

示例15: calculateTabWidth

import javax.swing.text.View; //导入依赖的package包/类
protected int calculateTabWidth(final int tabPlacement, final int tabIndex, final FontMetrics metrics) {
    final Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
    int width = tabInsets.left + tabInsets.right + 3;
    final Component tabComponent = tabPane.getTabComponentAt(tabIndex);
    if (tabComponent != null) {
        width += tabComponent.getPreferredSize().width;
    } else {
        final Icon icon = getIconForTab(tabIndex);
        if (icon != null) {
            width += icon.getIconWidth() + textIconGap;
        }
        final View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            width += (int)v.getPreferredSpan(View.X_AXIS);
        } else {
            // plain text
            final String title = tabPane.getTitleAt(tabIndex);
            width += SwingUtilities2.stringWidth(tabPane, metrics, title);
        }
    }
    return width;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:AquaTabbedPaneCopyFromBasicUI.java


注:本文中的javax.swing.text.View类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。