Search in sources :

Example 6 with WKTType

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType in project sldeditor by robward-scisys.

the class WKTGeometryTest method testAddNewShape.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry#addNewShape()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry#removeShape(int)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry#removeSegment(int, int)}.
 */
@Test
public void testAddNewShape() {
    WKTGeometry g = new WKTGeometry();
    String expectedListItem = "listitem";
    WKTType wktType = new WKTType("name", false, 5, expectedListItem, false, true);
    g.setGeometryType(wktType);
    g.addNewShape();
    int expectedIndex = 0;
    String actualValue = g.getMultiShapeName(expectedIndex);
    assertTrue(actualValue.compareTo(String.format("%s %d", expectedListItem, expectedIndex + 1)) == 0);
    g.addNewShape();
    g.removeShape(-1);
    g.removeShape(2);
    g.removeShape(0);
    assertTrue(g.getNoOfSegments() == 1);
    assertEquals(2, g.addNewShape());
    assertEquals(1, g.addNewSegment(1));
    assertEquals(2, g.addNewSegment(1));
    g.removeSegment(0, -1);
    assertEquals(3, g.addNewSegment(1));
    g.removeSegment(0, 5);
    assertEquals(4, g.addNewSegment(1));
    g.removeSegment(1, 2);
    int actualSize = g.getSegmentList(1).size();
    assertEquals(4, actualSize);
    actualValue = g.getSegmentName(0);
    assertTrue(actualValue.compareTo(String.format("%s %d", expectedListItem, expectedIndex + 1)) == 0);
    wktType = new WKTType("name", false, 5, expectedListItem, true, true);
    g.setGeometryType(wktType);
    actualValue = g.getSegmentName(0);
    assertTrue(actualValue.compareTo(String.format("%s %d", Localisation.getString(WKTDialog.class, "WKTDialog.partShape"), expectedIndex + 1)) == 0);
    assertNull(g.getSegmentList(-4));
    assertNull(g.getSegmentList(43));
}
Also used : WKTGeometry(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry) WKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType) Test(org.junit.Test)

Example 7 with WKTType

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType in project sldeditor by robward-scisys.

the class WKTPointModelTest method testPopulateWKTSegmentList.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel#setWKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel#populate(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList)}.
 */
@Test
public void testPopulateWKTSegmentList() {
    WKTSegmentList segmentList = new WKTSegmentList();
    DirectPosition pos1 = new DirectPosition2D(1.0, 1.0);
    DirectPosition pos2 = new DirectPosition2D(2.0, 2.0);
    DirectPosition pos3 = new DirectPosition2D(3.0, 3.0);
    DirectPosition pos4 = new DirectPosition2D(4.0, 4.0);
    segmentList.addPoint(new WKTPoint(pos1));
    segmentList.addPoint(new WKTPoint(pos2));
    segmentList.addPoint(new WKTPoint(pos3));
    segmentList.addPoint(new WKTPoint(pos4));
    WKTPointModel model = new WKTPointModel();
    WKTType wktType = new WKTType("name", false, 5, "", false, false);
    model.setWKTType(wktType);
    model.populate(null);
    assertTrue(model.getRowCount() == 0);
    model.populate(segmentList);
    assertTrue(model.getRowCount() == 4);
    model.populate(segmentList);
    assertTrue(model.getRowCount() == 4);
    segmentList.addPoint(new WKTPoint(pos1));
    assertTrue(model.getRowCount() == 5);
    // Set WKTType to null is the same as first and last points flag = false
    model.setWKTType(null);
    model.populate(segmentList);
    assertTrue(model.getRowCount() == 5);
}
Also used : DirectPosition(org.opengis.geometry.DirectPosition) WKTPointModel(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel) WKTSegmentList(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList) WKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType) WKTPoint(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint) DirectPosition2D(org.geotools.geometry.DirectPosition2D) Test(org.junit.Test)

Example 8 with WKTType

use of com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType in project sldeditor by robward-scisys.

the class WKTTypeTest method testDoFirstLastHaveToBeSame.

/**
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#WKTType(java.lang.String, boolean, int, java.lang.String, boolean, boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#WKTType(java.lang.String, boolean, int, java.lang.String, boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#getName()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#isMultipleCoordinates()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#toString()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#getNumOfPoints()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#getListItem()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#canHaveMultipleShapes()}.
 * Test method for {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType#doFirstLastHaveToBeSame()}.
 */
@Test
public void testDoFirstLastHaveToBeSame() {
    String name = "test";
    boolean multipleCoordinates = true;
    int numOfPoints = 5;
    String listItem = "qwerty";
    boolean canHaveMultipleShapes = true;
    boolean doFirstLastHaveToBeSame = false;
    WKTType wktType = new WKTType(name, multipleCoordinates, numOfPoints, listItem, canHaveMultipleShapes, doFirstLastHaveToBeSame);
    assertTrue(wktType.canHaveMultipleShapes());
    assertTrue(wktType.isMultipleCoordinates());
    assertFalse(wktType.doFirstLastHaveToBeSame());
    assertEquals(numOfPoints, wktType.getNumOfPoints());
    assertTrue(wktType.getListItem().compareTo(listItem) == 0);
    assertTrue(wktType.getName().compareTo(name) == 0);
    assertTrue(wktType.toString().compareTo(name) == 0);
    WKTType wktType2 = new WKTType(name, multipleCoordinates, numOfPoints, listItem, false, doFirstLastHaveToBeSame);
    assertFalse(wktType2.canHaveMultipleShapes());
    assertFalse(wktType.equals(wktType2));
    WKTType wktTypeCopy = new WKTType(name, multipleCoordinates, numOfPoints, listItem, canHaveMultipleShapes, doFirstLastHaveToBeSame);
    assertEquals(wktType, wktTypeCopy);
    assertTrue(wktType.hashCode() != wktType2.hashCode());
}
Also used : WKTType(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType) Test(org.junit.Test)

Aggregations

WKTType (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTType)8 Test (org.junit.Test)8 WKTGeometry (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTGeometry)5 WKTPoint (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPoint)1 WKTPointModel (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTPointModel)1 WKTSegmentList (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.WKTSegmentList)1 DirectPosition2D (org.geotools.geometry.DirectPosition2D)1 DirectPosition (org.opengis.geometry.DirectPosition)1