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


Java Font类代码示例

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


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

示例1: extractFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Extract font.
 *
 * @return the font
 */
private Font extractFont() {
    Expression fontFamily = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_FAMILY);

    List<Expression> fontFamilyList = new ArrayList<Expression>();
    if (fontFamily != null) {
        fontFamilyList.add(fontFamily);
    }

    Font font = getStyleFactory().getDefaultFont();

    font.getFamily().clear();
    font.getFamily().addAll(fontFamilyList);

    Expression fontSize = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_SIZE);
    Expression fontStyle = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_STYLE);
    Expression fontWeight = fieldConfigVisitor.getExpression(FieldIdEnum.FONT_WEIGHT);

    font.setStyle(fontStyle);
    font.setWeight(fontWeight);
    font.setSize(fontSize);

    return font;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:29,代码来源:FontDetails.java

示例2: getFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Gets the font.
 *
 * @return the font
 */
public Font getFont() {

    List<Expression> family = new ArrayList<Expression>();
    Expression style = null;
    Expression weight = null;
    Expression size = null;

    if (firstEntry != null) {
        family = (familyMultipleValue ? firstEntry.getFamily() : family);
        style = (styleMultipleValue ? firstEntry.getStyle() : null);
        weight = (weightMultipleValue ? firstEntry.getWeight() : null);
        size = (sizeMultipleValue ? firstEntry.getSize() : null);
    }

    Font entry = styleFactory.font(family, style, weight, size);
    return entry;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:23,代码来源:MultipleFont.java

示例3: populateLabelFontDetails

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Populate label font details.
 *
 * @param font the font
 */
private void populateLabelFontDetails(java.awt.Font font) {
    labelFontName.setText(font.getFontName());
    String style;

    if (font.isBold() && font.isItalic()) {
        style = "Bold, Italic";
    } else if (font.isBold()) {
        style = "Bold";
    } else if (font.isItalic()) {
        style = "Italic";
    } else {
        style = "Plain";
    }
    labelFontStyle.setText(style);
    labelFontSize.setText(String.valueOf(font.getSize()));
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:LegendOptionPanel.java

示例4: testFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateFontField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.Font)}.
 */
@Test
public void testFont() {

    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;

    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);

    FieldConfigFont fontField = new FieldConfigFont(
            new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    fontField.createUI();
    fieldConfigManager.add(fieldId, fontField);

    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);

    StyleBuilder styleBuilder = new StyleBuilder();

    Font expectedValue = styleBuilder.createFont(java.awt.Font.decode(null));
    obj.populateFontField(fieldId, expectedValue);

    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateFontField(wrongFieldEnum, expectedValue);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:28,代码来源:FieldConfigPopulationTest.java

示例5: textFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Grabs the font from the first TextSymbolizer.
 * <p>
 * If you are using something fun like symbols you will need to do your own
 * thing.
 * </p>
 * 
 * @param symbolizer
 *            Text symbolizer information.
 * @return FontData[] of the font's fill, or null if unavailable.
 */
public static FontData[] textFont(final TextSymbolizer symbolizer) {

	final Font font = font(symbolizer);
	if (font == null)
		return null;

	final FontData[] tempFD = new FontData[1];
	final Expression fontFamilyExpression = font.getFamily().get(0);
	final Expression sizeExpression = font.getSize();
	if (sizeExpression == null || fontFamilyExpression == null)
		return null;

	final Double size = sizeExpression.evaluate(null, Double.class);

	try {
		final String fontFamily = fontFamilyExpression.evaluate(null, String.class);
		tempFD[0] = new FontData(fontFamily, size.intValue(), 1);
	} catch (final NullPointerException ignore) {
		return null;
	}
	if (tempFD[0] != null)
		return tempFD;
	return null;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:36,代码来源:SLDs.java

示例6: getFontEntries

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Gets the font entries.
 *
 * @param selectedRows the selected rows
 * @return the font entries
 */
public List<Font> getFontEntries(int[] selectedRows) {
    List<Font> selectedFontList = null;
    if (selectedRows != null) {
        selectedFontList = new ArrayList<Font>();
        for (int row : selectedRows) {
            BatchUpdateFontData entry = fontList.get(row);
            selectedFontList.add(entry.getFont());
        }
    }
    return selectedFontList;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:18,代码来源:BatchUpdateFontModel.java

示例7: applyData

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Apply data.
 *
 * @param selectedRows the selected rows
 * @param fontData the font data
 */
public void applyData(int[] selectedRows, Font fontData) {
    if (fontData != null) {
        for (int row : selectedRows) {
            BatchUpdateFontData entry = fontList.get(row);

            entry.updateFont(fontData);
        }
    }
    this.fireTableDataChanged();
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:17,代码来源:BatchUpdateFontModel.java

示例8: updateFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Update font.
 *
 * @param fontData the font data
 */
public void updateFont(Font fontData) {

    if ((fontData != null) && (font != null)) {
        if (!fontData.getFamily().isEmpty()) {
            if (!(fontData.getFamily().equals(font.getFamily()))) {
                font.getFamily().clear();
                font.getFamily().addAll(fontData.getFamily());
            }
        }

        if (fontData.getWeight() != null) {
            if (!(fontData.getWeight().equals(font.getWeight()))) {
                font.setWeight(fontData.getWeight());
            }
        }

        if (fontData.getStyle() != null) {
            if (!(fontData.getStyle().equals(font.getStyle()))) {
                font.setStyle(fontData.getStyle());
            }
        }

        if (fontData.getSize() != null) {
            if (!(fontData.getSize().equals(font.getSize()))) {
                font.setSize(fontData.getSize());
            }
        }
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:35,代码来源:BatchUpdateFontData.java

示例9: setFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Sets the font.
 *
 * @param newFont the new font
 */
public void setFont(Font newFont) {
    if (newFont != null) {
        this.font = styleFactory.getDefaultFont();

        font.getFamily().clear();
        font.getFamily().addAll(newFont.getFamily());
        font.setStyle(newFont.getStyle());
        font.setWeight(newFont.getWeight());
        font.setSize(newFont.getSize());

        setOriginalData(newFont);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:19,代码来源:BatchUpdateFontData.java

示例10: setOriginalData

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Sets the original data.
 *
 * @param newFont the new original data
 */
private void setOriginalData(Font newFont) {
    this.originalFontName = newFont.getFamily();
    this.originalFontStyle = newFont.getStyle();
    this.originalFontWeight = newFont.getWeight();
    this.originalFontSize = newFont.getSize();
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:12,代码来源:BatchUpdateFontData.java

示例11: populate

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Populate.
 *
 * @param fontList the font list
 */
public void populate(List<Font> fontList) {

    boolean emptyList = (fontList == null) || fontList.isEmpty();

    boolean showMultipleCheckbox = (fontList != null) && (fontList.size() > 1);

    MultipleFont multipleFont = new MultipleFont();
    multipleFont.parseList(fontList);
    Font font = multipleFont.getFont();

    FieldConfigBase fieldConfig = fieldConfigManager.get(FieldIdEnum.FONT_FAMILY);
    if (fieldConfig != null) {
        if (emptyList) {
            fieldConfig.showOptionField(false);
            fieldConfig.setEnabled(false);
        } else {
            fieldConfig.setEnabled(true);
            fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_FAMILY, font);
            fieldConfig.showOptionField(showMultipleCheckbox);
            boolean isSelected = !font.getFamily().isEmpty();
            fieldConfig.setOptionFieldValue(isSelected);
        }
    }
    populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_WEIGHT, font.getWeight());
    populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_STYLE, font.getStyle());
    populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_SIZE, font.getSize());

    fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:35,代码来源:FontDetails.java

示例12: updateSymbol

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Update symbol.
 */
private void updateSymbol() {
    //
    // Font
    //
    Font font = extractFont();

    // Any changes made to the font details need to be reflected
    // back to the FieldConfigFontPreview field
    fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:14,代码来源:FontDetails.java

示例13: parseList

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Parses the list.
 *
 * @param entries the entries
 */
public void parseList(List<Font> entries) {
    familyMultipleValue = true;
    styleMultipleValue = true;
    weightMultipleValue = true;
    sizeMultipleValue = true;

    if ((entries == null) || entries.isEmpty()) {
        firstEntry = null;
        familyMultipleValue = false;
        styleMultipleValue = false;
        weightMultipleValue = false;
        sizeMultipleValue = false;
    } else {
        firstEntry = entries.get(0);

        String fontFamilyValue = firstEntry.getFamily().get(0).toString();
        String styleValue = firstEntry.getStyle().toString();
        String weightValue = firstEntry.getWeight().toString();
        String sizeValue = firstEntry.getSize().toString();

        for (Font entry : entries) {
            if (fontFamilyValue.compareTo(entry.getFamily().get(0).toString()) != 0) {
                familyMultipleValue = false;
            }
            if (styleValue.compareTo(entry.getStyle().toString()) != 0) {
                styleMultipleValue = false;
            }
            if (weightValue.compareTo(entry.getWeight().toString()) != 0) {
                weightMultipleValue = false;
            }
            if (sizeValue.compareTo(entry.getSize().toString()) != 0) {
                sizeMultipleValue = false;
            }
        }
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:42,代码来源:MultipleFont.java

示例14: getFont

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Converts a org.geotools.styling.Font to java.awt.Font
 *
 * @param font the GeoTools font
 * @return the Java font
 */
public static java.awt.Font getFont(Font font) {
    LiteralExpressionImpl sizeExpression = ((LiteralExpressionImpl) font.getSize());
    Object obj = sizeExpression.getValue();
    int size = 10;
    if (obj instanceof String) {
        size = Integer.valueOf((String) obj);
    } else if (obj instanceof Double) {
        size = ((Double) obj).intValue();
    } else {
        size = Integer.valueOf(((String) obj).toString());
    }
    int styleMask = java.awt.Font.PLAIN;

    String styleName = font.getStyle().toString();

    if (styleName != null) {
        if (styleName.compareToIgnoreCase("ITALIC") == 0) {
            styleMask |= java.awt.Font.ITALIC;
        }
    }
    String weightName = font.getWeight().toString();
    if (weightName != null) {
        if (weightName.compareToIgnoreCase("BOLD") == 0) {
            styleMask |= java.awt.Font.BOLD;
        }
    }

    String name = font.getFamily().get(0).toString();

    java.awt.Font newFont = new java.awt.Font(name, styleMask, size);

    return newFont;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:40,代码来源:FontUtils.java

示例15: populateFontField

import org.geotools.styling.Font; //导入依赖的package包/类
/**
 * Populate font field.
 *
 * @param fieldId the field id
 * @param font the colour map
 */
public void populateFontField(FieldIdEnum fieldId, Font font) {
    if (fieldConfigManager == null) {
        return;
    }
    FieldConfigBase fieldConfig = fieldConfigManager.get(fieldId);
    if (fieldConfig != null) {
        fieldConfig.populateField(font);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:16,代码来源:FieldConfigPopulation.java


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