Search in sources :

Example 1 with CheckBoxRenderer

use of com.sldeditor.rendertransformation.CheckBoxRenderer in project sldeditor by robward-scisys.

the class CheckBoxRendererTest method testCheckBoxRenderer.

/**
 * Test method for {@link
 * com.sldeditor.rendertransformation.CheckBoxRenderer#CheckBoxRenderer(com.sldeditor.rendertransformation.FunctionTableModel)}.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testCheckBoxRenderer() {
    JTable table = new JTable();
    FunctionTableModel model = new FunctionTableModel();
    assertNull(new CheckBoxRenderer(null).getTableCellRendererComponent(null, null, false, false, 0, 0));
    assertNull(new CheckBoxRenderer(null).getTableCellRendererComponent(table, null, false, false, 0, 0));
    assertNull(new CheckBoxRenderer(model).getTableCellRendererComponent(null, null, false, false, 0, 0));
    model.addNewValue(0);
    ProcessFunction processFunction = createProcessFunction();
    FunctionName name = new FunctionNameImpl("Test", parameter("cellSize", Double.class), new Parameter("outputBBOX", Number.class, null, null, false, 0, 100, null, null), parameter("outputWidth", Number.class), parameter("outputHeight", Number.class));
    assertFalse(name.getArguments().get(0).isRequired());
    assertTrue(name.getArguments().get(1).isRequired());
    model.populate(name, processFunction);
    CheckBoxRenderer obj = new CheckBoxRenderer(model);
    // Row - optional and not selected
    assertEquals(obj, obj.getTableCellRendererComponent(table, null, false, false, 0, 0));
    assertEquals(obj, obj.getTableCellRendererComponent(table, true, false, false, 0, 0));
    assertTrue(obj.isSelected());
    assertEquals(obj, obj.getTableCellRendererComponent(table, false, false, false, 0, 0));
    assertFalse(obj.isSelected());
    // Row - optional and selected
    assertEquals(obj, obj.getTableCellRendererComponent(table, null, true, false, 0, 0));
    assertEquals(obj, obj.getTableCellRendererComponent(table, true, true, false, 0, 0));
    assertTrue(obj.isSelected());
    assertEquals(obj, obj.getTableCellRendererComponent(table, false, true, false, 0, 0));
    assertFalse(obj.isSelected());
    // Row - required and not selected
    assertEquals(JLabel.class, obj.getTableCellRendererComponent(table, null, false, false, 1, 0).getClass());
    // Row - required and selected
    assertEquals(JLabel.class, obj.getTableCellRendererComponent(table, null, true, false, 1, 0).getClass());
}
Also used : ProcessFunction(org.geotools.process.function.ProcessFunction) FunctionName(org.opengis.filter.capability.FunctionName) JTable(javax.swing.JTable) Parameter(org.geotools.data.Parameter) FunctionNameImpl(org.geotools.filter.capability.FunctionNameImpl) CheckBoxRenderer(com.sldeditor.rendertransformation.CheckBoxRenderer) FunctionTableModel(com.sldeditor.rendertransformation.FunctionTableModel) Test(org.junit.jupiter.api.Test)

Aggregations

CheckBoxRenderer (com.sldeditor.rendertransformation.CheckBoxRenderer)1 FunctionTableModel (com.sldeditor.rendertransformation.FunctionTableModel)1 JTable (javax.swing.JTable)1 Parameter (org.geotools.data.Parameter)1 FunctionNameImpl (org.geotools.filter.capability.FunctionNameImpl)1 ProcessFunction (org.geotools.process.function.ProcessFunction)1 Test (org.junit.jupiter.api.Test)1 FunctionName (org.opengis.filter.capability.FunctionName)1