/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.gui.swing.style.sld;
import java.awt.Component;
import org.geotools.gui.swing.style.StyleElementEditor;
import org.geotools.map.MapLayer;
import org.geotools.styling.Halo;
import org.geotools.styling.StyleBuilder;
/**
* Halo panel
*
* @author Johann Sorel
*
* @source $URL$
*/
public class JHaloPane extends javax.swing.JPanel implements StyleElementEditor<Halo> {
private Halo halo = null;
private MapLayer layer = null;
/** Creates new form JHaloPanel */
public JHaloPane() {
initComponents();
init();
}
private void init() {
guiRadius.setType(JExpressionPane.EXP_TYPE.NUMBER);
}
public void setLayer(MapLayer layer) {
this.layer = layer;
guiFill.setLayer(layer);
guiRadius.setLayer(layer);
}
public MapLayer getLayer() {
return layer;
}
public void setEdited(Halo halo) {
this.halo = halo;
if (halo != null) {
guiFill.setEdited(halo.getFill());
guiRadius.setExpression(halo.getRadius());
}
}
public Halo getEdited() {
if (halo == null) {
halo = new StyleBuilder().createHalo();
}
apply();
return halo;
}
public void apply() {
if (halo != null) {
halo.setFill(guiFill.getEdited());
halo.setRadius(guiRadius.getExpression());
}
}
public Component getComponent() {
return this;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
guiFill = new org.geotools.gui.swing.style.sld.JFillPane();
guiRadius = new org.geotools.gui.swing.style.sld.JExpressionPane();
jLabel1 = new javax.swing.JLabel();
jXTitledSeparator1 = new org.jdesktop.swingx.JXTitledSeparator();
setOpaque(false);
guiFill.setOpaque(false);
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/geotools/gui/swing/style/sld/Bundle"); // NOI18N
jLabel1.setText(bundle.getString("radius")); // NOI18N
jXTitledSeparator1.setAlpha(0.5F);
jXTitledSeparator1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jXTitledSeparator1.setTitle(bundle.getString("fill")); // NOI18N
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(guiRadius, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(guiFill, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(13, Short.MAX_VALUE))
.add(jXTitledSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(guiRadius, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jXTitledSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(guiFill, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private org.geotools.gui.swing.style.sld.JFillPane guiFill;
private org.geotools.gui.swing.style.sld.JExpressionPane guiRadius;
private javax.swing.JLabel jLabel1;
private org.jdesktop.swingx.JXTitledSeparator jXTitledSeparator1;
// End of variables declaration//GEN-END:variables
}