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


Java Font.SANS_SERIF属性代码示例

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


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

示例1: setDefaultChartFonts

/**
 * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a
 * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done
 * after calling this method.
 * 
 * @param chart
 *            the chart to change fonts for
 */
protected static void setDefaultChartFonts(JFreeChart chart) {
	final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme();

	if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) {
		StandardChartTheme standardTheme = (StandardChartTheme) chartTheme;
		// The default font used by JFreeChart cannot render japanese etc symbols
		final Font oldExtraLargeFont = standardTheme.getExtraLargeFont();
		final Font oldLargeFont = standardTheme.getLargeFont();
		final Font oldRegularFont = standardTheme.getRegularFont();
		final Font oldSmallFont = standardTheme.getSmallFont();

		final Font extraLargeFont = new Font(Font.SANS_SERIF, oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize());
		final Font largeFont = new Font(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize());
		final Font regularFont = new Font(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize());
		final Font smallFont = new Font(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize());

		standardTheme.setExtraLargeFont(extraLargeFont);
		standardTheme.setLargeFont(largeFont);
		standardTheme.setRegularFont(regularFont);
		standardTheme.setSmallFont(smallFont);

		standardTheme.apply(chart);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:AbstractAttributeStatisticsModel.java

示例2: setValue

public void setValue(Object value) { // ��дsetValue�������Ӷ����Զ�̬�����е�Ԫ������ɫ

		switch (value.toString()) {
		case "true":
			setForeground(Color.decode("#006400"));
			break;

		case "false":
			setForeground(Color.decode("#F08080"));
			break;

		}
		Font f = new Font(Font.SANS_SERIF, Font.BOLD, 12);
		setFont(f);
		setText(value.toString());

	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:BooleanColumnRender.java

示例3: setValue

public void setValue(Object value) { // ��дsetValue�������Ӷ����Զ�̬�����е�Ԫ������ɫ

		switch (value.toString()) {
		case Bootstrap.status_started:
			setForeground(Color.decode("#006400"));
			break;

		case Bootstrap.status_stopped:
			setForeground(Color.darkGray);
			break;
		case Bootstrap.status_starting:
			setForeground(Color.decode("#CD853F"));
			break;
		case Bootstrap.status_stopping:
			setForeground(Color.decode("#CD853F"));
			break;
		default:
			setForeground(Color.decode("#F08080"));
			break;

		}
		Font f = new Font(Font.SANS_SERIF, Font.BOLD, 12);
		setFont(f);
		setText(value.toString());

	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:TomcatTableStatusRender.java

示例4: setValue

public void setValue(Object value) { // ��дsetValue�������Ӷ����Զ�̬�����е�Ԫ������ɫ

		switch (value.toString()) {
		case WebApp.loaded:
			setForeground(Color.decode("#006400"));
			break;

		case WebApp.loading:
			setForeground(Color.decode("#CD853F"));
			break;
		case WebApp.failed:
			setForeground(Color.decode("#F08080"));
			break;
		default:
			setForeground(Color.darkGray);
			break;

		}
		Font f = new Font(Font.SANS_SERIF, Font.BOLD, 12);
		setFont(f);
		setText(value.toString());

	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:WebAppTableStatusRender.java

示例5: makeText

private static void makeText(Graphics2D graphics, ImageSize maxSize, Random rand) {
	switchColor(graphics, rand);
	
	String fontName = Font.SANS_SERIF;
	switch (rand.nextInt(4)) {
		case 0: fontName = Font.SANS_SERIF; break;
		case 1: fontName = Font.MONOSPACED; break;
		case 2: fontName = Font.SERIF; break;
		case 3: fontName = Font.DIALOG; break;
	}
	
	int fontStyle = Font.PLAIN;
	switch (rand.nextInt(3)) {
		case 0: fontStyle = Font.PLAIN; break;
		case 1: fontStyle = Font.BOLD; break;
		case 2: fontStyle = Font.ITALIC; break;
	}
	
	int fontSize = rand.nextInt(MAX_FONT_SIZE + 1);
	
	graphics.setFont(new Font(fontName, fontStyle, fontSize));
	
	int textLength = rand.nextInt(MAX_TEXT_LENGTH + 1);
	String str = Stream.generate(() -> rand.nextInt(MAX_CHAR_SIZE))
			.limit(textLength)
			.map(i -> (char)i.intValue())
			.collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();
	
	graphics.drawString(str, rand.nextInt(maxSize.getWidth()), rand.nextInt(maxSize.getHeight()));
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:30,代码来源:ImageCreator.java

示例6: getHtmlPane

public static RSyntaxTextArea getHtmlPane() {
	/*
	 * JEditorPane htmlPane = new JEditorPane();
	 * htmlPane.setBackground(Color.WHITE);
	 * htmlPane.setForeground(Color.BLACK); Font font = new
	 * Font(Font.SANS_SERIF, Font.PLAIN, 20); htmlPane.setFont(font);
	 */
	RSyntaxTextArea textArea = new RSyntaxTextArea();
	textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
	textArea.setCodeFoldingEnabled(true);
	Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 16);
	textArea.setFont(font);
	return textArea;
}
 
开发者ID:csanuragjain,项目名称:APKRepatcher,代码行数:14,代码来源:APKRepatcher.java

示例7: getInstalledFontFamilyNames

/**
 * Get a list of installed fonts in the requested {@link Locale}.
 * The list contains the fonts Family Names.
 * If Locale is null, the default locale is used.
 *
 * @param requestedLocale, if null the default locale is used.
 * @return list of installed fonts in the system.
 */
public String[] getInstalledFontFamilyNames(Locale requestedLocale) {
    if (requestedLocale == null) {
        requestedLocale = Locale.getDefault();
    }
    if (allFamilies != null && lastDefaultLocale != null &&
        requestedLocale.equals(lastDefaultLocale)) {
            String[] copyFamilies = new String[allFamilies.length];
            System.arraycopy(allFamilies, 0, copyFamilies,
                             0, allFamilies.length);
            return copyFamilies;
    }

    TreeMap<String,String> familyNames = new TreeMap<String,String>();
    //  these names are always there and aren't localised
    String str;
    str = Font.SERIF;         familyNames.put(str.toLowerCase(), str);
    str = Font.SANS_SERIF;    familyNames.put(str.toLowerCase(), str);
    str = Font.MONOSPACED;    familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG;        familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG_INPUT;  familyNames.put(str.toLowerCase(), str);

    /* Platform APIs may be used to get the set of available family
     * names for the current default locale so long as it is the same
     * as the start-up system locale, rather than loading all fonts.
     */
    if (requestedLocale.equals(getSystemStartupLocale()) &&
        getFamilyNamesFromPlatform(familyNames, requestedLocale)) {
        /* Augment platform names with JRE font family names */
        getJREFontFamilyNames(familyNames, requestedLocale);
    } else {
        loadFontFiles();
        Font2D[] physicalfonts = getPhysicalFonts();
        for (int i=0; i < physicalfonts.length; i++) {
            if (!(physicalfonts[i] instanceof NativeFont)) {
                String name =
                    physicalfonts[i].getFamilyName(requestedLocale);
                familyNames.put(name.toLowerCase(requestedLocale), name);
            }
        }
    }

    // Add any native font family names here
    addNativeFontFamilyNames(familyNames, requestedLocale);

    String[] retval =  new String[familyNames.size()];
    Object [] keyNames = familyNames.keySet().toArray();
    for (int i=0; i < keyNames.length; i++) {
        retval[i] = (String)familyNames.get(keyNames[i]);
    }
    if (requestedLocale.equals(Locale.getDefault())) {
        lastDefaultLocale = requestedLocale;
        allFamilies = new String[retval.length];
        System.arraycopy(retval, 0, allFamilies, 0, allFamilies.length);
    }
    return retval;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:64,代码来源:SunFontManager.java

示例8: getFont

/**
 * Returns the font for the values in the passed in AttributeSet.
 * It is assumed the keys will be CSS.Attribute keys.
 * <code>sc</code> is the StyleContext that will be messaged to get
 * the font once the size, name and style have been determined.
 */
Font getFont(StyleContext sc, AttributeSet a, int defaultSize, StyleSheet ss) {
    ss = getStyleSheet(ss);
    int size = getFontSize(a, defaultSize, ss);

    /*
     * If the vertical alignment is set to either superscirpt or
     * subscript we reduce the font size by 2 points.
     */
    StringValue vAlignV = (StringValue)a.getAttribute
                          (CSS.Attribute.VERTICAL_ALIGN);
    if ((vAlignV != null)) {
        String vAlign = vAlignV.toString();
        if ((vAlign.indexOf("sup") >= 0) ||
            (vAlign.indexOf("sub") >= 0)) {
            size -= 2;
        }
    }

    FontFamily familyValue = (FontFamily)a.getAttribute
                                        (CSS.Attribute.FONT_FAMILY);
    String family = (familyValue != null) ? familyValue.getValue() :
                              Font.SANS_SERIF;
    int style = Font.PLAIN;
    FontWeight weightValue = (FontWeight) a.getAttribute
                              (CSS.Attribute.FONT_WEIGHT);
    if ((weightValue != null) && (weightValue.getValue() > 400)) {
        style |= Font.BOLD;
    }
    Object fs = a.getAttribute(CSS.Attribute.FONT_STYLE);
    if ((fs != null) && (fs.toString().indexOf("italic") >= 0)) {
        style |= Font.ITALIC;
    }
    if (family.equalsIgnoreCase("monospace")) {
        family = Font.MONOSPACED;
    }
    Font f = sc.getFont(family, style, size);
    if (f == null
        || (f.getFamily().equals(Font.DIALOG)
            && ! family.equalsIgnoreCase(Font.DIALOG))) {
        family = Font.SANS_SERIF;
        f = sc.getFont(family, style, size);
    }
    return f;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:50,代码来源:CSS.java

示例9: parseCssValue

Object parseCssValue(String value) {
    int cIndex = value.indexOf(',');
    FontFamily ff = new FontFamily();
    ff.svalue = value;
    ff.family = null;

    if (cIndex == -1) {
        setFontName(ff, value);
    }
    else {
        boolean done = false;
        int lastIndex;
        int length = value.length();
        cIndex = 0;
        while (!done) {
            // skip ws.
            while (cIndex < length &&
                   Character.isWhitespace(value.charAt(cIndex)))
                cIndex++;
            // Find next ','
            lastIndex = cIndex;
            cIndex = value.indexOf(',', cIndex);
            if (cIndex == -1) {
                cIndex = length;
            }
            if (lastIndex < length) {
                if (lastIndex != cIndex) {
                    int lastCharIndex = cIndex;
                    if (cIndex > 0 && value.charAt(cIndex - 1) == ' '){
                        lastCharIndex--;
                    }
                    setFontName(ff, value.substring
                                (lastIndex, lastCharIndex));
                    done = (ff.family != null);
                }
                cIndex++;
            }
            else {
                done = true;
            }
        }
    }
    if (ff.family == null) {
        ff.family = Font.SANS_SERIF;
    }
    return ff;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:CSS.java

示例10: paintComponent

@Override
public void paintComponent(Graphics g)
{
	Day now = Day.now();

	// Initialisieren
	super.paintComponent(g);

	Graphics2D g2 = (Graphics2D) g;

	int dayWidth = getWidth() / days;
	int hourheight = getHeight() / (hoursPerDay + 1);
	Font defaultFont = g2.getFont();
	Font domFont = new Font(Font.SANS_SERIF, Font.BOLD, 15);
	// Rahmenzeichnen
	g2.setColor(Color.BLACK);
	g2.setStroke(new BasicStroke(3));
	g2.drawLine(0, hourheight, getWidth(), hourheight);

	g2.setColor(TODAY_BACKGROUND_COLOR);
	g2.fillRect(0, hourheight, dayWidth, getHeight());
	g2.setColor(Color.BLACK);

	// X-Achse
	Day tmpDate = null;
	for (int i = 0; i < days; ++i)
	{

		if (0 == i)
			tmpDate = now;
		else
		{
			tmpDate = now.getDateInDays(i);
			g2.drawLine((dayWidth * i), 0, (dayWidth * i), getHeight()); // Tagestrennstriche
		}

		// Day of month
		g2.setFont(domFont);
		int stringWidth = SwingUtilities.computeStringWidth(g2.getFontMetrics(),
				" " + tmpDate.getDate().getDayOfMonth());
		int numberX = (dayWidth * (i + 1)) - stringWidth;
		g2.drawString(tmpDate.getDate().getDayOfMonth() + " ", numberX, (hourheight / 2));

		// Dayname
		g2.setFont(defaultFont);
		g2.drawString(" " + tmpDate.getDayName(), (dayWidth * i), (hourheight / 2));
	}

	g2.setStroke(new BasicStroke(1));

	// Y-Achse
	for (int i = 2; i < (hoursPerDay + 1); ++i)
	{
		g2.drawLine(0, (hourheight * i), getWidth(), (hourheight * i));
	}

}
 
开发者ID:AnonymOnline,项目名称:saveOrganizer,代码行数:57,代码来源:CalendarFrame.java

示例11: doTest

protected void doTest() {
    Font f = new Font(Font.SANS_SERIF, Font.ITALIC, 24);
    f.getNumGlyphs();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:ClassLoaderLeakTest.java

示例12: getInstalledFontFamilyNames

/**
 * Get a list of installed fonts in the requested {@link Locale}.
 * The list contains the fonts Family Names.
 * If Locale is null, the default locale is used.
 *
 * @param requestedLocale, if null the default locale is used.
 * @return list of installed fonts in the system.
 */
public String[] getInstalledFontFamilyNames(Locale requestedLocale) {
    if (requestedLocale == null) {
        requestedLocale = Locale.getDefault();
    }
    if (allFamilies != null && lastDefaultLocale != null &&
        requestedLocale.equals(lastDefaultLocale)) {
            String[] copyFamilies = new String[allFamilies.length];
            System.arraycopy(allFamilies, 0, copyFamilies,
                             0, allFamilies.length);
            return copyFamilies;
    }

    TreeMap<String,String> familyNames = new TreeMap<String,String>();
    //  these names are always there and aren't localised
    String str;
    str = Font.SERIF;         familyNames.put(str.toLowerCase(), str);
    str = Font.SANS_SERIF;    familyNames.put(str.toLowerCase(), str);
    str = Font.MONOSPACED;    familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG;        familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG_INPUT;  familyNames.put(str.toLowerCase(), str);

    /* Platform APIs may be used to get the set of available family
     * names for the current default locale so long as it is the same
     * as the start-up system locale, rather than loading all fonts.
     */
    if (requestedLocale.equals(getSystemStartupLocale()) &&
        getFamilyNamesFromPlatform(familyNames, requestedLocale)) {
        /* Augment platform names with JRE font family names */
        getJREFontFamilyNames(familyNames, requestedLocale);
    } else {
        loadFontFiles();
        Font2D[] physicalfonts = getPhysicalFonts();
        for (int i=0; i < physicalfonts.length; i++) {
            if (!(physicalfonts[i] instanceof NativeFont)) {
                String name =
                    physicalfonts[i].getFamilyName(requestedLocale);
                familyNames.put(name.toLowerCase(requestedLocale), name);
            }
        }
    }

    // Add any native font family names here
    addNativeFontFamilyNames(familyNames, requestedLocale);

    String[] retval =  new String[familyNames.size()];
    Object [] keyNames = familyNames.keySet().toArray();
    for (int i=0; i < keyNames.length; i++) {
        retval[i] = familyNames.get(keyNames[i]);
    }
    if (requestedLocale.equals(Locale.getDefault())) {
        lastDefaultLocale = requestedLocale;
        allFamilies = new String[retval.length];
        System.arraycopy(retval, 0, allFamilies, 0, allFamilies.length);
    }
    return retval;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:64,代码来源:SunFontManager.java

示例13: getFont

/**
 * Returns the font for the values in the passed in AttributeSet.
 * It is assumed the keys will be CSS.Attribute keys.
 * <code>sc</code> is the StyleContext that will be messaged to get
 * the font once the size, name and style have been determined.
 */
Font getFont(StyleContext sc, AttributeSet a, int defaultSize, StyleSheet ss) {
    ss = getStyleSheet(ss);
    int size = getFontSize(a, defaultSize, ss);

    /*
     * If the vertical alignment is set to either superscript or
     * subscript we reduce the font size by 2 points.
     */
    StringValue vAlignV = (StringValue)a.getAttribute
                          (CSS.Attribute.VERTICAL_ALIGN);
    if ((vAlignV != null)) {
        String vAlign = vAlignV.toString();
        if ((vAlign.indexOf("sup") >= 0) ||
            (vAlign.indexOf("sub") >= 0)) {
            size -= 2;
        }
    }

    FontFamily familyValue = (FontFamily)a.getAttribute
                                        (CSS.Attribute.FONT_FAMILY);
    String family = (familyValue != null) ? familyValue.getValue() :
                              Font.SANS_SERIF;
    int style = Font.PLAIN;
    FontWeight weightValue = (FontWeight) a.getAttribute
                              (CSS.Attribute.FONT_WEIGHT);
    if ((weightValue != null) && (weightValue.getValue() > 400)) {
        style |= Font.BOLD;
    }
    Object fs = a.getAttribute(CSS.Attribute.FONT_STYLE);
    if ((fs != null) && (fs.toString().indexOf("italic") >= 0)) {
        style |= Font.ITALIC;
    }
    if (family.equalsIgnoreCase("monospace")) {
        family = Font.MONOSPACED;
    }
    Font f = sc.getFont(family, style, size);
    if (f == null
        || (f.getFamily().equals(Font.DIALOG)
            && ! family.equalsIgnoreCase(Font.DIALOG))) {
        family = Font.SANS_SERIF;
        f = sc.getFont(family, style, size);
    }
    return f;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:CSS.java


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