/**
   * Constructor
   *
   * @param mt Map transform
   * @param type Layer geometry type
   * @param layer Layer
   * @param style Style
   */
  public SimpleStyleEditor(MapTransform mt, Type type, ILayer layer, Style style) {
    // Set the layout.
    super(new BorderLayout());

    // Recover the first three paramters.
    this.mt = mt;
    this.type = type;
    this.layer = layer;

    // Get the geometry type and available legends.
    this.geometryType =
        (type == null) ? SimpleGeometryType.ALL : SimpleGeometryType.getSimpleType(type);

    // Initialize the dialog container, adding the empty dialog.
    cardLayout = new CardLayout();
    dialogContainer = new JPanel(cardLayout);
    dialogContainer.setPreferredSize(new Dimension(640, 420));
    addEmptyDialog();

    // Add all panels.
    styleWrapper = addAllPanels(style);

    // Initialize the legend tree.
    legendTree = new LegendTree(this);

    // Put everything inside a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, legendTree, dialogContainer);
    // Should be just wide enough for "Interval classification - Point"
    splitPane.setDividerLocation(260);
    Dimension minimumSize = new Dimension(100, 50);
    legendTree.setMinimumSize(minimumSize);
    dialogContainer.setMinimumSize(minimumSize);
    add(splitPane, BorderLayout.CENTER);
  }
 /**
  * Populates the names array with the names of legends that can be applied to the given layer.
  *
  * @param layer Layer
  */
 private void initNamesList(ILayer layer) {
   // Recover the geometry type of this ILayer.
   DataSource ds = layer.getDataManager().getDataSource();
   int geometryColumnsCount = 0;
   int geomType = GeometryTypeCodes.GEOMETRY;
   try (Connection connection = ds.getConnection()) {
     TableLocation tableLocation = TableLocation.parse(layer.getTableReference());
     geomType = SFSUtilities.getGeometryType(connection, tableLocation, "");
     geometryColumnsCount = SFSUtilities.getGeometryFields(connection, tableLocation).size();
   } catch (SQLException e) {
     LOGGER.warn("Could not determine the specific geometry type for " + "this layer.");
   }
   // Convert to a simple geometry.
   int simpleGeomType = SimpleGeometryType.getSimpleType(geomType);
   // Fill the names array.
   ArrayList<String> typeNames = new ArrayList<>();
   final int lineOrPolygon = SimpleGeometryType.LINE | SimpleGeometryType.POLYGON;
   if ((simpleGeomType & SimpleGeometryType.ALL) != 0) {
     typeNames.add(UniqueSymbolPoint.NAME);
     if ((simpleGeomType & lineOrPolygon) != 0) {
       typeNames.add(UniqueSymbolLine.NAME);
     }
     if ((simpleGeomType & SimpleGeometryType.POLYGON) != 0) {
       typeNames.add(UniqueSymbolArea.NAME);
     }
     // Do not display the thematic maps that need an attribute if there is
     // only one geometry
     if (geometryColumnsCount > -1) {
       typeNames.add(RecodedPoint.NAME);
       if ((simpleGeomType & lineOrPolygon) != 0) {
         typeNames.add(RecodedLine.NAME);
       }
       if ((simpleGeomType & SimpleGeometryType.POLYGON) != 0) {
         typeNames.add(RecodedArea.NAME);
       }
       typeNames.add(ProportionalPoint.NAME);
       if ((simpleGeomType & lineOrPolygon) != 0) {
         typeNames.add(ProportionalLine.NAME);
       }
       typeNames.add(CategorizedPoint.NAME);
       if ((simpleGeomType & lineOrPolygon) != 0) {
         typeNames.add(CategorizedLine.NAME);
       }
       if ((simpleGeomType & SimpleGeometryType.POLYGON) != 0) {
         typeNames.add(CategorizedArea.NAME);
       }
     }
   }
   names = typeNames.toArray(new String[typeNames.size()]);
 }