Class JSimpleStyleDialog

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class JSimpleStyleDialog extends JDialog
A dialog to prompt the user for feature style choices. It has a number of static showDialog methods to work with different sources (SimpleFeatureType, Layer, DataStore). Each of these displays a dialog and then creates a new Style instance.

Examples of use:


 // Use with a shapefile
 Component parentGUIComponent = null;
 ShapefileDataStore shapefile = ...
 Style style = JSimpleStyleDialog.showDialog(parentGUIComponent, shapefile);
 if (style != null) {
    // create a layer using this style
 }

 // Use with an existing Layer
 Layer layer = ...
 Style style = JSimpleStyleDialog.showDialog(parentGUIComponent, layer);
 if (style != null) {
     layer.setStyle( style );
 }
 
Since:
2.6
Author:
Michael Bedward
See Also:
  • Field Details

    • DEFAULT_LINE_COLOR

      public static final Color DEFAULT_LINE_COLOR
    • DEFAULT_FILL_COLOR

      public static final Color DEFAULT_FILL_COLOR
    • DEFAULT_LINE_WIDTH

      public static final float DEFAULT_LINE_WIDTH
      See Also:
    • DEFAULT_OPACITY

      public static final float DEFAULT_OPACITY
      See Also:
    • DEFAULT_POINT_SIZE

      public static final float DEFAULT_POINT_SIZE
      See Also:
    • DEFAULT_POINT_SYMBOL_NAME

      public static final String DEFAULT_POINT_SYMBOL_NAME
      See Also:
  • Constructor Details

    • JSimpleStyleDialog

      public JSimpleStyleDialog(Frame owner, SimpleFeatureType schema, Style initialStyle)
      Constructor.
      Parameters:
      owner - the parent Frame (may be null)
      schema - the feature type for which the style is being created
      initialStyle - an optional Style object to initialize the dialog (may be null)
      Throws:
      IllegalStateException - if the data store cannot be accessed
    • JSimpleStyleDialog

      public JSimpleStyleDialog(Dialog owner, SimpleFeatureType schema, Style initialStyle)
      Constructor.
      Parameters:
      owner - the parent Dialog (may be null)
      schema - the feature type for which the style is being created
      initialStyle - an optional Style object to initialize the dialog (may be null)
      Throws:
      IllegalStateException - if the data store cannot be accessed
  • Method Details

    • showDialog

      public static Style showDialog(Component parent, StyleLayer layer)
      Static convenience method: displays a JSimpleStyleDialog to prompt the user for style preferences to use with the given StyleLayer. The layer's existing style, if any, will be used to initialize the dialog.
      Parameters:
      parent - parent component (may be null)
      layer - the map layer
      Returns:
      a new Style instance or null if the user cancels the dialog
    • showDialog

      public static Style showDialog(Component parent, DataStore dataStore)
      Static convenience method: displays a JSimpleStyleDialog to prompt the user for style preferences to use with the first feature type in the dataStore.
      Parameters:
      parent - parent JFrame (may be null)
      dataStore - data store with the features to be rendered
      Returns:
      a new Style instance or null if the user cancels the dialog
    • showDialog

      public static Style showDialog(Component parent, DataStore dataStore, Style initialStyle)
      Static convenience method: displays a JSimpleStyleDialog to prompt the user for style preferences to use with the first feature type in the dataStore.
      Parameters:
      parent - parent JFrame (may be null)
      dataStore - data store with the features to be rendered
      initialStyle - an optional Style object to initialize the dialog (may be null)
      Returns:
      a new Style instance or null if the user cancels the dialog
    • showDialog

      public static Style showDialog(Component parent, SimpleFeatureType featureType)
      Static convenience method: displays a JSimpleStyleDialog to prompt the user for style preferences to use with the given feature type.
      Parameters:
      parent - parent component (may be null)
      featureType - the feature type that the Style will be used to display
      Returns:
      a new Style instance or null if the user cancels the dialog
    • showDialog

      public static Style showDialog(Component parent, SimpleFeatureType featureType, Style initialStyle)
      Static convenience method: displays a JSimpleStyleDialog to prompt the user for style preferences to use with the given feature type.
      Parameters:
      parent - parent component (may be null)
      featureType - the feature type that the Style will be used to display
      initialStyle - an optional Style object to initialize the dialog (may be null)
      Returns:
      a new Style instance or null if the user cancels the dialog
    • completed

      public boolean completed()
      Query if the dialog was completed (user clicked the Apply button)
      Returns:
      true if completed; false otherwise
    • getGeomType

      public Geometries getGeomType()
      Gets the geometry type of the selected feature type. Returns null if the user cancelled the dialog.
      Returns:
      the geometry type
    • getLineColor

      public Color getLineColor()
      Get the selected line color
      Returns:
      line color
    • getFillColor

      public Color getFillColor()
      Get the selected fill color
      Returns:
      fill color
    • getOpacity

      public float getOpacity()
      Get the fill opacity
      Overrides:
      getOpacity in class Window
      Returns:
      fill opacity between 0 and 1
    • getLineWidth

      public float getLineWidth()
      Get the selected line width
      Returns:
      line width
    • getPointSize

      public float getPointSize()
      Get the selected point size
      Returns:
      point size
    • getPointSymbolName

      public String getPointSymbolName()
      Get the selected point symbol name
      Returns:
      symbol name
    • getLabelField

      public String getLabelField()
      Get the feature field (attribute) to use for labels
      Returns:
      field name
    • getLabelFont

      public Font getLabelFont()
      Get the font to use for labels
      Returns:
      a GeoTools Font object