Search in sources :

Example 1 with LegendOptionData

use of com.sldeditor.ui.legend.option.LegendOptionData in project sldeditor by robward-scisys.

the class LegendManagerTest method testUpdateLegendOptionData.

@Test
public void testUpdateLegendOptionData() {
    StyledLayerDescriptor sld = testSLD1();
    String heading = "Test Heading";
    LegendOptionData legendOption = new LegendOptionData();
    legendOption.setBackgroundColour(Color.CYAN);
    legendOption.setBorder(true);
    legendOption.setBandInformation(true);
    legendOption.setBorderColour(Color.GREEN);
    legendOption.setImageHeight(100);
    legendOption.setImageWidth(100);
    legendOption.setImageHeight(100);
    legendOption.setShowLabels(true);
    legendOption.setShowTitle(true);
    LegendManager.getInstance().SLDLoaded(legendOption);
    boolean actualResult = compareLegendImage(sld, heading);
    assertTrue(actualResult);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) Test(org.junit.Test)

Example 2 with LegendOptionData

use of com.sldeditor.ui.legend.option.LegendOptionData in project sldeditor by robward-scisys.

the class LegendOptionDataTest method testImageHeight.

/**
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#getImageHeight()}.
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#setImageHeight(int)}.
 */
@Test
public void testImageHeight() {
    LegendOptionData data = new LegendOptionData();
    int imageHeight = 21;
    data.setImageHeight(imageHeight);
    assertEquals(imageHeight, data.getImageHeight());
}
Also used : LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) Test(org.junit.Test)

Example 3 with LegendOptionData

use of com.sldeditor.ui.legend.option.LegendOptionData in project sldeditor by robward-scisys.

the class LegendOptionDataTest method testEncodeXML.

/**
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#encodeXML(org.w3c.dom.Document, org.w3c.dom.Element, java.lang.String)}.
 */
@Test
public void testEncodeXML() {
    LegendOptionData data = new LegendOptionData();
    data.encodeXML(null, null, null);
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document doc = documentBuilder.newDocument();
        Element root = doc.createElement("root");
        doc.appendChild(root);
        data.setBackgroundColour(Color.GREEN);
        data.setBorder(true);
        data.setDpi(320);
        String elementName = "legend";
        data.encodeXML(doc, root, elementName);
        LegendOptionData newData = LegendOptionData.decodeXML(doc, elementName);
        assertEquals(newData.getBackgroundColour(), data.getBackgroundColour());
        assertEquals(newData.getDpi(), data.getDpi());
        assertEquals(newData.isBorder(), data.isBorder());
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 4 with LegendOptionData

use of com.sldeditor.ui.legend.option.LegendOptionData in project sldeditor by robward-scisys.

the class LegendOptionDataTest method testLabelFont.

/**
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#getLabelFont()}.
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#setLabelFont(java.awt.Font)}.
 */
@Test
public void testLabelFont() {
    LegendOptionData data = new LegendOptionData();
    Font expectedFont = new Font(new JLabel().getFont().getName(), Font.BOLD, 24);
    data.setLabelFont(expectedFont);
    assertEquals(expectedFont, data.getLabelFont());
}
Also used : JLabel(javax.swing.JLabel) LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) Font(java.awt.Font) Test(org.junit.Test)

Example 5 with LegendOptionData

use of com.sldeditor.ui.legend.option.LegendOptionData in project sldeditor by robward-scisys.

the class LegendOptionDataTest method testBorderColour.

/**
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#getBorderColour()}.
 * Test method for {@link com.sldeditor.ui.legend.option.LegendOptionData#setBorderColour(java.awt.Color)}.
 */
@Test
public void testBorderColour() {
    LegendOptionData data = new LegendOptionData();
    Color expectedColor = Color.LIGHT_GRAY;
    data.setBorderColour(expectedColor);
    assertEquals(expectedColor, data.getBorderColour());
}
Also used : Color(java.awt.Color) LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) Test(org.junit.Test)

Aggregations

LegendOptionData (com.sldeditor.ui.legend.option.LegendOptionData)24 Test (org.junit.Test)21 Color (java.awt.Color)3 IOException (java.io.IOException)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 Document (org.w3c.dom.Document)3 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)2 SLDData (com.sldeditor.common.data.SLDData)2 VersionData (com.sldeditor.common.vendoroption.VersionData)2 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)2 EnvVar (com.sldeditor.filter.v2.envvar.EnvVar)2 Font (java.awt.Font)2 File (java.io.File)2 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)2 Element (org.w3c.dom.Element)2 SLDDataInterface (com.sldeditor.common.SLDDataInterface)1 StyleWrapper (com.sldeditor.common.data.StyleWrapper)1 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)1