/* * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2012 Geomatys * * 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.geotoolkit.gui.swing.propertyedit.styleproperty.simple; import java.awt.Component; import java.awt.Dimension; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JLabel; import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.SwingConstants; import org.geotoolkit.gui.swing.resource.MessageBundle; import org.geotoolkit.gui.swing.style.JNumberSliderExpressionPane; import org.geotoolkit.gui.swing.style.StyleElementEditor; import org.opengis.style.Halo; /** * Text halo editor * @author Fabien Rétif (Geomatys) * @author Johann Sorel (Geomatys) */ public class JHaloPane extends StyleElementEditor<Halo> { /** * Creates new form JHaloPane */ public JHaloPane() { super(Halo.class); initComponents(); guiHaloFillPane.setBackground(getBackground()); guiRadius.setModel(0, 0, 100, 1); } /** * 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel6 = new JLabel(); jLabel7 = new JLabel(); jLabel9 = new JLabel(); guiRadius = new JNumberSliderExpressionPane(); guiHaloFillPane = new JFillControlPane(); setMaximumSize(new Dimension(625, 32767)); setPreferredSize(new Dimension(625, 156)); jLabel6.setText(MessageBundle.format("halo")); // NOI18N jLabel7.setText(MessageBundle.format("radius")); // NOI18N jLabel9.setText(MessageBundle.format("color")); // NOI18N guiRadius.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { JHaloPane.this.propertyChange(evt); } }); guiHaloFillPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { JHaloPane.this.propertyChange(evt); } }); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(jLabel6) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(jLabel7) .addComponent(jLabel9)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(guiHaloFillPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(guiRadius, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {jLabel6, jLabel7, jLabel9}); layout.setVerticalGroup( layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel6) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(guiRadius, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(jLabel9) .addComponent(guiHaloFillPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.linkSize(SwingConstants.VERTICAL, new Component[] {guiRadius, jLabel7}); layout.linkSize(SwingConstants.VERTICAL, new Component[] {guiHaloFillPane, jLabel9}); }// </editor-fold>//GEN-END:initComponents private void propertyChange(PropertyChangeEvent evt) {//GEN-FIRST:event_propertyChange firePropertyChange(PROPERTY_UPDATED, null, create()); }//GEN-LAST:event_propertyChange // Variables declaration - do not modify//GEN-BEGIN:variables private JFillControlPane guiHaloFillPane; private JNumberSliderExpressionPane guiRadius; private JLabel jLabel6; private JLabel jLabel7; private JLabel jLabel9; // End of variables declaration//GEN-END:variables @Override public void parse(Halo target) { if(target!= null) { guiRadius.parse(target.getRadius()); guiHaloFillPane.parse(target.getFill()); } } @Override public Halo create() { return getStyleFactory().halo(guiHaloFillPane.create(), guiRadius.create()); } @Override protected Object[] getFirstColumnComponents() { return new Object[]{}; } }