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


Java View.paint方法代码示例

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


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

示例1: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SynthTabbedPaneUI.java

示例2: 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) {
    super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, 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 (isSelected) {
            g.setColor(deSelectColor);
            //BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
        } else if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
            g.setColor(selectColor);
            //BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
        } else { // tab disabled
            g.setColor(selectColor);
            //BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
            //g.setColor(selectColor.darker());
            //BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);
        }
    }
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:26,代码来源:CustomTabbedPaneUI.java

示例3: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SynthToolTipUI.java

示例4: 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:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:AquaTabbedPaneContrastUI.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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:AquaTabbedPaneUI.java

示例6: paint

import javax.swing.text.View; //导入方法依赖的package包/类
/**
 * Paints the label text with the foreground color, if the label is opaque
 * then paints the entire background with the background color. The Label
 * text is drawn by {@link #paintEnabledText} or {@link #paintDisabledText}.
 * The locations of the label parts are computed by {@link #layoutCL}.
 *
 * @see #paintEnabledText
 * @see #paintDisabledText
 * @see #layoutCL
 */
public void paint(Graphics g, JComponent c)
{
    JLabel label = (JLabel)c;
    String text = label.getText();
    Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();

    if ((icon == null) && (text == null)) {
        return;
    }

    FontMetrics fm = SwingUtilities2.getFontMetrics(label, g);
    String clippedText = layout(label, fm, c.getWidth(), c.getHeight());

    if (icon != null) {
        icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
    }

    if (text != null) {
        View v = (View) c.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
            v.paint(g, paintTextR);
        } else {
            int textX = paintTextR.x;
            int textY = paintTextR.y + fm.getAscent();

            if (label.isEnabled()) {
                paintEnabledText(label, g, clippedText, textX, textY);
            }
            else {
                paintDisabledText(label, g, clippedText, textX, textY);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:BasicLabelUI.java

示例7: paint

import javax.swing.text.View; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c)
{
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    String text = layout(b, SwingUtilities2.getFontMetrics(b, g),
           b.getWidth(), b.getHeight());

    clearTextShiftOffset();

    // perform UI specific press action, e.g. Windows L&F shifts text
    if (model.isArmed() && model.isPressed()) {
        paintButtonPressed(g,b);
    }

    // Paint the Icon
    if(b.getIcon() != null) {
        paintIcon(g,c,iconRect);
    }

    if (text != null && !text.equals("")){
        View v = (View) c.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
            v.paint(g, textRect);
        } else {
            paintText(g, b, textRect, text);
        }
    }

    if (b.isFocusPainted() && b.hasFocus()) {
        // paint UI specific focus
        paintFocus(g,b,viewRect,textRect,iconRect);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:BasicButtonUI.java

示例8: paintText

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

        g.setFont(font);

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

            if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
                Color fg = tabPane.getForegroundAt(tabIndex);
                if (isSelected && (fg instanceof UIResource)) {
                    final Color selectedFG = UIManager.getColor("TabbedPane.selectedForeground");
                    if (selectedFG != null) {
                        fg = selectedFG;
                    }
                }
                g.setColor(fg);
                SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());

            } else { // tab disabled
                g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
                SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
                g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
                SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);

            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:AquaTabbedPaneCopyFromBasicUI.java

示例9: paint

import javax.swing.text.View; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    Dimension size = b.getSize();
    FontMetrics fm = g.getFontMetrics();

    Insets i = c.getInsets();

    Rectangle viewRect = new Rectangle(size);

    viewRect.x += i.left;
    viewRect.y += i.top;
    viewRect.width -= (i.right + viewRect.x);
    viewRect.height -= (i.bottom + viewRect.y);

    Rectangle iconRect = new Rectangle();
    Rectangle textRect = new Rectangle();

    Font f = c.getFont();
    g.setFont(f);

    // layout the text and icon
    String text = SwingUtilities.layoutCompoundLabel(
        c, fm, b.getText(), b.getIcon(),
        b.getVerticalAlignment(), b.getHorizontalAlignment(),
        b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
        viewRect, iconRect, textRect,
        b.getText() == null ? 0 : b.getIconTextGap());

    g.setColor(b.getBackground());

    if (model.isArmed() && model.isPressed() || model.isSelected()) {
        paintButtonPressed(g,b);
    }

    // Paint the Icon
    if(b.getIcon() != null) {
        paintIcon(g, b, iconRect);
    }

    // Draw the Text
    if(text != null && !text.equals("")) {
        View v = (View) c.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
           v.paint(g, textRect);
        } else {
           paintText(g, b, textRect, text);
        }
    }

    // draw the dashed focus line.
    if (b.isFocusPainted() && b.hasFocus()) {
        paintFocus(g, b, viewRect, textRect, iconRect);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:57,代码来源:BasicToggleButtonUI.java

示例10: paintView

import javax.swing.text.View; //导入方法依赖的package包/类
private void paintView(final Graphics2D graphics2D, final View view,
                       final Shape allocation) {
    if (graphics2D != null) {
        view.paint(graphics2D, allocation);
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:7,代码来源:HTMLPrintable.java

示例11: paintComponent

import javax.swing.text.View; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {

	//super.paintComponent(g);

	g.setColor(realBG);
	int iconW = 0;
	if (getIcon()!=null) {
		iconW = getIcon().getIconWidth();
	}
	if (selected && iconW>0) { // The icon area is never in the "selection"
		g.fillRect(0, 0, iconW, getHeight());
		g.setColor(getBackground());
		g.fillRect(iconW,0, getWidth()-iconW,getHeight());
	}
	else {
		g.setColor(getBackground());
		g.fillRect(0, 0, getWidth(), getHeight());
	}
	if (getIcon()!=null) {
		getIcon().paintIcon(this, g, 0, 0);
	}

	String text = getText();
	if (text != null) {
		paintTextR.setBounds(iconW,0, getWidth()-iconW,getHeight());
		paintTextR.x += 3; // Force a slight margin
		int space = paintTextR.height - g.getFontMetrics().getHeight();
		View v = (View)getClientProperty(BasicHTML.propertyKey);
		if (v != null) {
			// HTML rendering doesn't auto-center vertically, for some
			// reason
			paintTextR.y += space/2;
			paintTextR.height -= space;
			v.paint(g, paintTextR);
		}
		else {
			int textX = paintTextR.x;
			int textY = paintTextR.y;// + g.getFontMetrics().getAscent();
			//System.out.println(g.getFontMetrics().getAscent());
			g.drawString(text, textX, textY);
		}
	}

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:46,代码来源:CompletionCellRenderer.java

示例12: paint

import javax.swing.text.View; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {
    JToolTip tip = (JToolTip)c;
    Font font = c.getFont();
    FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g, font);
    Dimension size = c.getSize();
    int accelBL;

    g.setColor(c.getForeground());
    // fix for bug 4153892
    String tipText = tip.getTipText();
    if (tipText == null) {
        tipText = "";
    }

    String accelString = getAcceleratorString(tip);
    FontMetrics accelMetrics = SwingUtilities2.getFontMetrics(c, g, smallFont);
    int accelSpacing = calcAccelSpacing(c, accelMetrics, accelString);

    Insets insets = tip.getInsets();
    Rectangle paintTextR = new Rectangle(
        insets.left + 3,
        insets.top,
        size.width - (insets.left + insets.right) - 6 - accelSpacing,
        size.height - (insets.top + insets.bottom));
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        v.paint(g, paintTextR);
        accelBL = BasicHTML.getHTMLBaseline(v, paintTextR.width,
                                              paintTextR.height);
    } else {
        g.setFont(font);
        SwingUtilities2.drawString(tip, g, tipText, paintTextR.x,
                              paintTextR.y + metrics.getAscent());
        accelBL = metrics.getAscent();
    }

    if (!accelString.equals("")) {
        g.setFont(smallFont);
        g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
        SwingUtilities2.drawString(tip, g, accelString,
                                   tip.getWidth() - 1 - insets.right
                                       - accelSpacing
                                       + padSpaceBetweenStrings
                                       - 3,
                                   paintTextR.y + accelBL);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:MetalToolTipUI.java

示例13: paintText

import javax.swing.text.View; //导入方法依赖的package包/类
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)) {
            Color fg = tabPane.getForegroundAt(tabIndex);
            if (isSelected && (fg instanceof UIResource)) {
                Color selectedFG = UIManager.getColor(
                              "TabbedPane.selectedForeground");
                if (selectedFG != null) {
                    fg = selectedFG;
                }
            }
            g.setColor(fg);
            SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
                         title, mnemIndex,
                         textRect.x, textRect.y + metrics.getAscent());

        } else { // tab disabled
            g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
            SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
                         title, mnemIndex,
                         textRect.x, textRect.y + metrics.getAscent());
            g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
            SwingUtilities2.drawStringUnderlineCharAt(tabPane, g,
                         title, mnemIndex,
                         textRect.x - 1, textRect.y + metrics.getAscent() - 1);

        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:43,代码来源:BasicTabbedPaneUI.java


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