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


Java Style.setName方法代码示例

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


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

示例1: testGetTreeString

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link com.sldeditor.ui.tree.item.StyleTreeItem#getTreeString(java.lang.Object)}.
 */
@Test
public void testGetTreeString() {
    StyleTreeItem item = new StyleTreeItem();
    String actualValue = item.getTreeString(null, null);
    String expectedValue = String.format("%s : %s",
            Localisation.getString(SLDTreeTools.class, "TreeItem.style"), "");
    assertTrue(actualValue.compareTo(expectedValue) == 0);

    Style style = DefaultSymbols.createNewStyle();

    actualValue = item.getTreeString(null, style);
    expectedValue = String.format("%s : %s",
            Localisation.getString(SLDTreeTools.class, "TreeItem.style"),
            Localisation.getString(SLDTreeTools.class, "TreeItem.newStyle"));
    assertTrue(actualValue.compareTo(expectedValue) == 0);

    style.setName(null);
    actualValue = item.getTreeString(null, style);
    expectedValue = String.format("%s : %s",
            Localisation.getString(SLDTreeTools.class, "TreeItem.style"), "");
    assertTrue(actualValue.compareTo(expectedValue) == 0);

    String expectedName = "test name";
    style.setName(expectedName);
    actualValue = item.getTreeString(null, style);
    expectedValue = String.format("%s : %s",
            Localisation.getString(SLDTreeTools.class, "TreeItem.style"), expectedName);
    assertTrue(actualValue.compareTo(expectedValue) == 0);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:34,代码来源:StyleTreeItemTest.java

示例2: testStyleDetails

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#StyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#preLoadSymbol()}.
 */
@Test
public void testStyleDetails() {
    StyleDetails panel = new StyleDetails();
    panel.populate(null);

    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameValue = "style test value";
    style.setName(expectedNameValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    style.featureTypeStyles().add(fts);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);

    panel.populate(SelectedSymbol.getInstance());
    panel.dataChanged(null);
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);

    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertTrue(expectedNameValue.compareTo(nameField.getStringValue()) == 0);
    assertTrue(panel.isDataPresent());

    // Reset to default value
    panel.preLoadSymbol();
    assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:44,代码来源:StyleDetailsTest.java

示例3: createStyleFromGraphic

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Generates a style based on a graphic.
 * 
 * @param graphicsPath the graphic.
 * @return the generated style.
 * @throws IOException
 */
public static StyleWrapper createStyleFromGraphic( File graphicsPath ) throws IOException {
    String name = graphicsPath.getName();
    ExternalGraphic exGraphic = null;
    if (name.toLowerCase().endsWith(".png")) {
        exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png");
    } else if (name.toLowerCase().endsWith(".svg")) {
        exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml");
    } else if (name.toLowerCase().endsWith(".sld")) {
        StyledLayerDescriptor sld = readStyle(graphicsPath);
        Style style = SldUtilities.getDefaultStyle(sld);
        return new StyleWrapper(style);
    }

    if (exGraphic == null) {
        throw new IOException("Style could not be created!");
    }

    Graphic gr = sf.createDefaultGraphic();
    gr.graphicalSymbols().clear();
    gr.graphicalSymbols().add(exGraphic);
    Expression size = ff.literal(20);
    gr.setSize(size);

    Rule rule = sf.createRule();
    PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(gr, null);
    rule.symbolizers().add(pointSymbolizer);

    FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle();
    featureTypeStyle.rules().add(rule);

    Style namedStyle = sf.createStyle();
    namedStyle.featureTypeStyles().add(featureTypeStyle);
    namedStyle.setName(FilenameUtils.removeExtension(name));

    return new StyleWrapper(namedStyle);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:44,代码来源:Utilities.java

示例4: createDefaultPolygonLayerStyle

import org.geotools.styling.Style; //导入方法依赖的package包/类
public Style createDefaultPolygonLayerStyle(String strokeColor, String strokeWidth, String fillColor, String opacity){
	FeatureTypeStyle polygonFeatureTypeStyle = createDefaultPolygonFeatureTypeStyle(strokeColor, strokeWidth, fillColor, opacity);
	Style polygonStyle = sf.createStyle();
	polygonStyle.featureTypeStyles().add(polygonFeatureTypeStyle);
	polygonStyle.setName(DEFAULT_POLYGON_LAYER_STYLE_NAME);
	
	return polygonStyle;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:9,代码来源:LayerFactory.java

示例5: createDefaultLineLayerStyle

import org.geotools.styling.Style; //导入方法依赖的package包/类
public Style createDefaultLineLayerStyle(String strokeWidth, String strokeColor, String opacity){
	FeatureTypeStyle lineFeatureTypeStyle = createDefaultLineFeatureTypeStyle(strokeWidth, strokeColor, opacity);
	Style lineStyle = sf.createStyle();
	lineStyle.featureTypeStyles().add(lineFeatureTypeStyle);
	lineStyle.setName(DEFAULT_LINE_LAYER_STYLE_NAME);
	
	return lineStyle;	
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:9,代码来源:LayerFactory.java

示例6: createDefaultPointLayerStyle

import org.geotools.styling.Style; //导入方法依赖的package包/类
public Style createDefaultPointLayerStyle(String radius, String color, String opacity){
	FeatureTypeStyle pointFeatureTypeStyle = createDefaultPointFeatureTypeStyle(radius, color, opacity);		
	Style pointStyle = sf.createStyle();
	pointStyle.featureTypeStyles().add(pointFeatureTypeStyle);
	pointStyle.setName(DEFAULT_POINT_LAYER_STYLE_NAME);
	
	return pointStyle;	
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:9,代码来源:LayerFactory.java

示例7: createDefaultLayerStyles

import org.geotools.styling.Style; //导入方法依赖的package包/类
public Style createDefaultLayerStyles(){
	FeatureTypeStyle polygonFeatureTypeStyle = createDefaultPolygonFeatureTypeStyle(DEFAULT_COLOR, DEFAULT_STROKE_WIDTH, DEFAULT_COLOR, DEFAULT_OPACITY);
	FeatureTypeStyle pointFeatureTypeStyle = createDefaultPointFeatureTypeStyle(DEFAULT_RADIUS, DEFAULT_COLOR, DEFAULT_OPACITY);
	FeatureTypeStyle lineFeatureTypeStyle = createDefaultLineFeatureTypeStyle(DEFAULT_STROKE_WIDTH, DEFAULT_COLOR, DEFAULT_OPACITY);

	Style allStyle = sf.createStyle();
	allStyle.featureTypeStyles().addAll(Arrays.asList(new FeatureTypeStyle[]{polygonFeatureTypeStyle, pointFeatureTypeStyle, lineFeatureTypeStyle}));
       allStyle.setName(DEFAULT_ALL_STYLE_LAYER_NAME);
	
	return allStyle;		
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:12,代码来源:LayerFactory.java

示例8: markTestSLD

import org.geotools.styling.Style; //导入方法依赖的package包/类
private void markTestSLD() {
    // markTestSLD start
    StyleBuilder sb = new StyleBuilder();
    FilterFactory ff = sb.getFilterFactory();
    Style style = sb.createStyle();
    style.setName("MyStyle");
    
    // "testPoint" feature type style
    Mark testMark = sb.createMark(sb.attributeExpression("name"), sb.createFill(Color.RED, 0.5),
            null);
    Graphic graph = sb.createGraphic(null, new Mark[] { testMark }, null, sb.literalExpression(1),
            sb.attributeExpression("size"), sb.attributeExpression("rotation"));
    style.featureTypeStyles().add(
            sb.createFeatureTypeStyle("testPoint", sb.createPointSymbolizer(graph)));
    
    // "labelPoint" feature type style
    AnchorPoint anchorPoint = sb.createAnchorPoint(sb.attributeExpression("X"),
            sb.attributeExpression("Y"));
    PointPlacement pointPlacement = sb.createPointPlacement(anchorPoint, null,
            sb.literalExpression(0));
    TextSymbolizer textSymbolizer = sb.createTextSymbolizer(sb.createFill(Color.BLACK), new Font[] {
            sb.createFont("Lucida Sans", 10), sb.createFont("Arial", 10) }, sb.createHalo(),
            sb.attributeExpression("name"), pointPlacement, null);
    Mark circle = sb.createMark(StyleBuilder.MARK_CIRCLE, Color.RED);
    Graphic graph2 = sb.createGraphic(null, circle, null, 1, 4, 0);
    PointSymbolizer pointSymbolizer = sb.createPointSymbolizer(graph2);
    style.featureTypeStyles().add(
            sb.createFeatureTypeStyle("labelPoint", new Symbolizer[] { textSymbolizer,
                    pointSymbolizer }));
    // markTestSLD end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:32,代码来源:StyleExamples.java

示例9: visit

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Visit.
 *
 * @param style the style
 */
//CHECKSTYLE:OFF
@SuppressWarnings("deprecation")
//CHECKSTYLE:ON
@Override
public void visit(Style style) {
    Style copy = null;

    FeatureTypeStyle[] fts = style.getFeatureTypeStyles();
    FeatureTypeStyle[] ftsCopy = null;
    if (this.ftsToRender != null) {
        ftsCopy = new FeatureTypeStyle[1];
        for (int i = 0; i < fts.length; i++) {
            if (fts[i] != null) {
                if (fts[i] == this.ftsToRender) {
                    fts[i].accept(this);
                    ftsCopy[0] = (FeatureTypeStyle) pages.pop();
                }
            }
        }
    } else {
        ftsCopy = new FeatureTypeStyle[fts.length];
        for (int i = 0; i < fts.length; i++) {
            if (fts[i] != null) {
                fts[i].accept(this);
                ftsCopy[i] = (FeatureTypeStyle) pages.pop();
            }
        }
    }

    copy = sf.createStyle();
    copy.setAbstract(style.getAbstract());
    copy.setName(style.getName());
    copy.setTitle(style.getTitle());
    copy.setFeatureTypeStyles(ftsCopy);

    if (STRICT && !copy.equals(style)) {
        throw new IllegalStateException("Was unable to duplicate provided Style:" + style);
    }
    pages.push(copy);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:46,代码来源:RuleRenderVisitor.java

示例10: createNewStyle

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Creates the new style.
 *
 * @return the style
 */
public static Style createNewStyle() {
    Style style = styleFactory.createStyle();
    style.setName("New Style");
    return style;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:11,代码来源:DefaultSymbols.java

示例11: testContainsFonts

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.tool.batchupdatefont.BatchUpdateFontUtils#containsFonts(com.sldeditor.common.SLDDataInterface)}.
 */
@Test
public void testContainsFonts() {

    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);

    TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(DefaultSymbols.createDefaultPointSymbolizer());
    fts.rules().add(rule);
    sld.layers().add(namedLayer);

    SLDWriterInterface sldWriter = SLDWriterFactory.createWriter(null);
    String sldContents = sldWriter.encodeSLD(null, sld);

    SLDData sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), sldContents);

    // Empty sld
    List<BatchUpdateFontData> actualList = BatchUpdateFontUtils.containsFonts(null);
    assertNull(actualList);

    // No fonts
    actualList = BatchUpdateFontUtils.containsFonts(sldData);
    assertNull(actualList);

    // With textsymbolizer
    rule.symbolizers().add(symbolizer);
    sldContents = sldWriter.encodeSLD(null, sld);
    sldData = new SLDData(new StyleWrapper("workspace", "layer.sld"), sldContents);
    actualList = BatchUpdateFontUtils.containsFonts(sldData);
    assertEquals(1, actualList.size());
    assertEquals(rule.getName(), actualList.get(0).getRuleName());
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:52,代码来源:BatchUpdateFontUtilsTest.java

示例12: testTextSymbolizerDetails

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#TextSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testTextSymbolizerDetails() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    panel.populate(null);

    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);

    TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);

    panel.populate(SelectedSymbol.getInstance());

    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);

    panel.dataChanged(null);

    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());

    // Reset to default value
    panel.preLoadSymbol();
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:59,代码来源:TextSymbolizerDetailsTest.java

示例13: testPointSymbolizerDetails

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#preLoadSymbol()}.
 * Test method for {@link com.sldeditor.ui.detail.PointSymbolizerDetails#PointSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testPointSymbolizerDetails() {
    SelectedSymbol.destroyInstance();
    PointSymbolizerDetails panel = new PointSymbolizerDetails();
    panel.populate(null);

    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);

    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);

    panel.populate(SelectedSymbol.getInstance());

    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);

    panel.dataChanged(null);

    FieldConfigString descriptionField = (FieldConfigString) fieldDataManager
            .get(FieldIdEnum.DESCRIPTION);
    assertNull(descriptionField);
    assertTrue(panel.isDataPresent());

    // Reset to default value
    panel.preLoadSymbol();
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:61,代码来源:PointSymbolizerDetailsTest.java

示例14: testFillDetailsPolygon

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.ui.detail.PolygonFillDetailsTest#PolygonFillDetailsTest(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testFillDetailsPolygon() {
    PolygonFillDetails panel = new PolygonFillDetails();
    panel.populate(null);

    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);

    PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);

    panel.populate(SelectedSymbol.getInstance());

    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);

    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE);
    angleField.populateField(expectedAngle);

    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager
            .get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);

    panel.dataChanged(FieldIdEnum.UNKNOWN);

    double actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedAngle) < 0.01);
    assertTrue(panel.isDataPresent());

    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - opacity) < 0.01);

    // Reset to default value
    panel.preLoadSymbol();
    actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 0.0) < 0.01);
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 1.0) < 0.01);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:68,代码来源:PolygonFillDetailsTest.java

示例15: testFillDetailsPoint

import org.geotools.styling.Style; //导入方法依赖的package包/类
/**
 * Test method for {@link com.sldeditor.ui.detail.PointFillDetailsTest#FillDetails(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testFillDetailsPoint() {
    PointFillDetails panel = new PointFillDetails();
    panel.populate(null);

    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);

    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);

    panel.populate(SelectedSymbol.getInstance());

    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);

    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE);
    angleField.populateField(expectedAngle);

    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager
            .get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);

    panel.dataChanged(FieldIdEnum.UNKNOWN);

    double actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedAngle) < 0.01);
    assertTrue(panel.isDataPresent());

    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - opacity) < 0.01);

    // Reset to default value
    panel.preLoadSymbol();
    actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 0.0) < 0.01);
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 1.0) < 0.01);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:68,代码来源:PointFillDetailsTest.java


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