當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。