Ejemplo n.º 1
0
 /**
  * Adds the symbol panel attached to the given {@link Symbolizer} and returns the panel.
  *
  * @param symb Symbolizer
  * @return The newly generated symbol panel
  */
 private ILegendPanel addSymbolPanel(Symbolizer symb) {
   // Get the legend corresponding to this symbolizer.
   Legend legend = LegendFactory.getLegend(symb);
   if (legend instanceof AbstractRecodedLegend) {
     String table = layer.getTableReference();
     AbstractRecodedLegend leg = (AbstractRecodedLegend) legend;
     try (Connection connection = layer.getDataManager().getDataSource().getConnection()) {
       String f = leg.getLookupFieldName();
       int type = MetaData.getFieldType(connection, table, f);
       leg.setComparator(AbstractRecodedLegend.getComparator(type));
     } catch (SQLException e) {
       LOGGER.warn("Can't retrieve an accurate Comparator for this classification");
     }
   }
   // Initialize a panel for this legend.
   ILegendPanel panel = ILegendPanelFactory.getILegendPanel(this, legend);
   // Give it a new id.
   panel.setId(createNewID());
   // Add the symbol panel to the container after putting it in a
   // new JScrollPane.
   dialogContainer.add(panel.getId(), getJScrollPane(panel));
   return panel;
 }
Ejemplo n.º 2
0
 /**
  * Adds the symbol panel attached to the given {@link Symbolizer} and returns the panel.
  *
  * @param symb Symbolizer
  * @return The newly generated symbol panel
  */
 private ILegendPanel addSymbolPanel(Symbolizer symb) {
   // Get the legend corresponding to this symbolizer.
   Legend legend = LegendFactory.getLegend(symb);
   if (legend instanceof AbstractRecodedLegend) {
     DataSource dataSource = layer.getDataSource();
     AbstractRecodedLegend leg = (AbstractRecodedLegend) legend;
     try {
       Metadata metadata = dataSource.getMetadata();
       String f = leg.getLookupFieldName();
       int in = metadata.getFieldIndex(f);
       leg.setComparator(AbstractRecodedLegend.getComparator(metadata.getFieldType(in)));
     } catch (DriverException e) {
       LOGGER.warn("Can't retrieve an accurate Comparator for this classification");
     }
   }
   // Initialize a panel for this legend.
   ILegendPanel panel = ILegendPanelFactory.getILegendPanel(this, legend);
   // Give it a new id.
   panel.setId(createNewID());
   // Add the symbol panel to the container after putting it in a
   // new JScrollPane.
   dialogContainer.add(panel.getId(), getJScrollPane(panel));
   return panel;
 }