Point dispersal
arcgissamples\cartography\propertypage\PointDispersalPropertyPage.java
/* Copyright 2010 ESRI
* 
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* 
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* 
* See the use restrictions.
* 
*/
package arcgissamples.cartography.propertypage;

import java.io.IOException;
import javax.swing.JFrame;

import arcgissamples.cartography.PointDispersalRenderer;

import com.esri.arcgis.carto.IFeatureRenderer;
import com.esri.arcgis.cartoUI.BaseCustomRendererPropertyPage;
import com.esri.arcgis.display.ISymbol;
import com.esri.arcgis.display.PictureMarkerSymbol;
import com.esri.arcgis.display.esriIPictureType;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.interop.extn.ArcGISCategories;
import com.esri.arcgis.interop.extn.ArcGISExtension;

@ArcGISExtension(categories = { ArcGISCategories.ESRIRendererPropertyPages })
public class PointDispersalPropertyPage extends BaseCustomRendererPropertyPage {

  PointDispersalPropertyPageUI pointPropertyPageUI;

  @Override
  public void apply(IFeatureRenderer arg0) {
    try {
      ((PointDispersalRenderer) arg0).setDispersalRatio(Double.parseDouble(pointPropertyPageUI.getJTextField().getText()));
      Object obj = PointDispersalPropertyPageUI.styleGalleryItem.getItem();
      ((PointDispersalRenderer) arg0).setSymbol(null);
      ((PointDispersalRenderer) arg0).setSymbol((ISymbol) obj);
    } catch (Exception e) {
      e.printStackTrace();
    }

  }

  @Override
  public Class getCustomRendererDef() {
    return PointDispersalRenderer.class;
  }

  @Override
  public String getDescription() throws IOException, AutomationException {
    return "PointDispersal Renderer Property Page";
  }

  @Override
  public String getName() throws IOException, AutomationException {
    return "PointDispersal";
  }

  @Override
  public int getPreviewImage() throws IOException, AutomationException {
    return 0;
  }

  @Override
  public String getType() throws IOException, AutomationException {
    return "Dispersal Renderer";
  }

  public JFrame initGUI(IFeatureRenderer arg0) {
    try {
      pointPropertyPageUI = new PointDispersalPropertyPageUI();
      double ratio = ((PointDispersalRenderer)arg0).getdispersalRatio();
      pointPropertyPageUI.getJTextField().setText(Double.toString(ratio));
    } catch (Exception e) {
      e.printStackTrace();
    }
    return pointPropertyPageUI;
  }

  @Override
  public int getPriority() throws IOException, AutomationException {
    return 0;
  }

}